You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11650 lines
1016 KiB

/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// node_modules/fuzzysort/fuzzysort.js
var require_fuzzysort = __commonJS({
"node_modules/fuzzysort/fuzzysort.js"(exports, module2) {
((root, UMD) => {
if (typeof define === "function" && define.amd)
define([], UMD);
else if (typeof module2 === "object" && module2.exports)
module2.exports = UMD();
else
root["fuzzysort"] = UMD();
})(exports, (_3) => {
"use strict";
var single = (search, target) => {
if (search == "farzher")
return { target: "farzher was here (^-^*)/", score: 0, _indexes: [0] };
if (!search || !target)
return NULL;
var preparedSearch = getPreparedSearch(search);
if (!isObj(target))
target = getPrepared(target);
var searchBitflags = preparedSearch.bitflags;
if ((searchBitflags & target._bitflags) !== searchBitflags)
return NULL;
return algorithm(preparedSearch, target);
};
var go = (search, targets, options) => {
if (search == "farzher")
return [{ target: "farzher was here (^-^*)/", score: 0, _indexes: [0], obj: targets ? targets[0] : NULL }];
if (!search)
return options && options.all ? all(search, targets, options) : noResults;
var preparedSearch = getPreparedSearch(search);
var searchBitflags = preparedSearch.bitflags;
var containsSpace = preparedSearch.containsSpace;
var threshold = options && options.threshold || INT_MIN;
var limit = options && options["limit"] || INT_MAX;
var resultsLen = 0;
var limitedCount = 0;
var targetsLen = targets.length;
if (options && options.key) {
var key = options.key;
for (var i4 = 0; i4 < targetsLen; ++i4) {
var obj = targets[i4];
var target = getValue(obj, key);
if (!target)
continue;
if (!isObj(target))
target = getPrepared(target);
if ((searchBitflags & target._bitflags) !== searchBitflags)
continue;
var result = algorithm(preparedSearch, target);
if (result === NULL)
continue;
if (result.score < threshold)
continue;
result = { target: result.target, _targetLower: "", _targetLowerCodes: NULL, _nextBeginningIndexes: NULL, _bitflags: 0, score: result.score, _indexes: result._indexes, obj };
if (resultsLen < limit) {
q4.add(result);
++resultsLen;
} else {
++limitedCount;
if (result.score > q4.peek().score)
q4.replaceTop(result);
}
}
} else if (options && options.keys) {
var scoreFn = options["scoreFn"] || defaultScoreFn;
var keys2 = options.keys;
var keysLen = keys2.length;
for (var i4 = 0; i4 < targetsLen; ++i4) {
var obj = targets[i4];
var objResults = new Array(keysLen);
for (var keyI = 0; keyI < keysLen; ++keyI) {
var key = keys2[keyI];
var target = getValue(obj, key);
if (!target) {
objResults[keyI] = NULL;
continue;
}
if (!isObj(target))
target = getPrepared(target);
if ((searchBitflags & target._bitflags) !== searchBitflags)
objResults[keyI] = NULL;
else
objResults[keyI] = algorithm(preparedSearch, target);
}
objResults.obj = obj;
var score = scoreFn(objResults);
if (score === NULL)
continue;
if (score < threshold)
continue;
objResults.score = score;
if (resultsLen < limit) {
q4.add(objResults);
++resultsLen;
} else {
++limitedCount;
if (score > q4.peek().score)
q4.replaceTop(objResults);
}
}
} else {
for (var i4 = 0; i4 < targetsLen; ++i4) {
var target = targets[i4];
if (!target)
continue;
if (!isObj(target))
target = getPrepared(target);
if ((searchBitflags & target._bitflags) !== searchBitflags)
continue;
var result = algorithm(preparedSearch, target);
if (result === NULL)
continue;
if (result.score < threshold)
continue;
if (resultsLen < limit) {
q4.add(result);
++resultsLen;
} else {
++limitedCount;
if (result.score > q4.peek().score)
q4.replaceTop(result);
}
}
}
if (resultsLen === 0)
return noResults;
var results = new Array(resultsLen);
for (var i4 = resultsLen - 1; i4 >= 0; --i4)
results[i4] = q4.poll();
results.total = resultsLen + limitedCount;
return results;
};
var highlight = (result, hOpen, hClose) => {
if (typeof hOpen === "function")
return highlightCallback(result, hOpen);
if (result === NULL)
return NULL;
if (hOpen === void 0)
hOpen = "<b>";
if (hClose === void 0)
hClose = "</b>";
var highlighted = "";
var matchesIndex = 0;
var opened = false;
var target = result.target;
var targetLen = target.length;
var indexes2 = result._indexes;
indexes2 = indexes2.slice(0, indexes2.len).sort((a3, b3) => a3 - b3);
for (var i4 = 0; i4 < targetLen; ++i4) {
var char = target[i4];
if (indexes2[matchesIndex] === i4) {
++matchesIndex;
if (!opened) {
opened = true;
highlighted += hOpen;
}
if (matchesIndex === indexes2.length) {
highlighted += char + hClose + target.substr(i4 + 1);
break;
}
} else {
if (opened) {
opened = false;
highlighted += hClose;
}
}
highlighted += char;
}
return highlighted;
};
var highlightCallback = (result, cb) => {
if (result === NULL)
return NULL;
var target = result.target;
var targetLen = target.length;
var indexes2 = result._indexes;
indexes2 = indexes2.slice(0, indexes2.len).sort((a3, b3) => a3 - b3);
var highlighted = "";
var matchI = 0;
var indexesI = 0;
var opened = false;
var result = [];
for (var i4 = 0; i4 < targetLen; ++i4) {
var char = target[i4];
if (indexes2[indexesI] === i4) {
++indexesI;
if (!opened) {
opened = true;
result.push(highlighted);
highlighted = "";
}
if (indexesI === indexes2.length) {
highlighted += char;
result.push(cb(highlighted, matchI++));
highlighted = "";
result.push(target.substr(i4 + 1));
break;
}
} else {
if (opened) {
opened = false;
result.push(cb(highlighted, matchI++));
highlighted = "";
}
}
highlighted += char;
}
return result;
};
var indexes = (result) => result._indexes.slice(0, result._indexes.len).sort((a3, b3) => a3 - b3);
var prepare = (target) => {
if (typeof target !== "string")
target = "";
var info = prepareLowerInfo(target);
return { "target": target, _targetLower: info._lower, _targetLowerCodes: info.lowerCodes, _nextBeginningIndexes: NULL, _bitflags: info.bitflags, "score": NULL, _indexes: [0], "obj": NULL };
};
var prepareSearch = (search) => {
if (typeof search !== "string")
search = "";
search = search.trim();
var info = prepareLowerInfo(search);
var spaceSearches = [];
if (info.containsSpace) {
var searches = search.split(/\s+/);
searches = [...new Set(searches)];
for (var i4 = 0; i4 < searches.length; i4++) {
if (searches[i4] === "")
continue;
var _info = prepareLowerInfo(searches[i4]);
spaceSearches.push({ lowerCodes: _info.lowerCodes, _lower: searches[i4].toLowerCase(), containsSpace: false });
}
}
return { lowerCodes: info.lowerCodes, bitflags: info.bitflags, containsSpace: info.containsSpace, _lower: info._lower, spaceSearches };
};
var getPrepared = (target) => {
if (target.length > 999)
return prepare(target);
var targetPrepared = preparedCache.get(target);
if (targetPrepared !== void 0)
return targetPrepared;
targetPrepared = prepare(target);
preparedCache.set(target, targetPrepared);
return targetPrepared;
};
var getPreparedSearch = (search) => {
if (search.length > 999)
return prepareSearch(search);
var searchPrepared = preparedSearchCache.get(search);
if (searchPrepared !== void 0)
return searchPrepared;
searchPrepared = prepareSearch(search);
preparedSearchCache.set(search, searchPrepared);
return searchPrepared;
};
var all = (search, targets, options) => {
var results = [];
results.total = targets.length;
var limit = options && options.limit || INT_MAX;
if (options && options.key) {
for (var i4 = 0; i4 < targets.length; i4++) {
var obj = targets[i4];
var target = getValue(obj, options.key);
if (!target)
continue;
if (!isObj(target))
target = getPrepared(target);
target.score = INT_MIN;
target._indexes.len = 0;
var result = target;
result = { target: result.target, _targetLower: "", _targetLowerCodes: NULL, _nextBeginningIndexes: NULL, _bitflags: 0, score: target.score, _indexes: NULL, obj };
results.push(result);
if (results.length >= limit)
return results;
}
} else if (options && options.keys) {
for (var i4 = 0; i4 < targets.length; i4++) {
var obj = targets[i4];
var objResults = new Array(options.keys.length);
for (var keyI = options.keys.length - 1; keyI >= 0; --keyI) {
var target = getValue(obj, options.keys[keyI]);
if (!target) {
objResults[keyI] = NULL;
continue;
}
if (!isObj(target))
target = getPrepared(target);
target.score = INT_MIN;
target._indexes.len = 0;
objResults[keyI] = target;
}
objResults.obj = obj;
objResults.score = INT_MIN;
results.push(objResults);
if (results.length >= limit)
return results;
}
} else {
for (var i4 = 0; i4 < targets.length; i4++) {
var target = targets[i4];
if (!target)
continue;
if (!isObj(target))
target = getPrepared(target);
target.score = INT_MIN;
target._indexes.len = 0;
results.push(target);
if (results.length >= limit)
return results;
}
}
return results;
};
var algorithm = (preparedSearch, prepared, allowSpaces = false) => {
if (allowSpaces === false && preparedSearch.containsSpace)
return algorithmSpaces(preparedSearch, prepared);
var searchLower = preparedSearch._lower;
var searchLowerCodes = preparedSearch.lowerCodes;
var searchLowerCode = searchLowerCodes[0];
var targetLowerCodes = prepared._targetLowerCodes;
var searchLen = searchLowerCodes.length;
var targetLen = targetLowerCodes.length;
var searchI = 0;
var targetI = 0;
var matchesSimpleLen = 0;
for (; ; ) {
var isMatch = searchLowerCode === targetLowerCodes[targetI];
if (isMatch) {
matchesSimple[matchesSimpleLen++] = targetI;
++searchI;
if (searchI === searchLen)
break;
searchLowerCode = searchLowerCodes[searchI];
}
++targetI;
if (targetI >= targetLen)
return NULL;
}
var searchI = 0;
var successStrict = false;
var matchesStrictLen = 0;
var nextBeginningIndexes = prepared._nextBeginningIndexes;
if (nextBeginningIndexes === NULL)
nextBeginningIndexes = prepared._nextBeginningIndexes = prepareNextBeginningIndexes(prepared.target);
var firstPossibleI = targetI = matchesSimple[0] === 0 ? 0 : nextBeginningIndexes[matchesSimple[0] - 1];
var backtrackCount = 0;
if (targetI !== targetLen)
for (; ; ) {
if (targetI >= targetLen) {
if (searchI <= 0)
break;
++backtrackCount;
if (backtrackCount > 200)
break;
--searchI;
var lastMatch = matchesStrict[--matchesStrictLen];
targetI = nextBeginningIndexes[lastMatch];
} else {
var isMatch = searchLowerCodes[searchI] === targetLowerCodes[targetI];
if (isMatch) {
matchesStrict[matchesStrictLen++] = targetI;
++searchI;
if (searchI === searchLen) {
successStrict = true;
break;
}
++targetI;
} else {
targetI = nextBeginningIndexes[targetI];
}
}
}
var substringIndex = prepared._targetLower.indexOf(searchLower, matchesSimple[0]);
var isSubstring = ~substringIndex;
if (isSubstring && !successStrict) {
for (var i4 = 0; i4 < matchesSimpleLen; ++i4)
matchesSimple[i4] = substringIndex + i4;
}
var isSubstringBeginning = false;
if (isSubstring) {
isSubstringBeginning = prepared._nextBeginningIndexes[substringIndex - 1] === substringIndex;
}
{
if (successStrict) {
var matchesBest = matchesStrict;
var matchesBestLen = matchesStrictLen;
} else {
var matchesBest = matchesSimple;
var matchesBestLen = matchesSimpleLen;
}
var score = 0;
var extraMatchGroupCount = 0;
for (var i4 = 1; i4 < searchLen; ++i4) {
if (matchesBest[i4] - matchesBest[i4 - 1] !== 1) {
score -= matchesBest[i4];
++extraMatchGroupCount;
}
}
var unmatchedDistance = matchesBest[searchLen - 1] - matchesBest[0] - (searchLen - 1);
score -= (12 + unmatchedDistance) * extraMatchGroupCount;
if (matchesBest[0] !== 0)
score -= matchesBest[0] * matchesBest[0] * 0.2;
if (!successStrict) {
score *= 1e3;
} else {
var uniqueBeginningIndexes = 1;
for (var i4 = nextBeginningIndexes[0]; i4 < targetLen; i4 = nextBeginningIndexes[i4])
++uniqueBeginningIndexes;
if (uniqueBeginningIndexes > 24)
score *= (uniqueBeginningIndexes - 24) * 10;
}
if (isSubstring)
score /= 1 + searchLen * searchLen * 1;
if (isSubstringBeginning)
score /= 1 + searchLen * searchLen * 1;
score -= targetLen - searchLen;
prepared.score = score;
for (var i4 = 0; i4 < matchesBestLen; ++i4)
prepared._indexes[i4] = matchesBest[i4];
prepared._indexes.len = matchesBestLen;
return prepared;
}
};
var algorithmSpaces = (preparedSearch, target) => {
var seen_indexes = /* @__PURE__ */ new Set();
var score = 0;
var result = NULL;
var first_seen_index_last_search = 0;
var searches = preparedSearch.spaceSearches;
for (var i4 = 0; i4 < searches.length; ++i4) {
var search = searches[i4];
result = algorithm(search, target);
if (result === NULL)
return NULL;
score += result.score;
if (result._indexes[0] < first_seen_index_last_search) {
score -= first_seen_index_last_search - result._indexes[0];
}
first_seen_index_last_search = result._indexes[0];
for (var j4 = 0; j4 < result._indexes.len; ++j4)
seen_indexes.add(result._indexes[j4]);
}
var allowSpacesResult = algorithm(
preparedSearch,
target,
/*allowSpaces=*/
true
);
if (allowSpacesResult !== NULL && allowSpacesResult.score > score) {
return allowSpacesResult;
}
result.score = score;
var i4 = 0;
for (let index of seen_indexes)
result._indexes[i4++] = index;
result._indexes.len = i4;
return result;
};
var prepareLowerInfo = (str) => {
var strLen = str.length;
var lower = str.toLowerCase();
var lowerCodes = [];
var bitflags = 0;
var containsSpace = false;
for (var i4 = 0; i4 < strLen; ++i4) {
var lowerCode = lowerCodes[i4] = lower.charCodeAt(i4);
if (lowerCode === 32) {
containsSpace = true;
continue;
}
var bit = lowerCode >= 97 && lowerCode <= 122 ? lowerCode - 97 : lowerCode >= 48 && lowerCode <= 57 ? 26 : lowerCode <= 127 ? 30 : 31;
bitflags |= 1 << bit;
}
return { lowerCodes, bitflags, containsSpace, _lower: lower };
};
var prepareBeginningIndexes = (target) => {
var targetLen = target.length;
var beginningIndexes = [];
var beginningIndexesLen = 0;
var wasUpper = false;
var wasAlphanum = false;
for (var i4 = 0; i4 < targetLen; ++i4) {
var targetCode = target.charCodeAt(i4);
var isUpper = targetCode >= 65 && targetCode <= 90;
var isAlphanum = isUpper || targetCode >= 97 && targetCode <= 122 || targetCode >= 48 && targetCode <= 57;
var isBeginning = isUpper && !wasUpper || !wasAlphanum || !isAlphanum;
wasUpper = isUpper;
wasAlphanum = isAlphanum;
if (isBeginning)
beginningIndexes[beginningIndexesLen++] = i4;
}
return beginningIndexes;
};
var prepareNextBeginningIndexes = (target) => {
var targetLen = target.length;
var beginningIndexes = prepareBeginningIndexes(target);
var nextBeginningIndexes = [];
var lastIsBeginning = beginningIndexes[0];
var lastIsBeginningI = 0;
for (var i4 = 0; i4 < targetLen; ++i4) {
if (lastIsBeginning > i4) {
nextBeginningIndexes[i4] = lastIsBeginning;
} else {
lastIsBeginning = beginningIndexes[++lastIsBeginningI];
nextBeginningIndexes[i4] = lastIsBeginning === void 0 ? targetLen : lastIsBeginning;
}
}
return nextBeginningIndexes;
};
var cleanup = () => {
preparedCache.clear();
preparedSearchCache.clear();
matchesSimple = [];
matchesStrict = [];
};
var preparedCache = /* @__PURE__ */ new Map();
var preparedSearchCache = /* @__PURE__ */ new Map();
var matchesSimple = [];
var matchesStrict = [];
var defaultScoreFn = (a3) => {
var max = INT_MIN;
var len = a3.length;
for (var i4 = 0; i4 < len; ++i4) {
var result = a3[i4];
if (result === NULL)
continue;
var score = result.score;
if (score > max)
max = score;
}
if (max === INT_MIN)
return NULL;
return max;
};
var getValue = (obj, prop) => {
var tmp = obj[prop];
if (tmp !== void 0)
return tmp;
var segs = prop;
if (!Array.isArray(prop))
segs = prop.split(".");
var len = segs.length;
var i4 = -1;
while (obj && ++i4 < len)
obj = obj[segs[i4]];
return obj;
};
var isObj = (x4) => {
return typeof x4 === "object";
};
var INT_MAX = Infinity;
var INT_MIN = -INT_MAX;
var noResults = [];
noResults.total = 0;
var NULL = null;
var fastpriorityqueue = (r3) => {
var e3 = [], o3 = 0, a3 = {}, v3 = (r4) => {
for (var a4 = 0, v4 = e3[a4], c4 = 1; c4 < o3; ) {
var s4 = c4 + 1;
a4 = c4, s4 < o3 && e3[s4].score < e3[c4].score && (a4 = s4), e3[a4 - 1 >> 1] = e3[a4], c4 = 1 + (a4 << 1);
}
for (var f3 = a4 - 1 >> 1; a4 > 0 && v4.score < e3[f3].score; f3 = (a4 = f3) - 1 >> 1)
e3[a4] = e3[f3];
e3[a4] = v4;
};
return a3.add = (r4) => {
var a4 = o3;
e3[o3++] = r4;
for (var v4 = a4 - 1 >> 1; a4 > 0 && r4.score < e3[v4].score; v4 = (a4 = v4) - 1 >> 1)
e3[a4] = e3[v4];
e3[a4] = r4;
}, a3.poll = (r4) => {
if (0 !== o3) {
var a4 = e3[0];
return e3[0] = e3[--o3], v3(), a4;
}
}, a3.peek = (r4) => {
if (0 !== o3)
return e3[0];
}, a3.replaceTop = (r4) => {
e3[0] = r4, v3();
}, a3;
};
var q4 = fastpriorityqueue();
return { "single": single, "go": go, "highlight": highlight, "prepare": prepare, "indexes": indexes, "cleanup": cleanup };
});
}
});
// src/modules/msgreader.js
var require_msgreader = __commonJS({
"src/modules/msgreader.js"(exports, module2) {
DataStream = function(arrayBuffer, byteOffset, endianness) {
this._byteOffset = byteOffset || 0;
if (arrayBuffer instanceof ArrayBuffer) {
this.buffer = arrayBuffer;
} else if (typeof arrayBuffer == "object") {
this.dataView = arrayBuffer;
if (byteOffset) {
this._byteOffset += byteOffset;
}
} else {
this.buffer = new ArrayBuffer(arrayBuffer || 1);
}
this.position = 0;
this.endianness = endianness == null ? DataStream.LITTLE_ENDIAN : endianness;
};
DataStream.prototype = {};
if (Uint8Array.prototype.BYTES_PER_ELEMENT === void 0) {
Uint8Array.prototype.BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT;
Int8Array.prototype.BYTES_PER_ELEMENT = Int8Array.BYTES_PER_ELEMENT;
Uint8ClampedArray.prototype.BYTES_PER_ELEMENT = Uint8ClampedArray.BYTES_PER_ELEMENT;
Uint16Array.prototype.BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;
Int16Array.prototype.BYTES_PER_ELEMENT = Int16Array.BYTES_PER_ELEMENT;
Uint32Array.prototype.BYTES_PER_ELEMENT = Uint32Array.BYTES_PER_ELEMENT;
Int32Array.prototype.BYTES_PER_ELEMENT = Int32Array.BYTES_PER_ELEMENT;
Float64Array.prototype.BYTES_PER_ELEMENT = Float64Array.BYTES_PER_ELEMENT;
}
DataStream.prototype.save = function(filename) {
var blob = new Blob(this.buffer);
var URL = window.webkitURL || window.URL;
if (URL && URL.createObjectURL) {
var url = URL.createObjectURL(blob);
var a3 = document.createElement("a");
a3.setAttribute("href", url);
a3.setAttribute("download", filename);
a3.click();
URL.revokeObjectURL(url);
} else {
throw "DataStream.save: Can't create object URL.";
}
};
DataStream.BIG_ENDIAN = false;
DataStream.LITTLE_ENDIAN = true;
DataStream.prototype._dynamicSize = true;
Object.defineProperty(DataStream.prototype, "dynamicSize", {
get: function() {
return this._dynamicSize;
},
set: function(v3) {
if (!v3) {
this._trimAlloc();
}
this._dynamicSize = v3;
}
});
DataStream.prototype._byteLength = 0;
Object.defineProperty(DataStream.prototype, "byteLength", {
get: function() {
return this._byteLength - this._byteOffset;
}
});
Object.defineProperty(DataStream.prototype, "buffer", {
get: function() {
this._trimAlloc();
return this._buffer;
},
set: function(v3) {
this._buffer = v3;
this._dataView = new DataView(this._buffer, this._byteOffset);
this._byteLength = this._buffer.byteLength;
}
});
Object.defineProperty(DataStream.prototype, "byteOffset", {
get: function() {
return this._byteOffset;
},
set: function(v3) {
this._byteOffset = v3;
this._dataView = new DataView(this._buffer, this._byteOffset);
this._byteLength = this._buffer.byteLength;
}
});
Object.defineProperty(DataStream.prototype, "dataView", {
get: function() {
return this._dataView;
},
set: function(v3) {
this._byteOffset = v3.byteOffset;
this._buffer = v3.buffer;
this._dataView = new DataView(this._buffer, this._byteOffset);
this._byteLength = this._byteOffset + v3.byteLength;
}
});
DataStream.prototype._realloc = function(extra) {
if (!this._dynamicSize) {
return;
}
var req = this._byteOffset + this.position + extra;
var blen = this._buffer.byteLength;
if (req <= blen) {
if (req > this._byteLength) {
this._byteLength = req;
}
return;
}
if (blen < 1) {
blen = 1;
}
while (req > blen) {
blen *= 2;
}
var buf = new ArrayBuffer(blen);
var src = new Uint8Array(this._buffer);
var dst = new Uint8Array(buf, 0, src.length);
dst.set(src);
this.buffer = buf;
this._byteLength = req;
};
DataStream.prototype._trimAlloc = function() {
if (this._byteLength == this._buffer.byteLength) {
return;
}
var buf = new ArrayBuffer(this._byteLength);
var dst = new Uint8Array(buf);
var src = new Uint8Array(this._buffer, 0, dst.length);
dst.set(src);
this.buffer = buf;
};
DataStream.prototype.seek = function(pos) {
var npos = Math.max(0, Math.min(this.byteLength, pos));
this.position = isNaN(npos) || !isFinite(npos) ? 0 : npos;
};
DataStream.prototype.isEof = function() {
return this.position >= this.byteLength;
};
DataStream.prototype.mapInt32Array = function(length, e3) {
this._realloc(length * 4);
var arr = new Int32Array(this._buffer, this.byteOffset + this.position, length);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += length * 4;
return arr;
};
DataStream.prototype.mapInt16Array = function(length, e3) {
this._realloc(length * 2);
var arr = new Int16Array(this._buffer, this.byteOffset + this.position, length);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += length * 2;
return arr;
};
DataStream.prototype.mapInt8Array = function(length) {
this._realloc(length * 1);
var arr = new Int8Array(this._buffer, this.byteOffset + this.position, length);
this.position += length * 1;
return arr;
};
DataStream.prototype.mapUint32Array = function(length, e3) {
this._realloc(length * 4);
var arr = new Uint32Array(this._buffer, this.byteOffset + this.position, length);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += length * 4;
return arr;
};
DataStream.prototype.mapUint16Array = function(length, e3) {
this._realloc(length * 2);
var arr = new Uint16Array(this._buffer, this.byteOffset + this.position, length);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += length * 2;
return arr;
};
DataStream.prototype.mapUint8Array = function(length) {
this._realloc(length * 1);
var arr = new Uint8Array(this._buffer, this.byteOffset + this.position, length);
this.position += length * 1;
return arr;
};
DataStream.prototype.mapFloat64Array = function(length, e3) {
this._realloc(length * 8);
var arr = new Float64Array(this._buffer, this.byteOffset + this.position, length);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += length * 8;
return arr;
};
DataStream.prototype.mapFloat32Array = function(length, e3) {
this._realloc(length * 4);
var arr = new Float32Array(this._buffer, this.byteOffset + this.position, length);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += length * 4;
return arr;
};
DataStream.prototype.readInt32Array = function(length, e3) {
length = length == null ? this.byteLength - this.position / 4 : length;
var arr = new Int32Array(length);
DataStream.memcpy(arr.buffer, 0, this.buffer, this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += arr.byteLength;
return arr;
};
DataStream.prototype.readInt16Array = function(length, e3) {
length = length == null ? this.byteLength - this.position / 2 : length;
var arr = new Int16Array(length);
DataStream.memcpy(arr.buffer, 0, this.buffer, this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += arr.byteLength;
return arr;
};
DataStream.prototype.readInt8Array = function(length) {
length = length == null ? this.byteLength - this.position : length;
var arr = new Int8Array(length);
DataStream.memcpy(arr.buffer, 0, this.buffer, this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT);
this.position += arr.byteLength;
return arr;
};
DataStream.prototype.readUint32Array = function(length, e3) {
length = length == null ? this.byteLength - this.position / 4 : length;
var arr = new Uint32Array(length);
DataStream.memcpy(arr.buffer, 0, this.buffer, this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += arr.byteLength;
return arr;
};
DataStream.prototype.readUint16Array = function(length, e3) {
length = length == null ? this.byteLength - this.position / 2 : length;
var arr = new Uint16Array(length);
DataStream.memcpy(arr.buffer, 0, this.buffer, this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += arr.byteLength;
return arr;
};
DataStream.prototype.readUint8Array = function(length) {
length = length == null ? this.byteLength - this.position : length;
var arr = new Uint8Array(length);
DataStream.memcpy(arr.buffer, 0, this.buffer, this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT);
this.position += arr.byteLength;
return arr;
};
DataStream.prototype.readFloat64Array = function(length, e3) {
length = length == null ? this.byteLength - this.position / 8 : length;
var arr = new Float64Array(length);
DataStream.memcpy(arr.buffer, 0, this.buffer, this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += arr.byteLength;
return arr;
};
DataStream.prototype.readFloat32Array = function(length, e3) {
length = length == null ? this.byteLength - this.position / 4 : length;
var arr = new Float32Array(length);
DataStream.memcpy(arr.buffer, 0, this.buffer, this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT);
DataStream.arrayToNative(arr, e3 == null ? this.endianness : e3);
this.position += arr.byteLength;
return arr;
};
DataStream.prototype.writeInt32Array = function(arr, e3) {
this._realloc(arr.length * 4);
if (arr instanceof Int32Array && this.byteOffset + this.position % arr.BYTES_PER_ELEMENT == 0) {
DataStream.memcpy(this._buffer, this.byteOffset + this.position, arr.buffer, 0, arr.byteLength);
this.mapInt32Array(arr.length, e3);
} else {
for (var i4 = 0; i4 < arr.length; i4++) {
this.writeInt32(arr[i4], e3);
}
}
};
DataStream.prototype.writeInt16Array = function(arr, e3) {
this._realloc(arr.length * 2);
if (arr instanceof Int16Array && this.byteOffset + this.position % arr.BYTES_PER_ELEMENT == 0) {
DataStream.memcpy(this._buffer, this.byteOffset + this.position, arr.buffer, 0, arr.byteLength);
this.mapInt16Array(arr.length, e3);
} else {
for (var i4 = 0; i4 < arr.length; i4++) {
this.writeInt16(arr[i4], e3);
}
}
};
DataStream.prototype.writeInt8Array = function(arr) {
this._realloc(arr.length * 1);
if (arr instanceof Int8Array && this.byteOffset + this.position % arr.BYTES_PER_ELEMENT == 0) {
DataStream.memcpy(this._buffer, this.byteOffset + this.position, arr.buffer, 0, arr.byteLength);
this.mapInt8Array(arr.length);
} else {
for (var i4 = 0; i4 < arr.length; i4++) {
this.writeInt8(arr[i4]);
}
}
};
DataStream.prototype.writeUint32Array = function(arr, e3) {
this._realloc(arr.length * 4);
if (arr instanceof Uint32Array && this.byteOffset + this.position % arr.BYTES_PER_ELEMENT == 0) {
DataStream.memcpy(this._buffer, this.byteOffset + this.position, arr.buffer, 0, arr.byteLength);
this.mapUint32Array(arr.length, e3);
} else {
for (var i4 = 0; i4 < arr.length; i4++) {
this.writeUint32(arr[i4], e3);
}
}
};
DataStream.prototype.writeUint16Array = function(arr, e3) {
this._realloc(arr.length * 2);
if (arr instanceof Uint16Array && this.byteOffset + this.position % arr.BYTES_PER_ELEMENT == 0) {
DataStream.memcpy(this._buffer, this.byteOffset + this.position, arr.buffer, 0, arr.byteLength);
this.mapUint16Array(arr.length, e3);
} else {
for (var i4 = 0; i4 < arr.length; i4++) {
this.writeUint16(arr[i4], e3);
}
}
};
DataStream.prototype.writeUint8Array = function(arr) {
this._realloc(arr.length * 1);
if (arr instanceof Uint8Array && this.byteOffset + this.position % arr.BYTES_PER_ELEMENT == 0) {
DataStream.memcpy(this._buffer, this.byteOffset + this.position, arr.buffer, 0, arr.byteLength);
this.mapUint8Array(arr.length);
} else {
for (var i4 = 0; i4 < arr.length; i4++) {
this.writeUint8(arr[i4]);
}
}
};
DataStream.prototype.writeFloat64Array = function(arr, e3) {
this._realloc(arr.length * 8);
if (arr instanceof Float64Array && this.byteOffset + this.position % arr.BYTES_PER_ELEMENT == 0) {
DataStream.memcpy(this._buffer, this.byteOffset + this.position, arr.buffer, 0, arr.byteLength);
this.mapFloat64Array(arr.length, e3);
} else {
for (var i4 = 0; i4 < arr.length; i4++) {
this.writeFloat64(arr[i4], e3);
}
}
};
DataStream.prototype.writeFloat32Array = function(arr, e3) {
this._realloc(arr.length * 4);
if (arr instanceof Float32Array && this.byteOffset + this.position % arr.BYTES_PER_ELEMENT == 0) {
DataStream.memcpy(this._buffer, this.byteOffset + this.position, arr.buffer, 0, arr.byteLength);
this.mapFloat32Array(arr.length, e3);
} else {
for (var i4 = 0; i4 < arr.length; i4++) {
this.writeFloat32(arr[i4], e3);
}
}
};
DataStream.prototype.readInt32 = function(e3) {
var v3 = this._dataView.getInt32(this.position, e3 == null ? this.endianness : e3);
this.position += 4;
return v3;
};
DataStream.prototype.readInt = function(offset) {
this.seek(offset);
return this.readInt32();
};
DataStream.prototype.readInt16 = function(e3) {
var v3 = this._dataView.getInt16(this.position, e3 == null ? this.endianness : e3);
this.position += 2;
return v3;
};
DataStream.prototype.readShort = function(offset) {
this.seek(offset);
return this.readInt16();
};
DataStream.prototype.readInt8 = function() {
var v3 = this._dataView.getInt8(this.position);
this.position += 1;
return v3;
};
DataStream.prototype.readByte = function(offset) {
this.seek(offset);
return this.readInt8();
};
DataStream.prototype.readUint32 = function(e3) {
var v3 = this._dataView.getUint32(this.position, e3 == null ? this.endianness : e3);
this.position += 4;
return v3;
};
DataStream.prototype.readUint16 = function(e3) {
var v3 = this._dataView.getUint16(this.position, e3 == null ? this.endianness : e3);
this.position += 2;
return v3;
};
DataStream.prototype.readUint8 = function() {
var v3 = this._dataView.getUint8(this.position);
this.position += 1;
return v3;
};
DataStream.prototype.readFloat32 = function(e3) {
var v3 = this._dataView.getFloat32(this.position, e3 == null ? this.endianness : e3);
this.position += 4;
return v3;
};
DataStream.prototype.readFloat64 = function(e3) {
var v3 = this._dataView.getFloat64(this.position, e3 == null ? this.endianness : e3);
this.position += 8;
return v3;
};
DataStream.prototype.writeInt32 = function(v3, e3) {
this._realloc(4);
this._dataView.setInt32(this.position, v3, e3 == null ? this.endianness : e3);
this.position += 4;
};
DataStream.prototype.writeInt16 = function(v3, e3) {
this._realloc(2);
this._dataView.setInt16(this.position, v3, e3 == null ? this.endianness : e3);
this.position += 2;
};
DataStream.prototype.writeInt8 = function(v3) {
this._realloc(1);
this._dataView.setInt8(this.position, v3);
this.position += 1;
};
DataStream.prototype.writeUint32 = function(v3, e3) {
this._realloc(4);
this._dataView.setUint32(this.position, v3, e3 == null ? this.endianness : e3);
this.position += 4;
};
DataStream.prototype.writeUint16 = function(v3, e3) {
this._realloc(2);
this._dataView.setUint16(this.position, v3, e3 == null ? this.endianness : e3);
this.position += 2;
};
DataStream.prototype.writeUint8 = function(v3) {
this._realloc(1);
this._dataView.setUint8(this.position, v3);
this.position += 1;
};
DataStream.prototype.writeFloat32 = function(v3, e3) {
this._realloc(4);
this._dataView.setFloat32(this.position, v3, e3 == null ? this.endianness : e3);
this.position += 4;
};
DataStream.prototype.writeFloat64 = function(v3, e3) {
this._realloc(8);
this._dataView.setFloat64(this.position, v3, e3 == null ? this.endianness : e3);
this.position += 8;
};
DataStream.endianness = new Int8Array(new Int16Array([1]).buffer)[0] > 0;
DataStream.memcpy = function(dst, dstOffset, src, srcOffset, byteLength) {
var dstU8 = new Uint8Array(dst, dstOffset, byteLength);
var srcU8 = new Uint8Array(src, srcOffset, byteLength);
dstU8.set(srcU8);
};
DataStream.arrayToNative = function(array, arrayIsLittleEndian) {
if (arrayIsLittleEndian == this.endianness) {
return array;
} else {
return this.flipArrayEndianness(array);
}
};
DataStream.nativeToEndian = function(array, littleEndian) {
if (this.endianness == littleEndian) {
return array;
} else {
return this.flipArrayEndianness(array);
}
};
DataStream.flipArrayEndianness = function(array) {
var u8 = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
for (var i4 = 0; i4 < array.byteLength; i4 += array.BYTES_PER_ELEMENT) {
for (var j4 = i4 + array.BYTES_PER_ELEMENT - 1, k4 = i4; j4 > k4; j4--, k4++) {
var tmp = u8[k4];
u8[k4] = u8[j4];
u8[j4] = tmp;
}
}
return array;
};
DataStream.createStringFromArray = function(array) {
var str = "";
for (var i4 = 0; i4 < array.length; i4++) {
str += String.fromCharCode(array[i4]);
}
return str;
};
DataStream.prototype.failurePosition = 0;
DataStream.prototype.readStruct = function(structDefinition) {
var struct = {}, t3, v3, n3;
var p3 = this.position;
for (var i4 = 0; i4 < structDefinition.length; i4 += 2) {
t3 = structDefinition[i4 + 1];
v3 = this.readType(t3, struct);
if (v3 == null) {
if (this.failurePosition == 0) {
this.failurePosition = this.position;
}
this.position = p3;
return null;
}
struct[structDefinition[i4]] = v3;
}
return struct;
};
DataStream.prototype.readUCS2String = function(length, endianness) {
return DataStream.createStringFromArray(this.readUint16Array(length, endianness));
};
DataStream.prototype.readStringAt = function(offset, length) {
this.seek(offset);
return this.readUCS2String(length);
};
DataStream.prototype.writeUCS2String = function(str, endianness, lengthOverride) {
if (lengthOverride == null) {
lengthOverride = str.length;
}
for (var i4 = 0; i4 < str.length && i4 < lengthOverride; i4++) {
this.writeUint16(str.charCodeAt(i4), endianness);
}
for (; i4 < lengthOverride; i4++) {
this.writeUint16(0);
}
};
DataStream.prototype.readString = function(length, encoding) {
if (encoding == null || encoding == "ASCII") {
return DataStream.createStringFromArray(
this.mapUint8Array(length == null ? this.byteLength - this.position : length)
);
} else {
return new TextDecoder(encoding).decode(this.mapUint8Array(length));
}
};
DataStream.prototype.writeString = function(s4, encoding, length) {
if (encoding == null || encoding == "ASCII") {
if (length != null) {
var i4 = 0;
var len = Math.min(s4.length, length);
for (i4 = 0; i4 < len; i4++) {
this.writeUint8(s4.charCodeAt(i4));
}
for (; i4 < length; i4++) {
this.writeUint8(0);
}
} else {
for (var i4 = 0; i4 < s4.length; i4++) {
this.writeUint8(s4.charCodeAt(i4));
}
}
} else {
this.writeUint8Array(new TextEncoder(encoding).encode(s4.substring(0, length)));
}
};
DataStream.prototype.readCString = function(length) {
var blen = this.byteLength - this.position;
var u8 = new Uint8Array(this._buffer, this._byteOffset + this.position);
var len = blen;
if (length != null) {
len = Math.min(length, blen);
}
for (var i4 = 0; i4 < len && u8[i4] != 0; i4++)
;
var s4 = DataStream.createStringFromArray(this.mapUint8Array(i4));
if (length != null) {
this.position += len - i4;
} else if (i4 != blen) {
this.position += 1;
}
return s4;
};
DataStream.prototype.writeCString = function(s4, length) {
if (length != null) {
var i4 = 0;
var len = Math.min(s4.length, length);
for (i4 = 0; i4 < len; i4++) {
this.writeUint8(s4.charCodeAt(i4));
}
for (; i4 < length; i4++) {
this.writeUint8(0);
}
} else {
for (var i4 = 0; i4 < s4.length; i4++) {
this.writeUint8(s4.charCodeAt(i4));
}
this.writeUint8(0);
}
};
DataStream.prototype.readType = function(t3, struct) {
if (typeof t3 == "function") {
return t3(this, struct);
} else if (typeof t3 == "object" && !(t3 instanceof Array)) {
return t3.get(this, struct);
} else if (t3 instanceof Array && t3.length != 3) {
return this.readStruct(t3, struct);
}
var v3 = null;
var lengthOverride = null;
var charset = "ASCII";
var pos = this.position;
var len;
if (typeof t3 == "string" && /:/.test(t3)) {
var tp = t3.split(":");
t3 = tp[0];
len = tp[1];
if (struct[len] != null) {
lengthOverride = parseInt(struct[len]);
} else {
lengthOverride = parseInt(tp[1]);
}
}
if (typeof t3 == "string" && /,/.test(t3)) {
var tp = t3.split(",");
t3 = tp[0];
charset = parseInt(tp[1]);
}
switch (t3) {
case "uint8":
v3 = this.readUint8();
break;
case "int8":
v3 = this.readInt8();
break;
case "uint16":
v3 = this.readUint16(this.endianness);
break;
case "int16":
v3 = this.readInt16(this.endianness);
break;
case "uint32":
v3 = this.readUint32(this.endianness);
break;
case "int32":
v3 = this.readInt32(this.endianness);
break;
case "float32":
v3 = this.readFloat32(this.endianness);
break;
case "float64":
v3 = this.readFloat64(this.endianness);
break;
case "uint16be":
v3 = this.readUint16(DataStream.BIG_ENDIAN);
break;
case "int16be":
v3 = this.readInt16(DataStream.BIG_ENDIAN);
break;
case "uint32be":
v3 = this.readUint32(DataStream.BIG_ENDIAN);
break;
case "int32be":
v3 = this.readInt32(DataStream.BIG_ENDIAN);
break;
case "float32be":
v3 = this.readFloat32(DataStream.BIG_ENDIAN);
break;
case "float64be":
v3 = this.readFloat64(DataStream.BIG_ENDIAN);
break;
case "uint16le":
v3 = this.readUint16(DataStream.LITTLE_ENDIAN);
break;
case "int16le":
v3 = this.readInt16(DataStream.LITTLE_ENDIAN);
break;
case "uint32le":
v3 = this.readUint32(DataStream.LITTLE_ENDIAN);
break;
case "int32le":
v3 = this.readInt32(DataStream.LITTLE_ENDIAN);
break;
case "float32le":
v3 = this.readFloat32(DataStream.LITTLE_ENDIAN);
break;
case "float64le":
v3 = this.readFloat64(DataStream.LITTLE_ENDIAN);
break;
case "cstring":
v3 = this.readCString(lengthOverride);
break;
case "string":
v3 = this.readString(lengthOverride, charset);
break;
case "u16string":
v3 = this.readUCS2String(lengthOverride, this.endianness);
break;
case "u16stringle":
v3 = this.readUCS2String(lengthOverride, DataStream.LITTLE_ENDIAN);
break;
case "u16stringbe":
v3 = this.readUCS2String(lengthOverride, DataStream.BIG_ENDIAN);
break;
default:
if (t3.length == 3) {
var ta = t3[1];
var len = t3[2];
var length = 0;
if (typeof len == "function") {
length = len(struct, this, t3);
} else if (typeof len == "string" && struct[len] != null) {
length = parseInt(struct[len]);
} else {
length = parseInt(len);
}
if (typeof ta == "string") {
var tap = ta.replace(/(le|be)$/, "");
var endianness = null;
if (/le$/.test(ta)) {
endianness = DataStream.LITTLE_ENDIAN;
} else if (/be$/.test(ta)) {
endianness = DataStream.BIG_ENDIAN;
}
if (len == "*") {
length = null;
}
switch (tap) {
case "uint8":
v3 = this.readUint8Array(length);
break;
case "uint16":
v3 = this.readUint16Array(length, endianness);
break;
case "uint32":
v3 = this.readUint32Array(length, endianness);
break;
case "int8":
v3 = this.readInt8Array(length);
break;
case "int16":
v3 = this.readInt16Array(length, endianness);
break;
case "int32":
v3 = this.readInt32Array(length, endianness);
break;
case "float32":
v3 = this.readFloat32Array(length, endianness);
break;
case "float64":
v3 = this.readFloat64Array(length, endianness);
break;
case "cstring":
case "utf16string":
case "string":
if (length == null) {
v3 = [];
while (!this.isEof()) {
var u3 = this.readType(ta, struct);
if (u3 == null)
break;
v3.push(u3);
}
} else {
v3 = new Array(length);
for (var i4 = 0; i4 < length; i4++) {
v3[i4] = this.readType(ta, struct);
}
}
break;
}
} else {
if (len == "*") {
v3 = [];
this.buffer;
while (true) {
var p3 = this.position;
try {
var o3 = this.readType(ta, struct);
if (o3 == null) {
this.position = p3;
break;
}
v3.push(o3);
} catch (e3) {
this.position = p3;
break;
}
}
} else {
v3 = new Array(length);
for (var i4 = 0; i4 < length; i4++) {
var u3 = this.readType(ta, struct);
if (u3 == null)
return null;
v3[i4] = u3;
}
}
}
break;
}
}
if (lengthOverride != null) {
this.position = pos + lengthOverride;
}
return v3;
};
DataStream.prototype.writeStruct = function(structDefinition, struct) {
for (var i4 = 0; i4 < structDefinition.length; i4 += 2) {
var t3 = structDefinition[i4 + 1];
this.writeType(t3, struct[structDefinition[i4]], struct);
}
};
DataStream.prototype.writeType = function(t3, v3, struct) {
if (typeof t3 == "function") {
return t3(this, v3);
} else if (typeof t3 == "object" && !(t3 instanceof Array)) {
return t3.set(this, v3, struct);
}
var lengthOverride = null;
var charset = "ASCII";
var pos = this.position;
if (typeof t3 == "string" && /:/.test(t3)) {
var tp = t3.split(":");
t3 = tp[0];
lengthOverride = parseInt(tp[1]);
}
if (typeof t3 == "string" && /,/.test(t3)) {
var tp = t3.split(",");
t3 = tp[0];
charset = parseInt(tp[1]);
}
switch (t3) {
case "uint8":
this.writeUint8(v3);
break;
case "int8":
this.writeInt8(v3);
break;
case "uint16":
this.writeUint16(v3, this.endianness);
break;
case "int16":
this.writeInt16(v3, this.endianness);
break;
case "uint32":
this.writeUint32(v3, this.endianness);
break;
case "int32":
this.writeInt32(v3, this.endianness);
break;
case "float32":
this.writeFloat32(v3, this.endianness);
break;
case "float64":
this.writeFloat64(v3, this.endianness);
break;
case "uint16be":
this.writeUint16(v3, DataStream.BIG_ENDIAN);
break;
case "int16be":
this.writeInt16(v3, DataStream.BIG_ENDIAN);
break;
case "uint32be":
this.writeUint32(v3, DataStream.BIG_ENDIAN);
break;
case "int32be":
this.writeInt32(v3, DataStream.BIG_ENDIAN);
break;
case "float32be":
this.writeFloat32(v3, DataStream.BIG_ENDIAN);
break;
case "float64be":
this.writeFloat64(v3, DataStream.BIG_ENDIAN);
break;
case "uint16le":
this.writeUint16(v3, DataStream.LITTLE_ENDIAN);
break;
case "int16le":
this.writeInt16(v3, DataStream.LITTLE_ENDIAN);
break;
case "uint32le":
this.writeUint32(v3, DataStream.LITTLE_ENDIAN);
break;
case "int32le":
this.writeInt32(v3, DataStream.LITTLE_ENDIAN);
break;
case "float32le":
this.writeFloat32(v3, DataStream.LITTLE_ENDIAN);
break;
case "float64le":
this.writeFloat64(v3, DataStream.LITTLE_ENDIAN);
break;
case "cstring":
this.writeCString(v3, lengthOverride);
break;
case "string":
this.writeString(v3, charset, lengthOverride);
break;
case "u16string":
this.writeUCS2String(v3, this.endianness, lengthOverride);
break;
case "u16stringle":
this.writeUCS2String(v3, DataStream.LITTLE_ENDIAN, lengthOverride);
break;
case "u16stringbe":
this.writeUCS2String(v3, DataStream.BIG_ENDIAN, lengthOverride);
break;
default:
if (t3.length == 3) {
var ta = t3[1];
for (var i4 = 0; i4 < v3.length; i4++) {
this.writeType(ta, v3[i4]);
}
break;
} else {
this.writeStruct(t3, v3);
break;
}
}
if (lengthOverride != null) {
this.position = pos;
this._realloc(lengthOverride);
this.position = pos + lengthOverride;
}
};
if (typeof define === "function" && define.amd) {
define("DataStream", [], function() {
return DataStream;
});
}
var CONST = {
FILE_HEADER: uInt2int([208, 207, 17, 224, 161, 177, 26, 225]),
MSG: {
UNUSED_BLOCK: -1,
END_OF_CHAIN: -2,
S_BIG_BLOCK_SIZE: 512,
S_BIG_BLOCK_MARK: 9,
L_BIG_BLOCK_SIZE: 4096,
L_BIG_BLOCK_MARK: 12,
SMALL_BLOCK_SIZE: 64,
BIG_BLOCK_MIN_DOC_SIZE: 4096,
HEADER: {
PROPERTY_START_OFFSET: 48,
BAT_START_OFFSET: 76,
BAT_COUNT_OFFSET: 44,
SBAT_START_OFFSET: 60,
SBAT_COUNT_OFFSET: 64,
XBAT_START_OFFSET: 68,
XBAT_COUNT_OFFSET: 72
},
PROP: {
NO_INDEX: -1,
PROPERTY_SIZE: 128,
NAME_SIZE_OFFSET: 64,
MAX_NAME_LENGTH: (
/*NAME_SIZE_OFFSET*/
64 / 2 - 1
),
TYPE_OFFSET: 66,
PREVIOUS_PROPERTY_OFFSET: 68,
NEXT_PROPERTY_OFFSET: 72,
CHILD_PROPERTY_OFFSET: 76,
START_BLOCK_OFFSET: 116,
SIZE_OFFSET: 120,
TYPE_ENUM: {
DIRECTORY: 1,
DOCUMENT: 2,
ROOT: 5
}
},
FIELD: {
PREFIX: {
ATTACHMENT: "__attach_version1.0",
RECIPIENT: "__recip_version1.0",
DOCUMENT: "__substg1."
},
// example (use fields as needed)
NAME_MAPPING: {
// email specific
"0037": "subject",
"0c1a": "senderName",
"5d02": "senderEmail",
1e3: "body",
1013: "bodyHTML",
"007d": "headers",
// attachment specific
3703: "extension",
3704: "fileNameShort",
3707: "fileName",
3712: "pidContentId",
"370e": "mimeType",
// recipient specific
3001: "name",
"39fe": "email"
},
CLASS_MAPPING: {
ATTACHMENT_DATA: "3701"
},
TYPE_MAPPING: {
"001e": "string",
"001f": "unicode",
"0102": "binary"
},
DIR_TYPE: {
INNER_MSG: "000d"
}
}
}
};
function arraysEqual(a3, b3) {
if (a3 === b3)
return true;
if (a3 == null || b3 == null)
return false;
if (a3.length != b3.length)
return false;
for (var i4 = 0; i4 < a3.length; i4++) {
if (a3[i4] !== b3[i4])
return false;
}
return true;
}
function uInt2int(data) {
var result = new Array(data.length);
for (var i4 = 0; i4 < data.length; i4++) {
result[i4] = data[i4] << 24 >> 24;
}
return result;
}
function isMSGFile(ds) {
ds.seek(0);
return arraysEqual(CONST.FILE_HEADER, ds.readInt8Array(CONST.FILE_HEADER.length));
}
function getBlockOffsetAt(msgData, offset) {
return (offset + 1) * msgData.bigBlockSize;
}
function getBlockAt(ds, msgData, offset) {
var startOffset = getBlockOffsetAt(msgData, offset);
ds.seek(startOffset);
return ds.readInt32Array(msgData.bigBlockLength);
}
function getNextBlockInner(ds, msgData, offset, blockOffsetData) {
var currentBlock = Math.floor(offset / msgData.bigBlockLength);
var currentBlockIndex = offset % msgData.bigBlockLength;
var startBlockOffset = blockOffsetData[currentBlock];
return getBlockAt(ds, msgData, startBlockOffset)[currentBlockIndex];
}
function getNextBlock(ds, msgData, offset) {
return getNextBlockInner(ds, msgData, offset, msgData.batData);
}
function getNextBlockSmall(ds, msgData, offset) {
return getNextBlockInner(ds, msgData, offset, msgData.sbatData);
}
function parseMsgData(ds) {
var msgData = headerData(ds);
msgData.batData = batData(ds, msgData);
msgData.sbatData = sbatData(ds, msgData);
if (msgData.xbatCount > 0) {
xbatData(ds, msgData);
}
msgData.propertyData = propertyData(ds, msgData);
msgData.fieldsData = fieldsData(ds, msgData);
return msgData;
}
function headerData(ds) {
var headerData2 = {};
headerData2.bigBlockSize = ds.readByte(
/*const position*/
30
) == CONST.MSG.L_BIG_BLOCK_MARK ? CONST.MSG.L_BIG_BLOCK_SIZE : CONST.MSG.S_BIG_BLOCK_SIZE;
headerData2.bigBlockLength = headerData2.bigBlockSize / 4;
headerData2.xBlockLength = headerData2.bigBlockLength - 1;
headerData2.batCount = ds.readInt(CONST.MSG.HEADER.BAT_COUNT_OFFSET);
headerData2.propertyStart = ds.readInt(CONST.MSG.HEADER.PROPERTY_START_OFFSET);
headerData2.sbatStart = ds.readInt(CONST.MSG.HEADER.SBAT_START_OFFSET);
headerData2.sbatCount = ds.readInt(CONST.MSG.HEADER.SBAT_COUNT_OFFSET);
headerData2.xbatStart = ds.readInt(CONST.MSG.HEADER.XBAT_START_OFFSET);
headerData2.xbatCount = ds.readInt(CONST.MSG.HEADER.XBAT_COUNT_OFFSET);
return headerData2;
}
function batCountInHeader(msgData) {
var maxBatsInHeader = (CONST.MSG.S_BIG_BLOCK_SIZE - CONST.MSG.HEADER.BAT_START_OFFSET) / 4;
return Math.min(msgData.batCount, maxBatsInHeader);
}
function batData(ds, msgData) {
var result = new Array(batCountInHeader(msgData));
ds.seek(CONST.MSG.HEADER.BAT_START_OFFSET);
for (var i4 = 0; i4 < result.length; i4++) {
result[i4] = ds.readInt32();
}
return result;
}
function sbatData(ds, msgData) {
var result = [];
var startIndex = msgData.sbatStart;
for (var i4 = 0; i4 < msgData.sbatCount && startIndex != CONST.MSG.END_OF_CHAIN; i4++) {
result.push(startIndex);
startIndex = getNextBlock(ds, msgData, startIndex);
}
return result;
}
function xbatData(ds, msgData) {
var batCount = batCountInHeader(msgData);
var batCountTotal = msgData.batCount;
var remainingBlocks = batCountTotal - batCount;
var nextBlockAt = msgData.xbatStart;
for (var i4 = 0; i4 < msgData.xbatCount; i4++) {
var xBatBlock = getBlockAt(ds, msgData, nextBlockAt);
nextBlockAt = xBatBlock[msgData.xBlockLength];
var blocksToProcess = Math.min(remainingBlocks, msgData.xBlockLength);
for (var j4 = 0; j4 < blocksToProcess; j4++) {
var blockStartAt = xBatBlock[j4];
if (blockStartAt == CONST.MSG.UNUSED_BLOCK || blockStartAt == CONST.MSG.END_OF_CHAIN) {
break;
}
msgData.batData.push(blockStartAt);
}
remainingBlocks -= blocksToProcess;
}
}
function propertyData(ds, msgData) {
var props2 = [];
var currentOffset = msgData.propertyStart;
while (currentOffset != CONST.MSG.END_OF_CHAIN) {
convertBlockToProperties(ds, msgData, currentOffset, props2);
currentOffset = getNextBlock(ds, msgData, currentOffset);
}
createPropertyHierarchy(
props2,
/*property with index 0 (zero) always as root*/
props2[0]
);
return props2;
}
function convertName(ds, offset) {
var nameLength = ds.readShort(offset + CONST.MSG.PROP.NAME_SIZE_OFFSET);
if (nameLength < 1) {
return "";
} else {
return ds.readStringAt(offset, nameLength / 2);
}
}
function convertProperty(ds, index, offset) {
return {
index,
type: ds.readByte(offset + CONST.MSG.PROP.TYPE_OFFSET),
name: convertName(ds, offset),
// hierarchy
previousProperty: ds.readInt(offset + CONST.MSG.PROP.PREVIOUS_PROPERTY_OFFSET),
nextProperty: ds.readInt(offset + CONST.MSG.PROP.NEXT_PROPERTY_OFFSET),
childProperty: ds.readInt(offset + CONST.MSG.PROP.CHILD_PROPERTY_OFFSET),
// data offset
startBlock: ds.readInt(offset + CONST.MSG.PROP.START_BLOCK_OFFSET),
sizeBlock: ds.readInt(offset + CONST.MSG.PROP.SIZE_OFFSET)
};
}
function convertBlockToProperties(ds, msgData, propertyBlockOffset, props2) {
var propertyCount = msgData.bigBlockSize / CONST.MSG.PROP.PROPERTY_SIZE;
var propertyOffset = getBlockOffsetAt(msgData, propertyBlockOffset);
for (var i4 = 0; i4 < propertyCount; i4++) {
var propertyType = ds.readByte(propertyOffset + CONST.MSG.PROP.TYPE_OFFSET);
switch (propertyType) {
case CONST.MSG.PROP.TYPE_ENUM.ROOT:
case CONST.MSG.PROP.TYPE_ENUM.DIRECTORY:
case CONST.MSG.PROP.TYPE_ENUM.DOCUMENT:
props2.push(convertProperty(ds, props2.length, propertyOffset));
break;
default:
props2.push(null);
}
propertyOffset += CONST.MSG.PROP.PROPERTY_SIZE;
}
}
function createPropertyHierarchy(props2, nodeProperty) {
if (nodeProperty.childProperty == CONST.MSG.PROP.NO_INDEX) {
return;
}
nodeProperty.children = [];
var children = [nodeProperty.childProperty];
while (children.length != 0) {
var currentIndex = children.shift();
var current = props2[currentIndex];
if (current == null) {
continue;
}
nodeProperty.children.push(currentIndex);
if (current.type == CONST.MSG.PROP.TYPE_ENUM.DIRECTORY) {
createPropertyHierarchy(props2, current);
}
if (current.previousProperty != CONST.MSG.PROP.NO_INDEX) {
children.push(current.previousProperty);
}
if (current.nextProperty != CONST.MSG.PROP.NO_INDEX) {
children.push(current.nextProperty);
}
}
}
function fieldsData(ds, msgData) {
var fields = {
attachments: [],
recipients: []
};
fieldsDataDir(ds, msgData, msgData.propertyData[0], fields);
return fields;
}
function fieldsDataDir(ds, msgData, dirProperty, fields) {
if (dirProperty.children && dirProperty.children.length > 0) {
for (var i4 = 0; i4 < dirProperty.children.length; i4++) {
var childProperty = msgData.propertyData[dirProperty.children[i4]];
if (childProperty.type == CONST.MSG.PROP.TYPE_ENUM.DIRECTORY) {
fieldsDataDirInner(ds, msgData, childProperty, fields);
} else if (childProperty.type == CONST.MSG.PROP.TYPE_ENUM.DOCUMENT && childProperty.name.indexOf(CONST.MSG.FIELD.PREFIX.DOCUMENT) == 0) {
fieldsDataDocument(ds, msgData, childProperty, fields);
}
}
}
}
function fieldsDataDirInner(ds, msgData, dirProperty, fields) {
if (dirProperty.name.indexOf(CONST.MSG.FIELD.PREFIX.ATTACHMENT) == 0) {
var attachmentField = {};
fields.attachments.push(attachmentField);
fieldsDataDir(ds, msgData, dirProperty, attachmentField);
} else if (dirProperty.name.indexOf(CONST.MSG.FIELD.PREFIX.RECIPIENT) == 0) {
var recipientField = {};
fields.recipients.push(recipientField);
fieldsDataDir(ds, msgData, dirProperty, recipientField);
} else {
var childFieldType = getFieldType(dirProperty);
if (childFieldType != CONST.MSG.FIELD.DIR_TYPE.INNER_MSG) {
fieldsDataDir(ds, msgData, dirProperty, fields);
} else {
fields.innerMsgContent = true;
}
}
}
function isAddPropertyValue(fieldName, fieldTypeMapped) {
return fieldName !== "body" || fieldTypeMapped !== "binary";
}
function fieldsDataDocument(ds, msgData, documentProperty, fields) {
var value = documentProperty.name.substring(12).toLowerCase();
var fieldClass = value.substring(0, 4);
var fieldType = value.substring(4, 8);
var fieldName = CONST.MSG.FIELD.NAME_MAPPING[fieldClass];
var fieldTypeMapped = CONST.MSG.FIELD.TYPE_MAPPING[fieldType];
if (fieldName) {
var fieldValue = getFieldValue(ds, msgData, documentProperty, fieldTypeMapped);
if (isAddPropertyValue(fieldName, fieldTypeMapped)) {
fields[fieldName] = applyValueConverter(fieldName, fieldTypeMapped, fieldValue);
}
}
if (fieldClass == CONST.MSG.FIELD.CLASS_MAPPING.ATTACHMENT_DATA) {
fields["dataId"] = documentProperty.index;
fields["contentLength"] = documentProperty.sizeBlock;
}
}
function applyValueConverter(fieldName, fieldTypeMapped, fieldValue) {
if (fieldTypeMapped === "binary" && fieldName === "bodyHTML") {
return convertUint8ArrayToString(fieldValue);
}
return fieldValue;
}
function getFieldType(fieldProperty) {
var value = fieldProperty.name.substring(12).toLowerCase();
return value.substring(4, 8);
}
var extractorFieldValue = {
sbat: {
extractor: function extractDataViaSbat(ds, msgData, fieldProperty, dataTypeExtractor) {
var chain = getChainByBlockSmall(ds, msgData, fieldProperty);
if (chain.length == 1) {
return readDataByBlockSmall(
ds,
msgData,
fieldProperty.startBlock,
fieldProperty.sizeBlock,
dataTypeExtractor
);
} else if (chain.length > 1) {
return readChainDataByBlockSmall(ds, msgData, fieldProperty, chain, dataTypeExtractor);
}
return null;
},
dataType: {
string: function extractBatString(ds, msgData, blockStartOffset, bigBlockOffset, blockSize) {
ds.seek(blockStartOffset + bigBlockOffset);
return ds.readString(blockSize);
},
unicode: function extractBatUnicode(ds, msgData, blockStartOffset, bigBlockOffset, blockSize) {
ds.seek(blockStartOffset + bigBlockOffset);
return ds.readUCS2String(blockSize / 2);
},
binary: function extractBatBinary(ds, msgData, blockStartOffset, bigBlockOffset, blockSize) {
ds.seek(blockStartOffset + bigBlockOffset);
return ds.readUint8Array(blockSize);
}
}
},
bat: {
extractor: function extractDataViaBat(ds, msgData, fieldProperty, dataTypeExtractor) {
var offset = getBlockOffsetAt(msgData, fieldProperty.startBlock);
ds.seek(offset);
return dataTypeExtractor(ds, fieldProperty);
},
dataType: {
string: function extractSbatString(ds, fieldProperty) {
return ds.readString(fieldProperty.sizeBlock);
},
unicode: function extractSbatUnicode(ds, fieldProperty) {
return ds.readUCS2String(fieldProperty.sizeBlock / 2);
},
binary: function extractSbatBinary(ds, fieldProperty) {
return ds.readUint8Array(fieldProperty.sizeBlock);
}
}
}
};
function readDataByBlockSmall(ds, msgData, startBlock, blockSize, dataTypeExtractor) {
var byteOffset = startBlock * CONST.MSG.SMALL_BLOCK_SIZE;
var bigBlockNumber = Math.floor(byteOffset / msgData.bigBlockSize);
var bigBlockOffset = byteOffset % msgData.bigBlockSize;
var rootProp = msgData.propertyData[0];
var nextBlock = rootProp.startBlock;
for (var i4 = 0; i4 < bigBlockNumber; i4++) {
nextBlock = getNextBlock(ds, msgData, nextBlock);
}
var blockStartOffset = getBlockOffsetAt(msgData, nextBlock);
return dataTypeExtractor(ds, msgData, blockStartOffset, bigBlockOffset, blockSize);
}
function readChainDataByBlockSmall(ds, msgData, fieldProperty, chain, dataTypeExtractor) {
var resultData = new Int8Array(fieldProperty.sizeBlock);
for (var i4 = 0, idx = 0; i4 < chain.length; i4++) {
var data = readDataByBlockSmall(
ds,
msgData,
chain[i4],
CONST.MSG.SMALL_BLOCK_SIZE,
extractorFieldValue.sbat.dataType.binary
);
for (var j4 = 0; j4 < data.length; j4++) {
resultData[idx++] = data[j4];
}
}
var localDs = new DataStream(resultData, 0, DataStream.LITTLE_ENDIAN);
return dataTypeExtractor(localDs, msgData, 0, 0, fieldProperty.sizeBlock);
}
function getChainByBlockSmall(ds, msgData, fieldProperty) {
var blockChain = [];
var nextBlockSmall = fieldProperty.startBlock;
while (nextBlockSmall != CONST.MSG.END_OF_CHAIN) {
blockChain.push(nextBlockSmall);
nextBlockSmall = getNextBlockSmall(ds, msgData, nextBlockSmall);
}
return blockChain;
}
function getFieldValue(ds, msgData, fieldProperty, typeMapped) {
var value = null;
var valueExtractor = fieldProperty.sizeBlock < CONST.MSG.BIG_BLOCK_MIN_DOC_SIZE ? extractorFieldValue.sbat : extractorFieldValue.bat;
var dataTypeExtractor = valueExtractor.dataType[typeMapped];
if (dataTypeExtractor) {
value = valueExtractor.extractor(ds, msgData, fieldProperty, dataTypeExtractor);
}
return value;
}
function convertUint8ArrayToString(uint8ArraValue) {
return new TextDecoder("utf-8").decode(uint8ArraValue);
}
var MSGReader2 = function(arrayBuffer) {
this.ds = new DataStream(arrayBuffer, 0, DataStream.LITTLE_ENDIAN);
};
MSGReader2.prototype = {
/**
Converts bytes to fields information
@return {Object} The fields data for MSG file
*/
getFileData: function() {
if (!isMSGFile(this.ds)) {
return { error: "Unsupported file type!" };
}
if (this.fileData == null) {
this.fileData = parseMsgData(this.ds);
}
return this.fileData.fieldsData;
},
/**
Reads an attachment content by key/ID
@return {Object} The attachment for specific attachment key
*/
getAttachment: function(attach) {
var attachData = typeof attach === "number" ? this.fileData.fieldsData.attachments[attach] : attach;
var fieldProperty = this.fileData.propertyData[attachData.dataId];
var fieldTypeMapped = CONST.MSG.FIELD.TYPE_MAPPING[getFieldType(fieldProperty)];
var fieldData = getFieldValue(this.ds, this.fileData, fieldProperty, fieldTypeMapped);
return { fileName: attachData.fileName, content: fieldData };
}
};
module2.exports = {
MSGReader: MSGReader2,
DataStream
};
}
});
// node_modules/@sinonjs/text-encoding/lib/encoding-indexes.js
var require_encoding_indexes = __commonJS({
"node_modules/@sinonjs/text-encoding/lib/encoding-indexes.js"(exports, module2) {
(function(global2) {
"use strict";
if (typeof module2 !== "undefined" && module2.exports) {
module2.exports = global2;
}
global2["encoding-indexes"] = {
"big5": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null
"euc-kr": [44034, 44035, 44037, 44038, 44043, 44044, 44045, 44046, 44047, 44056, 44062, 44063, 44065, 44066, 44067, 44069, 44070, 44071, 44072, 44073, 44074, 44075, 44078, 44082, 44083, 44084, null, null, null, null, null, null, 44085, 44086, 44087, 44090, 44091, 44093, 44094, 44095, 44097, 44098, 44099, 44100, 44101, 44102, 44103, 44104, 44105, 44106, 44108, 44110, 44111, 44112, 44113, 44114, 44115, 44117, null, null, null, null, null, null, 44118, 44119, 44121, 44122, 44123, 44125, 44126, 44127, 44128, 44129, 44130, 44131, 44132, 44133, 44134, 44135, 44136, 44137, 44138, 44139, 44140, 44141, 44142, 44143, 44146, 44147, 44149, 44150, 44153, 44155, 44156, 44157, 44158, 44159, 44162, 44167, 44168, 44173, 44174, 44175, 44177, 44178, 44179, 44181, 44182, 44183, 44184, 44185, 44186, 44187, 44190, 44194, 44195, 44196, 44197, 44198, 44199, 44203, 44205, 44206, 44209, 44210, 44211, 44212, 44213, 44214, 44215, 44218, 44222, 44223, 44224, 44226, 44227, 44229, 44230, 44231, 44233, 44234, 44235, 44237, 44238, 44239, 44240, 44241, 44242, 44243, 44244, 44246, 44248, 44249, 44250, 44251, 44252, 44253, 44254, 44255, 44258, 44259, 44261, 44262, 44265, 44267, 44269, 44270, 44274, 44276, 44279, 44280, 44281, 44282, 44283, 44286, 44287, 44289, 44290, 44291, 44293, 44295, 44296, 44297, 44298, 44299, 44302, 44304, 44306, 44307, 44308, 44309, 44310, 44311, 44313, 44314, 44315, 44317, 44318, 44319, 44321, 44322, 44323, 44324, 44325, 44326, 44327, 44328, 44330, 44331, 44334, 44335, 44336, 44337, 44338, 44339, null, null, null, null, null, null, 44342, 44343, 44345, 44346, 44347, 44349, 44350, 44351, 44352, 44353, 44354, 44355, 44358, 44360, 44362, 44363, 44364, 44365, 44366, 44367, 44369, 44370, 44371, 44373, 44374, 44375, null, null, null, null, null, null, 44377, 44378, 44379, 44380, 44381, 44382, 44383, 44384, 44386, 44388, 44389, 44390, 44391, 44392, 44393, 44394, 44395, 44398, 44399, 44401, 44402, 44407, 44408, 44409, 44410, 44414, 44416, 44419, 44420, 44421, 44422, 44423, 44426, 44427, 44429, 44430, 44431, 44433, 44434, 44435, 44436, 44437, 44438, 44439, 44440, 44441, 44442, 44443, 44446, 44447, 44448, 44449, 44450, 44451, 44453, 44454, 44455, 44456, 44457, 44458, 44459, 44460, 44461, 44462, 44463, 44464, 44465, 44466, 44467, 44468, 44469, 44470, 44472, 44473, 44474, 44475, 44476, 44477, 44478, 44479, 44482, 44483, 44485, 44486, 44487, 44489, 44490, 44491, 44492, 44493, 44494, 44495, 44498, 44500, 44501, 44502, 44503, 44504, 44505, 44506, 44507, 44509, 44510, 44511, 44513, 44514, 44515, 44517, 44518, 44519, 44520, 44521, 44522, 44523, 44524, 44525, 44526, 44527, 44528, 44529, 44530, 44531, 44532, 44533, 44534, 44535, 44538, 44539, 44541, 44542, 44546, 44547, 44548, 44549, 44550, 44551, 44554, 44556, 44558, 44559, 44560, 44561, 44562, 44563, 44565, 44566, 44567, 44568, 44569, 44570, 44571, 44572, null, null, null, null, null, null, 44573, 44574, 44575, 44576, 44577, 44578, 44579, 44580, 44581, 44582, 44583, 44584, 44585, 44586, 44587, 44588, 44589, 44590, 44591, 44594, 44595, 44597, 44598, 44601, 44603, 44604, null, null, null, null, null, null, 44605, 44606, 44607, 44610, 44612, 44615, 44616, 44617, 44619, 44623, 44625, 44626, 44627, 44629, 44631, 44632, 44633, 44634, 44635, 44638, 44642, 44643, 44644, 44646, 44647, 44650, 44651, 44653, 44654, 44655, 44657, 44658, 44659, 44660, 44661, 44662, 44663, 44666, 44670, 44671, 44672, 44673, 44674, 44675, 44678, 44679, 44680, 44681, 44682, 44683, 44685, 44686, 44687, 44688, 44689, 44690, 44691, 44692, 44693, 44694, 44695, 44696, 44697, 44698, 44699, 44700, 44701, 44702, 44703, 44704, 44705, 44706, 44707, 44708, 44709, 44710, 44711, 44712, 44713, 44714, 44715, 44716, 44717, 44718, 44719, 44720, 44721, 44722, 44723, 44724, 44725, 44726, 44727, 44728, 44729, 44730, 44731, 44735, 44737, 44738, 44739, 44741, 44742, 44743, 44744, 44745, 44746, 44747, 44750, 44754, 44755, 44756, 44757, 44758, 44759, 44762, 44763, 44765, 44766, 44767, 44768, 44769, 44770, 44771, 44772, 44773, 44774, 44775, 44777, 44778, 44780, 44782, 44783, 44784, 44785, 44786, 44787, 44789, 44790, 44791, 44793, 44794, 44795, 447
"gb18030": [19970, 19972, 19973, 19974, 19983, 19986, 19991, 19999, 2e4, 20001, 20003, 20006, 20009, 20014, 20015, 20017, 20019, 20021, 20023, 20028, 20032, 20033, 20034, 20036, 20038, 20042, 20049, 20053, 20055, 20058, 20059, 20066, 20067, 20068, 20069, 20071, 20072, 20074, 20075, 20076, 20077, 20078, 20079, 20082, 20084, 20085, 20086, 20087, 20088, 20089, 20090, 20091, 20092, 20093, 20095, 20096, 20097, 20098, 20099, 20100, 20101, 20103, 20106, 20112, 20118, 20119, 20121, 20124, 20125, 20126, 20131, 20138, 20143, 20144, 20145, 20148, 20150, 20151, 20152, 20153, 20156, 20157, 20158, 20168, 20172, 20175, 20176, 20178, 20186, 20187, 20188, 20192, 20194, 20198, 20199, 20201, 20205, 20206, 20207, 20209, 20212, 20216, 20217, 20218, 20220, 20222, 20224, 20226, 20227, 20228, 20229, 20230, 20231, 20232, 20235, 20236, 20242, 20243, 20244, 20245, 20246, 20252, 20253, 20257, 20259, 20264, 20265, 20268, 20269, 20270, 20273, 20275, 20277, 20279, 20281, 20283, 20286, 20287, 20288, 20289, 20290, 20292, 20293, 20295, 20296, 20297, 20298, 20299, 20300, 20306, 20308, 20310, 20321, 20322, 20326, 20328, 20330, 20331, 20333, 20334, 20337, 20338, 20341, 20343, 20344, 20345, 20346, 20349, 20352, 20353, 20354, 20357, 20358, 20359, 20362, 20364, 20366, 20368, 20370, 20371, 20373, 20374, 20376, 20377, 20378, 20380, 20382, 20383, 20385, 20386, 20388, 20395, 20397, 20400, 20401, 20402, 20403, 20404, 20406, 20407, 20408, 20409, 20410, 20411, 20412, 20413, 20414, 20416, 20417, 20418, 20422, 20423, 20424, 20425, 20427, 20428, 20429, 20434, 20435, 20436, 20437, 20438, 20441, 20443, 20448, 20450, 20452, 20453, 20455, 20459, 20460, 20464, 20466, 20468, 20469, 20470, 20471, 20473, 20475, 20476, 20477, 20479, 20480, 20481, 20482, 20483, 20484, 20485, 20486, 20487, 20488, 20489, 20490, 20491, 20494, 20496, 20497, 20499, 20501, 20502, 20503, 20507, 20509, 20510, 20512, 20514, 20515, 20516, 20519, 20523, 20527, 20528, 20529, 20530, 20531, 20532, 20533, 20534, 20535, 20536, 20537, 20539, 20541, 20543, 20544, 20545, 20546, 20548, 20549, 20550, 20553, 20554, 20555, 20557, 20560, 20561, 20562, 20563, 20564, 20566, 20567, 20568, 20569, 20571, 20573, 20574, 20575, 20576, 20577, 20578, 20579, 20580, 20582, 20583, 20584, 20585, 20586, 20587, 20589, 20590, 20591, 20592, 20593, 20594, 20595, 20596, 20597, 20600, 20601, 20602, 20604, 20605, 20609, 20610, 20611, 20612, 20614, 20615, 20617, 20618, 20619, 20620, 20622, 20623, 20624, 20625, 20626, 20627, 20628, 20629, 20630, 20631, 20632, 20633, 20634, 20635, 20636, 20637, 20638, 20639, 20640, 20641, 20642, 20644, 20646, 20650, 20651, 20653, 20654, 20655, 20656, 20657, 20659, 20660, 20661, 20662, 20663, 20664, 20665, 20668, 20669, 20670, 20671, 20672, 20673, 20674, 20675, 20676, 20677, 20678, 20679, 20680, 20681, 20682, 20683, 20684, 20685, 20686, 20688, 20689, 20690, 20691, 20692, 20693, 20695, 20696, 20697, 20699, 20700, 20701, 20702, 20703, 20704, 20705, 20706, 20707, 20708, 20709, 20712, 20713, 20714, 20715, 20719, 20720, 20721, 20722, 20724, 20726, 20727, 20728, 20729, 20730, 20732, 20733, 20734, 20735, 20736, 20737, 20738, 20739, 20740, 20741, 20744, 20745, 20746, 20748, 20749, 20750, 20751, 20752, 20753, 20755, 20756, 20757, 20758, 20759, 20760, 20761, 20762, 20763, 20764, 20765, 20766, 20767, 20768, 20770, 20771, 20772, 20773, 20774, 20775, 20776, 20777, 20778, 20779, 20780, 20781, 20782, 20783, 20784, 20785, 20786, 20787, 20788, 20789, 20790, 20791, 20792, 20793, 20794, 20795, 20796, 20797, 20798, 20802, 20807, 20810, 20812, 20814, 20815, 20816, 20818, 20819, 20823, 20824, 20825, 20827, 20829, 20830, 20831, 20832, 20833, 20835, 20836, 20838, 20839, 20841, 20842, 20847, 20850, 20858, 20862, 20863, 20867, 20868, 20870, 20871, 20874, 20875, 20878, 20879, 20880, 20881, 20883, 20884, 20888, 20890, 20893, 20894, 20895, 20897, 20899, 20902, 20903, 20904, 20905, 20906, 20909, 20910, 20916, 20920, 20921, 20922, 20926, 20927, 20929, 20930, 20931, 20933, 20936, 20938, 20941, 20942, 20944, 20946, 20947, 20948, 20949, 20950, 20951, 20952, 20953, 20954, 20956, 20958, 20959, 20962, 20963, 20965, 20966, 20967, 20968, 209
"gb18030-ranges": [[0, 128], [36, 165], [38, 169], [45, 178], [50, 184], [81, 216], [89, 226], [95, 235], [96, 238], [100, 244], [103, 248], [104, 251], [105, 253], [109, 258], [126, 276], [133, 284], [148, 300], [172, 325], [175, 329], [179, 334], [208, 364], [306, 463], [307, 465], [308, 467], [309, 469], [310, 471], [311, 473], [312, 475], [313, 477], [341, 506], [428, 594], [443, 610], [544, 712], [545, 716], [558, 730], [741, 930], [742, 938], [749, 962], [750, 970], [805, 1026], [819, 1104], [820, 1106], [7922, 8209], [7924, 8215], [7925, 8218], [7927, 8222], [7934, 8231], [7943, 8241], [7944, 8244], [7945, 8246], [7950, 8252], [8062, 8365], [8148, 8452], [8149, 8454], [8152, 8458], [8164, 8471], [8174, 8482], [8236, 8556], [8240, 8570], [8262, 8596], [8264, 8602], [8374, 8713], [8380, 8720], [8381, 8722], [8384, 8726], [8388, 8731], [8390, 8737], [8392, 8740], [8393, 8742], [8394, 8748], [8396, 8751], [8401, 8760], [8406, 8766], [8416, 8777], [8419, 8781], [8424, 8787], [8437, 8802], [8439, 8808], [8445, 8816], [8482, 8854], [8485, 8858], [8496, 8870], [8521, 8896], [8603, 8979], [8936, 9322], [8946, 9372], [9046, 9548], [9050, 9588], [9063, 9616], [9066, 9622], [9076, 9634], [9092, 9652], [9100, 9662], [9108, 9672], [9111, 9676], [9113, 9680], [9131, 9702], [9162, 9735], [9164, 9738], [9218, 9793], [9219, 9795], [11329, 11906], [11331, 11909], [11334, 11913], [11336, 11917], [11346, 11928], [11361, 11944], [11363, 11947], [11366, 11951], [11370, 11956], [11372, 11960], [11375, 11964], [11389, 11979], [11682, 12284], [11686, 12292], [11687, 12312], [11692, 12319], [11694, 12330], [11714, 12351], [11716, 12436], [11723, 12447], [11725, 12535], [11730, 12543], [11736, 12586], [11982, 12842], [11989, 12850], [12102, 12964], [12336, 13200], [12348, 13215], [12350, 13218], [12384, 13253], [12393, 13263], [12395, 13267], [12397, 13270], [12510, 13384], [12553, 13428], [12851, 13727], [12962, 13839], [12973, 13851], [13738, 14617], [13823, 14703], [13919, 14801], [13933, 14816], [14080, 14964], [14298, 15183], [14585, 15471], [14698, 15585], [15583, 16471], [15847, 16736], [16318, 17208], [16434, 17325], [16438, 17330], [16481, 17374], [16729, 17623], [17102, 17997], [17122, 18018], [17315, 18212], [17320, 18218], [17402, 18301], [17418, 18318], [17859, 18760], [17909, 18811], [17911, 18814], [17915, 18820], [17916, 18823], [17936, 18844], [17939, 18848], [17961, 18872], [18664, 19576], [18703, 19620], [18814, 19738], [18962, 19887], [19043, 40870], [33469, 59244], [33470, 59336], [33471, 59367], [33484, 59413], [33485, 59417], [33490, 59423], [33497, 59431], [33501, 59437], [33505, 59443], [33513, 59452], [33520, 59460], [33536, 59478], [33550, 59493], [37845, 63789], [37921, 63866], [37948, 63894], [38029, 63976], [38038, 63986], [38064, 64016], [38065, 64018], [38066, 64021], [38069, 64025], [38075, 64034], [38076, 64037], [38078, 64042], [39108, 65074], [39109, 65093], [39113, 65107], [39114, 65112], [39115, 65127], [39116, 65132], [39265, 65375], [39394, 65510], [189e3, 65536]],
"jis0208": [12288, 12289, 12290, 65292, 65294, 12539, 65306, 65307, 65311, 65281, 12443, 12444, 180, 65344, 168, 65342, 65507, 65343, 12541, 12542, 12445, 12446, 12291, 20189, 12293, 12294, 12295, 12540, 8213, 8208, 65295, 65340, 65374, 8741, 65372, 8230, 8229, 8216, 8217, 8220, 8221, 65288, 65289, 12308, 12309, 65339, 65341, 65371, 65373, 12296, 12297, 12298, 12299, 12300, 12301, 12302, 12303, 12304, 12305, 65291, 65293, 177, 215, 247, 65309, 8800, 65308, 65310, 8806, 8807, 8734, 8756, 9794, 9792, 176, 8242, 8243, 8451, 65509, 65284, 65504, 65505, 65285, 65283, 65286, 65290, 65312, 167, 9734, 9733, 9675, 9679, 9678, 9671, 9670, 9633, 9632, 9651, 9650, 9661, 9660, 8251, 12306, 8594, 8592, 8593, 8595, 12307, null, null, null, null, null, null, null, null, null, null, null, 8712, 8715, 8838, 8839, 8834, 8835, 8746, 8745, null, null, null, null, null, null, null, null, 8743, 8744, 65506, 8658, 8660, 8704, 8707, null, null, null, null, null, null, null, null, null, null, null, 8736, 8869, 8978, 8706, 8711, 8801, 8786, 8810, 8811, 8730, 8765, 8733, 8757, 8747, 8748, null, null, null, null, null, null, null, 8491, 8240, 9839, 9837, 9834, 8224, 8225, 182, null, null, null, null, 9711, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 65296, 65297, 65298, 65299, 65300, 65301, 65302, 65303, 65304, 65305, null, null, null, null, null, null, null, 65313, 65314, 65315, 65316, 65317, 65318, 65319, 65320, 65321, 65322, 65323, 65324, 65325, 65326, 65327, 65328, 65329, 65330, 65331, 65332, 65333, 65334, 65335, 65336, 65337, 65338, null, null, null, null, null, null, 65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370, null, null, null, null, 12353, 12354, 12355, 12356, 12357, 12358, 12359, 12360, 12361, 12362, 12363, 12364, 12365, 12366, 12367, 12368, 12369, 12370, 12371, 12372, 12373, 12374, 12375, 12376, 12377, 12378, 12379, 12380, 12381, 12382, 12383, 12384, 12385, 12386, 12387, 12388, 12389, 12390, 12391, 12392, 12393, 12394, 12395, 12396, 12397, 12398, 12399, 12400, 12401, 12402, 12403, 12404, 12405, 12406, 12407, 12408, 12409, 12410, 12411, 12412, 12413, 12414, 12415, 12416, 12417, 12418, 12419, 12420, 12421, 12422, 12423, 12424, 12425, 12426, 12427, 12428, 12429, 12430, 12431, 12432, 12433, 12434, 12435, null, null, null, null, null, null, null, null, null, null, null, 12449, 12450, 12451, 12452, 12453, 12454, 12455, 12456, 12457, 12458, 12459, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12484, 12485, 12486, 12487, 12488, 12489, 12490, 12491, 12492, 12493, 12494, 12495, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12511, 12512, 12513, 12514, 12515, 12516, 12517, 12518, 12519, 12520, 12521, 12522, 12523, 12524, 12525, 12526, 12527, 12528, 12529, 12530, 12531, 12532, 12533, 12534, null, null, null, null, null, null, null, null, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, null, null, null, null, null, null, null, null, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 963, 964, 965, 966, 967, 968, 969, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1040, 1041, 1042, 1043, 1044, 1045, 1025, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1072, 1073, 1074, 1075, 1076, 1077, 1105, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1
"jis0212": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 728, 711, 184, 729, 733, 175, 731, 730, 65374, 900, 901, null, null, null, null, null, null, null, null, 161, 166, 191, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 186, 170, 169, 174, 8482, 164, 8470, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 902, 904, 905, 906, 938, null, 908, null, 910, 939, null, 911, null, null, null, null, 940, 941, 942, 943, 970, 912, 972, 962, 973, 971, 944, 974, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1038, 1039, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, nul
"ibm866": [1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1025, 1105, 1028, 1108, 1031, 1111, 1038, 1118, 176, 8729, 183, 8730, 8470, 164, 9632, 160],
"iso-8859-2": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 728, 321, 164, 317, 346, 167, 168, 352, 350, 356, 377, 173, 381, 379, 176, 261, 731, 322, 180, 318, 347, 711, 184, 353, 351, 357, 378, 733, 382, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729],
"iso-8859-3": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 294, 728, 163, 164, null, 292, 167, 168, 304, 350, 286, 308, 173, null, 379, 176, 295, 178, 179, 180, 181, 293, 183, 184, 305, 351, 287, 309, 189, null, 380, 192, 193, 194, null, 196, 266, 264, 199, 200, 201, 202, 203, 204, 205, 206, 207, null, 209, 210, 211, 212, 288, 214, 215, 284, 217, 218, 219, 220, 364, 348, 223, 224, 225, 226, null, 228, 267, 265, 231, 232, 233, 234, 235, 236, 237, 238, 239, null, 241, 242, 243, 244, 289, 246, 247, 285, 249, 250, 251, 252, 365, 349, 729],
"iso-8859-4": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 312, 342, 164, 296, 315, 167, 168, 352, 274, 290, 358, 173, 381, 175, 176, 261, 731, 343, 180, 297, 316, 711, 184, 353, 275, 291, 359, 330, 382, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, 203, 278, 205, 206, 298, 272, 325, 332, 310, 212, 213, 214, 215, 216, 370, 218, 219, 220, 360, 362, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, 233, 281, 235, 279, 237, 238, 299, 273, 326, 333, 311, 244, 245, 246, 247, 248, 371, 250, 251, 252, 361, 363, 729],
"iso-8859-5": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 173, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 8470, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 167, 1118, 1119],
"iso-8859-6": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, null, null, null, 164, null, null, null, null, null, null, null, 1548, 173, null, null, null, null, null, null, null, null, null, null, null, null, null, 1563, null, null, null, 1567, null, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, null, null, null, null, null, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, null, null, null, null, null, null, null, null, null, null, null, null, null],
"iso-8859-7": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 8216, 8217, 163, 8364, 8367, 166, 167, 168, 169, 890, 171, 172, 173, null, 8213, 176, 177, 178, 179, 900, 901, 902, 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, null, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, null],
"iso-8859-8": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, null, 162, 163, 164, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, 187, 188, 189, 190, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 8215, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, null, null, 8206, 8207, null],
"iso-8859-10": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 274, 290, 298, 296, 310, 167, 315, 272, 352, 358, 381, 173, 362, 330, 176, 261, 275, 291, 299, 297, 311, 183, 316, 273, 353, 359, 382, 8213, 363, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, 203, 278, 205, 206, 207, 208, 325, 332, 211, 212, 213, 214, 360, 216, 370, 218, 219, 220, 221, 222, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, 233, 281, 235, 279, 237, 238, 239, 240, 326, 333, 243, 244, 245, 246, 361, 248, 371, 250, 251, 252, 253, 254, 312],
"iso-8859-13": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 8221, 162, 163, 164, 8222, 166, 167, 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 8220, 181, 182, 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 8217],
"iso-8859-14": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 7682, 7683, 163, 266, 267, 7690, 167, 7808, 169, 7810, 7691, 7922, 173, 174, 376, 7710, 7711, 288, 289, 7744, 7745, 182, 7766, 7809, 7767, 7811, 7776, 7923, 7812, 7813, 7777, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 372, 209, 210, 211, 212, 213, 214, 7786, 216, 217, 218, 219, 220, 221, 374, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 373, 241, 242, 243, 244, 245, 246, 7787, 248, 249, 250, 251, 252, 253, 375, 255],
"iso-8859-15": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 8364, 165, 352, 167, 353, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 381, 181, 182, 183, 382, 185, 186, 187, 338, 339, 376, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255],
"iso-8859-16": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 261, 321, 8364, 8222, 352, 167, 353, 169, 536, 171, 377, 173, 378, 379, 176, 177, 268, 322, 381, 8221, 182, 183, 382, 269, 537, 187, 338, 339, 376, 380, 192, 193, 194, 258, 196, 262, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 272, 323, 210, 211, 212, 336, 214, 346, 368, 217, 218, 219, 220, 280, 538, 223, 224, 225, 226, 259, 228, 263, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 273, 324, 242, 243, 244, 337, 246, 347, 369, 249, 250, 251, 252, 281, 539, 255],
"koi8-r": [9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992, 9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178, 183, 247, 9552, 9553, 9554, 1105, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 1025, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 169, 1102, 1072, 1073, 1094, 1076, 1077, 1092, 1075, 1093, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1103, 1088, 1089, 1090, 1091, 1078, 1074, 1100, 1099, 1079, 1096, 1101, 1097, 1095, 1098, 1070, 1040, 1041, 1062, 1044, 1045, 1060, 1043, 1061, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1071, 1056, 1057, 1058, 1059, 1046, 1042, 1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066],
"koi8-u": [9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992, 9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178, 183, 247, 9552, 9553, 9554, 1105, 1108, 9556, 1110, 1111, 9559, 9560, 9561, 9562, 9563, 1169, 1118, 9566, 9567, 9568, 9569, 1025, 1028, 9571, 1030, 1031, 9574, 9575, 9576, 9577, 9578, 1168, 1038, 169, 1102, 1072, 1073, 1094, 1076, 1077, 1092, 1075, 1093, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1103, 1088, 1089, 1090, 1091, 1078, 1074, 1100, 1099, 1079, 1096, 1101, 1097, 1095, 1098, 1070, 1040, 1041, 1062, 1044, 1045, 1060, 1043, 1061, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1071, 1056, 1057, 1058, 1059, 1046, 1042, 1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066],
"macintosh": [196, 197, 199, 201, 209, 214, 220, 225, 224, 226, 228, 227, 229, 231, 233, 232, 234, 235, 237, 236, 238, 239, 241, 243, 242, 244, 246, 245, 250, 249, 251, 252, 8224, 176, 162, 163, 167, 8226, 182, 223, 174, 169, 8482, 180, 168, 8800, 198, 216, 8734, 177, 8804, 8805, 165, 181, 8706, 8721, 8719, 960, 8747, 170, 186, 937, 230, 248, 191, 161, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, 192, 195, 213, 338, 339, 8211, 8212, 8220, 8221, 8216, 8217, 247, 9674, 255, 376, 8260, 8364, 8249, 8250, 64257, 64258, 8225, 183, 8218, 8222, 8240, 194, 202, 193, 203, 200, 205, 206, 207, 204, 211, 212, 63743, 210, 218, 219, 217, 305, 710, 732, 175, 728, 729, 730, 184, 733, 731, 711],
"windows-874": [8364, 129, 130, 131, 132, 8230, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 153, 154, 155, 156, 157, 158, 159, 160, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, null, null, null, null, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, null, null, null, null],
"windows-1250": [8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 352, 8249, 346, 356, 381, 377, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 353, 8250, 347, 357, 382, 378, 160, 711, 728, 321, 164, 260, 166, 167, 168, 169, 350, 171, 172, 173, 174, 379, 176, 177, 731, 322, 180, 181, 182, 183, 184, 261, 351, 187, 317, 733, 318, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729],
"windows-1251": [1026, 1027, 8218, 1107, 8222, 8230, 8224, 8225, 8364, 8240, 1033, 8249, 1034, 1036, 1035, 1039, 1106, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 1113, 8250, 1114, 1116, 1115, 1119, 160, 1038, 1118, 1032, 164, 1168, 166, 167, 1025, 169, 1028, 171, 172, 173, 174, 1031, 176, 177, 1030, 1110, 1169, 181, 182, 183, 1105, 8470, 1108, 187, 1112, 1029, 1109, 1111, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103],
"windows-1252": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 381, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 382, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255],
"windows-1253": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 157, 158, 159, 160, 901, 902, 163, 164, 165, 166, 167, 168, 169, null, 171, 172, 173, 174, 8213, 176, 177, 178, 179, 900, 181, 182, 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, null, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, null],
"windows-1254": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 286, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 304, 350, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 287, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 305, 351, 255],
"windows-1255": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 156, 157, 158, 159, 160, 161, 162, 163, 8362, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, 187, 188, 189, 190, 191, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1520, 1521, 1522, 1523, 1524, null, null, null, null, null, null, null, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, null, null, 8206, 8207, null],
"windows-1256": [8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 1657, 8249, 338, 1670, 1688, 1672, 1711, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 1705, 8482, 1681, 8250, 339, 8204, 8205, 1722, 160, 1548, 162, 163, 164, 165, 166, 167, 168, 169, 1726, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 1563, 187, 188, 189, 190, 1567, 1729, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 215, 1591, 1592, 1593, 1594, 1600, 1601, 1602, 1603, 224, 1604, 226, 1605, 1606, 1607, 1608, 231, 232, 233, 234, 235, 1609, 1610, 238, 239, 1611, 1612, 1613, 1614, 244, 1615, 1616, 247, 1617, 249, 1618, 251, 252, 8206, 8207, 1746],
"windows-1257": [8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140, 168, 711, 184, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 175, 731, 159, 160, null, 162, 163, 164, null, 166, 167, 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 180, 181, 182, 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 729],
"windows-1258": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 258, 196, 197, 198, 199, 200, 201, 202, 203, 768, 205, 206, 207, 272, 209, 777, 211, 212, 416, 214, 215, 216, 217, 218, 219, 220, 431, 771, 223, 224, 225, 226, 259, 228, 229, 230, 231, 232, 233, 234, 235, 769, 237, 238, 239, 273, 241, 803, 243, 244, 417, 246, 247, 248, 249, 250, 251, 252, 432, 8363, 255],
"x-mac-cyrillic": [1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 8224, 176, 1168, 163, 167, 8226, 182, 1030, 174, 169, 8482, 1026, 1106, 8800, 1027, 1107, 8734, 177, 8804, 8805, 1110, 181, 1169, 1032, 1028, 1108, 1031, 1111, 1033, 1113, 1034, 1114, 1112, 1029, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, 1035, 1115, 1036, 1116, 1109, 8211, 8212, 8220, 8221, 8216, 8217, 247, 8222, 1038, 1118, 1039, 1119, 8470, 1025, 1105, 1103, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 8364]
};
})(exports || {});
}
});
// node_modules/@sinonjs/text-encoding/lib/encoding.js
var require_encoding = __commonJS({
"node_modules/@sinonjs/text-encoding/lib/encoding.js"(exports, module2) {
(function(global2) {
"use strict";
if (typeof module2 !== "undefined" && module2.exports && !global2["encoding-indexes"]) {
global2["encoding-indexes"] = require_encoding_indexes()["encoding-indexes"];
}
function inRange(a3, min, max) {
return min <= a3 && a3 <= max;
}
function includes(array, item) {
return array.indexOf(item) !== -1;
}
var floor = Math.floor;
function ToDictionary(o3) {
if (o3 === void 0)
return {};
if (o3 === Object(o3))
return o3;
throw TypeError("Could not convert argument to dictionary");
}
function stringToCodePoints(string) {
var s4 = String(string);
var n3 = s4.length;
var i4 = 0;
var u3 = [];
while (i4 < n3) {
var c4 = s4.charCodeAt(i4);
if (c4 < 55296 || c4 > 57343) {
u3.push(c4);
} else if (56320 <= c4 && c4 <= 57343) {
u3.push(65533);
} else if (55296 <= c4 && c4 <= 56319) {
if (i4 === n3 - 1) {
u3.push(65533);
} else {
var d3 = s4.charCodeAt(i4 + 1);
if (56320 <= d3 && d3 <= 57343) {
var a3 = c4 & 1023;
var b3 = d3 & 1023;
u3.push(65536 + (a3 << 10) + b3);
i4 += 1;
} else {
u3.push(65533);
}
}
}
i4 += 1;
}
return u3;
}
function codePointsToString(code_points) {
var s4 = "";
for (var i4 = 0; i4 < code_points.length; ++i4) {
var cp = code_points[i4];
if (cp <= 65535) {
s4 += String.fromCharCode(cp);
} else {
cp -= 65536;
s4 += String.fromCharCode(
(cp >> 10) + 55296,
(cp & 1023) + 56320
);
}
}
return s4;
}
function isASCIIByte(a3) {
return 0 <= a3 && a3 <= 127;
}
var isASCIICodePoint = isASCIIByte;
var end_of_stream = -1;
function Stream(tokens) {
this.tokens = [].slice.call(tokens);
this.tokens.reverse();
}
Stream.prototype = {
/**
* @return {boolean} True if end-of-stream has been hit.
*/
endOfStream: function() {
return !this.tokens.length;
},
/**
* When a token is read from a stream, the first token in the
* stream must be returned and subsequently removed, and
* end-of-stream must be returned otherwise.
*
* @return {number} Get the next token from the stream, or
* end_of_stream.
*/
read: function() {
if (!this.tokens.length)
return end_of_stream;
return this.tokens.pop();
},
/**
* When one or more tokens are prepended to a stream, those tokens
* must be inserted, in given order, before the first token in the
* stream.
*
* @param {(number|!Array.<number>)} token The token(s) to prepend to the
* stream.
*/
prepend: function(token) {
if (Array.isArray(token)) {
var tokens = (
/**@type {!Array.<number>}*/
token
);
while (tokens.length)
this.tokens.push(tokens.pop());
} else {
this.tokens.push(token);
}
},
/**
* When one or more tokens are pushed to a stream, those tokens
* must be inserted, in given order, after the last token in the
* stream.
*
* @param {(number|!Array.<number>)} token The tokens(s) to push to the
* stream.
*/
push: function(token) {
if (Array.isArray(token)) {
var tokens = (
/**@type {!Array.<number>}*/
token
);
while (tokens.length)
this.tokens.unshift(tokens.shift());
} else {
this.tokens.unshift(token);
}
}
};
var finished = -1;
function decoderError(fatal, opt_code_point) {
if (fatal)
throw TypeError("Decoder error");
return opt_code_point || 65533;
}
function encoderError(code_point) {
throw TypeError("The code point " + code_point + " could not be encoded.");
}
function Decoder() {
}
Decoder.prototype = {
/**
* @param {Stream} stream The stream of bytes being decoded.
* @param {number} bite The next byte read from the stream.
* @return {?(number|!Array.<number>)} The next code point(s)
* decoded, or null if not enough data exists in the input
* stream to decode a complete code point, or |finished|.
*/
handler: function(stream, bite) {
}
};
function Encoder() {
}
Encoder.prototype = {
/**
* @param {Stream} stream The stream of code points being encoded.
* @param {number} code_point Next code point read from the stream.
* @return {(number|!Array.<number>)} Byte(s) to emit, or |finished|.
*/
handler: function(stream, code_point) {
}
};
function getEncoding(label) {
label = String(label).trim().toLowerCase();
if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) {
return label_to_encoding[label];
}
return null;
}
var encodings = [
{
"encodings": [
{
"labels": [
"unicode-1-1-utf-8",
"utf-8",
"utf8"
],
"name": "UTF-8"
}
],
"heading": "The Encoding"
},
{
"encodings": [
{
"labels": [
"866",
"cp866",
"csibm866",
"ibm866"
],
"name": "IBM866"
},
{
"labels": [
"csisolatin2",
"iso-8859-2",
"iso-ir-101",
"iso8859-2",
"iso88592",
"iso_8859-2",
"iso_8859-2:1987",
"l2",
"latin2"
],
"name": "ISO-8859-2"
},
{
"labels": [
"csisolatin3",
"iso-8859-3",
"iso-ir-109",
"iso8859-3",
"iso88593",
"iso_8859-3",
"iso_8859-3:1988",
"l3",
"latin3"
],
"name": "ISO-8859-3"
},
{
"labels": [
"csisolatin4",
"iso-8859-4",
"iso-ir-110",
"iso8859-4",
"iso88594",
"iso_8859-4",
"iso_8859-4:1988",
"l4",
"latin4"
],
"name": "ISO-8859-4"
},
{
"labels": [
"csisolatincyrillic",
"cyrillic",
"iso-8859-5",
"iso-ir-144",
"iso8859-5",
"iso88595",
"iso_8859-5",
"iso_8859-5:1988"
],
"name": "ISO-8859-5"
},
{
"labels": [
"arabic",
"asmo-708",
"csiso88596e",
"csiso88596i",
"csisolatinarabic",
"ecma-114",
"iso-8859-6",
"iso-8859-6-e",
"iso-8859-6-i",
"iso-ir-127",
"iso8859-6",
"iso88596",
"iso_8859-6",
"iso_8859-6:1987"
],
"name": "ISO-8859-6"
},
{
"labels": [
"csisolatingreek",
"ecma-118",
"elot_928",
"greek",
"greek8",
"iso-8859-7",
"iso-ir-126",
"iso8859-7",
"iso88597",
"iso_8859-7",
"iso_8859-7:1987",
"sun_eu_greek"
],
"name": "ISO-8859-7"
},
{
"labels": [
"csiso88598e",
"csisolatinhebrew",
"hebrew",
"iso-8859-8",
"iso-8859-8-e",
"iso-ir-138",
"iso8859-8",
"iso88598",
"iso_8859-8",
"iso_8859-8:1988",
"visual"
],
"name": "ISO-8859-8"
},
{
"labels": [
"csiso88598i",
"iso-8859-8-i",
"logical"
],
"name": "ISO-8859-8-I"
},
{
"labels": [
"csisolatin6",
"iso-8859-10",
"iso-ir-157",
"iso8859-10",
"iso885910",
"l6",
"latin6"
],
"name": "ISO-8859-10"
},
{
"labels": [
"iso-8859-13",
"iso8859-13",
"iso885913"
],
"name": "ISO-8859-13"
},
{
"labels": [
"iso-8859-14",
"iso8859-14",
"iso885914"
],
"name": "ISO-8859-14"
},
{
"labels": [
"csisolatin9",
"iso-8859-15",
"iso8859-15",
"iso885915",
"iso_8859-15",
"l9"
],
"name": "ISO-8859-15"
},
{
"labels": [
"iso-8859-16"
],
"name": "ISO-8859-16"
},
{
"labels": [
"cskoi8r",
"koi",
"koi8",
"koi8-r",
"koi8_r"
],
"name": "KOI8-R"
},
{
"labels": [
"koi8-ru",
"koi8-u"
],
"name": "KOI8-U"
},
{
"labels": [
"csmacintosh",
"mac",
"macintosh",
"x-mac-roman"
],
"name": "macintosh"
},
{
"labels": [
"dos-874",
"iso-8859-11",
"iso8859-11",
"iso885911",
"tis-620",
"windows-874"
],
"name": "windows-874"
},
{
"labels": [
"cp1250",
"windows-1250",
"x-cp1250"
],
"name": "windows-1250"
},
{
"labels": [
"cp1251",
"windows-1251",
"x-cp1251"
],
"name": "windows-1251"
},
{
"labels": [
"ansi_x3.4-1968",
"ascii",
"cp1252",
"cp819",
"csisolatin1",
"ibm819",
"iso-8859-1",
"iso-ir-100",
"iso8859-1",
"iso88591",
"iso_8859-1",
"iso_8859-1:1987",
"l1",
"latin1",
"us-ascii",
"windows-1252",
"x-cp1252"
],
"name": "windows-1252"
},
{
"labels": [
"cp1253",
"windows-1253",
"x-cp1253"
],
"name": "windows-1253"
},
{
"labels": [
"cp1254",
"csisolatin5",
"iso-8859-9",
"iso-ir-148",
"iso8859-9",
"iso88599",
"iso_8859-9",
"iso_8859-9:1989",
"l5",
"latin5",
"windows-1254",
"x-cp1254"
],
"name": "windows-1254"
},
{
"labels": [
"cp1255",
"windows-1255",
"x-cp1255"
],
"name": "windows-1255"
},
{
"labels": [
"cp1256",
"windows-1256",
"x-cp1256"
],
"name": "windows-1256"
},
{
"labels": [
"cp1257",
"windows-1257",
"x-cp1257"
],
"name": "windows-1257"
},
{
"labels": [
"cp1258",
"windows-1258",
"x-cp1258"
],
"name": "windows-1258"
},
{
"labels": [
"x-mac-cyrillic",
"x-mac-ukrainian"
],
"name": "x-mac-cyrillic"
}
],
"heading": "Legacy single-byte encodings"
},
{
"encodings": [
{
"labels": [
"chinese",
"csgb2312",
"csiso58gb231280",
"gb2312",
"gb_2312",
"gb_2312-80",
"gbk",
"iso-ir-58",
"x-gbk"
],
"name": "GBK"
},
{
"labels": [
"gb18030"
],
"name": "gb18030"
}
],
"heading": "Legacy multi-byte Chinese (simplified) encodings"
},
{
"encodings": [
{
"labels": [
"big5",
"big5-hkscs",
"cn-big5",
"csbig5",
"x-x-big5"
],
"name": "Big5"
}
],
"heading": "Legacy multi-byte Chinese (traditional) encodings"
},
{
"encodings": [
{
"labels": [
"cseucpkdfmtjapanese",
"euc-jp",
"x-euc-jp"
],
"name": "EUC-JP"
},
{
"labels": [
"csiso2022jp",
"iso-2022-jp"
],
"name": "ISO-2022-JP"
},
{
"labels": [
"csshiftjis",
"ms932",
"ms_kanji",
"shift-jis",
"shift_jis",
"sjis",
"windows-31j",
"x-sjis"
],
"name": "Shift_JIS"
}
],
"heading": "Legacy multi-byte Japanese encodings"
},
{
"encodings": [
{
"labels": [
"cseuckr",
"csksc56011987",
"euc-kr",
"iso-ir-149",
"korean",
"ks_c_5601-1987",
"ks_c_5601-1989",
"ksc5601",
"ksc_5601",
"windows-949"
],
"name": "EUC-KR"
}
],
"heading": "Legacy multi-byte Korean encodings"
},
{
"encodings": [
{
"labels": [
"csiso2022kr",
"hz-gb-2312",
"iso-2022-cn",
"iso-2022-cn-ext",
"iso-2022-kr"
],
"name": "replacement"
},
{
"labels": [
"utf-16be"
],
"name": "UTF-16BE"
},
{
"labels": [
"utf-16",
"utf-16le"
],
"name": "UTF-16LE"
},
{
"labels": [
"x-user-defined"
],
"name": "x-user-defined"
}
],
"heading": "Legacy miscellaneous encodings"
}
];
var label_to_encoding = {};
encodings.forEach(function(category) {
category.encodings.forEach(function(encoding) {
encoding.labels.forEach(function(label) {
label_to_encoding[label] = encoding;
});
});
});
var encoders = {};
var decoders = {};
function indexCodePointFor(pointer, index2) {
if (!index2)
return null;
return index2[pointer] || null;
}
function indexPointerFor(code_point, index2) {
var pointer = index2.indexOf(code_point);
return pointer === -1 ? null : pointer;
}
function index(name) {
if (!("encoding-indexes" in global2)) {
throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?");
}
return global2["encoding-indexes"][name];
}
function indexGB18030RangesCodePointFor(pointer) {
if (pointer > 39419 && pointer < 189e3 || pointer > 1237575)
return null;
if (pointer === 7457)
return 59335;
var offset = 0;
var code_point_offset = 0;
var idx = index("gb18030-ranges");
var i4;
for (i4 = 0; i4 < idx.length; ++i4) {
var entry = idx[i4];
if (entry[0] <= pointer) {
offset = entry[0];
code_point_offset = entry[1];
} else {
break;
}
}
return code_point_offset + pointer - offset;
}
function indexGB18030RangesPointerFor(code_point) {
if (code_point === 59335)
return 7457;
var offset = 0;
var pointer_offset = 0;
var idx = index("gb18030-ranges");
var i4;
for (i4 = 0; i4 < idx.length; ++i4) {
var entry = idx[i4];
if (entry[1] <= code_point) {
offset = entry[1];
pointer_offset = entry[0];
} else {
break;
}
}
return pointer_offset + code_point - offset;
}
function indexShiftJISPointerFor(code_point) {
shift_jis_index = shift_jis_index || index("jis0208").map(function(code_point2, pointer) {
return inRange(pointer, 8272, 8835) ? null : code_point2;
});
var index_ = shift_jis_index;
return index_.indexOf(code_point);
}
var shift_jis_index;
function indexBig5PointerFor(code_point) {
big5_index_no_hkscs = big5_index_no_hkscs || index("big5").map(function(code_point2, pointer) {
return pointer < (161 - 129) * 157 ? null : code_point2;
});
var index_ = big5_index_no_hkscs;
if (code_point === 9552 || code_point === 9566 || code_point === 9569 || code_point === 9578 || code_point === 21313 || code_point === 21317) {
return index_.lastIndexOf(code_point);
}
return indexPointerFor(code_point, index_);
}
var big5_index_no_hkscs;
var DEFAULT_ENCODING = "utf-8";
function TextDecoder3(label, options) {
if (!(this instanceof TextDecoder3))
throw TypeError("Called as a function. Did you forget 'new'?");
label = label !== void 0 ? String(label) : DEFAULT_ENCODING;
options = ToDictionary(options);
this._encoding = null;
this._decoder = null;
this._ignoreBOM = false;
this._BOMseen = false;
this._error_mode = "replacement";
this._do_not_flush = false;
var encoding = getEncoding(label);
if (encoding === null || encoding.name === "replacement")
throw RangeError("Unknown encoding: " + label);
if (!decoders[encoding.name]) {
throw Error("Decoder not present. Did you forget to include encoding-indexes.js first?");
}
var dec = this;
dec._encoding = encoding;
if (Boolean(options["fatal"]))
dec._error_mode = "fatal";
if (Boolean(options["ignoreBOM"]))
dec._ignoreBOM = true;
if (!Object.defineProperty) {
this.encoding = dec._encoding.name.toLowerCase();
this.fatal = dec._error_mode === "fatal";
this.ignoreBOM = dec._ignoreBOM;
}
return dec;
}
if (Object.defineProperty) {
Object.defineProperty(TextDecoder3.prototype, "encoding", {
/** @this {TextDecoder} */
get: function() {
return this._encoding.name.toLowerCase();
}
});
Object.defineProperty(TextDecoder3.prototype, "fatal", {
/** @this {TextDecoder} */
get: function() {
return this._error_mode === "fatal";
}
});
Object.defineProperty(TextDecoder3.prototype, "ignoreBOM", {
/** @this {TextDecoder} */
get: function() {
return this._ignoreBOM;
}
});
}
TextDecoder3.prototype.decode = function decode3(input, options) {
var bytes;
if (typeof input === "object" && input instanceof ArrayBuffer) {
bytes = new Uint8Array(input);
} else if (typeof input === "object" && "buffer" in input && input.buffer instanceof ArrayBuffer) {
bytes = new Uint8Array(
input.buffer,
input.byteOffset,
input.byteLength
);
} else {
bytes = new Uint8Array(0);
}
options = ToDictionary(options);
if (!this._do_not_flush) {
this._decoder = decoders[this._encoding.name]({
fatal: this._error_mode === "fatal"
});
this._BOMseen = false;
}
this._do_not_flush = Boolean(options["stream"]);
var input_stream = new Stream(bytes);
var output = [];
var result;
while (true) {
var token = input_stream.read();
if (token === end_of_stream)
break;
result = this._decoder.handler(input_stream, token);
if (result === finished)
break;
if (result !== null) {
if (Array.isArray(result))
output.push.apply(
output,
/**@type {!Array.<number>}*/
result
);
else
output.push(result);
}
}
if (!this._do_not_flush) {
do {
result = this._decoder.handler(input_stream, input_stream.read());
if (result === finished)
break;
if (result === null)
continue;
if (Array.isArray(result))
output.push.apply(
output,
/**@type {!Array.<number>}*/
result
);
else
output.push(result);
} while (!input_stream.endOfStream());
this._decoder = null;
}
function serializeStream(stream) {
if (includes(["UTF-8", "UTF-16LE", "UTF-16BE"], this._encoding.name) && !this._ignoreBOM && !this._BOMseen) {
if (stream.length > 0 && stream[0] === 65279) {
this._BOMseen = true;
stream.shift();
} else if (stream.length > 0) {
this._BOMseen = true;
} else {
}
}
return codePointsToString(stream);
}
return serializeStream.call(this, output);
};
function TextEncoder3(label, options) {
if (!(this instanceof TextEncoder3))
throw TypeError("Called as a function. Did you forget 'new'?");
options = ToDictionary(options);
this._encoding = null;
this._encoder = null;
this._do_not_flush = false;
this._fatal = Boolean(options["fatal"]) ? "fatal" : "replacement";
var enc = this;
if (Boolean(options["NONSTANDARD_allowLegacyEncoding"])) {
label = label !== void 0 ? String(label) : DEFAULT_ENCODING;
var encoding = getEncoding(label);
if (encoding === null || encoding.name === "replacement")
throw RangeError("Unknown encoding: " + label);
if (!encoders[encoding.name]) {
throw Error("Encoder not present. Did you forget to include encoding-indexes.js first?");
}
enc._encoding = encoding;
} else {
enc._encoding = getEncoding("utf-8");
if (label !== void 0 && "console" in global2) {
console.warn("TextEncoder constructor called with encoding label, which is ignored.");
}
}
if (!Object.defineProperty)
this.encoding = enc._encoding.name.toLowerCase();
return enc;
}
if (Object.defineProperty) {
Object.defineProperty(TextEncoder3.prototype, "encoding", {
/** @this {TextEncoder} */
get: function() {
return this._encoding.name.toLowerCase();
}
});
}
TextEncoder3.prototype.encode = function encode3(opt_string, options) {
opt_string = opt_string === void 0 ? "" : String(opt_string);
options = ToDictionary(options);
if (!this._do_not_flush)
this._encoder = encoders[this._encoding.name]({
fatal: this._fatal === "fatal"
});
this._do_not_flush = Boolean(options["stream"]);
var input = new Stream(stringToCodePoints(opt_string));
var output = [];
var result;
while (true) {
var token = input.read();
if (token === end_of_stream)
break;
result = this._encoder.handler(input, token);
if (result === finished)
break;
if (Array.isArray(result))
output.push.apply(
output,
/**@type {!Array.<number>}*/
result
);
else
output.push(result);
}
if (!this._do_not_flush) {
while (true) {
result = this._encoder.handler(input, input.read());
if (result === finished)
break;
if (Array.isArray(result))
output.push.apply(
output,
/**@type {!Array.<number>}*/
result
);
else
output.push(result);
}
this._encoder = null;
}
return new Uint8Array(output);
};
function UTF8Decoder(options) {
var fatal = options.fatal;
var utf8_code_point = 0, utf8_bytes_seen = 0, utf8_bytes_needed = 0, utf8_lower_boundary = 128, utf8_upper_boundary = 191;
this.handler = function(stream, bite) {
if (bite === end_of_stream && utf8_bytes_needed !== 0) {
utf8_bytes_needed = 0;
return decoderError(fatal);
}
if (bite === end_of_stream)
return finished;
if (utf8_bytes_needed === 0) {
if (inRange(bite, 0, 127)) {
return bite;
} else if (inRange(bite, 194, 223)) {
utf8_bytes_needed = 1;
utf8_code_point = bite & 31;
} else if (inRange(bite, 224, 239)) {
if (bite === 224)
utf8_lower_boundary = 160;
if (bite === 237)
utf8_upper_boundary = 159;
utf8_bytes_needed = 2;
utf8_code_point = bite & 15;
} else if (inRange(bite, 240, 244)) {
if (bite === 240)
utf8_lower_boundary = 144;
if (bite === 244)
utf8_upper_boundary = 143;
utf8_bytes_needed = 3;
utf8_code_point = bite & 7;
} else {
return decoderError(fatal);
}
return null;
}
if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
utf8_lower_boundary = 128;
utf8_upper_boundary = 191;
stream.prepend(bite);
return decoderError(fatal);
}
utf8_lower_boundary = 128;
utf8_upper_boundary = 191;
utf8_code_point = utf8_code_point << 6 | bite & 63;
utf8_bytes_seen += 1;
if (utf8_bytes_seen !== utf8_bytes_needed)
return null;
var code_point = utf8_code_point;
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
return code_point;
};
}
function UTF8Encoder(options) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (isASCIICodePoint(code_point))
return code_point;
var count, offset;
if (inRange(code_point, 128, 2047)) {
count = 1;
offset = 192;
} else if (inRange(code_point, 2048, 65535)) {
count = 2;
offset = 224;
} else if (inRange(code_point, 65536, 1114111)) {
count = 3;
offset = 240;
}
var bytes = [(code_point >> 6 * count) + offset];
while (count > 0) {
var temp = code_point >> 6 * (count - 1);
bytes.push(128 | temp & 63);
count -= 1;
}
return bytes;
};
}
encoders["UTF-8"] = function(options) {
return new UTF8Encoder(options);
};
decoders["UTF-8"] = function(options) {
return new UTF8Decoder(options);
};
function SingleByteDecoder(index2, options) {
var fatal = options.fatal;
this.handler = function(stream, bite) {
if (bite === end_of_stream)
return finished;
if (isASCIIByte(bite))
return bite;
var code_point = index2[bite - 128];
if (code_point === null)
return decoderError(fatal);
return code_point;
};
}
function SingleByteEncoder(index2, options) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (isASCIICodePoint(code_point))
return code_point;
var pointer = indexPointerFor(code_point, index2);
if (pointer === null)
encoderError(code_point);
return pointer + 128;
};
}
(function() {
if (!("encoding-indexes" in global2))
return;
encodings.forEach(function(category) {
if (category.heading !== "Legacy single-byte encodings")
return;
category.encodings.forEach(function(encoding) {
var name = encoding.name;
var idx = index(name.toLowerCase());
decoders[name] = function(options) {
return new SingleByteDecoder(idx, options);
};
encoders[name] = function(options) {
return new SingleByteEncoder(idx, options);
};
});
});
})();
decoders["GBK"] = function(options) {
return new GB18030Decoder(options);
};
encoders["GBK"] = function(options) {
return new GB18030Encoder(options, true);
};
function GB18030Decoder(options) {
var fatal = options.fatal;
var gb18030_first = 0, gb18030_second = 0, gb18030_third = 0;
this.handler = function(stream, bite) {
if (bite === end_of_stream && gb18030_first === 0 && gb18030_second === 0 && gb18030_third === 0) {
return finished;
}
if (bite === end_of_stream && (gb18030_first !== 0 || gb18030_second !== 0 || gb18030_third !== 0)) {
gb18030_first = 0;
gb18030_second = 0;
gb18030_third = 0;
decoderError(fatal);
}
var code_point;
if (gb18030_third !== 0) {
code_point = null;
if (inRange(bite, 48, 57)) {
code_point = indexGB18030RangesCodePointFor(
(((gb18030_first - 129) * 10 + gb18030_second - 48) * 126 + gb18030_third - 129) * 10 + bite - 48
);
}
var buffer = [gb18030_second, gb18030_third, bite];
gb18030_first = 0;
gb18030_second = 0;
gb18030_third = 0;
if (code_point === null) {
stream.prepend(buffer);
return decoderError(fatal);
}
return code_point;
}
if (gb18030_second !== 0) {
if (inRange(bite, 129, 254)) {
gb18030_third = bite;
return null;
}
stream.prepend([gb18030_second, bite]);
gb18030_first = 0;
gb18030_second = 0;
return decoderError(fatal);
}
if (gb18030_first !== 0) {
if (inRange(bite, 48, 57)) {
gb18030_second = bite;
return null;
}
var lead = gb18030_first;
var pointer = null;
gb18030_first = 0;
var offset = bite < 127 ? 64 : 65;
if (inRange(bite, 64, 126) || inRange(bite, 128, 254))
pointer = (lead - 129) * 190 + (bite - offset);
code_point = pointer === null ? null : indexCodePointFor(pointer, index("gb18030"));
if (code_point === null && isASCIIByte(bite))
stream.prepend(bite);
if (code_point === null)
return decoderError(fatal);
return code_point;
}
if (isASCIIByte(bite))
return bite;
if (bite === 128)
return 8364;
if (inRange(bite, 129, 254)) {
gb18030_first = bite;
return null;
}
return decoderError(fatal);
};
}
function GB18030Encoder(options, gbk_flag) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (isASCIICodePoint(code_point))
return code_point;
if (code_point === 58853)
return encoderError(code_point);
if (gbk_flag && code_point === 8364)
return 128;
var pointer = indexPointerFor(code_point, index("gb18030"));
if (pointer !== null) {
var lead = floor(pointer / 190) + 129;
var trail = pointer % 190;
var offset = trail < 63 ? 64 : 65;
return [lead, trail + offset];
}
if (gbk_flag)
return encoderError(code_point);
pointer = indexGB18030RangesPointerFor(code_point);
var byte1 = floor(pointer / 10 / 126 / 10);
pointer = pointer - byte1 * 10 * 126 * 10;
var byte2 = floor(pointer / 10 / 126);
pointer = pointer - byte2 * 10 * 126;
var byte3 = floor(pointer / 10);
var byte4 = pointer - byte3 * 10;
return [
byte1 + 129,
byte2 + 48,
byte3 + 129,
byte4 + 48
];
};
}
encoders["gb18030"] = function(options) {
return new GB18030Encoder(options);
};
decoders["gb18030"] = function(options) {
return new GB18030Decoder(options);
};
function Big5Decoder(options) {
var fatal = options.fatal;
var Big5_lead = 0;
this.handler = function(stream, bite) {
if (bite === end_of_stream && Big5_lead !== 0) {
Big5_lead = 0;
return decoderError(fatal);
}
if (bite === end_of_stream && Big5_lead === 0)
return finished;
if (Big5_lead !== 0) {
var lead = Big5_lead;
var pointer = null;
Big5_lead = 0;
var offset = bite < 127 ? 64 : 98;
if (inRange(bite, 64, 126) || inRange(bite, 161, 254))
pointer = (lead - 129) * 157 + (bite - offset);
switch (pointer) {
case 1133:
return [202, 772];
case 1135:
return [202, 780];
case 1164:
return [234, 772];
case 1166:
return [234, 780];
}
var code_point = pointer === null ? null : indexCodePointFor(pointer, index("big5"));
if (code_point === null && isASCIIByte(bite))
stream.prepend(bite);
if (code_point === null)
return decoderError(fatal);
return code_point;
}
if (isASCIIByte(bite))
return bite;
if (inRange(bite, 129, 254)) {
Big5_lead = bite;
return null;
}
return decoderError(fatal);
};
}
function Big5Encoder(options) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (isASCIICodePoint(code_point))
return code_point;
var pointer = indexBig5PointerFor(code_point);
if (pointer === null)
return encoderError(code_point);
var lead = floor(pointer / 157) + 129;
if (lead < 161)
return encoderError(code_point);
var trail = pointer % 157;
var offset = trail < 63 ? 64 : 98;
return [lead, trail + offset];
};
}
encoders["Big5"] = function(options) {
return new Big5Encoder(options);
};
decoders["Big5"] = function(options) {
return new Big5Decoder(options);
};
function EUCJPDecoder(options) {
var fatal = options.fatal;
var eucjp_jis0212_flag = false, eucjp_lead = 0;
this.handler = function(stream, bite) {
if (bite === end_of_stream && eucjp_lead !== 0) {
eucjp_lead = 0;
return decoderError(fatal);
}
if (bite === end_of_stream && eucjp_lead === 0)
return finished;
if (eucjp_lead === 142 && inRange(bite, 161, 223)) {
eucjp_lead = 0;
return 65377 - 161 + bite;
}
if (eucjp_lead === 143 && inRange(bite, 161, 254)) {
eucjp_jis0212_flag = true;
eucjp_lead = bite;
return null;
}
if (eucjp_lead !== 0) {
var lead = eucjp_lead;
eucjp_lead = 0;
var code_point = null;
if (inRange(lead, 161, 254) && inRange(bite, 161, 254)) {
code_point = indexCodePointFor(
(lead - 161) * 94 + (bite - 161),
index(!eucjp_jis0212_flag ? "jis0208" : "jis0212")
);
}
eucjp_jis0212_flag = false;
if (!inRange(bite, 161, 254))
stream.prepend(bite);
if (code_point === null)
return decoderError(fatal);
return code_point;
}
if (isASCIIByte(bite))
return bite;
if (bite === 142 || bite === 143 || inRange(bite, 161, 254)) {
eucjp_lead = bite;
return null;
}
return decoderError(fatal);
};
}
function EUCJPEncoder(options) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (isASCIICodePoint(code_point))
return code_point;
if (code_point === 165)
return 92;
if (code_point === 8254)
return 126;
if (inRange(code_point, 65377, 65439))
return [142, code_point - 65377 + 161];
if (code_point === 8722)
code_point = 65293;
var pointer = indexPointerFor(code_point, index("jis0208"));
if (pointer === null)
return encoderError(code_point);
var lead = floor(pointer / 94) + 161;
var trail = pointer % 94 + 161;
return [lead, trail];
};
}
encoders["EUC-JP"] = function(options) {
return new EUCJPEncoder(options);
};
decoders["EUC-JP"] = function(options) {
return new EUCJPDecoder(options);
};
function ISO2022JPDecoder(options) {
var fatal = options.fatal;
var states = {
ASCII: 0,
Roman: 1,
Katakana: 2,
LeadByte: 3,
TrailByte: 4,
EscapeStart: 5,
Escape: 6
};
var iso2022jp_decoder_state = states.ASCII, iso2022jp_decoder_output_state = states.ASCII, iso2022jp_lead = 0, iso2022jp_output_flag = false;
this.handler = function(stream, bite) {
switch (iso2022jp_decoder_state) {
default:
case states.ASCII:
if (bite === 27) {
iso2022jp_decoder_state = states.EscapeStart;
return null;
}
if (inRange(bite, 0, 127) && bite !== 14 && bite !== 15 && bite !== 27) {
iso2022jp_output_flag = false;
return bite;
}
if (bite === end_of_stream) {
return finished;
}
iso2022jp_output_flag = false;
return decoderError(fatal);
case states.Roman:
if (bite === 27) {
iso2022jp_decoder_state = states.EscapeStart;
return null;
}
if (bite === 92) {
iso2022jp_output_flag = false;
return 165;
}
if (bite === 126) {
iso2022jp_output_flag = false;
return 8254;
}
if (inRange(bite, 0, 127) && bite !== 14 && bite !== 15 && bite !== 27 && bite !== 92 && bite !== 126) {
iso2022jp_output_flag = false;
return bite;
}
if (bite === end_of_stream) {
return finished;
}
iso2022jp_output_flag = false;
return decoderError(fatal);
case states.Katakana:
if (bite === 27) {
iso2022jp_decoder_state = states.EscapeStart;
return null;
}
if (inRange(bite, 33, 95)) {
iso2022jp_output_flag = false;
return 65377 - 33 + bite;
}
if (bite === end_of_stream) {
return finished;
}
iso2022jp_output_flag = false;
return decoderError(fatal);
case states.LeadByte:
if (bite === 27) {
iso2022jp_decoder_state = states.EscapeStart;
return null;
}
if (inRange(bite, 33, 126)) {
iso2022jp_output_flag = false;
iso2022jp_lead = bite;
iso2022jp_decoder_state = states.TrailByte;
return null;
}
if (bite === end_of_stream) {
return finished;
}
iso2022jp_output_flag = false;
return decoderError(fatal);
case states.TrailByte:
if (bite === 27) {
iso2022jp_decoder_state = states.EscapeStart;
return decoderError(fatal);
}
if (inRange(bite, 33, 126)) {
iso2022jp_decoder_state = states.LeadByte;
var pointer = (iso2022jp_lead - 33) * 94 + bite - 33;
var code_point = indexCodePointFor(pointer, index("jis0208"));
if (code_point === null)
return decoderError(fatal);
return code_point;
}
if (bite === end_of_stream) {
iso2022jp_decoder_state = states.LeadByte;
stream.prepend(bite);
return decoderError(fatal);
}
iso2022jp_decoder_state = states.LeadByte;
return decoderError(fatal);
case states.EscapeStart:
if (bite === 36 || bite === 40) {
iso2022jp_lead = bite;
iso2022jp_decoder_state = states.Escape;
return null;
}
stream.prepend(bite);
iso2022jp_output_flag = false;
iso2022jp_decoder_state = iso2022jp_decoder_output_state;
return decoderError(fatal);
case states.Escape:
var lead = iso2022jp_lead;
iso2022jp_lead = 0;
var state = null;
if (lead === 40 && bite === 66)
state = states.ASCII;
if (lead === 40 && bite === 74)
state = states.Roman;
if (lead === 40 && bite === 73)
state = states.Katakana;
if (lead === 36 && (bite === 64 || bite === 66))
state = states.LeadByte;
if (state !== null) {
iso2022jp_decoder_state = iso2022jp_decoder_state = state;
var output_flag = iso2022jp_output_flag;
iso2022jp_output_flag = true;
return !output_flag ? null : decoderError(fatal);
}
stream.prepend([lead, bite]);
iso2022jp_output_flag = false;
iso2022jp_decoder_state = iso2022jp_decoder_output_state;
return decoderError(fatal);
}
};
}
function ISO2022JPEncoder(options) {
var fatal = options.fatal;
var states = {
ASCII: 0,
Roman: 1,
jis0208: 2
};
var iso2022jp_state = states.ASCII;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream && iso2022jp_state !== states.ASCII) {
stream.prepend(code_point);
iso2022jp_state = states.ASCII;
return [27, 40, 66];
}
if (code_point === end_of_stream && iso2022jp_state === states.ASCII)
return finished;
if ((iso2022jp_state === states.ASCII || iso2022jp_state === states.Roman) && (code_point === 14 || code_point === 15 || code_point === 27)) {
return encoderError(65533);
}
if (iso2022jp_state === states.ASCII && isASCIICodePoint(code_point))
return code_point;
if (iso2022jp_state === states.Roman && (isASCIICodePoint(code_point) && code_point !== 92 && code_point !== 126 || (code_point == 165 || code_point == 8254))) {
if (isASCIICodePoint(code_point))
return code_point;
if (code_point === 165)
return 92;
if (code_point === 8254)
return 126;
}
if (isASCIICodePoint(code_point) && iso2022jp_state !== states.ASCII) {
stream.prepend(code_point);
iso2022jp_state = states.ASCII;
return [27, 40, 66];
}
if ((code_point === 165 || code_point === 8254) && iso2022jp_state !== states.Roman) {
stream.prepend(code_point);
iso2022jp_state = states.Roman;
return [27, 40, 74];
}
if (code_point === 8722)
code_point = 65293;
var pointer = indexPointerFor(code_point, index("jis0208"));
if (pointer === null)
return encoderError(code_point);
if (iso2022jp_state !== states.jis0208) {
stream.prepend(code_point);
iso2022jp_state = states.jis0208;
return [27, 36, 66];
}
var lead = floor(pointer / 94) + 33;
var trail = pointer % 94 + 33;
return [lead, trail];
};
}
encoders["ISO-2022-JP"] = function(options) {
return new ISO2022JPEncoder(options);
};
decoders["ISO-2022-JP"] = function(options) {
return new ISO2022JPDecoder(options);
};
function ShiftJISDecoder(options) {
var fatal = options.fatal;
var Shift_JIS_lead = 0;
this.handler = function(stream, bite) {
if (bite === end_of_stream && Shift_JIS_lead !== 0) {
Shift_JIS_lead = 0;
return decoderError(fatal);
}
if (bite === end_of_stream && Shift_JIS_lead === 0)
return finished;
if (Shift_JIS_lead !== 0) {
var lead = Shift_JIS_lead;
var pointer = null;
Shift_JIS_lead = 0;
var offset = bite < 127 ? 64 : 65;
var lead_offset = lead < 160 ? 129 : 193;
if (inRange(bite, 64, 126) || inRange(bite, 128, 252))
pointer = (lead - lead_offset) * 188 + bite - offset;
if (inRange(pointer, 8836, 10715))
return 57344 - 8836 + pointer;
var code_point = pointer === null ? null : indexCodePointFor(pointer, index("jis0208"));
if (code_point === null && isASCIIByte(bite))
stream.prepend(bite);
if (code_point === null)
return decoderError(fatal);
return code_point;
}
if (isASCIIByte(bite) || bite === 128)
return bite;
if (inRange(bite, 161, 223))
return 65377 - 161 + bite;
if (inRange(bite, 129, 159) || inRange(bite, 224, 252)) {
Shift_JIS_lead = bite;
return null;
}
return decoderError(fatal);
};
}
function ShiftJISEncoder(options) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (isASCIICodePoint(code_point) || code_point === 128)
return code_point;
if (code_point === 165)
return 92;
if (code_point === 8254)
return 126;
if (inRange(code_point, 65377, 65439))
return code_point - 65377 + 161;
if (code_point === 8722)
code_point = 65293;
var pointer = indexShiftJISPointerFor(code_point);
if (pointer === null)
return encoderError(code_point);
var lead = floor(pointer / 188);
var lead_offset = lead < 31 ? 129 : 193;
var trail = pointer % 188;
var offset = trail < 63 ? 64 : 65;
return [lead + lead_offset, trail + offset];
};
}
encoders["Shift_JIS"] = function(options) {
return new ShiftJISEncoder(options);
};
decoders["Shift_JIS"] = function(options) {
return new ShiftJISDecoder(options);
};
function EUCKRDecoder(options) {
var fatal = options.fatal;
var euckr_lead = 0;
this.handler = function(stream, bite) {
if (bite === end_of_stream && euckr_lead !== 0) {
euckr_lead = 0;
return decoderError(fatal);
}
if (bite === end_of_stream && euckr_lead === 0)
return finished;
if (euckr_lead !== 0) {
var lead = euckr_lead;
var pointer = null;
euckr_lead = 0;
if (inRange(bite, 65, 254))
pointer = (lead - 129) * 190 + (bite - 65);
var code_point = pointer === null ? null : indexCodePointFor(pointer, index("euc-kr"));
if (pointer === null && isASCIIByte(bite))
stream.prepend(bite);
if (code_point === null)
return decoderError(fatal);
return code_point;
}
if (isASCIIByte(bite))
return bite;
if (inRange(bite, 129, 254)) {
euckr_lead = bite;
return null;
}
return decoderError(fatal);
};
}
function EUCKREncoder(options) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (isASCIICodePoint(code_point))
return code_point;
var pointer = indexPointerFor(code_point, index("euc-kr"));
if (pointer === null)
return encoderError(code_point);
var lead = floor(pointer / 190) + 129;
var trail = pointer % 190 + 65;
return [lead, trail];
};
}
encoders["EUC-KR"] = function(options) {
return new EUCKREncoder(options);
};
decoders["EUC-KR"] = function(options) {
return new EUCKRDecoder(options);
};
function convertCodeUnitToBytes(code_unit, utf16be) {
var byte1 = code_unit >> 8;
var byte2 = code_unit & 255;
if (utf16be)
return [byte1, byte2];
return [byte2, byte1];
}
function UTF16Decoder(utf16_be, options) {
var fatal = options.fatal;
var utf16_lead_byte = null, utf16_lead_surrogate = null;
this.handler = function(stream, bite) {
if (bite === end_of_stream && (utf16_lead_byte !== null || utf16_lead_surrogate !== null)) {
return decoderError(fatal);
}
if (bite === end_of_stream && utf16_lead_byte === null && utf16_lead_surrogate === null) {
return finished;
}
if (utf16_lead_byte === null) {
utf16_lead_byte = bite;
return null;
}
var code_unit;
if (utf16_be) {
code_unit = (utf16_lead_byte << 8) + bite;
} else {
code_unit = (bite << 8) + utf16_lead_byte;
}
utf16_lead_byte = null;
if (utf16_lead_surrogate !== null) {
var lead_surrogate = utf16_lead_surrogate;
utf16_lead_surrogate = null;
if (inRange(code_unit, 56320, 57343)) {
return 65536 + (lead_surrogate - 55296) * 1024 + (code_unit - 56320);
}
stream.prepend(convertCodeUnitToBytes(code_unit, utf16_be));
return decoderError(fatal);
}
if (inRange(code_unit, 55296, 56319)) {
utf16_lead_surrogate = code_unit;
return null;
}
if (inRange(code_unit, 56320, 57343))
return decoderError(fatal);
return code_unit;
};
}
function UTF16Encoder(utf16_be, options) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (inRange(code_point, 0, 65535))
return convertCodeUnitToBytes(code_point, utf16_be);
var lead = convertCodeUnitToBytes(
(code_point - 65536 >> 10) + 55296,
utf16_be
);
var trail = convertCodeUnitToBytes(
(code_point - 65536 & 1023) + 56320,
utf16_be
);
return lead.concat(trail);
};
}
encoders["UTF-16BE"] = function(options) {
return new UTF16Encoder(true, options);
};
decoders["UTF-16BE"] = function(options) {
return new UTF16Decoder(true, options);
};
encoders["UTF-16LE"] = function(options) {
return new UTF16Encoder(false, options);
};
decoders["UTF-16LE"] = function(options) {
return new UTF16Decoder(false, options);
};
function XUserDefinedDecoder(options) {
var fatal = options.fatal;
this.handler = function(stream, bite) {
if (bite === end_of_stream)
return finished;
if (isASCIIByte(bite))
return bite;
return 63360 + bite - 128;
};
}
function XUserDefinedEncoder(options) {
var fatal = options.fatal;
this.handler = function(stream, code_point) {
if (code_point === end_of_stream)
return finished;
if (isASCIICodePoint(code_point))
return code_point;
if (inRange(code_point, 63360, 63487))
return code_point - 63360 + 128;
return encoderError(code_point);
};
}
encoders["x-user-defined"] = function(options) {
return new XUserDefinedEncoder(options);
};
decoders["x-user-defined"] = function(options) {
return new XUserDefinedDecoder(options);
};
if (!global2["TextEncoder"])
global2["TextEncoder"] = TextEncoder3;
if (!global2["TextDecoder"])
global2["TextDecoder"] = TextDecoder3;
if (typeof module2 !== "undefined" && module2.exports) {
module2.exports = {
TextEncoder: global2["TextEncoder"],
TextDecoder: global2["TextDecoder"],
EncodingIndexes: global2["encoding-indexes"]
};
}
})(exports || {});
}
});
// node_modules/@sinonjs/text-encoding/index.js
var require_text_encoding = __commonJS({
"node_modules/@sinonjs/text-encoding/index.js"(exports, module2) {
var encoding = require_encoding();
module2.exports = {
TextEncoder: encoding.TextEncoder,
TextDecoder: encoding.TextDecoder
};
}
});
// node_modules/dayjs/dayjs.min.js
var require_dayjs_min = __commonJS({
"node_modules/dayjs/dayjs.min.js"(exports, module2) {
!function(t3, e3) {
"object" == typeof exports && "undefined" != typeof module2 ? module2.exports = e3() : "function" == typeof define && define.amd ? define(e3) : (t3 = "undefined" != typeof globalThis ? globalThis : t3 || self).dayjs = e3();
}(exports, function() {
"use strict";
var t3 = 1e3, e3 = 6e4, n3 = 36e5, r3 = "millisecond", i4 = "second", s4 = "minute", u3 = "hour", a3 = "day", o3 = "week", f3 = "month", h3 = "quarter", c4 = "year", d3 = "date", l3 = "Invalid Date", $3 = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y3 = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M3 = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t4) {
var e4 = ["th", "st", "nd", "rd"], n4 = t4 % 100;
return "[" + t4 + (e4[(n4 - 20) % 10] || e4[n4] || e4[0]) + "]";
} }, m3 = function(t4, e4, n4) {
var r4 = String(t4);
return !r4 || r4.length >= e4 ? t4 : "" + Array(e4 + 1 - r4.length).join(n4) + t4;
}, v3 = { s: m3, z: function(t4) {
var e4 = -t4.utcOffset(), n4 = Math.abs(e4), r4 = Math.floor(n4 / 60), i5 = n4 % 60;
return (e4 <= 0 ? "+" : "-") + m3(r4, 2, "0") + ":" + m3(i5, 2, "0");
}, m: function t4(e4, n4) {
if (e4.date() < n4.date())
return -t4(n4, e4);
var r4 = 12 * (n4.year() - e4.year()) + (n4.month() - e4.month()), i5 = e4.clone().add(r4, f3), s5 = n4 - i5 < 0, u4 = e4.clone().add(r4 + (s5 ? -1 : 1), f3);
return +(-(r4 + (n4 - i5) / (s5 ? i5 - u4 : u4 - i5)) || 0);
}, a: function(t4) {
return t4 < 0 ? Math.ceil(t4) || 0 : Math.floor(t4);
}, p: function(t4) {
return { M: f3, y: c4, w: o3, d: a3, D: d3, h: u3, m: s4, s: i4, ms: r3, Q: h3 }[t4] || String(t4 || "").toLowerCase().replace(/s$/, "");
}, u: function(t4) {
return void 0 === t4;
} }, g4 = "en", D3 = {};
D3[g4] = M3;
var p3 = function(t4) {
return t4 instanceof _3;
}, S2 = function t4(e4, n4, r4) {
var i5;
if (!e4)
return g4;
if ("string" == typeof e4) {
var s5 = e4.toLowerCase();
D3[s5] && (i5 = s5), n4 && (D3[s5] = n4, i5 = s5);
var u4 = e4.split("-");
if (!i5 && u4.length > 1)
return t4(u4[0]);
} else {
var a4 = e4.name;
D3[a4] = e4, i5 = a4;
}
return !r4 && i5 && (g4 = i5), i5 || !r4 && g4;
}, w4 = function(t4, e4) {
if (p3(t4))
return t4.clone();
var n4 = "object" == typeof e4 ? e4 : {};
return n4.date = t4, n4.args = arguments, new _3(n4);
}, O3 = v3;
O3.l = S2, O3.i = p3, O3.w = function(t4, e4) {
return w4(t4, { locale: e4.$L, utc: e4.$u, x: e4.$x, $offset: e4.$offset });
};
var _3 = function() {
function M4(t4) {
this.$L = S2(t4.locale, null, true), this.parse(t4);
}
var m4 = M4.prototype;
return m4.parse = function(t4) {
this.$d = function(t5) {
var e4 = t5.date, n4 = t5.utc;
if (null === e4)
return new Date(NaN);
if (O3.u(e4))
return new Date();
if (e4 instanceof Date)
return new Date(e4);
if ("string" == typeof e4 && !/Z$/i.test(e4)) {
var r4 = e4.match($3);
if (r4) {
var i5 = r4[2] - 1 || 0, s5 = (r4[7] || "0").substring(0, 3);
return n4 ? new Date(Date.UTC(r4[1], i5, r4[3] || 1, r4[4] || 0, r4[5] || 0, r4[6] || 0, s5)) : new Date(r4[1], i5, r4[3] || 1, r4[4] || 0, r4[5] || 0, r4[6] || 0, s5);
}
}
return new Date(e4);
}(t4), this.$x = t4.x || {}, this.init();
}, m4.init = function() {
var t4 = this.$d;
this.$y = t4.getFullYear(), this.$M = t4.getMonth(), this.$D = t4.getDate(), this.$W = t4.getDay(), this.$H = t4.getHours(), this.$m = t4.getMinutes(), this.$s = t4.getSeconds(), this.$ms = t4.getMilliseconds();
}, m4.$utils = function() {
return O3;
}, m4.isValid = function() {
return !(this.$d.toString() === l3);
}, m4.isSame = function(t4, e4) {
var n4 = w4(t4);
return this.startOf(e4) <= n4 && n4 <= this.endOf(e4);
}, m4.isAfter = function(t4, e4) {
return w4(t4) < this.startOf(e4);
}, m4.isBefore = function(t4, e4) {
return this.endOf(e4) < w4(t4);
}, m4.$g = function(t4, e4, n4) {
return O3.u(t4) ? this[e4] : this.set(n4, t4);
}, m4.unix = function() {
return Math.floor(this.valueOf() / 1e3);
}, m4.valueOf = function() {
return this.$d.getTime();
}, m4.startOf = function(t4, e4) {
var n4 = this, r4 = !!O3.u(e4) || e4, h4 = O3.p(t4), l4 = function(t5, e5) {
var i5 = O3.w(n4.$u ? Date.UTC(n4.$y, e5, t5) : new Date(n4.$y, e5, t5), n4);
return r4 ? i5 : i5.endOf(a3);
}, $4 = function(t5, e5) {
return O3.w(n4.toDate()[t5].apply(n4.toDate("s"), (r4 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e5)), n4);
}, y4 = this.$W, M5 = this.$M, m5 = this.$D, v4 = "set" + (this.$u ? "UTC" : "");
switch (h4) {
case c4:
return r4 ? l4(1, 0) : l4(31, 11);
case f3:
return r4 ? l4(1, M5) : l4(0, M5 + 1);
case o3:
var g5 = this.$locale().weekStart || 0, D4 = (y4 < g5 ? y4 + 7 : y4) - g5;
return l4(r4 ? m5 - D4 : m5 + (6 - D4), M5);
case a3:
case d3:
return $4(v4 + "Hours", 0);
case u3:
return $4(v4 + "Minutes", 1);
case s4:
return $4(v4 + "Seconds", 2);
case i4:
return $4(v4 + "Milliseconds", 3);
default:
return this.clone();
}
}, m4.endOf = function(t4) {
return this.startOf(t4, false);
}, m4.$set = function(t4, e4) {
var n4, o4 = O3.p(t4), h4 = "set" + (this.$u ? "UTC" : ""), l4 = (n4 = {}, n4[a3] = h4 + "Date", n4[d3] = h4 + "Date", n4[f3] = h4 + "Month", n4[c4] = h4 + "FullYear", n4[u3] = h4 + "Hours", n4[s4] = h4 + "Minutes", n4[i4] = h4 + "Seconds", n4[r3] = h4 + "Milliseconds", n4)[o4], $4 = o4 === a3 ? this.$D + (e4 - this.$W) : e4;
if (o4 === f3 || o4 === c4) {
var y4 = this.clone().set(d3, 1);
y4.$d[l4]($4), y4.init(), this.$d = y4.set(d3, Math.min(this.$D, y4.daysInMonth())).$d;
} else
l4 && this.$d[l4]($4);
return this.init(), this;
}, m4.set = function(t4, e4) {
return this.clone().$set(t4, e4);
}, m4.get = function(t4) {
return this[O3.p(t4)]();
}, m4.add = function(r4, h4) {
var d4, l4 = this;
r4 = Number(r4);
var $4 = O3.p(h4), y4 = function(t4) {
var e4 = w4(l4);
return O3.w(e4.date(e4.date() + Math.round(t4 * r4)), l4);
};
if ($4 === f3)
return this.set(f3, this.$M + r4);
if ($4 === c4)
return this.set(c4, this.$y + r4);
if ($4 === a3)
return y4(1);
if ($4 === o3)
return y4(7);
var M5 = (d4 = {}, d4[s4] = e3, d4[u3] = n3, d4[i4] = t3, d4)[$4] || 1, m5 = this.$d.getTime() + r4 * M5;
return O3.w(m5, this);
}, m4.subtract = function(t4, e4) {
return this.add(-1 * t4, e4);
}, m4.format = function(t4) {
var e4 = this, n4 = this.$locale();
if (!this.isValid())
return n4.invalidDate || l3;
var r4 = t4 || "YYYY-MM-DDTHH:mm:ssZ", i5 = O3.z(this), s5 = this.$H, u4 = this.$m, a4 = this.$M, o4 = n4.weekdays, f4 = n4.months, h4 = function(t5, n5, i6, s6) {
return t5 && (t5[n5] || t5(e4, r4)) || i6[n5].slice(0, s6);
}, c5 = function(t5) {
return O3.s(s5 % 12 || 12, t5, "0");
}, d4 = n4.meridiem || function(t5, e5, n5) {
var r5 = t5 < 12 ? "AM" : "PM";
return n5 ? r5.toLowerCase() : r5;
}, $4 = { YY: String(this.$y).slice(-2), YYYY: this.$y, M: a4 + 1, MM: O3.s(a4 + 1, 2, "0"), MMM: h4(n4.monthsShort, a4, f4, 3), MMMM: h4(f4, a4), D: this.$D, DD: O3.s(this.$D, 2, "0"), d: String(this.$W), dd: h4(n4.weekdaysMin, this.$W, o4, 2), ddd: h4(n4.weekdaysShort, this.$W, o4, 3), dddd: o4[this.$W], H: String(s5), HH: O3.s(s5, 2, "0"), h: c5(1), hh: c5(2), a: d4(s5, u4, true), A: d4(s5, u4, false), m: String(u4), mm: O3.s(u4, 2, "0"), s: String(this.$s), ss: O3.s(this.$s, 2, "0"), SSS: O3.s(this.$ms, 3, "0"), Z: i5 };
return r4.replace(y3, function(t5, e5) {
return e5 || $4[t5] || i5.replace(":", "");
});
}, m4.utcOffset = function() {
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
}, m4.diff = function(r4, d4, l4) {
var $4, y4 = O3.p(d4), M5 = w4(r4), m5 = (M5.utcOffset() - this.utcOffset()) * e3, v4 = this - M5, g5 = O3.m(this, M5);
return g5 = ($4 = {}, $4[c4] = g5 / 12, $4[f3] = g5, $4[h3] = g5 / 3, $4[o3] = (v4 - m5) / 6048e5, $4[a3] = (v4 - m5) / 864e5, $4[u3] = v4 / n3, $4[s4] = v4 / e3, $4[i4] = v4 / t3, $4)[y4] || v4, l4 ? g5 : O3.a(g5);
}, m4.daysInMonth = function() {
return this.endOf(f3).$D;
}, m4.$locale = function() {
return D3[this.$L];
}, m4.locale = function(t4, e4) {
if (!t4)
return this.$L;
var n4 = this.clone(), r4 = S2(t4, e4, true);
return r4 && (n4.$L = r4), n4;
}, m4.clone = function() {
return O3.w(this.$d, this);
}, m4.toDate = function() {
return new Date(this.valueOf());
}, m4.toJSON = function() {
return this.isValid() ? this.toISOString() : null;
}, m4.toISOString = function() {
return this.$d.toISOString();
}, m4.toString = function() {
return this.$d.toUTCString();
}, M4;
}(), T4 = _3.prototype;
return w4.prototype = T4, [["$ms", r3], ["$s", i4], ["$m", s4], ["$H", u3], ["$W", a3], ["$M", f3], ["$y", c4], ["$D", d3]].forEach(function(t4) {
T4[t4[1]] = function(e4) {
return this.$g(e4, t4[0], t4[1]);
};
}), w4.extend = function(t4, e4) {
return t4.$i || (t4(e4, _3, w4), t4.$i = true), w4;
}, w4.locale = S2, w4.isDayjs = p3, w4.unix = function(t4) {
return w4(1e3 * t4);
}, w4.en = D3[g4], w4.Ls = D3, w4.p = {}, w4;
});
}
});
// src/main.ts
var main_exports = {};
__export(main_exports, {
default: () => MsgHandlerPlugin
});
module.exports = __toCommonJS(main_exports);
var import_obsidian6 = require("obsidian");
// src/view.tsx
var import_obsidian4 = require("obsidian");
// node_modules/preact/dist/preact.module.js
var n2;
var l;
var u;
var i2;
var t;
var r;
var o;
var f;
var e = {};
var c2 = [];
var s2 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
function a(n3, l3) {
for (var u3 in l3)
n3[u3] = l3[u3];
return n3;
}
function h(n3) {
var l3 = n3.parentNode;
l3 && l3.removeChild(n3);
}
function v(l3, u3, i4) {
var t3, r3, o3, f3 = {};
for (o3 in u3)
"key" == o3 ? t3 = u3[o3] : "ref" == o3 ? r3 = u3[o3] : f3[o3] = u3[o3];
if (arguments.length > 2 && (f3.children = arguments.length > 3 ? n2.call(arguments, 2) : i4), "function" == typeof l3 && null != l3.defaultProps)
for (o3 in l3.defaultProps)
void 0 === f3[o3] && (f3[o3] = l3.defaultProps[o3]);
return y(l3, f3, t3, r3, null);
}
function y(n3, i4, t3, r3, o3) {
var f3 = { type: n3, props: i4, key: t3, ref: r3, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, __h: null, constructor: void 0, __v: null == o3 ? ++u : o3 };
return null == o3 && null != l.vnode && l.vnode(f3), f3;
}
function p() {
return { current: null };
}
function d(n3) {
return n3.children;
}
function _(n3, l3) {
this.props = n3, this.context = l3;
}
function k(n3, l3) {
if (null == l3)
return n3.__ ? k(n3.__, n3.__.__k.indexOf(n3) + 1) : null;
for (var u3; l3 < n3.__k.length; l3++)
if (null != (u3 = n3.__k[l3]) && null != u3.__e)
return u3.__e;
return "function" == typeof n3.type ? k(n3) : null;
}
function b(n3) {
var l3, u3;
if (null != (n3 = n3.__) && null != n3.__c) {
for (n3.__e = n3.__c.base = null, l3 = 0; l3 < n3.__k.length; l3++)
if (null != (u3 = n3.__k[l3]) && null != u3.__e) {
n3.__e = n3.__c.base = u3.__e;
break;
}
return b(n3);
}
}
function g(n3) {
(!n3.__d && (n3.__d = true) && t.push(n3) && !m.__r++ || r !== l.debounceRendering) && ((r = l.debounceRendering) || o)(m);
}
function m() {
var n3, l3, u3, i4, r3, o3, f3, e3;
for (t.sort(function(n4, l4) {
return n4.__v.__b - l4.__v.__b;
}); n3 = t.shift(); )
n3.__d && (l3 = t.length, i4 = void 0, r3 = void 0, f3 = (o3 = (u3 = n3).__v).__e, (e3 = u3.__P) && (i4 = [], (r3 = a({}, o3)).__v = o3.__v + 1, z(e3, o3, r3, u3.__n, void 0 !== e3.ownerSVGElement, null != o3.__h ? [f3] : null, i4, null == f3 ? k(o3) : f3, o3.__h), L(i4, o3), o3.__e != f3 && b(o3)), t.length > l3 && t.sort(function(n4, l4) {
return n4.__v.__b - l4.__v.__b;
}));
m.__r = 0;
}
function w(n3, l3, u3, i4, t3, r3, o3, f3, s4, a3) {
var h3, v3, p3, _3, b3, g4, m3, w4 = i4 && i4.__k || c2, A4 = w4.length;
for (u3.__k = [], h3 = 0; h3 < l3.length; h3++)
if (null != (_3 = u3.__k[h3] = null == (_3 = l3[h3]) || "boolean" == typeof _3 ? null : "string" == typeof _3 || "number" == typeof _3 || "bigint" == typeof _3 ? y(null, _3, null, null, _3) : Array.isArray(_3) ? y(d, { children: _3 }, null, null, null) : _3.__b > 0 ? y(_3.type, _3.props, _3.key, _3.ref ? _3.ref : null, _3.__v) : _3)) {
if (_3.__ = u3, _3.__b = u3.__b + 1, null === (p3 = w4[h3]) || p3 && _3.key == p3.key && _3.type === p3.type)
w4[h3] = void 0;
else
for (v3 = 0; v3 < A4; v3++) {
if ((p3 = w4[v3]) && _3.key == p3.key && _3.type === p3.type) {
w4[v3] = void 0;
break;
}
p3 = null;
}
z(n3, _3, p3 = p3 || e, t3, r3, o3, f3, s4, a3), b3 = _3.__e, (v3 = _3.ref) && p3.ref != v3 && (m3 || (m3 = []), p3.ref && m3.push(p3.ref, null, _3), m3.push(v3, _3.__c || b3, _3)), null != b3 ? (null == g4 && (g4 = b3), "function" == typeof _3.type && _3.__k === p3.__k ? _3.__d = s4 = x(_3, s4, n3) : s4 = P(n3, _3, p3, w4, b3, s4), "function" == typeof u3.type && (u3.__d = s4)) : s4 && p3.__e == s4 && s4.parentNode != n3 && (s4 = k(p3));
}
for (u3.__e = g4, h3 = A4; h3--; )
null != w4[h3] && ("function" == typeof u3.type && null != w4[h3].__e && w4[h3].__e == u3.__d && (u3.__d = C(i4).nextSibling), O(w4[h3], w4[h3]));
if (m3)
for (h3 = 0; h3 < m3.length; h3++)
N(m3[h3], m3[++h3], m3[++h3]);
}
function x(n3, l3, u3) {
for (var i4, t3 = n3.__k, r3 = 0; t3 && r3 < t3.length; r3++)
(i4 = t3[r3]) && (i4.__ = n3, l3 = "function" == typeof i4.type ? x(i4, l3, u3) : P(u3, i4, i4, t3, i4.__e, l3));
return l3;
}
function A(n3, l3) {
return l3 = l3 || [], null == n3 || "boolean" == typeof n3 || (Array.isArray(n3) ? n3.some(function(n4) {
A(n4, l3);
}) : l3.push(n3)), l3;
}
function P(n3, l3, u3, i4, t3, r3) {
var o3, f3, e3;
if (void 0 !== l3.__d)
o3 = l3.__d, l3.__d = void 0;
else if (null == u3 || t3 != r3 || null == t3.parentNode)
n:
if (null == r3 || r3.parentNode !== n3)
n3.appendChild(t3), o3 = null;
else {
for (f3 = r3, e3 = 0; (f3 = f3.nextSibling) && e3 < i4.length; e3 += 1)
if (f3 == t3)
break n;
n3.insertBefore(t3, r3), o3 = r3;
}
return void 0 !== o3 ? o3 : t3.nextSibling;
}
function C(n3) {
var l3, u3, i4;
if (null == n3.type || "string" == typeof n3.type)
return n3.__e;
if (n3.__k) {
for (l3 = n3.__k.length - 1; l3 >= 0; l3--)
if ((u3 = n3.__k[l3]) && (i4 = C(u3)))
return i4;
}
return null;
}
function $(n3, l3, u3, i4, t3) {
var r3;
for (r3 in u3)
"children" === r3 || "key" === r3 || r3 in l3 || I(n3, r3, null, u3[r3], i4);
for (r3 in l3)
t3 && "function" != typeof l3[r3] || "children" === r3 || "key" === r3 || "value" === r3 || "checked" === r3 || u3[r3] === l3[r3] || I(n3, r3, l3[r3], u3[r3], i4);
}
function H(n3, l3, u3) {
"-" === l3[0] ? n3.setProperty(l3, null == u3 ? "" : u3) : n3[l3] = null == u3 ? "" : "number" != typeof u3 || s2.test(l3) ? u3 : u3 + "px";
}
function I(n3, l3, u3, i4, t3) {
var r3;
n:
if ("style" === l3)
if ("string" == typeof u3)
n3.style.cssText = u3;
else {
if ("string" == typeof i4 && (n3.style.cssText = i4 = ""), i4)
for (l3 in i4)
u3 && l3 in u3 || H(n3.style, l3, "");
if (u3)
for (l3 in u3)
i4 && u3[l3] === i4[l3] || H(n3.style, l3, u3[l3]);
}
else if ("o" === l3[0] && "n" === l3[1])
r3 = l3 !== (l3 = l3.replace(/Capture$/, "")), l3 = l3.toLowerCase() in n3 ? l3.toLowerCase().slice(2) : l3.slice(2), n3.l || (n3.l = {}), n3.l[l3 + r3] = u3, u3 ? i4 || n3.addEventListener(l3, r3 ? j : T, r3) : n3.removeEventListener(l3, r3 ? j : T, r3);
else if ("dangerouslySetInnerHTML" !== l3) {
if (t3)
l3 = l3.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
else if ("width" !== l3 && "height" !== l3 && "href" !== l3 && "list" !== l3 && "form" !== l3 && "tabIndex" !== l3 && "download" !== l3 && l3 in n3)
try {
n3[l3] = null == u3 ? "" : u3;
break n;
} catch (n4) {
}
"function" == typeof u3 || (null == u3 || false === u3 && -1 == l3.indexOf("-") ? n3.removeAttribute(l3) : n3.setAttribute(l3, u3));
}
}
function T(n3) {
return this.l[n3.type + false](l.event ? l.event(n3) : n3);
}
function j(n3) {
return this.l[n3.type + true](l.event ? l.event(n3) : n3);
}
function z(n3, u3, i4, t3, r3, o3, f3, e3, c4) {
var s4, h3, v3, y3, p3, k4, b3, g4, m3, x4, A4, P3, C3, $3, H3, I3 = u3.type;
if (void 0 !== u3.constructor)
return null;
null != i4.__h && (c4 = i4.__h, e3 = u3.__e = i4.__e, u3.__h = null, o3 = [e3]), (s4 = l.__b) && s4(u3);
try {
n:
if ("function" == typeof I3) {
if (g4 = u3.props, m3 = (s4 = I3.contextType) && t3[s4.__c], x4 = s4 ? m3 ? m3.props.value : s4.__ : t3, i4.__c ? b3 = (h3 = u3.__c = i4.__c).__ = h3.__E : ("prototype" in I3 && I3.prototype.render ? u3.__c = h3 = new I3(g4, x4) : (u3.__c = h3 = new _(g4, x4), h3.constructor = I3, h3.render = S), m3 && m3.sub(h3), h3.props = g4, h3.state || (h3.state = {}), h3.context = x4, h3.__n = t3, v3 = h3.__d = true, h3.__h = [], h3._sb = []), null == h3.__s && (h3.__s = h3.state), null != I3.getDerivedStateFromProps && (h3.__s == h3.state && (h3.__s = a({}, h3.__s)), a(h3.__s, I3.getDerivedStateFromProps(g4, h3.__s))), y3 = h3.props, p3 = h3.state, h3.__v = u3, v3)
null == I3.getDerivedStateFromProps && null != h3.componentWillMount && h3.componentWillMount(), null != h3.componentDidMount && h3.__h.push(h3.componentDidMount);
else {
if (null == I3.getDerivedStateFromProps && g4 !== y3 && null != h3.componentWillReceiveProps && h3.componentWillReceiveProps(g4, x4), !h3.__e && null != h3.shouldComponentUpdate && false === h3.shouldComponentUpdate(g4, h3.__s, x4) || u3.__v === i4.__v) {
for (u3.__v !== i4.__v && (h3.props = g4, h3.state = h3.__s, h3.__d = false), h3.__e = false, u3.__e = i4.__e, u3.__k = i4.__k, u3.__k.forEach(function(n4) {
n4 && (n4.__ = u3);
}), A4 = 0; A4 < h3._sb.length; A4++)
h3.__h.push(h3._sb[A4]);
h3._sb = [], h3.__h.length && f3.push(h3);
break n;
}
null != h3.componentWillUpdate && h3.componentWillUpdate(g4, h3.__s, x4), null != h3.componentDidUpdate && h3.__h.push(function() {
h3.componentDidUpdate(y3, p3, k4);
});
}
if (h3.context = x4, h3.props = g4, h3.__P = n3, P3 = l.__r, C3 = 0, "prototype" in I3 && I3.prototype.render) {
for (h3.state = h3.__s, h3.__d = false, P3 && P3(u3), s4 = h3.render(h3.props, h3.state, h3.context), $3 = 0; $3 < h3._sb.length; $3++)
h3.__h.push(h3._sb[$3]);
h3._sb = [];
} else
do {
h3.__d = false, P3 && P3(u3), s4 = h3.render(h3.props, h3.state, h3.context), h3.state = h3.__s;
} while (h3.__d && ++C3 < 25);
h3.state = h3.__s, null != h3.getChildContext && (t3 = a(a({}, t3), h3.getChildContext())), v3 || null == h3.getSnapshotBeforeUpdate || (k4 = h3.getSnapshotBeforeUpdate(y3, p3)), H3 = null != s4 && s4.type === d && null == s4.key ? s4.props.children : s4, w(n3, Array.isArray(H3) ? H3 : [H3], u3, i4, t3, r3, o3, f3, e3, c4), h3.base = u3.__e, u3.__h = null, h3.__h.length && f3.push(h3), b3 && (h3.__E = h3.__ = null), h3.__e = false;
} else
null == o3 && u3.__v === i4.__v ? (u3.__k = i4.__k, u3.__e = i4.__e) : u3.__e = M(i4.__e, u3, i4, t3, r3, o3, f3, c4);
(s4 = l.diffed) && s4(u3);
} catch (n4) {
u3.__v = null, (c4 || null != o3) && (u3.__e = e3, u3.__h = !!c4, o3[o3.indexOf(e3)] = null), l.__e(n4, u3, i4);
}
}
function L(n3, u3) {
l.__c && l.__c(u3, n3), n3.some(function(u4) {
try {
n3 = u4.__h, u4.__h = [], n3.some(function(n4) {
n4.call(u4);
});
} catch (n4) {
l.__e(n4, u4.__v);
}
});
}
function M(l3, u3, i4, t3, r3, o3, f3, c4) {
var s4, a3, v3, y3 = i4.props, p3 = u3.props, d3 = u3.type, _3 = 0;
if ("svg" === d3 && (r3 = true), null != o3) {
for (; _3 < o3.length; _3++)
if ((s4 = o3[_3]) && "setAttribute" in s4 == !!d3 && (d3 ? s4.localName === d3 : 3 === s4.nodeType)) {
l3 = s4, o3[_3] = null;
break;
}
}
if (null == l3) {
if (null === d3)
return document.createTextNode(p3);
l3 = r3 ? document.createElementNS("http://www.w3.org/2000/svg", d3) : document.createElement(d3, p3.is && p3), o3 = null, c4 = false;
}
if (null === d3)
y3 === p3 || c4 && l3.data === p3 || (l3.data = p3);
else {
if (o3 = o3 && n2.call(l3.childNodes), a3 = (y3 = i4.props || e).dangerouslySetInnerHTML, v3 = p3.dangerouslySetInnerHTML, !c4) {
if (null != o3)
for (y3 = {}, _3 = 0; _3 < l3.attributes.length; _3++)
y3[l3.attributes[_3].name] = l3.attributes[_3].value;
(v3 || a3) && (v3 && (a3 && v3.__html == a3.__html || v3.__html === l3.innerHTML) || (l3.innerHTML = v3 && v3.__html || ""));
}
if ($(l3, p3, y3, r3, c4), v3)
u3.__k = [];
else if (_3 = u3.props.children, w(l3, Array.isArray(_3) ? _3 : [_3], u3, i4, t3, r3 && "foreignObject" !== d3, o3, f3, o3 ? o3[0] : i4.__k && k(i4, 0), c4), null != o3)
for (_3 = o3.length; _3--; )
null != o3[_3] && h(o3[_3]);
c4 || ("value" in p3 && void 0 !== (_3 = p3.value) && (_3 !== l3.value || "progress" === d3 && !_3 || "option" === d3 && _3 !== y3.value) && I(l3, "value", _3, y3.value, false), "checked" in p3 && void 0 !== (_3 = p3.checked) && _3 !== l3.checked && I(l3, "checked", _3, y3.checked, false));
}
return l3;
}
function N(n3, u3, i4) {
try {
"function" == typeof n3 ? n3(u3) : n3.current = u3;
} catch (n4) {
l.__e(n4, i4);
}
}
function O(n3, u3, i4) {
var t3, r3;
if (l.unmount && l.unmount(n3), (t3 = n3.ref) && (t3.current && t3.current !== n3.__e || N(t3, null, u3)), null != (t3 = n3.__c)) {
if (t3.componentWillUnmount)
try {
t3.componentWillUnmount();
} catch (n4) {
l.__e(n4, u3);
}
t3.base = t3.__P = null, n3.__c = void 0;
}
if (t3 = n3.__k)
for (r3 = 0; r3 < t3.length; r3++)
t3[r3] && O(t3[r3], u3, i4 || "function" != typeof n3.type);
i4 || null == n3.__e || h(n3.__e), n3.__ = n3.__e = n3.__d = void 0;
}
function S(n3, l3, u3) {
return this.constructor(n3, u3);
}
function q(u3, i4, t3) {
var r3, o3, f3;
l.__ && l.__(u3, i4), o3 = (r3 = "function" == typeof t3) ? null : t3 && t3.__k || i4.__k, f3 = [], z(i4, u3 = (!r3 && t3 || i4).__k = v(d, null, [u3]), o3 || e, e, void 0 !== i4.ownerSVGElement, !r3 && t3 ? [t3] : o3 ? null : i4.firstChild ? n2.call(i4.childNodes) : null, f3, !r3 && t3 ? t3 : o3 ? o3.__e : i4.firstChild, r3), L(f3, u3);
}
function B(n3, l3) {
q(n3, l3, B);
}
function D(l3, u3, i4) {
var t3, r3, o3, f3 = a({}, l3.props);
for (o3 in u3)
"key" == o3 ? t3 = u3[o3] : "ref" == o3 ? r3 = u3[o3] : f3[o3] = u3[o3];
return arguments.length > 2 && (f3.children = arguments.length > 3 ? n2.call(arguments, 2) : i4), y(l3.type, f3, t3 || l3.key, r3 || l3.ref, null);
}
function E(n3, l3) {
var u3 = { __c: l3 = "__cC" + f++, __: n3, Consumer: function(n4, l4) {
return n4.children(l4);
}, Provider: function(n4) {
var u4, i4;
return this.getChildContext || (u4 = [], (i4 = {})[l3] = this, this.getChildContext = function() {
return i4;
}, this.shouldComponentUpdate = function(n5) {
this.props.value !== n5.value && u4.some(function(n6) {
n6.__e = true, g(n6);
});
}, this.sub = function(n5) {
u4.push(n5);
var l4 = n5.componentWillUnmount;
n5.componentWillUnmount = function() {
u4.splice(u4.indexOf(n5), 1), l4 && l4.call(n5);
};
}), n4.children;
} };
return u3.Provider.__ = u3.Consumer.contextType = u3;
}
n2 = c2.slice, l = { __e: function(n3, l3, u3, i4) {
for (var t3, r3, o3; l3 = l3.__; )
if ((t3 = l3.__c) && !t3.__)
try {
if ((r3 = t3.constructor) && null != r3.getDerivedStateFromError && (t3.setState(r3.getDerivedStateFromError(n3)), o3 = t3.__d), null != t3.componentDidCatch && (t3.componentDidCatch(n3, i4 || {}), o3 = t3.__d), o3)
return t3.__E = t3;
} catch (l4) {
n3 = l4;
}
throw n3;
} }, u = 0, i2 = function(n3) {
return null != n3 && void 0 === n3.constructor;
}, _.prototype.setState = function(n3, l3) {
var u3;
u3 = null != this.__s && this.__s !== this.state ? this.__s : this.__s = a({}, this.state), "function" == typeof n3 && (n3 = n3(a({}, u3), this.props)), n3 && a(u3, n3), null != n3 && this.__v && (l3 && this._sb.push(l3), g(this));
}, _.prototype.forceUpdate = function(n3) {
this.__v && (this.__e = true, n3 && this.__h.push(n3), g(this));
}, _.prototype.render = d, t = [], o = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, m.__r = 0, f = 0;
// node_modules/preact/hooks/dist/hooks.module.js
var t2;
var r2;
var u2;
var i3;
var o2 = 0;
var f2 = [];
var c3 = [];
var e2 = l.__b;
var a2 = l.__r;
var v2 = l.diffed;
var l2 = l.__c;
var m2 = l.unmount;
function d2(t3, u3) {
l.__h && l.__h(r2, t3, o2 || u3), o2 = 0;
var i4 = r2.__H || (r2.__H = { __: [], __h: [] });
return t3 >= i4.__.length && i4.__.push({ __V: c3 }), i4.__[t3];
}
function p2(n3) {
return o2 = 1, y2(B2, n3);
}
function y2(n3, u3, i4) {
var o3 = d2(t2++, 2);
if (o3.t = n3, !o3.__c && (o3.__ = [i4 ? i4(u3) : B2(void 0, u3), function(n4) {
var t3 = o3.__N ? o3.__N[0] : o3.__[0], r3 = o3.t(t3, n4);
t3 !== r3 && (o3.__N = [r3, o3.__[1]], o3.__c.setState({}));
}], o3.__c = r2, !r2.u)) {
r2.u = true;
var f3 = r2.shouldComponentUpdate;
r2.shouldComponentUpdate = function(n4, t3, r3) {
if (!o3.__c.__H)
return true;
var u4 = o3.__c.__H.__.filter(function(n5) {
return n5.__c;
});
if (u4.every(function(n5) {
return !n5.__N;
}))
return !f3 || f3.call(this, n4, t3, r3);
var i5 = false;
return u4.forEach(function(n5) {
if (n5.__N) {
var t4 = n5.__[0];
n5.__ = n5.__N, n5.__N = void 0, t4 !== n5.__[0] && (i5 = true);
}
}), !(!i5 && o3.__c.props === n4) && (!f3 || f3.call(this, n4, t3, r3));
};
}
return o3.__N || o3.__;
}
function h2(u3, i4) {
var o3 = d2(t2++, 3);
!l.__s && z2(o3.__H, i4) && (o3.__ = u3, o3.i = i4, r2.__H.__h.push(o3));
}
function s3(u3, i4) {
var o3 = d2(t2++, 4);
!l.__s && z2(o3.__H, i4) && (o3.__ = u3, o3.i = i4, r2.__h.push(o3));
}
function _2(n3) {
return o2 = 5, F(function() {
return { current: n3 };
}, []);
}
function A2(n3, t3, r3) {
o2 = 6, s3(function() {
return "function" == typeof n3 ? (n3(t3()), function() {
return n3(null);
}) : n3 ? (n3.current = t3(), function() {
return n3.current = null;
}) : void 0;
}, null == r3 ? r3 : r3.concat(n3));
}
function F(n3, r3) {
var u3 = d2(t2++, 7);
return z2(u3.__H, r3) ? (u3.__V = n3(), u3.i = r3, u3.__h = n3, u3.__V) : u3.__;
}
function T2(n3, t3) {
return o2 = 8, F(function() {
return n3;
}, t3);
}
function q2(n3) {
var u3 = r2.context[n3.__c], i4 = d2(t2++, 9);
return i4.c = n3, u3 ? (null == i4.__ && (i4.__ = true, u3.sub(r2)), u3.props.value) : n3.__;
}
function x2(t3, r3) {
l.useDebugValue && l.useDebugValue(r3 ? r3(t3) : t3);
}
function V() {
var n3 = d2(t2++, 11);
if (!n3.__) {
for (var u3 = r2.__v; null !== u3 && !u3.__m && null !== u3.__; )
u3 = u3.__;
var i4 = u3.__m || (u3.__m = [0, 0]);
n3.__ = "P" + i4[0] + "-" + i4[1]++;
}
return n3.__;
}
function b2() {
for (var t3; t3 = f2.shift(); )
if (t3.__P && t3.__H)
try {
t3.__H.__h.forEach(k2), t3.__H.__h.forEach(w2), t3.__H.__h = [];
} catch (r3) {
t3.__H.__h = [], l.__e(r3, t3.__v);
}
}
l.__b = function(n3) {
r2 = null, e2 && e2(n3);
}, l.__r = function(n3) {
a2 && a2(n3), t2 = 0;
var i4 = (r2 = n3.__c).__H;
i4 && (u2 === r2 ? (i4.__h = [], r2.__h = [], i4.__.forEach(function(n4) {
n4.__N && (n4.__ = n4.__N), n4.__V = c3, n4.__N = n4.i = void 0;
})) : (i4.__h.forEach(k2), i4.__h.forEach(w2), i4.__h = [])), u2 = r2;
}, l.diffed = function(t3) {
v2 && v2(t3);
var o3 = t3.__c;
o3 && o3.__H && (o3.__H.__h.length && (1 !== f2.push(o3) && i3 === l.requestAnimationFrame || ((i3 = l.requestAnimationFrame) || j2)(b2)), o3.__H.__.forEach(function(n3) {
n3.i && (n3.__H = n3.i), n3.__V !== c3 && (n3.__ = n3.__V), n3.i = void 0, n3.__V = c3;
})), u2 = r2 = null;
}, l.__c = function(t3, r3) {
r3.some(function(t4) {
try {
t4.__h.forEach(k2), t4.__h = t4.__h.filter(function(n3) {
return !n3.__ || w2(n3);
});
} catch (u3) {
r3.some(function(n3) {
n3.__h && (n3.__h = []);
}), r3 = [], l.__e(u3, t4.__v);
}
}), l2 && l2(t3, r3);
}, l.unmount = function(t3) {
m2 && m2(t3);
var r3, u3 = t3.__c;
u3 && u3.__H && (u3.__H.__.forEach(function(n3) {
try {
k2(n3);
} catch (n4) {
r3 = n4;
}
}), u3.__H = void 0, r3 && l.__e(r3, u3.__v));
};
var g2 = "function" == typeof requestAnimationFrame;
function j2(n3) {
var t3, r3 = function() {
clearTimeout(u3), g2 && cancelAnimationFrame(t3), setTimeout(n3);
}, u3 = setTimeout(r3, 100);
g2 && (t3 = requestAnimationFrame(r3));
}
function k2(n3) {
var t3 = r2, u3 = n3.__c;
"function" == typeof u3 && (n3.__c = void 0, u3()), r2 = t3;
}
function w2(n3) {
var t3 = r2;
n3.__c = n3.__(), r2 = t3;
}
function z2(n3, t3) {
return !n3 || n3.length !== t3.length || t3.some(function(t4, r3) {
return t4 !== n3[r3];
});
}
function B2(n3, t3) {
return "function" == typeof t3 ? t3(n3) : t3;
}
// node_modules/preact/compat/dist/compat.module.js
function g3(n3, t3) {
for (var e3 in t3)
n3[e3] = t3[e3];
return n3;
}
function C2(n3, t3) {
for (var e3 in n3)
if ("__source" !== e3 && !(e3 in t3))
return true;
for (var r3 in t3)
if ("__source" !== r3 && n3[r3] !== t3[r3])
return true;
return false;
}
function E2(n3, t3) {
return n3 === t3 && (0 !== n3 || 1 / n3 == 1 / t3) || n3 != n3 && t3 != t3;
}
function w3(n3) {
this.props = n3;
}
function x3(n3, e3) {
function r3(n4) {
var t3 = this.props.ref, r4 = t3 == n4.ref;
return !r4 && t3 && (t3.call ? t3(null) : t3.current = null), e3 ? !e3(this.props, n4) || !r4 : C2(this.props, n4);
}
function u3(e4) {
return this.shouldComponentUpdate = r3, v(n3, e4);
}
return u3.displayName = "Memo(" + (n3.displayName || n3.name) + ")", u3.prototype.isReactComponent = true, u3.__f = true, u3;
}
(w3.prototype = new _()).isPureReactComponent = true, w3.prototype.shouldComponentUpdate = function(n3, t3) {
return C2(this.props, n3) || C2(this.state, t3);
};
var R = l.__b;
l.__b = function(n3) {
n3.type && n3.type.__f && n3.ref && (n3.props.ref = n3.ref, n3.ref = null), R && R(n3);
};
var N2 = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.forward_ref") || 3911;
function k3(n3) {
function t3(t4) {
var e3 = g3({}, t4);
return delete e3.ref, n3(e3, t4.ref || null);
}
return t3.$$typeof = N2, t3.render = t3, t3.prototype.isReactComponent = t3.__f = true, t3.displayName = "ForwardRef(" + (n3.displayName || n3.name) + ")", t3;
}
var A3 = function(n3, t3) {
return null == n3 ? null : A(A(n3).map(t3));
};
var O2 = { map: A3, forEach: A3, count: function(n3) {
return n3 ? A(n3).length : 0;
}, only: function(n3) {
var t3 = A(n3);
if (1 !== t3.length)
throw "Children.only";
return t3[0];
}, toArray: A };
var T3 = l.__e;
l.__e = function(n3, t3, e3, r3) {
if (n3.then) {
for (var u3, o3 = t3; o3 = o3.__; )
if ((u3 = o3.__c) && u3.__c)
return null == t3.__e && (t3.__e = e3.__e, t3.__k = e3.__k), u3.__c(n3, t3);
}
T3(n3, t3, e3, r3);
};
var I2 = l.unmount;
function L2(n3, t3, e3) {
return n3 && (n3.__c && n3.__c.__H && (n3.__c.__H.__.forEach(function(n4) {
"function" == typeof n4.__c && n4.__c();
}), n3.__c.__H = null), null != (n3 = g3({}, n3)).__c && (n3.__c.__P === e3 && (n3.__c.__P = t3), n3.__c = null), n3.__k = n3.__k && n3.__k.map(function(n4) {
return L2(n4, t3, e3);
})), n3;
}
function U(n3, t3, e3) {
return n3 && (n3.__v = null, n3.__k = n3.__k && n3.__k.map(function(n4) {
return U(n4, t3, e3);
}), n3.__c && n3.__c.__P === t3 && (n3.__e && e3.insertBefore(n3.__e, n3.__d), n3.__c.__e = true, n3.__c.__P = e3)), n3;
}
function D2() {
this.__u = 0, this.t = null, this.__b = null;
}
function F2(n3) {
var t3 = n3.__.__c;
return t3 && t3.__a && t3.__a(n3);
}
function M2(n3) {
var e3, r3, u3;
function o3(o4) {
if (e3 || (e3 = n3()).then(function(n4) {
r3 = n4.default || n4;
}, function(n4) {
u3 = n4;
}), u3)
throw u3;
if (!r3)
throw e3;
return v(r3, o4);
}
return o3.displayName = "Lazy", o3.__f = true, o3;
}
function V2() {
this.u = null, this.o = null;
}
l.unmount = function(n3) {
var t3 = n3.__c;
t3 && t3.__R && t3.__R(), t3 && true === n3.__h && (n3.type = null), I2 && I2(n3);
}, (D2.prototype = new _()).__c = function(n3, t3) {
var e3 = t3.__c, r3 = this;
null == r3.t && (r3.t = []), r3.t.push(e3);
var u3 = F2(r3.__v), o3 = false, i4 = function() {
o3 || (o3 = true, e3.__R = null, u3 ? u3(l3) : l3());
};
e3.__R = i4;
var l3 = function() {
if (!--r3.__u) {
if (r3.state.__a) {
var n4 = r3.state.__a;
r3.__v.__k[0] = U(n4, n4.__c.__P, n4.__c.__O);
}
var t4;
for (r3.setState({ __a: r3.__b = null }); t4 = r3.t.pop(); )
t4.forceUpdate();
}
}, c4 = true === t3.__h;
r3.__u++ || c4 || r3.setState({ __a: r3.__b = r3.__v.__k[0] }), n3.then(i4, i4);
}, D2.prototype.componentWillUnmount = function() {
this.t = [];
}, D2.prototype.render = function(n3, e3) {
if (this.__b) {
if (this.__v.__k) {
var r3 = document.createElement("div"), o3 = this.__v.__k[0].__c;
this.__v.__k[0] = L2(this.__b, r3, o3.__O = o3.__P);
}
this.__b = null;
}
var i4 = e3.__a && v(d, null, n3.fallback);
return i4 && (i4.__h = null), [v(d, null, e3.__a ? null : n3.children), i4];
};
var W = function(n3, t3, e3) {
if (++e3[1] === e3[0] && n3.o.delete(t3), n3.props.revealOrder && ("t" !== n3.props.revealOrder[0] || !n3.o.size))
for (e3 = n3.u; e3; ) {
for (; e3.length > 3; )
e3.pop()();
if (e3[1] < e3[0])
break;
n3.u = e3 = e3[2];
}
};
function P2(n3) {
return this.getChildContext = function() {
return n3.context;
}, n3.children;
}
function $2(n3) {
var e3 = this, r3 = n3.i;
e3.componentWillUnmount = function() {
q(null, e3.l), e3.l = null, e3.i = null;
}, e3.i && e3.i !== r3 && e3.componentWillUnmount(), n3.__v ? (e3.l || (e3.i = r3, e3.l = { nodeType: 1, parentNode: r3, childNodes: [], appendChild: function(n4) {
this.childNodes.push(n4), e3.i.appendChild(n4);
}, insertBefore: function(n4, t3) {
this.childNodes.push(n4), e3.i.appendChild(n4);
}, removeChild: function(n4) {
this.childNodes.splice(this.childNodes.indexOf(n4) >>> 1, 1), e3.i.removeChild(n4);
} }), q(v(P2, { context: e3.context }, n3.__v), e3.l)) : e3.l && e3.componentWillUnmount();
}
function j3(n3, e3) {
var r3 = v($2, { __v: n3, i: e3 });
return r3.containerInfo = e3, r3;
}
(V2.prototype = new _()).__a = function(n3) {
var t3 = this, e3 = F2(t3.__v), r3 = t3.o.get(n3);
return r3[0]++, function(u3) {
var o3 = function() {
t3.props.revealOrder ? (r3.push(u3), W(t3, n3, r3)) : u3();
};
e3 ? e3(o3) : o3();
};
}, V2.prototype.render = function(n3) {
this.u = null, this.o = /* @__PURE__ */ new Map();
var t3 = A(n3.children);
n3.revealOrder && "b" === n3.revealOrder[0] && t3.reverse();
for (var e3 = t3.length; e3--; )
this.o.set(t3[e3], this.u = [1, 0, this.u]);
return n3.children;
}, V2.prototype.componentDidUpdate = V2.prototype.componentDidMount = function() {
var n3 = this;
this.o.forEach(function(t3, e3) {
W(n3, e3, t3);
});
};
var z3 = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.element") || 60103;
var B3 = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
var H2 = "undefined" != typeof document;
var Z = function(n3) {
return ("undefined" != typeof Symbol && "symbol" == typeof Symbol() ? /fil|che|rad/i : /fil|che|ra/i).test(n3);
};
function Y(n3, t3, e3) {
return null == t3.__k && (t3.textContent = ""), q(n3, t3), "function" == typeof e3 && e3(), n3 ? n3.__c : null;
}
function q3(n3, t3, e3) {
return B(n3, t3), "function" == typeof e3 && e3(), n3 ? n3.__c : null;
}
_.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t3) {
Object.defineProperty(_.prototype, t3, { configurable: true, get: function() {
return this["UNSAFE_" + t3];
}, set: function(n3) {
Object.defineProperty(this, t3, { configurable: true, writable: true, value: n3 });
} });
});
var G = l.event;
function J() {
}
function K() {
return this.cancelBubble;
}
function Q() {
return this.defaultPrevented;
}
l.event = function(n3) {
return G && (n3 = G(n3)), n3.persist = J, n3.isPropagationStopped = K, n3.isDefaultPrevented = Q, n3.nativeEvent = n3;
};
var X;
var nn = { configurable: true, get: function() {
return this.class;
} };
var tn = l.vnode;
l.vnode = function(n3) {
var t3 = n3.type, e3 = n3.props, u3 = e3;
if ("string" == typeof t3) {
var o3 = -1 === t3.indexOf("-");
for (var i4 in u3 = {}, e3) {
var l3 = e3[i4];
H2 && "children" === i4 && "noscript" === t3 || "value" === i4 && "defaultValue" in e3 && null == l3 || ("defaultValue" === i4 && "value" in e3 && null == e3.value ? i4 = "value" : "download" === i4 && true === l3 ? l3 = "" : /ondoubleclick/i.test(i4) ? i4 = "ondblclick" : /^onchange(textarea|input)/i.test(i4 + t3) && !Z(e3.type) ? i4 = "oninput" : /^onfocus$/i.test(i4) ? i4 = "onfocusin" : /^onblur$/i.test(i4) ? i4 = "onfocusout" : /^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(i4) ? i4 = i4.toLowerCase() : o3 && B3.test(i4) ? i4 = i4.replace(/[A-Z0-9]/g, "-$&").toLowerCase() : null === l3 && (l3 = void 0), /^oninput$/i.test(i4) && (i4 = i4.toLowerCase(), u3[i4] && (i4 = "oninputCapture")), u3[i4] = l3);
}
"select" == t3 && u3.multiple && Array.isArray(u3.value) && (u3.value = A(e3.children).forEach(function(n4) {
n4.props.selected = -1 != u3.value.indexOf(n4.props.value);
})), "select" == t3 && null != u3.defaultValue && (u3.value = A(e3.children).forEach(function(n4) {
n4.props.selected = u3.multiple ? -1 != u3.defaultValue.indexOf(n4.props.value) : u3.defaultValue == n4.props.value;
})), n3.props = u3, e3.class != e3.className && (nn.enumerable = "className" in e3, null != e3.className && (u3.class = e3.className), Object.defineProperty(u3, "className", nn));
}
n3.$$typeof = z3, tn && tn(n3);
};
var en = l.__r;
l.__r = function(n3) {
en && en(n3), X = n3.__c;
};
var rn = l.diffed;
l.diffed = function(n3) {
rn && rn(n3);
var t3 = n3.props, e3 = n3.__e;
null != e3 && "textarea" === n3.type && "value" in t3 && t3.value !== e3.value && (e3.value = null == t3.value ? "" : t3.value), X = null;
};
var un = { ReactCurrentDispatcher: { current: { readContext: function(n3) {
return X.__n[n3.__c].props.value;
} } } };
function ln(n3) {
return v.bind(null, n3);
}
function cn(n3) {
return !!n3 && n3.$$typeof === z3;
}
function fn(n3) {
return cn(n3) ? D.apply(null, arguments) : n3;
}
function an(n3) {
return !!n3.__k && (q(null, n3), true);
}
function sn(n3) {
return n3 && (n3.base || 1 === n3.nodeType && n3) || null;
}
var hn = function(n3, t3) {
return n3(t3);
};
var vn = function(n3, t3) {
return n3(t3);
};
var dn = d;
function pn(n3) {
n3();
}
function mn(n3) {
return n3;
}
function yn() {
return [false, pn];
}
var _n = s3;
function bn(n3, t3) {
var e3 = t3(), r3 = p2({ h: { __: e3, v: t3 } }), u3 = r3[0].h, o3 = r3[1];
return s3(function() {
u3.__ = e3, u3.v = t3, E2(u3.__, t3()) || o3({ h: u3 });
}, [n3, e3, t3]), h2(function() {
return E2(u3.__, u3.v()) || o3({ h: u3 }), n3(function() {
E2(u3.__, u3.v()) || o3({ h: u3 });
});
}, [n3]), e3;
}
var Sn = { useState: p2, useId: V, useReducer: y2, useEffect: h2, useLayoutEffect: s3, useInsertionEffect: _n, useTransition: yn, useDeferredValue: mn, useSyncExternalStore: bn, startTransition: pn, useRef: _2, useImperativeHandle: A2, useMemo: F, useCallback: T2, useContext: q2, useDebugValue: x2, version: "17.0.2", Children: O2, render: Y, hydrate: q3, unmountComponentAtNode: an, createPortal: j3, createElement: v, createContext: E, createFactory: ln, cloneElement: fn, createRef: p, Fragment: d, isValidElement: cn, findDOMNode: sn, Component: _, PureComponent: w3, memo: x3, forwardRef: k3, flushSync: vn, unstable_batchedUpdates: hn, StrictMode: dn, Suspense: D2, SuspenseList: V2, lazy: M2, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: un };
// src/components/search/index.tsx
var import_fuzzysort2 = __toESM(require_fuzzysort());
// node_modules/react-icons/lib/esm/iconContext.js
var DefaultContext = {
color: void 0,
size: void 0,
className: void 0,
style: void 0,
attr: void 0
};
var IconContext = Sn.createContext && Sn.createContext(DefaultContext);
// node_modules/react-icons/lib/esm/iconBase.js
var __assign = function() {
__assign = Object.assign || function(t3) {
for (var s4, i4 = 1, n3 = arguments.length; i4 < n3; i4++) {
s4 = arguments[i4];
for (var p3 in s4)
if (Object.prototype.hasOwnProperty.call(s4, p3))
t3[p3] = s4[p3];
}
return t3;
};
return __assign.apply(this, arguments);
};
var __rest = function(s4, e3) {
var t3 = {};
for (var p3 in s4)
if (Object.prototype.hasOwnProperty.call(s4, p3) && e3.indexOf(p3) < 0)
t3[p3] = s4[p3];
if (s4 != null && typeof Object.getOwnPropertySymbols === "function")
for (var i4 = 0, p3 = Object.getOwnPropertySymbols(s4); i4 < p3.length; i4++) {
if (e3.indexOf(p3[i4]) < 0 && Object.prototype.propertyIsEnumerable.call(s4, p3[i4]))
t3[p3[i4]] = s4[p3[i4]];
}
return t3;
};
function Tree2Element(tree) {
return tree && tree.map(function(node, i4) {
return Sn.createElement(node.tag, __assign({
key: i4
}, node.attr), Tree2Element(node.child));
});
}
function GenIcon(data) {
return function(props2) {
return Sn.createElement(IconBase, __assign({
attr: __assign({}, data.attr)
}, props2), Tree2Element(data.child));
};
}
function IconBase(props2) {
var elem = function(conf) {
var attr = props2.attr, size = props2.size, title = props2.title, svgProps = __rest(props2, ["attr", "size", "title"]);
var computedSize = size || conf.size || "1em";
var className;
if (conf.className)
className = conf.className;
if (props2.className)
className = (className ? className + " " : "") + props2.className;
return Sn.createElement("svg", __assign({
stroke: "currentColor",
fill: "currentColor",
strokeWidth: "0"
}, conf.attr, attr, svgProps, {
className,
style: __assign(__assign({
color: props2.color || conf.color
}, conf.style), props2.style),
height: computedSize,
width: computedSize,
xmlns: "http://www.w3.org/2000/svg"
}), title && Sn.createElement("title", null, title), props2.children);
};
return IconContext !== void 0 ? Sn.createElement(IconContext.Consumer, null, function(conf) {
return elem(conf);
}) : elem(DefaultContext);
}
// node_modules/react-icons/md/index.esm.js
function MdKeyboardArrowDown(props2) {
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" } }, { "tag": "path", "attr": { "d": "M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z" } }] })(props2);
}
function MdKeyboardArrowRight(props2) {
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" } }, { "tag": "path", "attr": { "d": "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z" } }] })(props2);
}
function MdClose(props2) {
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0z" } }, { "tag": "path", "attr": { "d": "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" } }] })(props2);
}
// node_modules/react-icons/cg/index.esm.js
function CgChevronDoubleDown(props2) {
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none" }, "child": [{ "tag": "path", "attr": { "d": "M7.75735 5.63605L6.34314 7.05026L12 12.7071L17.6569 7.05029L16.2427 5.63608L12 9.87872L7.75735 5.63605Z", "fill": "currentColor" } }, { "tag": "path", "attr": { "d": "M6.34314 12.7071L7.75735 11.2929L12 15.5356L16.2427 11.2929L17.6569 12.7071L12 18.364L6.34314 12.7071Z", "fill": "currentColor" } }] })(props2);
}
function CgChevronDoubleUp(props2) {
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none" }, "child": [{ "tag": "path", "attr": { "d": "M17.6569 11.2929L16.2427 12.7071L12 8.46444L7.75735 12.7071L6.34314 11.2929L12 5.63605L17.6569 11.2929Z", "fill": "currentColor" } }, { "tag": "path", "attr": { "d": "M17.6569 16.9497L16.2427 18.3639L12 14.1213L7.75735 18.364L6.34314 16.9498L12 11.2929L17.6569 16.9497Z", "fill": "currentColor" } }] })(props2);
}
// node_modules/dexie/dist/modern/dexie.mjs
var _global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
var keys = Object.keys;
var isArray = Array.isArray;
if (typeof Promise !== "undefined" && !_global.Promise) {
_global.Promise = Promise;
}
function extend(obj, extension) {
if (typeof extension !== "object")
return obj;
keys(extension).forEach(function(key) {
obj[key] = extension[key];
});
return obj;
}
var getProto = Object.getPrototypeOf;
var _hasOwn = {}.hasOwnProperty;
function hasOwn(obj, prop) {
return _hasOwn.call(obj, prop);
}
function props(proto, extension) {
if (typeof extension === "function")
extension = extension(getProto(proto));
(typeof Reflect === "undefined" ? keys : Reflect.ownKeys)(extension).forEach((key) => {
setProp(proto, key, extension[key]);
});
}
var defineProperty = Object.defineProperty;
function setProp(obj, prop, functionOrGetSet, options) {
defineProperty(obj, prop, extend(functionOrGetSet && hasOwn(functionOrGetSet, "get") && typeof functionOrGetSet.get === "function" ? { get: functionOrGetSet.get, set: functionOrGetSet.set, configurable: true } : { value: functionOrGetSet, configurable: true, writable: true }, options));
}
function derive(Child) {
return {
from: function(Parent) {
Child.prototype = Object.create(Parent.prototype);
setProp(Child.prototype, "constructor", Child);
return {
extend: props.bind(null, Child.prototype)
};
}
};
}
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
function getPropertyDescriptor(obj, prop) {
const pd = getOwnPropertyDescriptor(obj, prop);
let proto;
return pd || (proto = getProto(obj)) && getPropertyDescriptor(proto, prop);
}
var _slice = [].slice;
function slice(args, start, end) {
return _slice.call(args, start, end);
}
function override(origFunc, overridedFactory) {
return overridedFactory(origFunc);
}
function assert(b3) {
if (!b3)
throw new Error("Assertion Failed");
}
function asap$1(fn2) {
if (_global.setImmediate)
setImmediate(fn2);
else
setTimeout(fn2, 0);
}
function arrayToObject(array, extractor) {
return array.reduce((result, item, i4) => {
var nameAndValue = extractor(item, i4);
if (nameAndValue)
result[nameAndValue[0]] = nameAndValue[1];
return result;
}, {});
}
function tryCatch(fn2, onerror, args) {
try {
fn2.apply(null, args);
} catch (ex) {
onerror && onerror(ex);
}
}
function getByKeyPath(obj, keyPath) {
if (hasOwn(obj, keyPath))
return obj[keyPath];
if (!keyPath)
return obj;
if (typeof keyPath !== "string") {
var rv = [];
for (var i4 = 0, l3 = keyPath.length; i4 < l3; ++i4) {
var val = getByKeyPath(obj, keyPath[i4]);
rv.push(val);
}
return rv;
}
var period = keyPath.indexOf(".");
if (period !== -1) {
var innerObj = obj[keyPath.substr(0, period)];
return innerObj === void 0 ? void 0 : getByKeyPath(innerObj, keyPath.substr(period + 1));
}
return void 0;
}
function setByKeyPath(obj, keyPath, value) {
if (!obj || keyPath === void 0)
return;
if ("isFrozen" in Object && Object.isFrozen(obj))
return;
if (typeof keyPath !== "string" && "length" in keyPath) {
assert(typeof value !== "string" && "length" in value);
for (var i4 = 0, l3 = keyPath.length; i4 < l3; ++i4) {
setByKeyPath(obj, keyPath[i4], value[i4]);
}
} else {
var period = keyPath.indexOf(".");
if (period !== -1) {
var currentKeyPath = keyPath.substr(0, period);
var remainingKeyPath = keyPath.substr(period + 1);
if (remainingKeyPath === "")
if (value === void 0) {
if (isArray(obj) && !isNaN(parseInt(currentKeyPath)))
obj.splice(currentKeyPath, 1);
else
delete obj[currentKeyPath];
} else
obj[currentKeyPath] = value;
else {
var innerObj = obj[currentKeyPath];
if (!innerObj || !hasOwn(obj, currentKeyPath))
innerObj = obj[currentKeyPath] = {};
setByKeyPath(innerObj, remainingKeyPath, value);
}
} else {
if (value === void 0) {
if (isArray(obj) && !isNaN(parseInt(keyPath)))
obj.splice(keyPath, 1);
else
delete obj[keyPath];
} else
obj[keyPath] = value;
}
}
}
function delByKeyPath(obj, keyPath) {
if (typeof keyPath === "string")
setByKeyPath(obj, keyPath, void 0);
else if ("length" in keyPath)
[].map.call(keyPath, function(kp) {
setByKeyPath(obj, kp, void 0);
});
}
function shallowClone(obj) {
var rv = {};
for (var m3 in obj) {
if (hasOwn(obj, m3))
rv[m3] = obj[m3];
}
return rv;
}
var concat = [].concat;
function flatten(a3) {
return concat.apply([], a3);
}
var intrinsicTypeNames = "Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(flatten([8, 16, 32, 64].map((num) => ["Int", "Uint", "Float"].map((t3) => t3 + num + "Array")))).filter((t3) => _global[t3]);
var intrinsicTypes = intrinsicTypeNames.map((t3) => _global[t3]);
arrayToObject(intrinsicTypeNames, (x4) => [x4, true]);
var circularRefs = null;
function deepClone(any) {
circularRefs = typeof WeakMap !== "undefined" && /* @__PURE__ */ new WeakMap();
const rv = innerDeepClone(any);
circularRefs = null;
return rv;
}
function innerDeepClone(any) {
if (!any || typeof any !== "object")
return any;
let rv = circularRefs && circularRefs.get(any);
if (rv)
return rv;
if (isArray(any)) {
rv = [];
circularRefs && circularRefs.set(any, rv);
for (var i4 = 0, l3 = any.length; i4 < l3; ++i4) {
rv.push(innerDeepClone(any[i4]));
}
} else if (intrinsicTypes.indexOf(any.constructor) >= 0) {
rv = any;
} else {
const proto = getProto(any);
rv = proto === Object.prototype ? {} : Object.create(proto);
circularRefs && circularRefs.set(any, rv);
for (var prop in any) {
if (hasOwn(any, prop)) {
rv[prop] = innerDeepClone(any[prop]);
}
}
}
return rv;
}
var { toString } = {};
function toStringTag(o3) {
return toString.call(o3).slice(8, -1);
}
var iteratorSymbol = typeof Symbol !== "undefined" ? Symbol.iterator : "@@iterator";
var getIteratorOf = typeof iteratorSymbol === "symbol" ? function(x4) {
var i4;
return x4 != null && (i4 = x4[iteratorSymbol]) && i4.apply(x4);
} : function() {
return null;
};
var NO_CHAR_ARRAY = {};
function getArrayOf(arrayLike) {
var i4, a3, x4, it;
if (arguments.length === 1) {
if (isArray(arrayLike))
return arrayLike.slice();
if (this === NO_CHAR_ARRAY && typeof arrayLike === "string")
return [arrayLike];
if (it = getIteratorOf(arrayLike)) {
a3 = [];
while (x4 = it.next(), !x4.done)
a3.push(x4.value);
return a3;
}
if (arrayLike == null)
return [arrayLike];
i4 = arrayLike.length;
if (typeof i4 === "number") {
a3 = new Array(i4);
while (i4--)
a3[i4] = arrayLike[i4];
return a3;
}
return [arrayLike];
}
i4 = arguments.length;
a3 = new Array(i4);
while (i4--)
a3[i4] = arguments[i4];
return a3;
}
var isAsyncFunction = typeof Symbol !== "undefined" ? (fn2) => fn2[Symbol.toStringTag] === "AsyncFunction" : () => false;
var debug = typeof location !== "undefined" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
function setDebug(value, filter) {
debug = value;
libraryFilter = filter;
}
var libraryFilter = () => true;
var NEEDS_THROW_FOR_STACK = !new Error("").stack;
function getErrorWithStack() {
if (NEEDS_THROW_FOR_STACK)
try {
getErrorWithStack.arguments;
throw new Error();
} catch (e3) {
return e3;
}
return new Error();
}
function prettyStack(exception, numIgnoredFrames) {
var stack = exception.stack;
if (!stack)
return "";
numIgnoredFrames = numIgnoredFrames || 0;
if (stack.indexOf(exception.name) === 0)
numIgnoredFrames += (exception.name + exception.message).split("\n").length;
return stack.split("\n").slice(numIgnoredFrames).filter(libraryFilter).map((frame) => "\n" + frame).join("");
}
var dexieErrorNames = [
"Modify",
"Bulk",
"OpenFailed",
"VersionChange",
"Schema",
"Upgrade",
"InvalidTable",
"MissingAPI",
"NoSuchDatabase",
"InvalidArgument",
"SubTransaction",
"Unsupported",
"Internal",
"DatabaseClosed",
"PrematureCommit",
"ForeignAwait"
];
var idbDomErrorNames = [
"Unknown",
"Constraint",
"Data",
"TransactionInactive",
"ReadOnly",
"Version",
"NotFound",
"InvalidState",
"InvalidAccess",
"Abort",
"Timeout",
"QuotaExceeded",
"Syntax",
"DataClone"
];
var errorList = dexieErrorNames.concat(idbDomErrorNames);
var defaultTexts = {
VersionChanged: "Database version changed by other database connection",
DatabaseClosed: "Database has been closed",
Abort: "Transaction aborted",
TransactionInactive: "Transaction has already completed or failed",
MissingAPI: "IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"
};
function DexieError(name, msg) {
this._e = getErrorWithStack();
this.name = name;
this.message = msg;
}
derive(DexieError).from(Error).extend({
stack: {
get: function() {
return this._stack || (this._stack = this.name + ": " + this.message + prettyStack(this._e, 2));
}
},
toString: function() {
return this.name + ": " + this.message;
}
});
function getMultiErrorMessage(msg, failures) {
return msg + ". Errors: " + Object.keys(failures).map((key) => failures[key].toString()).filter((v3, i4, s4) => s4.indexOf(v3) === i4).join("\n");
}
function ModifyError(msg, failures, successCount, failedKeys) {
this._e = getErrorWithStack();
this.failures = failures;
this.failedKeys = failedKeys;
this.successCount = successCount;
this.message = getMultiErrorMessage(msg, failures);
}
derive(ModifyError).from(DexieError);
function BulkError(msg, failures) {
this._e = getErrorWithStack();
this.name = "BulkError";
this.failures = Object.keys(failures).map((pos) => failures[pos]);
this.failuresByPos = failures;
this.message = getMultiErrorMessage(msg, failures);
}
derive(BulkError).from(DexieError);
var errnames = errorList.reduce((obj, name) => (obj[name] = name + "Error", obj), {});
var BaseException = DexieError;
var exceptions = errorList.reduce((obj, name) => {
var fullName = name + "Error";
function DexieError2(msgOrInner, inner) {
this._e = getErrorWithStack();
this.name = fullName;
if (!msgOrInner) {
this.message = defaultTexts[name] || fullName;
this.inner = null;
} else if (typeof msgOrInner === "string") {
this.message = `${msgOrInner}${!inner ? "" : "\n " + inner}`;
this.inner = inner || null;
} else if (typeof msgOrInner === "object") {
this.message = `${msgOrInner.name} ${msgOrInner.message}`;
this.inner = msgOrInner;
}
}
derive(DexieError2).from(BaseException);
obj[name] = DexieError2;
return obj;
}, {});
exceptions.Syntax = SyntaxError;
exceptions.Type = TypeError;
exceptions.Range = RangeError;
var exceptionMap = idbDomErrorNames.reduce((obj, name) => {
obj[name + "Error"] = exceptions[name];
return obj;
}, {});
function mapError(domError, message) {
if (!domError || domError instanceof DexieError || domError instanceof TypeError || domError instanceof SyntaxError || !domError.name || !exceptionMap[domError.name])
return domError;
var rv = new exceptionMap[domError.name](message || domError.message, domError);
if ("stack" in domError) {
setProp(rv, "stack", { get: function() {
return this.inner.stack;
} });
}
return rv;
}
var fullNameExceptions = errorList.reduce((obj, name) => {
if (["Syntax", "Type", "Range"].indexOf(name) === -1)
obj[name + "Error"] = exceptions[name];
return obj;
}, {});
fullNameExceptions.ModifyError = ModifyError;
fullNameExceptions.DexieError = DexieError;
fullNameExceptions.BulkError = BulkError;
function nop() {
}
function mirror(val) {
return val;
}
function pureFunctionChain(f1, f22) {
if (f1 == null || f1 === mirror)
return f22;
return function(val) {
return f22(f1(val));
};
}
function callBoth(on1, on2) {
return function() {
on1.apply(this, arguments);
on2.apply(this, arguments);
};
}
function hookCreatingChain(f1, f22) {
if (f1 === nop)
return f22;
return function() {
var res = f1.apply(this, arguments);
if (res !== void 0)
arguments[0] = res;
var onsuccess = this.onsuccess, onerror = this.onerror;
this.onsuccess = null;
this.onerror = null;
var res2 = f22.apply(this, arguments);
if (onsuccess)
this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;
if (onerror)
this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;
return res2 !== void 0 ? res2 : res;
};
}
function hookDeletingChain(f1, f22) {
if (f1 === nop)
return f22;
return function() {
f1.apply(this, arguments);
var onsuccess = this.onsuccess, onerror = this.onerror;
this.onsuccess = this.onerror = null;
f22.apply(this, arguments);
if (onsuccess)
this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;
if (onerror)
this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;
};
}
function hookUpdatingChain(f1, f22) {
if (f1 === nop)
return f22;
return function(modifications) {
var res = f1.apply(this, arguments);
extend(modifications, res);
var onsuccess = this.onsuccess, onerror = this.onerror;
this.onsuccess = null;
this.onerror = null;
var res2 = f22.apply(this, arguments);
if (onsuccess)
this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;
if (onerror)
this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;
return res === void 0 ? res2 === void 0 ? void 0 : res2 : extend(res, res2);
};
}
function reverseStoppableEventChain(f1, f22) {
if (f1 === nop)
return f22;
return function() {
if (f22.apply(this, arguments) === false)
return false;
return f1.apply(this, arguments);
};
}
function promisableChain(f1, f22) {
if (f1 === nop)
return f22;
return function() {
var res = f1.apply(this, arguments);
if (res && typeof res.then === "function") {
var thiz = this, i4 = arguments.length, args = new Array(i4);
while (i4--)
args[i4] = arguments[i4];
return res.then(function() {
return f22.apply(thiz, args);
});
}
return f22.apply(this, arguments);
};
}
var INTERNAL = {};
var LONG_STACKS_CLIP_LIMIT = 100;
var MAX_LONG_STACKS = 20;
var ZONE_ECHO_LIMIT = 100;
var [resolvedNativePromise, nativePromiseProto, resolvedGlobalPromise] = typeof Promise === "undefined" ? [] : (() => {
let globalP = Promise.resolve();
if (typeof crypto === "undefined" || !crypto.subtle)
return [globalP, getProto(globalP), globalP];
const nativeP = crypto.subtle.digest("SHA-512", new Uint8Array([0]));
return [
nativeP,
getProto(nativeP),
globalP
];
})();
var nativePromiseThen = nativePromiseProto && nativePromiseProto.then;
var NativePromise = resolvedNativePromise && resolvedNativePromise.constructor;
var patchGlobalPromise = !!resolvedGlobalPromise;
var stack_being_generated = false;
var schedulePhysicalTick = resolvedGlobalPromise ? () => {
resolvedGlobalPromise.then(physicalTick);
} : _global.setImmediate ? setImmediate.bind(null, physicalTick) : _global.MutationObserver ? () => {
var hiddenDiv = document.createElement("div");
new MutationObserver(() => {
physicalTick();
hiddenDiv = null;
}).observe(hiddenDiv, { attributes: true });
hiddenDiv.setAttribute("i", "1");
} : () => {
setTimeout(physicalTick, 0);
};
var asap = function(callback, args) {
microtickQueue.push([callback, args]);
if (needsNewPhysicalTick) {
schedulePhysicalTick();
needsNewPhysicalTick = false;
}
};
var isOutsideMicroTick = true;
var needsNewPhysicalTick = true;
var unhandledErrors = [];
var rejectingErrors = [];
var currentFulfiller = null;
var rejectionMapper = mirror;
var globalPSD = {
id: "global",
global: true,
ref: 0,
unhandleds: [],
onunhandled: globalError,
pgp: false,
env: {},
finalize: function() {
this.unhandleds.forEach((uh) => {
try {
globalError(uh[0], uh[1]);
} catch (e3) {
}
});
}
};
var PSD = globalPSD;
var microtickQueue = [];
var numScheduledCalls = 0;
var tickFinalizers = [];
function DexiePromise(fn2) {
if (typeof this !== "object")
throw new TypeError("Promises must be constructed via new");
this._listeners = [];
this.onuncatched = nop;
this._lib = false;
var psd = this._PSD = PSD;
if (debug) {
this._stackHolder = getErrorWithStack();
this._prev = null;
this._numPrev = 0;
}
if (typeof fn2 !== "function") {
if (fn2 !== INTERNAL)
throw new TypeError("Not a function");
this._state = arguments[1];
this._value = arguments[2];
if (this._state === false)
handleRejection(this, this._value);
return;
}
this._state = null;
this._value = null;
++psd.ref;
executePromiseTask(this, fn2);
}
var thenProp = {
get: function() {
var psd = PSD, microTaskId = totalEchoes;
function then(onFulfilled, onRejected) {
var possibleAwait = !psd.global && (psd !== PSD || microTaskId !== totalEchoes);
const cleanup = possibleAwait && !decrementExpectedAwaits();
var rv = new DexiePromise((resolve, reject) => {
propagateToListener(this, new Listener(nativeAwaitCompatibleWrap(onFulfilled, psd, possibleAwait, cleanup), nativeAwaitCompatibleWrap(onRejected, psd, possibleAwait, cleanup), resolve, reject, psd));
});
debug && linkToPreviousPromise(rv, this);
return rv;
}
then.prototype = INTERNAL;
return then;
},
set: function(value) {
setProp(this, "then", value && value.prototype === INTERNAL ? thenProp : {
get: function() {
return value;
},
set: thenProp.set
});
}
};
props(DexiePromise.prototype, {
then: thenProp,
_then: function(onFulfilled, onRejected) {
propagateToListener(this, new Listener(null, null, onFulfilled, onRejected, PSD));
},
catch: function(onRejected) {
if (arguments.length === 1)
return this.then(null, onRejected);
var type2 = arguments[0], handler = arguments[1];
return typeof type2 === "function" ? this.then(null, (err) => err instanceof type2 ? handler(err) : PromiseReject(err)) : this.then(null, (err) => err && err.name === type2 ? handler(err) : PromiseReject(err));
},
finally: function(onFinally) {
return this.then((value) => {
onFinally();
return value;
}, (err) => {
onFinally();
return PromiseReject(err);
});
},
stack: {
get: function() {
if (this._stack)
return this._stack;
try {
stack_being_generated = true;
var stacks = getStack(this, [], MAX_LONG_STACKS);
var stack = stacks.join("\nFrom previous: ");
if (this._state !== null)
this._stack = stack;
return stack;
} finally {
stack_being_generated = false;
}
}
},
timeout: function(ms, msg) {
return ms < Infinity ? new DexiePromise((resolve, reject) => {
var handle = setTimeout(() => reject(new exceptions.Timeout(msg)), ms);
this.then(resolve, reject).finally(clearTimeout.bind(null, handle));
}) : this;
}
});
if (typeof Symbol !== "undefined" && Symbol.toStringTag)
setProp(DexiePromise.prototype, Symbol.toStringTag, "Dexie.Promise");
globalPSD.env = snapShot();
function Listener(onFulfilled, onRejected, resolve, reject, zone) {
this.onFulfilled = typeof onFulfilled === "function" ? onFulfilled : null;
this.onRejected = typeof onRejected === "function" ? onRejected : null;
this.resolve = resolve;
this.reject = reject;
this.psd = zone;
}
props(DexiePromise, {
all: function() {
var values = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);
return new DexiePromise(function(resolve, reject) {
if (values.length === 0)
resolve([]);
var remaining = values.length;
values.forEach((a3, i4) => DexiePromise.resolve(a3).then((x4) => {
values[i4] = x4;
if (!--remaining)
resolve(values);
}, reject));
});
},
resolve: (value) => {
if (value instanceof DexiePromise)
return value;
if (value && typeof value.then === "function")
return new DexiePromise((resolve, reject) => {
value.then(resolve, reject);
});
var rv = new DexiePromise(INTERNAL, true, value);
linkToPreviousPromise(rv, currentFulfiller);
return rv;
},
reject: PromiseReject,
race: function() {
var values = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);
return new DexiePromise((resolve, reject) => {
values.map((value) => DexiePromise.resolve(value).then(resolve, reject));
});
},
PSD: {
get: () => PSD,
set: (value) => PSD = value
},
totalEchoes: { get: () => totalEchoes },
newPSD: newScope,
usePSD,
scheduler: {
get: () => asap,
set: (value) => {
asap = value;
}
},
rejectionMapper: {
get: () => rejectionMapper,
set: (value) => {
rejectionMapper = value;
}
},
follow: (fn2, zoneProps) => {
return new DexiePromise((resolve, reject) => {
return newScope((resolve2, reject2) => {
var psd = PSD;
psd.unhandleds = [];
psd.onunhandled = reject2;
psd.finalize = callBoth(function() {
run_at_end_of_this_or_next_physical_tick(() => {
this.unhandleds.length === 0 ? resolve2() : reject2(this.unhandleds[0]);
});
}, psd.finalize);
fn2();
}, zoneProps, resolve, reject);
});
}
});
if (NativePromise) {
if (NativePromise.allSettled)
setProp(DexiePromise, "allSettled", function() {
const possiblePromises = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);
return new DexiePromise((resolve) => {
if (possiblePromises.length === 0)
resolve([]);
let remaining = possiblePromises.length;
const results = new Array(remaining);
possiblePromises.forEach((p3, i4) => DexiePromise.resolve(p3).then((value) => results[i4] = { status: "fulfilled", value }, (reason) => results[i4] = { status: "rejected", reason }).then(() => --remaining || resolve(results)));
});
});
if (NativePromise.any && typeof AggregateError !== "undefined")
setProp(DexiePromise, "any", function() {
const possiblePromises = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);
return new DexiePromise((resolve, reject) => {
if (possiblePromises.length === 0)
reject(new AggregateError([]));
let remaining = possiblePromises.length;
const failures = new Array(remaining);
possiblePromises.forEach((p3, i4) => DexiePromise.resolve(p3).then((value) => resolve(value), (failure) => {
failures[i4] = failure;
if (!--remaining)
reject(new AggregateError(failures));
}));
});
});
}
function executePromiseTask(promise, fn2) {
try {
fn2((value) => {
if (promise._state !== null)
return;
if (value === promise)
throw new TypeError("A promise cannot be resolved with itself.");
var shouldExecuteTick = promise._lib && beginMicroTickScope();
if (value && typeof value.then === "function") {
executePromiseTask(promise, (resolve, reject) => {
value instanceof DexiePromise ? value._then(resolve, reject) : value.then(resolve, reject);
});
} else {
promise._state = true;
promise._value = value;
propagateAllListeners(promise);
}
if (shouldExecuteTick)
endMicroTickScope();
}, handleRejection.bind(null, promise));
} catch (ex) {
handleRejection(promise, ex);
}
}
function handleRejection(promise, reason) {
rejectingErrors.push(reason);
if (promise._state !== null)
return;
var shouldExecuteTick = promise._lib && beginMicroTickScope();
reason = rejectionMapper(reason);
promise._state = false;
promise._value = reason;
debug && reason !== null && typeof reason === "object" && !reason._promise && tryCatch(() => {
var origProp = getPropertyDescriptor(reason, "stack");
reason._promise = promise;
setProp(reason, "stack", {
get: () => stack_being_generated ? origProp && (origProp.get ? origProp.get.apply(reason) : origProp.value) : promise.stack
});
});
addPossiblyUnhandledError(promise);
propagateAllListeners(promise);
if (shouldExecuteTick)
endMicroTickScope();
}
function propagateAllListeners(promise) {
var listeners = promise._listeners;
promise._listeners = [];
for (var i4 = 0, len = listeners.length; i4 < len; ++i4) {
propagateToListener(promise, listeners[i4]);
}
var psd = promise._PSD;
--psd.ref || psd.finalize();
if (numScheduledCalls === 0) {
++numScheduledCalls;
asap(() => {
if (--numScheduledCalls === 0)
finalizePhysicalTick();
}, []);
}
}
function propagateToListener(promise, listener) {
if (promise._state === null) {
promise._listeners.push(listener);
return;
}
var cb = promise._state ? listener.onFulfilled : listener.onRejected;
if (cb === null) {
return (promise._state ? listener.resolve : listener.reject)(promise._value);
}
++listener.psd.ref;
++numScheduledCalls;
asap(callListener, [cb, promise, listener]);
}
function callListener(cb, promise, listener) {
try {
currentFulfiller = promise;
var ret, value = promise._value;
if (promise._state) {
ret = cb(value);
} else {
if (rejectingErrors.length)
rejectingErrors = [];
ret = cb(value);
if (rejectingErrors.indexOf(value) === -1)
markErrorAsHandled(promise);
}
listener.resolve(ret);
} catch (e3) {
listener.reject(e3);
} finally {
currentFulfiller = null;
if (--numScheduledCalls === 0)
finalizePhysicalTick();
--listener.psd.ref || listener.psd.finalize();
}
}
function getStack(promise, stacks, limit) {
if (stacks.length === limit)
return stacks;
var stack = "";
if (promise._state === false) {
var failure = promise._value, errorName, message;
if (failure != null) {
errorName = failure.name || "Error";
message = failure.message || failure;
stack = prettyStack(failure, 0);
} else {
errorName = failure;
message = "";
}
stacks.push(errorName + (message ? ": " + message : "") + stack);
}
if (debug) {
stack = prettyStack(promise._stackHolder, 2);
if (stack && stacks.indexOf(stack) === -1)
stacks.push(stack);
if (promise._prev)
getStack(promise._prev, stacks, limit);
}
return stacks;
}
function linkToPreviousPromise(promise, prev) {
var numPrev = prev ? prev._numPrev + 1 : 0;
if (numPrev < LONG_STACKS_CLIP_LIMIT) {
promise._prev = prev;
promise._numPrev = numPrev;
}
}
function physicalTick() {
beginMicroTickScope() && endMicroTickScope();
}
function beginMicroTickScope() {
var wasRootExec = isOutsideMicroTick;
isOutsideMicroTick = false;
needsNewPhysicalTick = false;
return wasRootExec;
}
function endMicroTickScope() {
var callbacks, i4, l3;
do {
while (microtickQueue.length > 0) {
callbacks = microtickQueue;
microtickQueue = [];
l3 = callbacks.length;
for (i4 = 0; i4 < l3; ++i4) {
var item = callbacks[i4];
item[0].apply(null, item[1]);
}
}
} while (microtickQueue.length > 0);
isOutsideMicroTick = true;
needsNewPhysicalTick = true;
}
function finalizePhysicalTick() {
var unhandledErrs = unhandledErrors;
unhandledErrors = [];
unhandledErrs.forEach((p3) => {
p3._PSD.onunhandled.call(null, p3._value, p3);
});
var finalizers = tickFinalizers.slice(0);
var i4 = finalizers.length;
while (i4)
finalizers[--i4]();
}
function run_at_end_of_this_or_next_physical_tick(fn2) {
function finalizer() {
fn2();
tickFinalizers.splice(tickFinalizers.indexOf(finalizer), 1);
}
tickFinalizers.push(finalizer);
++numScheduledCalls;
asap(() => {
if (--numScheduledCalls === 0)
finalizePhysicalTick();
}, []);
}
function addPossiblyUnhandledError(promise) {
if (!unhandledErrors.some((p3) => p3._value === promise._value))
unhandledErrors.push(promise);
}
function markErrorAsHandled(promise) {
var i4 = unhandledErrors.length;
while (i4)
if (unhandledErrors[--i4]._value === promise._value) {
unhandledErrors.splice(i4, 1);
return;
}
}
function PromiseReject(reason) {
return new DexiePromise(INTERNAL, false, reason);
}
function wrap(fn2, errorCatcher) {
var psd = PSD;
return function() {
var wasRootExec = beginMicroTickScope(), outerScope = PSD;
try {
switchToZone(psd, true);
return fn2.apply(this, arguments);
} catch (e3) {
errorCatcher && errorCatcher(e3);
} finally {
switchToZone(outerScope, false);
if (wasRootExec)
endMicroTickScope();
}
};
}
var task = { awaits: 0, echoes: 0, id: 0 };
var taskCounter = 0;
var zoneStack = [];
var zoneEchoes = 0;
var totalEchoes = 0;
var zone_id_counter = 0;
function newScope(fn2, props2, a1, a22) {
var parent = PSD, psd = Object.create(parent);
psd.parent = parent;
psd.ref = 0;
psd.global = false;
psd.id = ++zone_id_counter;
var globalEnv = globalPSD.env;
psd.env = patchGlobalPromise ? {
Promise: DexiePromise,
PromiseProp: { value: DexiePromise, configurable: true, writable: true },
all: DexiePromise.all,
race: DexiePromise.race,
allSettled: DexiePromise.allSettled,
any: DexiePromise.any,
resolve: DexiePromise.resolve,
reject: DexiePromise.reject,
nthen: getPatchedPromiseThen(globalEnv.nthen, psd),
gthen: getPatchedPromiseThen(globalEnv.gthen, psd)
} : {};
if (props2)
extend(psd, props2);
++parent.ref;
psd.finalize = function() {
--this.parent.ref || this.parent.finalize();
};
var rv = usePSD(psd, fn2, a1, a22);
if (psd.ref === 0)
psd.finalize();
return rv;
}
function incrementExpectedAwaits() {
if (!task.id)
task.id = ++taskCounter;
++task.awaits;
task.echoes += ZONE_ECHO_LIMIT;
return task.id;
}
function decrementExpectedAwaits() {
if (!task.awaits)
return false;
if (--task.awaits === 0)
task.id = 0;
task.echoes = task.awaits * ZONE_ECHO_LIMIT;
return true;
}
if (("" + nativePromiseThen).indexOf("[native code]") === -1) {
incrementExpectedAwaits = decrementExpectedAwaits = nop;
}
function onPossibleParallellAsync(possiblePromise) {
if (task.echoes && possiblePromise && possiblePromise.constructor === NativePromise) {
incrementExpectedAwaits();
return possiblePromise.then((x4) => {
decrementExpectedAwaits();
return x4;
}, (e3) => {
decrementExpectedAwaits();
return rejection(e3);
});
}
return possiblePromise;
}
function zoneEnterEcho(targetZone) {
++totalEchoes;
if (!task.echoes || --task.echoes === 0) {
task.echoes = task.id = 0;
}
zoneStack.push(PSD);
switchToZone(targetZone, true);
}
function zoneLeaveEcho() {
var zone = zoneStack[zoneStack.length - 1];
zoneStack.pop();
switchToZone(zone, false);
}
function switchToZone(targetZone, bEnteringZone) {
var currentZone = PSD;
if (bEnteringZone ? task.echoes && (!zoneEchoes++ || targetZone !== PSD) : zoneEchoes && (!--zoneEchoes || targetZone !== PSD)) {
enqueueNativeMicroTask(bEnteringZone ? zoneEnterEcho.bind(null, targetZone) : zoneLeaveEcho);
}
if (targetZone === PSD)
return;
PSD = targetZone;
if (currentZone === globalPSD)
globalPSD.env = snapShot();
if (patchGlobalPromise) {
var GlobalPromise = globalPSD.env.Promise;
var targetEnv = targetZone.env;
nativePromiseProto.then = targetEnv.nthen;
GlobalPromise.prototype.then = targetEnv.gthen;
if (currentZone.global || targetZone.global) {
Object.defineProperty(_global, "Promise", targetEnv.PromiseProp);
GlobalPromise.all = targetEnv.all;
GlobalPromise.race = targetEnv.race;
GlobalPromise.resolve = targetEnv.resolve;
GlobalPromise.reject = targetEnv.reject;
if (targetEnv.allSettled)
GlobalPromise.allSettled = targetEnv.allSettled;
if (targetEnv.any)
GlobalPromise.any = targetEnv.any;
}
}
}
function snapShot() {
var GlobalPromise = _global.Promise;
return patchGlobalPromise ? {
Promise: GlobalPromise,
PromiseProp: Object.getOwnPropertyDescriptor(_global, "Promise"),
all: GlobalPromise.all,
race: GlobalPromise.race,
allSettled: GlobalPromise.allSettled,
any: GlobalPromise.any,
resolve: GlobalPromise.resolve,
reject: GlobalPromise.reject,
nthen: nativePromiseProto.then,
gthen: GlobalPromise.prototype.then
} : {};
}
function usePSD(psd, fn2, a1, a22, a3) {
var outerScope = PSD;
try {
switchToZone(psd, true);
return fn2(a1, a22, a3);
} finally {
switchToZone(outerScope, false);
}
}
function enqueueNativeMicroTask(job) {
nativePromiseThen.call(resolvedNativePromise, job);
}
function nativeAwaitCompatibleWrap(fn2, zone, possibleAwait, cleanup) {
return typeof fn2 !== "function" ? fn2 : function() {
var outerZone = PSD;
if (possibleAwait)
incrementExpectedAwaits();
switchToZone(zone, true);
try {
return fn2.apply(this, arguments);
} finally {
switchToZone(outerZone, false);
if (cleanup)
enqueueNativeMicroTask(decrementExpectedAwaits);
}
};
}
function getPatchedPromiseThen(origThen, zone) {
return function(onResolved, onRejected) {
return origThen.call(this, nativeAwaitCompatibleWrap(onResolved, zone), nativeAwaitCompatibleWrap(onRejected, zone));
};
}
var UNHANDLEDREJECTION = "unhandledrejection";
function globalError(err, promise) {
var rv;
try {
rv = promise.onuncatched(err);
} catch (e3) {
}
if (rv !== false)
try {
var event, eventData = { promise, reason: err };
if (_global.document && document.createEvent) {
event = document.createEvent("Event");
event.initEvent(UNHANDLEDREJECTION, true, true);
extend(event, eventData);
} else if (_global.CustomEvent) {
event = new CustomEvent(UNHANDLEDREJECTION, { detail: eventData });
extend(event, eventData);
}
if (event && _global.dispatchEvent) {
dispatchEvent(event);
if (!_global.PromiseRejectionEvent && _global.onunhandledrejection)
try {
_global.onunhandledrejection(event);
} catch (_3) {
}
}
if (debug && event && !event.defaultPrevented) {
console.warn(`Unhandled rejection: ${err.stack || err}`);
}
} catch (e3) {
}
}
var rejection = DexiePromise.reject;
function tempTransaction(db, mode, storeNames, fn2) {
if (!db.idbdb || !db._state.openComplete && (!PSD.letThrough && !db._vip)) {
if (db._state.openComplete) {
return rejection(new exceptions.DatabaseClosed(db._state.dbOpenError));
}
if (!db._state.isBeingOpened) {
if (!db._options.autoOpen)
return rejection(new exceptions.DatabaseClosed());
db.open().catch(nop);
}
return db._state.dbReadyPromise.then(() => tempTransaction(db, mode, storeNames, fn2));
} else {
var trans = db._createTransaction(mode, storeNames, db._dbSchema);
try {
trans.create();
db._state.PR1398_maxLoop = 3;
} catch (ex) {
if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
console.warn("Dexie: Need to reopen db");
db._close();
return db.open().then(() => tempTransaction(db, mode, storeNames, fn2));
}
return rejection(ex);
}
return trans._promise(mode, (resolve, reject) => {
return newScope(() => {
PSD.trans = trans;
return fn2(resolve, reject, trans);
});
}).then((result) => {
return trans._completion.then(() => result);
});
}
}
var DEXIE_VERSION = "3.2.3";
var maxString = String.fromCharCode(65535);
var minKey = -Infinity;
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
var STRING_EXPECTED = "String expected.";
var connections = [];
var isIEOrEdge = typeof navigator !== "undefined" && /(MSIE|Trident|Edge)/.test(navigator.userAgent);
var hasIEDeleteObjectStoreBug = isIEOrEdge;
var hangsOnDeleteLargeKeyRange = isIEOrEdge;
var dexieStackFrameFilter = (frame) => !/(dexie\.js|dexie\.min\.js)/.test(frame);
var DBNAMES_DB = "__dbnames";
var READONLY = "readonly";
var READWRITE = "readwrite";
function combine(filter1, filter2) {
return filter1 ? filter2 ? function() {
return filter1.apply(this, arguments) && filter2.apply(this, arguments);
} : filter1 : filter2;
}
var AnyRange = {
type: 3,
lower: -Infinity,
lowerOpen: false,
upper: [[]],
upperOpen: false
};
function workaroundForUndefinedPrimKey(keyPath) {
return typeof keyPath === "string" && !/\./.test(keyPath) ? (obj) => {
if (obj[keyPath] === void 0 && keyPath in obj) {
obj = deepClone(obj);
delete obj[keyPath];
}
return obj;
} : (obj) => obj;
}
var Table = class {
_trans(mode, fn2, writeLocked) {
const trans = this._tx || PSD.trans;
const tableName = this.name;
function checkTableInTransaction(resolve, reject, trans2) {
if (!trans2.schema[tableName])
throw new exceptions.NotFound("Table " + tableName + " not part of transaction");
return fn2(trans2.idbtrans, trans2);
}
const wasRootExec = beginMicroTickScope();
try {
return trans && trans.db === this.db ? trans === PSD.trans ? trans._promise(mode, checkTableInTransaction, writeLocked) : newScope(() => trans._promise(mode, checkTableInTransaction, writeLocked), { trans, transless: PSD.transless || PSD }) : tempTransaction(this.db, mode, [this.name], checkTableInTransaction);
} finally {
if (wasRootExec)
endMicroTickScope();
}
}
get(keyOrCrit, cb) {
if (keyOrCrit && keyOrCrit.constructor === Object)
return this.where(keyOrCrit).first(cb);
return this._trans("readonly", (trans) => {
return this.core.get({ trans, key: keyOrCrit }).then((res) => this.hook.reading.fire(res));
}).then(cb);
}
where(indexOrCrit) {
if (typeof indexOrCrit === "string")
return new this.db.WhereClause(this, indexOrCrit);
if (isArray(indexOrCrit))
return new this.db.WhereClause(this, `[${indexOrCrit.join("+")}]`);
const keyPaths = keys(indexOrCrit);
if (keyPaths.length === 1)
return this.where(keyPaths[0]).equals(indexOrCrit[keyPaths[0]]);
const compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter((ix) => ix.compound && keyPaths.every((keyPath) => ix.keyPath.indexOf(keyPath) >= 0) && ix.keyPath.every((keyPath) => keyPaths.indexOf(keyPath) >= 0))[0];
if (compoundIndex && this.db._maxKey !== maxString)
return this.where(compoundIndex.name).equals(compoundIndex.keyPath.map((kp) => indexOrCrit[kp]));
if (!compoundIndex && debug)
console.warn(`The query ${JSON.stringify(indexOrCrit)} on ${this.name} would benefit of a compound index [${keyPaths.join("+")}]`);
const { idxByName } = this.schema;
const idb = this.db._deps.indexedDB;
function equals(a3, b3) {
try {
return idb.cmp(a3, b3) === 0;
} catch (e3) {
return false;
}
}
const [idx, filterFunction] = keyPaths.reduce(([prevIndex, prevFilterFn], keyPath) => {
const index = idxByName[keyPath];
const value = indexOrCrit[keyPath];
return [
prevIndex || index,
prevIndex || !index ? combine(prevFilterFn, index && index.multi ? (x4) => {
const prop = getByKeyPath(x4, keyPath);
return isArray(prop) && prop.some((item) => equals(value, item));
} : (x4) => equals(value, getByKeyPath(x4, keyPath))) : prevFilterFn
];
}, [null, null]);
return idx ? this.where(idx.name).equals(indexOrCrit[idx.keyPath]).filter(filterFunction) : compoundIndex ? this.filter(filterFunction) : this.where(keyPaths).equals("");
}
filter(filterFunction) {
return this.toCollection().and(filterFunction);
}
count(thenShortcut) {
return this.toCollection().count(thenShortcut);
}
offset(offset) {
return this.toCollection().offset(offset);
}
limit(numRows) {
return this.toCollection().limit(numRows);
}
each(callback) {
return this.toCollection().each(callback);
}
toArray(thenShortcut) {
return this.toCollection().toArray(thenShortcut);
}
toCollection() {
return new this.db.Collection(new this.db.WhereClause(this));
}
orderBy(index) {
return new this.db.Collection(new this.db.WhereClause(this, isArray(index) ? `[${index.join("+")}]` : index));
}
reverse() {
return this.toCollection().reverse();
}
mapToClass(constructor) {
this.schema.mappedClass = constructor;
const readHook = (obj) => {
if (!obj)
return obj;
const res = Object.create(constructor.prototype);
for (var m3 in obj)
if (hasOwn(obj, m3))
try {
res[m3] = obj[m3];
} catch (_3) {
}
return res;
};
if (this.schema.readHook) {
this.hook.reading.unsubscribe(this.schema.readHook);
}
this.schema.readHook = readHook;
this.hook("reading", readHook);
return constructor;
}
defineClass() {
function Class(content) {
extend(this, content);
}
return this.mapToClass(Class);
}
add(obj, key) {
const { auto, keyPath } = this.schema.primKey;
let objToAdd = obj;
if (keyPath && auto) {
objToAdd = workaroundForUndefinedPrimKey(keyPath)(obj);
}
return this._trans("readwrite", (trans) => {
return this.core.mutate({ trans, type: "add", keys: key != null ? [key] : null, values: [objToAdd] });
}).then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : res.lastResult).then((lastResult) => {
if (keyPath) {
try {
setByKeyPath(obj, keyPath, lastResult);
} catch (_3) {
}
}
return lastResult;
});
}
update(keyOrObject, modifications) {
if (typeof keyOrObject === "object" && !isArray(keyOrObject)) {
const key = getByKeyPath(keyOrObject, this.schema.primKey.keyPath);
if (key === void 0)
return rejection(new exceptions.InvalidArgument("Given object does not contain its primary key"));
try {
if (typeof modifications !== "function") {
keys(modifications).forEach((keyPath) => {
setByKeyPath(keyOrObject, keyPath, modifications[keyPath]);
});
} else {
modifications(keyOrObject, { value: keyOrObject, primKey: key });
}
} catch (_a) {
}
return this.where(":id").equals(key).modify(modifications);
} else {
return this.where(":id").equals(keyOrObject).modify(modifications);
}
}
put(obj, key) {
const { auto, keyPath } = this.schema.primKey;
let objToAdd = obj;
if (keyPath && auto) {
objToAdd = workaroundForUndefinedPrimKey(keyPath)(obj);
}
return this._trans("readwrite", (trans) => this.core.mutate({ trans, type: "put", values: [objToAdd], keys: key != null ? [key] : null })).then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : res.lastResult).then((lastResult) => {
if (keyPath) {
try {
setByKeyPath(obj, keyPath, lastResult);
} catch (_3) {
}
}
return lastResult;
});
}
delete(key) {
return this._trans("readwrite", (trans) => this.core.mutate({ trans, type: "delete", keys: [key] })).then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : void 0);
}
clear() {
return this._trans("readwrite", (trans) => this.core.mutate({ trans, type: "deleteRange", range: AnyRange })).then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : void 0);
}
bulkGet(keys2) {
return this._trans("readonly", (trans) => {
return this.core.getMany({
keys: keys2,
trans
}).then((result) => result.map((res) => this.hook.reading.fire(res)));
});
}
bulkAdd(objects, keysOrOptions, options) {
const keys2 = Array.isArray(keysOrOptions) ? keysOrOptions : void 0;
options = options || (keys2 ? void 0 : keysOrOptions);
const wantResults = options ? options.allKeys : void 0;
return this._trans("readwrite", (trans) => {
const { auto, keyPath } = this.schema.primKey;
if (keyPath && keys2)
throw new exceptions.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
if (keys2 && keys2.length !== objects.length)
throw new exceptions.InvalidArgument("Arguments objects and keys must have the same length");
const numObjects = objects.length;
let objectsToAdd = keyPath && auto ? objects.map(workaroundForUndefinedPrimKey(keyPath)) : objects;
return this.core.mutate({ trans, type: "add", keys: keys2, values: objectsToAdd, wantResults }).then(({ numFailures, results, lastResult, failures }) => {
const result = wantResults ? results : lastResult;
if (numFailures === 0)
return result;
throw new BulkError(`${this.name}.bulkAdd(): ${numFailures} of ${numObjects} operations failed`, failures);
});
});
}
bulkPut(objects, keysOrOptions, options) {
const keys2 = Array.isArray(keysOrOptions) ? keysOrOptions : void 0;
options = options || (keys2 ? void 0 : keysOrOptions);
const wantResults = options ? options.allKeys : void 0;
return this._trans("readwrite", (trans) => {
const { auto, keyPath } = this.schema.primKey;
if (keyPath && keys2)
throw new exceptions.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
if (keys2 && keys2.length !== objects.length)
throw new exceptions.InvalidArgument("Arguments objects and keys must have the same length");
const numObjects = objects.length;
let objectsToPut = keyPath && auto ? objects.map(workaroundForUndefinedPrimKey(keyPath)) : objects;
return this.core.mutate({ trans, type: "put", keys: keys2, values: objectsToPut, wantResults }).then(({ numFailures, results, lastResult, failures }) => {
const result = wantResults ? results : lastResult;
if (numFailures === 0)
return result;
throw new BulkError(`${this.name}.bulkPut(): ${numFailures} of ${numObjects} operations failed`, failures);
});
});
}
bulkDelete(keys2) {
const numKeys = keys2.length;
return this._trans("readwrite", (trans) => {
return this.core.mutate({ trans, type: "delete", keys: keys2 });
}).then(({ numFailures, lastResult, failures }) => {
if (numFailures === 0)
return lastResult;
throw new BulkError(`${this.name}.bulkDelete(): ${numFailures} of ${numKeys} operations failed`, failures);
});
}
};
function Events(ctx) {
var evs = {};
var rv = function(eventName, subscriber) {
if (subscriber) {
var i5 = arguments.length, args = new Array(i5 - 1);
while (--i5)
args[i5 - 1] = arguments[i5];
evs[eventName].subscribe.apply(null, args);
return ctx;
} else if (typeof eventName === "string") {
return evs[eventName];
}
};
rv.addEventType = add;
for (var i4 = 1, l3 = arguments.length; i4 < l3; ++i4) {
add(arguments[i4]);
}
return rv;
function add(eventName, chainFunction, defaultFunction) {
if (typeof eventName === "object")
return addConfiguredEvents(eventName);
if (!chainFunction)
chainFunction = reverseStoppableEventChain;
if (!defaultFunction)
defaultFunction = nop;
var context = {
subscribers: [],
fire: defaultFunction,
subscribe: function(cb) {
if (context.subscribers.indexOf(cb) === -1) {
context.subscribers.push(cb);
context.fire = chainFunction(context.fire, cb);
}
},
unsubscribe: function(cb) {
context.subscribers = context.subscribers.filter(function(fn2) {
return fn2 !== cb;
});
context.fire = context.subscribers.reduce(chainFunction, defaultFunction);
}
};
evs[eventName] = rv[eventName] = context;
return context;
}
function addConfiguredEvents(cfg) {
keys(cfg).forEach(function(eventName) {
var args = cfg[eventName];
if (isArray(args)) {
add(eventName, cfg[eventName][0], cfg[eventName][1]);
} else if (args === "asap") {
var context = add(eventName, mirror, function fire() {
var i5 = arguments.length, args2 = new Array(i5);
while (i5--)
args2[i5] = arguments[i5];
context.subscribers.forEach(function(fn2) {
asap$1(function fireEvent() {
fn2.apply(null, args2);
});
});
});
} else
throw new exceptions.InvalidArgument("Invalid event config");
});
}
}
function makeClassConstructor(prototype, constructor) {
derive(constructor).from({ prototype });
return constructor;
}
function createTableConstructor(db) {
return makeClassConstructor(Table.prototype, function Table2(name, tableSchema, trans) {
this.db = db;
this._tx = trans;
this.name = name;
this.schema = tableSchema;
this.hook = db._allTables[name] ? db._allTables[name].hook : Events(null, {
"creating": [hookCreatingChain, nop],
"reading": [pureFunctionChain, mirror],
"updating": [hookUpdatingChain, nop],
"deleting": [hookDeletingChain, nop]
});
});
}
function isPlainKeyRange(ctx, ignoreLimitFilter) {
return !(ctx.filter || ctx.algorithm || ctx.or) && (ignoreLimitFilter ? ctx.justLimit : !ctx.replayFilter);
}
function addFilter(ctx, fn2) {
ctx.filter = combine(ctx.filter, fn2);
}
function addReplayFilter(ctx, factory, isLimitFilter) {
var curr = ctx.replayFilter;
ctx.replayFilter = curr ? () => combine(curr(), factory()) : factory;
ctx.justLimit = isLimitFilter && !curr;
}
function addMatchFilter(ctx, fn2) {
ctx.isMatch = combine(ctx.isMatch, fn2);
}
function getIndexOrStore(ctx, coreSchema) {
if (ctx.isPrimKey)
return coreSchema.primaryKey;
const index = coreSchema.getIndexByKeyPath(ctx.index);
if (!index)
throw new exceptions.Schema("KeyPath " + ctx.index + " on object store " + coreSchema.name + " is not indexed");
return index;
}
function openCursor(ctx, coreTable, trans) {
const index = getIndexOrStore(ctx, coreTable.schema);
return coreTable.openCursor({
trans,
values: !ctx.keysOnly,
reverse: ctx.dir === "prev",
unique: !!ctx.unique,
query: {
index,
range: ctx.range
}
});
}
function iter(ctx, fn2, coreTrans, coreTable) {
const filter = ctx.replayFilter ? combine(ctx.filter, ctx.replayFilter()) : ctx.filter;
if (!ctx.or) {
return iterate(openCursor(ctx, coreTable, coreTrans), combine(ctx.algorithm, filter), fn2, !ctx.keysOnly && ctx.valueMapper);
} else {
const set = {};
const union = (item, cursor, advance) => {
if (!filter || filter(cursor, advance, (result) => cursor.stop(result), (err) => cursor.fail(err))) {
var primaryKey = cursor.primaryKey;
var key = "" + primaryKey;
if (key === "[object ArrayBuffer]")
key = "" + new Uint8Array(primaryKey);
if (!hasOwn(set, key)) {
set[key] = true;
fn2(item, cursor, advance);
}
}
};
return Promise.all([
ctx.or._iterate(union, coreTrans),
iterate(openCursor(ctx, coreTable, coreTrans), ctx.algorithm, union, !ctx.keysOnly && ctx.valueMapper)
]);
}
}
function iterate(cursorPromise, filter, fn2, valueMapper) {
var mappedFn = valueMapper ? (x4, c4, a3) => fn2(valueMapper(x4), c4, a3) : fn2;
var wrappedFn = wrap(mappedFn);
return cursorPromise.then((cursor) => {
if (cursor) {
return cursor.start(() => {
var c4 = () => cursor.continue();
if (!filter || filter(cursor, (advancer) => c4 = advancer, (val) => {
cursor.stop(val);
c4 = nop;
}, (e3) => {
cursor.fail(e3);
c4 = nop;
}))
wrappedFn(cursor.value, cursor, (advancer) => c4 = advancer);
c4();
});
}
});
}
function cmp(a3, b3) {
try {
const ta = type(a3);
const tb = type(b3);
if (ta !== tb) {
if (ta === "Array")
return 1;
if (tb === "Array")
return -1;
if (ta === "binary")
return 1;
if (tb === "binary")
return -1;
if (ta === "string")
return 1;
if (tb === "string")
return -1;
if (ta === "Date")
return 1;
if (tb !== "Date")
return NaN;
return -1;
}
switch (ta) {
case "number":
case "Date":
case "string":
return a3 > b3 ? 1 : a3 < b3 ? -1 : 0;
case "binary": {
return compareUint8Arrays(getUint8Array(a3), getUint8Array(b3));
}
case "Array":
return compareArrays(a3, b3);
}
} catch (_a) {
}
return NaN;
}
function compareArrays(a3, b3) {
const al = a3.length;
const bl = b3.length;
const l3 = al < bl ? al : bl;
for (let i4 = 0; i4 < l3; ++i4) {
const res = cmp(a3[i4], b3[i4]);
if (res !== 0)
return res;
}
return al === bl ? 0 : al < bl ? -1 : 1;
}
function compareUint8Arrays(a3, b3) {
const al = a3.length;
const bl = b3.length;
const l3 = al < bl ? al : bl;
for (let i4 = 0; i4 < l3; ++i4) {
if (a3[i4] !== b3[i4])
return a3[i4] < b3[i4] ? -1 : 1;
}
return al === bl ? 0 : al < bl ? -1 : 1;
}
function type(x4) {
const t3 = typeof x4;
if (t3 !== "object")
return t3;
if (ArrayBuffer.isView(x4))
return "binary";
const tsTag = toStringTag(x4);
return tsTag === "ArrayBuffer" ? "binary" : tsTag;
}
function getUint8Array(a3) {
if (a3 instanceof Uint8Array)
return a3;
if (ArrayBuffer.isView(a3))
return new Uint8Array(a3.buffer, a3.byteOffset, a3.byteLength);
return new Uint8Array(a3);
}
var Collection = class {
_read(fn2, cb) {
var ctx = this._ctx;
return ctx.error ? ctx.table._trans(null, rejection.bind(null, ctx.error)) : ctx.table._trans("readonly", fn2).then(cb);
}
_write(fn2) {
var ctx = this._ctx;
return ctx.error ? ctx.table._trans(null, rejection.bind(null, ctx.error)) : ctx.table._trans("readwrite", fn2, "locked");
}
_addAlgorithm(fn2) {
var ctx = this._ctx;
ctx.algorithm = combine(ctx.algorithm, fn2);
}
_iterate(fn2, coreTrans) {
return iter(this._ctx, fn2, coreTrans, this._ctx.table.core);
}
clone(props2) {
var rv = Object.create(this.constructor.prototype), ctx = Object.create(this._ctx);
if (props2)
extend(ctx, props2);
rv._ctx = ctx;
return rv;
}
raw() {
this._ctx.valueMapper = null;
return this;
}
each(fn2) {
var ctx = this._ctx;
return this._read((trans) => iter(ctx, fn2, trans, ctx.table.core));
}
count(cb) {
return this._read((trans) => {
const ctx = this._ctx;
const coreTable = ctx.table.core;
if (isPlainKeyRange(ctx, true)) {
return coreTable.count({
trans,
query: {
index: getIndexOrStore(ctx, coreTable.schema),
range: ctx.range
}
}).then((count2) => Math.min(count2, ctx.limit));
} else {
var count = 0;
return iter(ctx, () => {
++count;
return false;
}, trans, coreTable).then(() => count);
}
}).then(cb);
}
sortBy(keyPath, cb) {
const parts = keyPath.split(".").reverse(), lastPart = parts[0], lastIndex = parts.length - 1;
function getval(obj, i4) {
if (i4)
return getval(obj[parts[i4]], i4 - 1);
return obj[lastPart];
}
var order = this._ctx.dir === "next" ? 1 : -1;
function sorter(a3, b3) {
var aVal = getval(a3, lastIndex), bVal = getval(b3, lastIndex);
return aVal < bVal ? -order : aVal > bVal ? order : 0;
}
return this.toArray(function(a3) {
return a3.sort(sorter);
}).then(cb);
}
toArray(cb) {
return this._read((trans) => {
var ctx = this._ctx;
if (ctx.dir === "next" && isPlainKeyRange(ctx, true) && ctx.limit > 0) {
const { valueMapper } = ctx;
const index = getIndexOrStore(ctx, ctx.table.core.schema);
return ctx.table.core.query({
trans,
limit: ctx.limit,
values: true,
query: {
index,
range: ctx.range
}
}).then(({ result }) => valueMapper ? result.map(valueMapper) : result);
} else {
const a3 = [];
return iter(ctx, (item) => a3.push(item), trans, ctx.table.core).then(() => a3);
}
}, cb);
}
offset(offset) {
var ctx = this._ctx;
if (offset <= 0)
return this;
ctx.offset += offset;
if (isPlainKeyRange(ctx)) {
addReplayFilter(ctx, () => {
var offsetLeft = offset;
return (cursor, advance) => {
if (offsetLeft === 0)
return true;
if (offsetLeft === 1) {
--offsetLeft;
return false;
}
advance(() => {
cursor.advance(offsetLeft);
offsetLeft = 0;
});
return false;
};
});
} else {
addReplayFilter(ctx, () => {
var offsetLeft = offset;
return () => --offsetLeft < 0;
});
}
return this;
}
limit(numRows) {
this._ctx.limit = Math.min(this._ctx.limit, numRows);
addReplayFilter(this._ctx, () => {
var rowsLeft = numRows;
return function(cursor, advance, resolve) {
if (--rowsLeft <= 0)
advance(resolve);
return rowsLeft >= 0;
};
}, true);
return this;
}
until(filterFunction, bIncludeStopEntry) {
addFilter(this._ctx, function(cursor, advance, resolve) {
if (filterFunction(cursor.value)) {
advance(resolve);
return bIncludeStopEntry;
} else {
return true;
}
});
return this;
}
first(cb) {
return this.limit(1).toArray(function(a3) {
return a3[0];
}).then(cb);
}
last(cb) {
return this.reverse().first(cb);
}
filter(filterFunction) {
addFilter(this._ctx, function(cursor) {
return filterFunction(cursor.value);
});
addMatchFilter(this._ctx, filterFunction);
return this;
}
and(filter) {
return this.filter(filter);
}
or(indexName) {
return new this.db.WhereClause(this._ctx.table, indexName, this);
}
reverse() {
this._ctx.dir = this._ctx.dir === "prev" ? "next" : "prev";
if (this._ondirectionchange)
this._ondirectionchange(this._ctx.dir);
return this;
}
desc() {
return this.reverse();
}
eachKey(cb) {
var ctx = this._ctx;
ctx.keysOnly = !ctx.isMatch;
return this.each(function(val, cursor) {
cb(cursor.key, cursor);
});
}
eachUniqueKey(cb) {
this._ctx.unique = "unique";
return this.eachKey(cb);
}
eachPrimaryKey(cb) {
var ctx = this._ctx;
ctx.keysOnly = !ctx.isMatch;
return this.each(function(val, cursor) {
cb(cursor.primaryKey, cursor);
});
}
keys(cb) {
var ctx = this._ctx;
ctx.keysOnly = !ctx.isMatch;
var a3 = [];
return this.each(function(item, cursor) {
a3.push(cursor.key);
}).then(function() {
return a3;
}).then(cb);
}
primaryKeys(cb) {
var ctx = this._ctx;
if (ctx.dir === "next" && isPlainKeyRange(ctx, true) && ctx.limit > 0) {
return this._read((trans) => {
var index = getIndexOrStore(ctx, ctx.table.core.schema);
return ctx.table.core.query({
trans,
values: false,
limit: ctx.limit,
query: {
index,
range: ctx.range
}
});
}).then(({ result }) => result).then(cb);
}
ctx.keysOnly = !ctx.isMatch;
var a3 = [];
return this.each(function(item, cursor) {
a3.push(cursor.primaryKey);
}).then(function() {
return a3;
}).then(cb);
}
uniqueKeys(cb) {
this._ctx.unique = "unique";
return this.keys(cb);
}
firstKey(cb) {
return this.limit(1).keys(function(a3) {
return a3[0];
}).then(cb);
}
lastKey(cb) {
return this.reverse().firstKey(cb);
}
distinct() {
var ctx = this._ctx, idx = ctx.index && ctx.table.schema.idxByName[ctx.index];
if (!idx || !idx.multi)
return this;
var set = {};
addFilter(this._ctx, function(cursor) {
var strKey = cursor.primaryKey.toString();
var found = hasOwn(set, strKey);
set[strKey] = true;
return !found;
});
return this;
}
modify(changes) {
var ctx = this._ctx;
return this._write((trans) => {
var modifyer;
if (typeof changes === "function") {
modifyer = changes;
} else {
var keyPaths = keys(changes);
var numKeys = keyPaths.length;
modifyer = function(item) {
var anythingModified = false;
for (var i4 = 0; i4 < numKeys; ++i4) {
var keyPath = keyPaths[i4], val = changes[keyPath];
if (getByKeyPath(item, keyPath) !== val) {
setByKeyPath(item, keyPath, val);
anythingModified = true;
}
}
return anythingModified;
};
}
const coreTable = ctx.table.core;
const { outbound, extractKey } = coreTable.schema.primaryKey;
const limit = this.db._options.modifyChunkSize || 200;
const totalFailures = [];
let successCount = 0;
const failedKeys = [];
const applyMutateResult = (expectedCount, res) => {
const { failures, numFailures } = res;
successCount += expectedCount - numFailures;
for (let pos of keys(failures)) {
totalFailures.push(failures[pos]);
}
};
return this.clone().primaryKeys().then((keys2) => {
const nextChunk = (offset) => {
const count = Math.min(limit, keys2.length - offset);
return coreTable.getMany({
trans,
keys: keys2.slice(offset, offset + count),
cache: "immutable"
}).then((values) => {
const addValues = [];
const putValues = [];
const putKeys = outbound ? [] : null;
const deleteKeys = [];
for (let i4 = 0; i4 < count; ++i4) {
const origValue = values[i4];
const ctx2 = {
value: deepClone(origValue),
primKey: keys2[offset + i4]
};
if (modifyer.call(ctx2, ctx2.value, ctx2) !== false) {
if (ctx2.value == null) {
deleteKeys.push(keys2[offset + i4]);
} else if (!outbound && cmp(extractKey(origValue), extractKey(ctx2.value)) !== 0) {
deleteKeys.push(keys2[offset + i4]);
addValues.push(ctx2.value);
} else {
putValues.push(ctx2.value);
if (outbound)
putKeys.push(keys2[offset + i4]);
}
}
}
const criteria = isPlainKeyRange(ctx) && ctx.limit === Infinity && (typeof changes !== "function" || changes === deleteCallback) && {
index: ctx.index,
range: ctx.range
};
return Promise.resolve(addValues.length > 0 && coreTable.mutate({ trans, type: "add", values: addValues }).then((res) => {
for (let pos in res.failures) {
deleteKeys.splice(parseInt(pos), 1);
}
applyMutateResult(addValues.length, res);
})).then(() => (putValues.length > 0 || criteria && typeof changes === "object") && coreTable.mutate({
trans,
type: "put",
keys: putKeys,
values: putValues,
criteria,
changeSpec: typeof changes !== "function" && changes
}).then((res) => applyMutateResult(putValues.length, res))).then(() => (deleteKeys.length > 0 || criteria && changes === deleteCallback) && coreTable.mutate({
trans,
type: "delete",
keys: deleteKeys,
criteria
}).then((res) => applyMutateResult(deleteKeys.length, res))).then(() => {
return keys2.length > offset + count && nextChunk(offset + limit);
});
});
};
return nextChunk(0).then(() => {
if (totalFailures.length > 0)
throw new ModifyError("Error modifying one or more objects", totalFailures, successCount, failedKeys);
return keys2.length;
});
});
});
}
delete() {
var ctx = this._ctx, range = ctx.range;
if (isPlainKeyRange(ctx) && (ctx.isPrimKey && !hangsOnDeleteLargeKeyRange || range.type === 3)) {
return this._write((trans) => {
const { primaryKey } = ctx.table.core.schema;
const coreRange = range;
return ctx.table.core.count({ trans, query: { index: primaryKey, range: coreRange } }).then((count) => {
return ctx.table.core.mutate({ trans, type: "deleteRange", range: coreRange }).then(({ failures, lastResult, results, numFailures }) => {
if (numFailures)
throw new ModifyError("Could not delete some values", Object.keys(failures).map((pos) => failures[pos]), count - numFailures);
return count - numFailures;
});
});
});
}
return this.modify(deleteCallback);
}
};
var deleteCallback = (value, ctx) => ctx.value = null;
function createCollectionConstructor(db) {
return makeClassConstructor(Collection.prototype, function Collection2(whereClause, keyRangeGenerator) {
this.db = db;
let keyRange = AnyRange, error = null;
if (keyRangeGenerator)
try {
keyRange = keyRangeGenerator();
} catch (ex) {
error = ex;
}
const whereCtx = whereClause._ctx;
const table = whereCtx.table;
const readingHook = table.hook.reading.fire;
this._ctx = {
table,
index: whereCtx.index,
isPrimKey: !whereCtx.index || table.schema.primKey.keyPath && whereCtx.index === table.schema.primKey.name,
range: keyRange,
keysOnly: false,
dir: "next",
unique: "",
algorithm: null,
filter: null,
replayFilter: null,
justLimit: true,
isMatch: null,
offset: 0,
limit: Infinity,
error,
or: whereCtx.or,
valueMapper: readingHook !== mirror ? readingHook : null
};
});
}
function simpleCompare(a3, b3) {
return a3 < b3 ? -1 : a3 === b3 ? 0 : 1;
}
function simpleCompareReverse(a3, b3) {
return a3 > b3 ? -1 : a3 === b3 ? 0 : 1;
}
function fail(collectionOrWhereClause, err, T4) {
var collection = collectionOrWhereClause instanceof WhereClause ? new collectionOrWhereClause.Collection(collectionOrWhereClause) : collectionOrWhereClause;
collection._ctx.error = T4 ? new T4(err) : new TypeError(err);
return collection;
}
function emptyCollection(whereClause) {
return new whereClause.Collection(whereClause, () => rangeEqual("")).limit(0);
}
function upperFactory(dir) {
return dir === "next" ? (s4) => s4.toUpperCase() : (s4) => s4.toLowerCase();
}
function lowerFactory(dir) {
return dir === "next" ? (s4) => s4.toLowerCase() : (s4) => s4.toUpperCase();
}
function nextCasing(key, lowerKey, upperNeedle, lowerNeedle, cmp2, dir) {
var length = Math.min(key.length, lowerNeedle.length);
var llp = -1;
for (var i4 = 0; i4 < length; ++i4) {
var lwrKeyChar = lowerKey[i4];
if (lwrKeyChar !== lowerNeedle[i4]) {
if (cmp2(key[i4], upperNeedle[i4]) < 0)
return key.substr(0, i4) + upperNeedle[i4] + upperNeedle.substr(i4 + 1);
if (cmp2(key[i4], lowerNeedle[i4]) < 0)
return key.substr(0, i4) + lowerNeedle[i4] + upperNeedle.substr(i4 + 1);
if (llp >= 0)
return key.substr(0, llp) + lowerKey[llp] + upperNeedle.substr(llp + 1);
return null;
}
if (cmp2(key[i4], lwrKeyChar) < 0)
llp = i4;
}
if (length < lowerNeedle.length && dir === "next")
return key + upperNeedle.substr(key.length);
if (length < key.length && dir === "prev")
return key.substr(0, upperNeedle.length);
return llp < 0 ? null : key.substr(0, llp) + lowerNeedle[llp] + upperNeedle.substr(llp + 1);
}
function addIgnoreCaseAlgorithm(whereClause, match, needles, suffix) {
var upper, lower, compare, upperNeedles, lowerNeedles, direction, nextKeySuffix, needlesLen = needles.length;
if (!needles.every((s4) => typeof s4 === "string")) {
return fail(whereClause, STRING_EXPECTED);
}
function initDirection(dir) {
upper = upperFactory(dir);
lower = lowerFactory(dir);
compare = dir === "next" ? simpleCompare : simpleCompareReverse;
var needleBounds = needles.map(function(needle) {
return { lower: lower(needle), upper: upper(needle) };
}).sort(function(a3, b3) {
return compare(a3.lower, b3.lower);
});
upperNeedles = needleBounds.map(function(nb) {
return nb.upper;
});
lowerNeedles = needleBounds.map(function(nb) {
return nb.lower;
});
direction = dir;
nextKeySuffix = dir === "next" ? "" : suffix;
}
initDirection("next");
var c4 = new whereClause.Collection(whereClause, () => createRange(upperNeedles[0], lowerNeedles[needlesLen - 1] + suffix));
c4._ondirectionchange = function(direction2) {
initDirection(direction2);
};
var firstPossibleNeedle = 0;
c4._addAlgorithm(function(cursor, advance, resolve) {
var key = cursor.key;
if (typeof key !== "string")
return false;
var lowerKey = lower(key);
if (match(lowerKey, lowerNeedles, firstPossibleNeedle)) {
return true;
} else {
var lowestPossibleCasing = null;
for (var i4 = firstPossibleNeedle; i4 < needlesLen; ++i4) {
var casing = nextCasing(key, lowerKey, upperNeedles[i4], lowerNeedles[i4], compare, direction);
if (casing === null && lowestPossibleCasing === null)
firstPossibleNeedle = i4 + 1;
else if (lowestPossibleCasing === null || compare(lowestPossibleCasing, casing) > 0) {
lowestPossibleCasing = casing;
}
}
if (lowestPossibleCasing !== null) {
advance(function() {
cursor.continue(lowestPossibleCasing + nextKeySuffix);
});
} else {
advance(resolve);
}
return false;
}
});
return c4;
}
function createRange(lower, upper, lowerOpen, upperOpen) {
return {
type: 2,
lower,
upper,
lowerOpen,
upperOpen
};
}
function rangeEqual(value) {
return {
type: 1,
lower: value,
upper: value
};
}
var WhereClause = class {
get Collection() {
return this._ctx.table.db.Collection;
}
between(lower, upper, includeLower, includeUpper) {
includeLower = includeLower !== false;
includeUpper = includeUpper === true;
try {
if (this._cmp(lower, upper) > 0 || this._cmp(lower, upper) === 0 && (includeLower || includeUpper) && !(includeLower && includeUpper))
return emptyCollection(this);
return new this.Collection(this, () => createRange(lower, upper, !includeLower, !includeUpper));
} catch (e3) {
return fail(this, INVALID_KEY_ARGUMENT);
}
}
equals(value) {
if (value == null)
return fail(this, INVALID_KEY_ARGUMENT);
return new this.Collection(this, () => rangeEqual(value));
}
above(value) {
if (value == null)
return fail(this, INVALID_KEY_ARGUMENT);
return new this.Collection(this, () => createRange(value, void 0, true));
}
aboveOrEqual(value) {
if (value == null)
return fail(this, INVALID_KEY_ARGUMENT);
return new this.Collection(this, () => createRange(value, void 0, false));
}
below(value) {
if (value == null)
return fail(this, INVALID_KEY_ARGUMENT);
return new this.Collection(this, () => createRange(void 0, value, false, true));
}
belowOrEqual(value) {
if (value == null)
return fail(this, INVALID_KEY_ARGUMENT);
return new this.Collection(this, () => createRange(void 0, value));
}
startsWith(str) {
if (typeof str !== "string")
return fail(this, STRING_EXPECTED);
return this.between(str, str + maxString, true, true);
}
startsWithIgnoreCase(str) {
if (str === "")
return this.startsWith(str);
return addIgnoreCaseAlgorithm(this, (x4, a3) => x4.indexOf(a3[0]) === 0, [str], maxString);
}
equalsIgnoreCase(str) {
return addIgnoreCaseAlgorithm(this, (x4, a3) => x4 === a3[0], [str], "");
}
anyOfIgnoreCase() {
var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
if (set.length === 0)
return emptyCollection(this);
return addIgnoreCaseAlgorithm(this, (x4, a3) => a3.indexOf(x4) !== -1, set, "");
}
startsWithAnyOfIgnoreCase() {
var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
if (set.length === 0)
return emptyCollection(this);
return addIgnoreCaseAlgorithm(this, (x4, a3) => a3.some((n3) => x4.indexOf(n3) === 0), set, maxString);
}
anyOf() {
const set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
let compare = this._cmp;
try {
set.sort(compare);
} catch (e3) {
return fail(this, INVALID_KEY_ARGUMENT);
}
if (set.length === 0)
return emptyCollection(this);
const c4 = new this.Collection(this, () => createRange(set[0], set[set.length - 1]));
c4._ondirectionchange = (direction) => {
compare = direction === "next" ? this._ascending : this._descending;
set.sort(compare);
};
let i4 = 0;
c4._addAlgorithm((cursor, advance, resolve) => {
const key = cursor.key;
while (compare(key, set[i4]) > 0) {
++i4;
if (i4 === set.length) {
advance(resolve);
return false;
}
}
if (compare(key, set[i4]) === 0) {
return true;
} else {
advance(() => {
cursor.continue(set[i4]);
});
return false;
}
});
return c4;
}
notEqual(value) {
return this.inAnyRange([[minKey, value], [value, this.db._maxKey]], { includeLowers: false, includeUppers: false });
}
noneOf() {
const set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
if (set.length === 0)
return new this.Collection(this);
try {
set.sort(this._ascending);
} catch (e3) {
return fail(this, INVALID_KEY_ARGUMENT);
}
const ranges = set.reduce((res, val) => res ? res.concat([[res[res.length - 1][1], val]]) : [[minKey, val]], null);
ranges.push([set[set.length - 1], this.db._maxKey]);
return this.inAnyRange(ranges, { includeLowers: false, includeUppers: false });
}
inAnyRange(ranges, options) {
const cmp2 = this._cmp, ascending = this._ascending, descending = this._descending, min = this._min, max = this._max;
if (ranges.length === 0)
return emptyCollection(this);
if (!ranges.every((range) => range[0] !== void 0 && range[1] !== void 0 && ascending(range[0], range[1]) <= 0)) {
return fail(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", exceptions.InvalidArgument);
}
const includeLowers = !options || options.includeLowers !== false;
const includeUppers = options && options.includeUppers === true;
function addRange2(ranges2, newRange) {
let i4 = 0, l3 = ranges2.length;
for (; i4 < l3; ++i4) {
const range = ranges2[i4];
if (cmp2(newRange[0], range[1]) < 0 && cmp2(newRange[1], range[0]) > 0) {
range[0] = min(range[0], newRange[0]);
range[1] = max(range[1], newRange[1]);
break;
}
}
if (i4 === l3)
ranges2.push(newRange);
return ranges2;
}
let sortDirection = ascending;
function rangeSorter(a3, b3) {
return sortDirection(a3[0], b3[0]);
}
let set;
try {
set = ranges.reduce(addRange2, []);
set.sort(rangeSorter);
} catch (ex) {
return fail(this, INVALID_KEY_ARGUMENT);
}
let rangePos = 0;
const keyIsBeyondCurrentEntry = includeUppers ? (key) => ascending(key, set[rangePos][1]) > 0 : (key) => ascending(key, set[rangePos][1]) >= 0;
const keyIsBeforeCurrentEntry = includeLowers ? (key) => descending(key, set[rangePos][0]) > 0 : (key) => descending(key, set[rangePos][0]) >= 0;
function keyWithinCurrentRange(key) {
return !keyIsBeyondCurrentEntry(key) && !keyIsBeforeCurrentEntry(key);
}
let checkKey = keyIsBeyondCurrentEntry;
const c4 = new this.Collection(this, () => createRange(set[0][0], set[set.length - 1][1], !includeLowers, !includeUppers));
c4._ondirectionchange = (direction) => {
if (direction === "next") {
checkKey = keyIsBeyondCurrentEntry;
sortDirection = ascending;
} else {
checkKey = keyIsBeforeCurrentEntry;
sortDirection = descending;
}
set.sort(rangeSorter);
};
c4._addAlgorithm((cursor, advance, resolve) => {
var key = cursor.key;
while (checkKey(key)) {
++rangePos;
if (rangePos === set.length) {
advance(resolve);
return false;
}
}
if (keyWithinCurrentRange(key)) {
return true;
} else if (this._cmp(key, set[rangePos][1]) === 0 || this._cmp(key, set[rangePos][0]) === 0) {
return false;
} else {
advance(() => {
if (sortDirection === ascending)
cursor.continue(set[rangePos][0]);
else
cursor.continue(set[rangePos][1]);
});
return false;
}
});
return c4;
}
startsWithAnyOf() {
const set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
if (!set.every((s4) => typeof s4 === "string")) {
return fail(this, "startsWithAnyOf() only works with strings");
}
if (set.length === 0)
return emptyCollection(this);
return this.inAnyRange(set.map((str) => [str, str + maxString]));
}
};
function createWhereClauseConstructor(db) {
return makeClassConstructor(WhereClause.prototype, function WhereClause2(table, index, orCollection) {
this.db = db;
this._ctx = {
table,
index: index === ":id" ? null : index,
or: orCollection
};
const indexedDB2 = db._deps.indexedDB;
if (!indexedDB2)
throw new exceptions.MissingAPI();
this._cmp = this._ascending = indexedDB2.cmp.bind(indexedDB2);
this._descending = (a3, b3) => indexedDB2.cmp(b3, a3);
this._max = (a3, b3) => indexedDB2.cmp(a3, b3) > 0 ? a3 : b3;
this._min = (a3, b3) => indexedDB2.cmp(a3, b3) < 0 ? a3 : b3;
this._IDBKeyRange = db._deps.IDBKeyRange;
});
}
function eventRejectHandler(reject) {
return wrap(function(event) {
preventDefault(event);
reject(event.target.error);
return false;
});
}
function preventDefault(event) {
if (event.stopPropagation)
event.stopPropagation();
if (event.preventDefault)
event.preventDefault();
}
var DEXIE_STORAGE_MUTATED_EVENT_NAME = "storagemutated";
var STORAGE_MUTATED_DOM_EVENT_NAME = "x-storagemutated-1";
var globalEvents = Events(null, DEXIE_STORAGE_MUTATED_EVENT_NAME);
var Transaction = class {
_lock() {
assert(!PSD.global);
++this._reculock;
if (this._reculock === 1 && !PSD.global)
PSD.lockOwnerFor = this;
return this;
}
_unlock() {
assert(!PSD.global);
if (--this._reculock === 0) {
if (!PSD.global)
PSD.lockOwnerFor = null;
while (this._blockedFuncs.length > 0 && !this._locked()) {
var fnAndPSD = this._blockedFuncs.shift();
try {
usePSD(fnAndPSD[1], fnAndPSD[0]);
} catch (e3) {
}
}
}
return this;
}
_locked() {
return this._reculock && PSD.lockOwnerFor !== this;
}
create(idbtrans) {
if (!this.mode)
return this;
const idbdb = this.db.idbdb;
const dbOpenError = this.db._state.dbOpenError;
assert(!this.idbtrans);
if (!idbtrans && !idbdb) {
switch (dbOpenError && dbOpenError.name) {
case "DatabaseClosedError":
throw new exceptions.DatabaseClosed(dbOpenError);
case "MissingAPIError":
throw new exceptions.MissingAPI(dbOpenError.message, dbOpenError);
default:
throw new exceptions.OpenFailed(dbOpenError);
}
}
if (!this.active)
throw new exceptions.TransactionInactive();
assert(this._completion._state === null);
idbtrans = this.idbtrans = idbtrans || (this.db.core ? this.db.core.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }) : idbdb.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }));
idbtrans.onerror = wrap((ev) => {
preventDefault(ev);
this._reject(idbtrans.error);
});
idbtrans.onabort = wrap((ev) => {
preventDefault(ev);
this.active && this._reject(new exceptions.Abort(idbtrans.error));
this.active = false;
this.on("abort").fire(ev);
});
idbtrans.oncomplete = wrap(() => {
this.active = false;
this._resolve();
if ("mutatedParts" in idbtrans) {
globalEvents.storagemutated.fire(idbtrans["mutatedParts"]);
}
});
return this;
}
_promise(mode, fn2, bWriteLock) {
if (mode === "readwrite" && this.mode !== "readwrite")
return rejection(new exceptions.ReadOnly("Transaction is readonly"));
if (!this.active)
return rejection(new exceptions.TransactionInactive());
if (this._locked()) {
return new DexiePromise((resolve, reject) => {
this._blockedFuncs.push([() => {
this._promise(mode, fn2, bWriteLock).then(resolve, reject);
}, PSD]);
});
} else if (bWriteLock) {
return newScope(() => {
var p4 = new DexiePromise((resolve, reject) => {
this._lock();
const rv = fn2(resolve, reject, this);
if (rv && rv.then)
rv.then(resolve, reject);
});
p4.finally(() => this._unlock());
p4._lib = true;
return p4;
});
} else {
var p3 = new DexiePromise((resolve, reject) => {
var rv = fn2(resolve, reject, this);
if (rv && rv.then)
rv.then(resolve, reject);
});
p3._lib = true;
return p3;
}
}
_root() {
return this.parent ? this.parent._root() : this;
}
waitFor(promiseLike) {
var root = this._root();
const promise = DexiePromise.resolve(promiseLike);
if (root._waitingFor) {
root._waitingFor = root._waitingFor.then(() => promise);
} else {
root._waitingFor = promise;
root._waitingQueue = [];
var store = root.idbtrans.objectStore(root.storeNames[0]);
(function spin() {
++root._spinCount;
while (root._waitingQueue.length)
root._waitingQueue.shift()();
if (root._waitingFor)
store.get(-Infinity).onsuccess = spin;
})();
}
var currentWaitPromise = root._waitingFor;
return new DexiePromise((resolve, reject) => {
promise.then((res) => root._waitingQueue.push(wrap(resolve.bind(null, res))), (err) => root._waitingQueue.push(wrap(reject.bind(null, err)))).finally(() => {
if (root._waitingFor === currentWaitPromise) {
root._waitingFor = null;
}
});
});
}
abort() {
if (this.active) {
this.active = false;
if (this.idbtrans)
this.idbtrans.abort();
this._reject(new exceptions.Abort());
}
}
table(tableName) {
const memoizedTables = this._memoizedTables || (this._memoizedTables = {});
if (hasOwn(memoizedTables, tableName))
return memoizedTables[tableName];
const tableSchema = this.schema[tableName];
if (!tableSchema) {
throw new exceptions.NotFound("Table " + tableName + " not part of transaction");
}
const transactionBoundTable = new this.db.Table(tableName, tableSchema, this);
transactionBoundTable.core = this.db.core.table(tableName);
memoizedTables[tableName] = transactionBoundTable;
return transactionBoundTable;
}
};
function createTransactionConstructor(db) {
return makeClassConstructor(Transaction.prototype, function Transaction2(mode, storeNames, dbschema, chromeTransactionDurability, parent) {
this.db = db;
this.mode = mode;
this.storeNames = storeNames;
this.schema = dbschema;
this.chromeTransactionDurability = chromeTransactionDurability;
this.idbtrans = null;
this.on = Events(this, "complete", "error", "abort");
this.parent = parent || null;
this.active = true;
this._reculock = 0;
this._blockedFuncs = [];
this._resolve = null;
this._reject = null;
this._waitingFor = null;
this._waitingQueue = null;
this._spinCount = 0;
this._completion = new DexiePromise((resolve, reject) => {
this._resolve = resolve;
this._reject = reject;
});
this._completion.then(() => {
this.active = false;
this.on.complete.fire();
}, (e3) => {
var wasActive = this.active;
this.active = false;
this.on.error.fire(e3);
this.parent ? this.parent._reject(e3) : wasActive && this.idbtrans && this.idbtrans.abort();
return rejection(e3);
});
});
}
function createIndexSpec(name, keyPath, unique, multi, auto, compound, isPrimKey) {
return {
name,
keyPath,
unique,
multi,
auto,
compound,
src: (unique && !isPrimKey ? "&" : "") + (multi ? "*" : "") + (auto ? "++" : "") + nameFromKeyPath(keyPath)
};
}
function nameFromKeyPath(keyPath) {
return typeof keyPath === "string" ? keyPath : keyPath ? "[" + [].join.call(keyPath, "+") + "]" : "";
}
function createTableSchema(name, primKey, indexes) {
return {
name,
primKey,
indexes,
mappedClass: null,
idxByName: arrayToObject(indexes, (index) => [index.name, index])
};
}
function safariMultiStoreFix(storeNames) {
return storeNames.length === 1 ? storeNames[0] : storeNames;
}
var getMaxKey = (IdbKeyRange) => {
try {
IdbKeyRange.only([[]]);
getMaxKey = () => [[]];
return [[]];
} catch (e3) {
getMaxKey = () => maxString;
return maxString;
}
};
function getKeyExtractor(keyPath) {
if (keyPath == null) {
return () => void 0;
} else if (typeof keyPath === "string") {
return getSinglePathKeyExtractor(keyPath);
} else {
return (obj) => getByKeyPath(obj, keyPath);
}
}
function getSinglePathKeyExtractor(keyPath) {
const split = keyPath.split(".");
if (split.length === 1) {
return (obj) => obj[keyPath];
} else {
return (obj) => getByKeyPath(obj, keyPath);
}
}
function arrayify(arrayLike) {
return [].slice.call(arrayLike);
}
var _id_counter = 0;
function getKeyPathAlias(keyPath) {
return keyPath == null ? ":id" : typeof keyPath === "string" ? keyPath : `[${keyPath.join("+")}]`;
}
function createDBCore(db, IdbKeyRange, tmpTrans) {
function extractSchema(db2, trans) {
const tables2 = arrayify(db2.objectStoreNames);
return {
schema: {
name: db2.name,
tables: tables2.map((table) => trans.objectStore(table)).map((store) => {
const { keyPath, autoIncrement } = store;
const compound = isArray(keyPath);
const outbound = keyPath == null;
const indexByKeyPath = {};
const result = {
name: store.name,
primaryKey: {
name: null,
isPrimaryKey: true,
outbound,
compound,
keyPath,
autoIncrement,
unique: true,
extractKey: getKeyExtractor(keyPath)
},
indexes: arrayify(store.indexNames).map((indexName) => store.index(indexName)).map((index) => {
const { name, unique, multiEntry, keyPath: keyPath2 } = index;
const compound2 = isArray(keyPath2);
const result2 = {
name,
compound: compound2,
keyPath: keyPath2,
unique,
multiEntry,
extractKey: getKeyExtractor(keyPath2)
};
indexByKeyPath[getKeyPathAlias(keyPath2)] = result2;
return result2;
}),
getIndexByKeyPath: (keyPath2) => indexByKeyPath[getKeyPathAlias(keyPath2)]
};
indexByKeyPath[":id"] = result.primaryKey;
if (keyPath != null) {
indexByKeyPath[getKeyPathAlias(keyPath)] = result.primaryKey;
}
return result;
})
},
hasGetAll: tables2.length > 0 && "getAll" in trans.objectStore(tables2[0]) && !(typeof navigator !== "undefined" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604)
};
}
function makeIDBKeyRange(range) {
if (range.type === 3)
return null;
if (range.type === 4)
throw new Error("Cannot convert never type to IDBKeyRange");
const { lower, upper, lowerOpen, upperOpen } = range;
const idbRange = lower === void 0 ? upper === void 0 ? null : IdbKeyRange.upperBound(upper, !!upperOpen) : upper === void 0 ? IdbKeyRange.lowerBound(lower, !!lowerOpen) : IdbKeyRange.bound(lower, upper, !!lowerOpen, !!upperOpen);
return idbRange;
}
function createDbCoreTable(tableSchema) {
const tableName = tableSchema.name;
function mutate({ trans, type: type2, keys: keys2, values, range }) {
return new Promise((resolve, reject) => {
resolve = wrap(resolve);
const store = trans.objectStore(tableName);
const outbound = store.keyPath == null;
const isAddOrPut = type2 === "put" || type2 === "add";
if (!isAddOrPut && type2 !== "delete" && type2 !== "deleteRange")
throw new Error("Invalid operation type: " + type2);
const { length } = keys2 || values || { length: 1 };
if (keys2 && values && keys2.length !== values.length) {
throw new Error("Given keys array must have same length as given values array.");
}
if (length === 0)
return resolve({ numFailures: 0, failures: {}, results: [], lastResult: void 0 });
let req;
const reqs = [];
const failures = [];
let numFailures = 0;
const errorHandler = (event) => {
++numFailures;
preventDefault(event);
};
if (type2 === "deleteRange") {
if (range.type === 4)
return resolve({ numFailures, failures, results: [], lastResult: void 0 });
if (range.type === 3)
reqs.push(req = store.clear());
else
reqs.push(req = store.delete(makeIDBKeyRange(range)));
} else {
const [args1, args2] = isAddOrPut ? outbound ? [values, keys2] : [values, null] : [keys2, null];
if (isAddOrPut) {
for (let i4 = 0; i4 < length; ++i4) {
reqs.push(req = args2 && args2[i4] !== void 0 ? store[type2](args1[i4], args2[i4]) : store[type2](args1[i4]));
req.onerror = errorHandler;
}
} else {
for (let i4 = 0; i4 < length; ++i4) {
reqs.push(req = store[type2](args1[i4]));
req.onerror = errorHandler;
}
}
}
const done = (event) => {
const lastResult = event.target.result;
reqs.forEach((req2, i4) => req2.error != null && (failures[i4] = req2.error));
resolve({
numFailures,
failures,
results: type2 === "delete" ? keys2 : reqs.map((req2) => req2.result),
lastResult
});
};
req.onerror = (event) => {
errorHandler(event);
done(event);
};
req.onsuccess = done;
});
}
function openCursor2({ trans, values, query: query2, reverse, unique }) {
return new Promise((resolve, reject) => {
resolve = wrap(resolve);
const { index, range } = query2;
const store = trans.objectStore(tableName);
const source = index.isPrimaryKey ? store : store.index(index.name);
const direction = reverse ? unique ? "prevunique" : "prev" : unique ? "nextunique" : "next";
const req = values || !("openKeyCursor" in source) ? source.openCursor(makeIDBKeyRange(range), direction) : source.openKeyCursor(makeIDBKeyRange(range), direction);
req.onerror = eventRejectHandler(reject);
req.onsuccess = wrap((ev) => {
const cursor = req.result;
if (!cursor) {
resolve(null);
return;
}
cursor.___id = ++_id_counter;
cursor.done = false;
const _cursorContinue = cursor.continue.bind(cursor);
let _cursorContinuePrimaryKey = cursor.continuePrimaryKey;
if (_cursorContinuePrimaryKey)
_cursorContinuePrimaryKey = _cursorContinuePrimaryKey.bind(cursor);
const _cursorAdvance = cursor.advance.bind(cursor);
const doThrowCursorIsNotStarted = () => {
throw new Error("Cursor not started");
};
const doThrowCursorIsStopped = () => {
throw new Error("Cursor not stopped");
};
cursor.trans = trans;
cursor.stop = cursor.continue = cursor.continuePrimaryKey = cursor.advance = doThrowCursorIsNotStarted;
cursor.fail = wrap(reject);
cursor.next = function() {
let gotOne = 1;
return this.start(() => gotOne-- ? this.continue() : this.stop()).then(() => this);
};
cursor.start = (callback) => {
const iterationPromise = new Promise((resolveIteration, rejectIteration) => {
resolveIteration = wrap(resolveIteration);
req.onerror = eventRejectHandler(rejectIteration);
cursor.fail = rejectIteration;
cursor.stop = (value) => {
cursor.stop = cursor.continue = cursor.continuePrimaryKey = cursor.advance = doThrowCursorIsStopped;
resolveIteration(value);
};
});
const guardedCallback = () => {
if (req.result) {
try {
callback();
} catch (err) {
cursor.fail(err);
}
} else {
cursor.done = true;
cursor.start = () => {
throw new Error("Cursor behind last entry");
};
cursor.stop();
}
};
req.onsuccess = wrap((ev2) => {
req.onsuccess = guardedCallback;
guardedCallback();
});
cursor.continue = _cursorContinue;
cursor.continuePrimaryKey = _cursorContinuePrimaryKey;
cursor.advance = _cursorAdvance;
guardedCallback();
return iterationPromise;
};
resolve(cursor);
}, reject);
});
}
function query(hasGetAll2) {
return (request) => {
return new Promise((resolve, reject) => {
resolve = wrap(resolve);
const { trans, values, limit, query: query2 } = request;
const nonInfinitLimit = limit === Infinity ? void 0 : limit;
const { index, range } = query2;
const store = trans.objectStore(tableName);
const source = index.isPrimaryKey ? store : store.index(index.name);
const idbKeyRange = makeIDBKeyRange(range);
if (limit === 0)
return resolve({ result: [] });
if (hasGetAll2) {
const req = values ? source.getAll(idbKeyRange, nonInfinitLimit) : source.getAllKeys(idbKeyRange, nonInfinitLimit);
req.onsuccess = (event) => resolve({ result: event.target.result });
req.onerror = eventRejectHandler(reject);
} else {
let count = 0;
const req = values || !("openKeyCursor" in source) ? source.openCursor(idbKeyRange) : source.openKeyCursor(idbKeyRange);
const result = [];
req.onsuccess = (event) => {
const cursor = req.result;
if (!cursor)
return resolve({ result });
result.push(values ? cursor.value : cursor.primaryKey);
if (++count === limit)
return resolve({ result });
cursor.continue();
};
req.onerror = eventRejectHandler(reject);
}
});
};
}
return {
name: tableName,
schema: tableSchema,
mutate,
getMany({ trans, keys: keys2 }) {
return new Promise((resolve, reject) => {
resolve = wrap(resolve);
const store = trans.objectStore(tableName);
const length = keys2.length;
const result = new Array(length);
let keyCount = 0;
let callbackCount = 0;
let req;
const successHandler = (event) => {
const req2 = event.target;
if ((result[req2._pos] = req2.result) != null)
;
if (++callbackCount === keyCount)
resolve(result);
};
const errorHandler = eventRejectHandler(reject);
for (let i4 = 0; i4 < length; ++i4) {
const key = keys2[i4];
if (key != null) {
req = store.get(keys2[i4]);
req._pos = i4;
req.onsuccess = successHandler;
req.onerror = errorHandler;
++keyCount;
}
}
if (keyCount === 0)
resolve(result);
});
},
get({ trans, key }) {
return new Promise((resolve, reject) => {
resolve = wrap(resolve);
const store = trans.objectStore(tableName);
const req = store.get(key);
req.onsuccess = (event) => resolve(event.target.result);
req.onerror = eventRejectHandler(reject);
});
},
query: query(hasGetAll),
openCursor: openCursor2,
count({ query: query2, trans }) {
const { index, range } = query2;
return new Promise((resolve, reject) => {
const store = trans.objectStore(tableName);
const source = index.isPrimaryKey ? store : store.index(index.name);
const idbKeyRange = makeIDBKeyRange(range);
const req = idbKeyRange ? source.count(idbKeyRange) : source.count();
req.onsuccess = wrap((ev) => resolve(ev.target.result));
req.onerror = eventRejectHandler(reject);
});
}
};
}
const { schema, hasGetAll } = extractSchema(db, tmpTrans);
const tables = schema.tables.map((tableSchema) => createDbCoreTable(tableSchema));
const tableMap = {};
tables.forEach((table) => tableMap[table.name] = table);
return {
stack: "dbcore",
transaction: db.transaction.bind(db),
table(name) {
const result = tableMap[name];
if (!result)
throw new Error(`Table '${name}' not found`);
return tableMap[name];
},
MIN_KEY: -Infinity,
MAX_KEY: getMaxKey(IdbKeyRange),
schema
};
}
function createMiddlewareStack(stackImpl, middlewares) {
return middlewares.reduce((down, { create }) => ({ ...down, ...create(down) }), stackImpl);
}
function createMiddlewareStacks(middlewares, idbdb, { IDBKeyRange, indexedDB: indexedDB2 }, tmpTrans) {
const dbcore = createMiddlewareStack(createDBCore(idbdb, IDBKeyRange, tmpTrans), middlewares.dbcore);
return {
dbcore
};
}
function generateMiddlewareStacks({ _novip: db }, tmpTrans) {
const idbdb = tmpTrans.db;
const stacks = createMiddlewareStacks(db._middlewares, idbdb, db._deps, tmpTrans);
db.core = stacks.dbcore;
db.tables.forEach((table) => {
const tableName = table.name;
if (db.core.schema.tables.some((tbl) => tbl.name === tableName)) {
table.core = db.core.table(tableName);
if (db[tableName] instanceof db.Table) {
db[tableName].core = table.core;
}
}
});
}
function setApiOnPlace({ _novip: db }, objs, tableNames, dbschema) {
tableNames.forEach((tableName) => {
const schema = dbschema[tableName];
objs.forEach((obj) => {
const propDesc = getPropertyDescriptor(obj, tableName);
if (!propDesc || "value" in propDesc && propDesc.value === void 0) {
if (obj === db.Transaction.prototype || obj instanceof db.Transaction) {
setProp(obj, tableName, {
get() {
return this.table(tableName);
},
set(value) {
defineProperty(this, tableName, { value, writable: true, configurable: true, enumerable: true });
}
});
} else {
obj[tableName] = new db.Table(tableName, schema);
}
}
});
});
}
function removeTablesApi({ _novip: db }, objs) {
objs.forEach((obj) => {
for (let key in obj) {
if (obj[key] instanceof db.Table)
delete obj[key];
}
});
}
function lowerVersionFirst(a3, b3) {
return a3._cfg.version - b3._cfg.version;
}
function runUpgraders(db, oldVersion, idbUpgradeTrans, reject) {
const globalSchema = db._dbSchema;
const trans = db._createTransaction("readwrite", db._storeNames, globalSchema);
trans.create(idbUpgradeTrans);
trans._completion.catch(reject);
const rejectTransaction = trans._reject.bind(trans);
const transless = PSD.transless || PSD;
newScope(() => {
PSD.trans = trans;
PSD.transless = transless;
if (oldVersion === 0) {
keys(globalSchema).forEach((tableName) => {
createTable(idbUpgradeTrans, tableName, globalSchema[tableName].primKey, globalSchema[tableName].indexes);
});
generateMiddlewareStacks(db, idbUpgradeTrans);
DexiePromise.follow(() => db.on.populate.fire(trans)).catch(rejectTransaction);
} else
updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans).catch(rejectTransaction);
});
}
function updateTablesAndIndexes({ _novip: db }, oldVersion, trans, idbUpgradeTrans) {
const queue = [];
const versions = db._versions;
let globalSchema = db._dbSchema = buildGlobalSchema(db, db.idbdb, idbUpgradeTrans);
let anyContentUpgraderHasRun = false;
const versToRun = versions.filter((v3) => v3._cfg.version >= oldVersion);
versToRun.forEach((version2) => {
queue.push(() => {
const oldSchema = globalSchema;
const newSchema = version2._cfg.dbschema;
adjustToExistingIndexNames(db, oldSchema, idbUpgradeTrans);
adjustToExistingIndexNames(db, newSchema, idbUpgradeTrans);
globalSchema = db._dbSchema = newSchema;
const diff = getSchemaDiff(oldSchema, newSchema);
diff.add.forEach((tuple) => {
createTable(idbUpgradeTrans, tuple[0], tuple[1].primKey, tuple[1].indexes);
});
diff.change.forEach((change) => {
if (change.recreate) {
throw new exceptions.Upgrade("Not yet support for changing primary key");
} else {
const store = idbUpgradeTrans.objectStore(change.name);
change.add.forEach((idx) => addIndex(store, idx));
change.change.forEach((idx) => {
store.deleteIndex(idx.name);
addIndex(store, idx);
});
change.del.forEach((idxName) => store.deleteIndex(idxName));
}
});
const contentUpgrade = version2._cfg.contentUpgrade;
if (contentUpgrade && version2._cfg.version > oldVersion) {
generateMiddlewareStacks(db, idbUpgradeTrans);
trans._memoizedTables = {};
anyContentUpgraderHasRun = true;
let upgradeSchema = shallowClone(newSchema);
diff.del.forEach((table) => {
upgradeSchema[table] = oldSchema[table];
});
removeTablesApi(db, [db.Transaction.prototype]);
setApiOnPlace(db, [db.Transaction.prototype], keys(upgradeSchema), upgradeSchema);
trans.schema = upgradeSchema;
const contentUpgradeIsAsync = isAsyncFunction(contentUpgrade);
if (contentUpgradeIsAsync) {
incrementExpectedAwaits();
}
let returnValue;
const promiseFollowed = DexiePromise.follow(() => {
returnValue = contentUpgrade(trans);
if (returnValue) {
if (contentUpgradeIsAsync) {
var decrementor = decrementExpectedAwaits.bind(null, null);
returnValue.then(decrementor, decrementor);
}
}
});
return returnValue && typeof returnValue.then === "function" ? DexiePromise.resolve(returnValue) : promiseFollowed.then(() => returnValue);
}
});
queue.push((idbtrans) => {
if (!anyContentUpgraderHasRun || !hasIEDeleteObjectStoreBug) {
const newSchema = version2._cfg.dbschema;
deleteRemovedTables(newSchema, idbtrans);
}
removeTablesApi(db, [db.Transaction.prototype]);
setApiOnPlace(db, [db.Transaction.prototype], db._storeNames, db._dbSchema);
trans.schema = db._dbSchema;
});
});
function runQueue() {
return queue.length ? DexiePromise.resolve(queue.shift()(trans.idbtrans)).then(runQueue) : DexiePromise.resolve();
}
return runQueue().then(() => {
createMissingTables(globalSchema, idbUpgradeTrans);
});
}
function getSchemaDiff(oldSchema, newSchema) {
const diff = {
del: [],
add: [],
change: []
};
let table;
for (table in oldSchema) {
if (!newSchema[table])
diff.del.push(table);
}
for (table in newSchema) {
const oldDef = oldSchema[table], newDef = newSchema[table];
if (!oldDef) {
diff.add.push([table, newDef]);
} else {
const change = {
name: table,
def: newDef,
recreate: false,
del: [],
add: [],
change: []
};
if ("" + (oldDef.primKey.keyPath || "") !== "" + (newDef.primKey.keyPath || "") || oldDef.primKey.auto !== newDef.primKey.auto && !isIEOrEdge) {
change.recreate = true;
diff.change.push(change);
} else {
const oldIndexes = oldDef.idxByName;
const newIndexes = newDef.idxByName;
let idxName;
for (idxName in oldIndexes) {
if (!newIndexes[idxName])
change.del.push(idxName);
}
for (idxName in newIndexes) {
const oldIdx = oldIndexes[idxName], newIdx = newIndexes[idxName];
if (!oldIdx)
change.add.push(newIdx);
else if (oldIdx.src !== newIdx.src)
change.change.push(newIdx);
}
if (change.del.length > 0 || change.add.length > 0 || change.change.length > 0) {
diff.change.push(change);
}
}
}
}
return diff;
}
function createTable(idbtrans, tableName, primKey, indexes) {
const store = idbtrans.db.createObjectStore(tableName, primKey.keyPath ? { keyPath: primKey.keyPath, autoIncrement: primKey.auto } : { autoIncrement: primKey.auto });
indexes.forEach((idx) => addIndex(store, idx));
return store;
}
function createMissingTables(newSchema, idbtrans) {
keys(newSchema).forEach((tableName) => {
if (!idbtrans.db.objectStoreNames.contains(tableName)) {
createTable(idbtrans, tableName, newSchema[tableName].primKey, newSchema[tableName].indexes);
}
});
}
function deleteRemovedTables(newSchema, idbtrans) {
[].slice.call(idbtrans.db.objectStoreNames).forEach((storeName) => newSchema[storeName] == null && idbtrans.db.deleteObjectStore(storeName));
}
function addIndex(store, idx) {
store.createIndex(idx.name, idx.keyPath, { unique: idx.unique, multiEntry: idx.multi });
}
function buildGlobalSchema(db, idbdb, tmpTrans) {
const globalSchema = {};
const dbStoreNames = slice(idbdb.objectStoreNames, 0);
dbStoreNames.forEach((storeName) => {
const store = tmpTrans.objectStore(storeName);
let keyPath = store.keyPath;
const primKey = createIndexSpec(nameFromKeyPath(keyPath), keyPath || "", false, false, !!store.autoIncrement, keyPath && typeof keyPath !== "string", true);
const indexes = [];
for (let j4 = 0; j4 < store.indexNames.length; ++j4) {
const idbindex = store.index(store.indexNames[j4]);
keyPath = idbindex.keyPath;
var index = createIndexSpec(idbindex.name, keyPath, !!idbindex.unique, !!idbindex.multiEntry, false, keyPath && typeof keyPath !== "string", false);
indexes.push(index);
}
globalSchema[storeName] = createTableSchema(storeName, primKey, indexes);
});
return globalSchema;
}
function readGlobalSchema({ _novip: db }, idbdb, tmpTrans) {
db.verno = idbdb.version / 10;
const globalSchema = db._dbSchema = buildGlobalSchema(db, idbdb, tmpTrans);
db._storeNames = slice(idbdb.objectStoreNames, 0);
setApiOnPlace(db, [db._allTables], keys(globalSchema), globalSchema);
}
function verifyInstalledSchema(db, tmpTrans) {
const installedSchema = buildGlobalSchema(db, db.idbdb, tmpTrans);
const diff = getSchemaDiff(installedSchema, db._dbSchema);
return !(diff.add.length || diff.change.some((ch) => ch.add.length || ch.change.length));
}
function adjustToExistingIndexNames({ _novip: db }, schema, idbtrans) {
const storeNames = idbtrans.db.objectStoreNames;
for (let i4 = 0; i4 < storeNames.length; ++i4) {
const storeName = storeNames[i4];
const store = idbtrans.objectStore(storeName);
db._hasGetAll = "getAll" in store;
for (let j4 = 0; j4 < store.indexNames.length; ++j4) {
const indexName = store.indexNames[j4];
const keyPath = store.index(indexName).keyPath;
const dexieName = typeof keyPath === "string" ? keyPath : "[" + slice(keyPath).join("+") + "]";
if (schema[storeName]) {
const indexSpec = schema[storeName].idxByName[dexieName];
if (indexSpec) {
indexSpec.name = indexName;
delete schema[storeName].idxByName[dexieName];
schema[storeName].idxByName[indexName] = indexSpec;
}
}
}
}
if (typeof navigator !== "undefined" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && _global.WorkerGlobalScope && _global instanceof _global.WorkerGlobalScope && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604) {
db._hasGetAll = false;
}
}
function parseIndexSyntax(primKeyAndIndexes) {
return primKeyAndIndexes.split(",").map((index, indexNum) => {
index = index.trim();
const name = index.replace(/([&*]|\+\+)/g, "");
const keyPath = /^\[/.test(name) ? name.match(/^\[(.*)\]$/)[1].split("+") : name;
return createIndexSpec(name, keyPath || null, /\&/.test(index), /\*/.test(index), /\+\+/.test(index), isArray(keyPath), indexNum === 0);
});
}
var Version = class {
_parseStoresSpec(stores, outSchema) {
keys(stores).forEach((tableName) => {
if (stores[tableName] !== null) {
var indexes = parseIndexSyntax(stores[tableName]);
var primKey = indexes.shift();
if (primKey.multi)
throw new exceptions.Schema("Primary key cannot be multi-valued");
indexes.forEach((idx) => {
if (idx.auto)
throw new exceptions.Schema("Only primary key can be marked as autoIncrement (++)");
if (!idx.keyPath)
throw new exceptions.Schema("Index must have a name and cannot be an empty string");
});
outSchema[tableName] = createTableSchema(tableName, primKey, indexes);
}
});
}
stores(stores) {
const db = this.db;
this._cfg.storesSource = this._cfg.storesSource ? extend(this._cfg.storesSource, stores) : stores;
const versions = db._versions;
const storesSpec = {};
let dbschema = {};
versions.forEach((version2) => {
extend(storesSpec, version2._cfg.storesSource);
dbschema = version2._cfg.dbschema = {};
version2._parseStoresSpec(storesSpec, dbschema);
});
db._dbSchema = dbschema;
removeTablesApi(db, [db._allTables, db, db.Transaction.prototype]);
setApiOnPlace(db, [db._allTables, db, db.Transaction.prototype, this._cfg.tables], keys(dbschema), dbschema);
db._storeNames = keys(dbschema);
return this;
}
upgrade(upgradeFunction) {
this._cfg.contentUpgrade = promisableChain(this._cfg.contentUpgrade || nop, upgradeFunction);
return this;
}
};
function createVersionConstructor(db) {
return makeClassConstructor(Version.prototype, function Version2(versionNumber) {
this.db = db;
this._cfg = {
version: versionNumber,
storesSource: null,
dbschema: {},
tables: {},
contentUpgrade: null
};
});
}
function getDbNamesTable(indexedDB2, IDBKeyRange) {
let dbNamesDB = indexedDB2["_dbNamesDB"];
if (!dbNamesDB) {
dbNamesDB = indexedDB2["_dbNamesDB"] = new Dexie$1(DBNAMES_DB, {
addons: [],
indexedDB: indexedDB2,
IDBKeyRange
});
dbNamesDB.version(1).stores({ dbnames: "name" });
}
return dbNamesDB.table("dbnames");
}
function hasDatabasesNative(indexedDB2) {
return indexedDB2 && typeof indexedDB2.databases === "function";
}
function getDatabaseNames({ indexedDB: indexedDB2, IDBKeyRange }) {
return hasDatabasesNative(indexedDB2) ? Promise.resolve(indexedDB2.databases()).then((infos) => infos.map((info) => info.name).filter((name) => name !== DBNAMES_DB)) : getDbNamesTable(indexedDB2, IDBKeyRange).toCollection().primaryKeys();
}
function _onDatabaseCreated({ indexedDB: indexedDB2, IDBKeyRange }, name) {
!hasDatabasesNative(indexedDB2) && name !== DBNAMES_DB && getDbNamesTable(indexedDB2, IDBKeyRange).put({ name }).catch(nop);
}
function _onDatabaseDeleted({ indexedDB: indexedDB2, IDBKeyRange }, name) {
!hasDatabasesNative(indexedDB2) && name !== DBNAMES_DB && getDbNamesTable(indexedDB2, IDBKeyRange).delete(name).catch(nop);
}
function vip(fn2) {
return newScope(function() {
PSD.letThrough = true;
return fn2();
});
}
function idbReady() {
var isSafari = !navigator.userAgentData && /Safari\//.test(navigator.userAgent) && !/Chrom(e|ium)\//.test(navigator.userAgent);
if (!isSafari || !indexedDB.databases)
return Promise.resolve();
var intervalId;
return new Promise(function(resolve) {
var tryIdb = function() {
return indexedDB.databases().finally(resolve);
};
intervalId = setInterval(tryIdb, 100);
tryIdb();
}).finally(function() {
return clearInterval(intervalId);
});
}
function dexieOpen(db) {
const state = db._state;
const { indexedDB: indexedDB2 } = db._deps;
if (state.isBeingOpened || db.idbdb)
return state.dbReadyPromise.then(() => state.dbOpenError ? rejection(state.dbOpenError) : db);
debug && (state.openCanceller._stackHolder = getErrorWithStack());
state.isBeingOpened = true;
state.dbOpenError = null;
state.openComplete = false;
const openCanceller = state.openCanceller;
function throwIfCancelled() {
if (state.openCanceller !== openCanceller)
throw new exceptions.DatabaseClosed("db.open() was cancelled");
}
let resolveDbReady = state.dbReadyResolve, upgradeTransaction = null, wasCreated = false;
return DexiePromise.race([openCanceller, (typeof navigator === "undefined" ? DexiePromise.resolve() : idbReady()).then(() => new DexiePromise((resolve, reject) => {
throwIfCancelled();
if (!indexedDB2)
throw new exceptions.MissingAPI();
const dbName = db.name;
const req = state.autoSchema ? indexedDB2.open(dbName) : indexedDB2.open(dbName, Math.round(db.verno * 10));
if (!req)
throw new exceptions.MissingAPI();
req.onerror = eventRejectHandler(reject);
req.onblocked = wrap(db._fireOnBlocked);
req.onupgradeneeded = wrap((e3) => {
upgradeTransaction = req.transaction;
if (state.autoSchema && !db._options.allowEmptyDB) {
req.onerror = preventDefault;
upgradeTransaction.abort();
req.result.close();
const delreq = indexedDB2.deleteDatabase(dbName);
delreq.onsuccess = delreq.onerror = wrap(() => {
reject(new exceptions.NoSuchDatabase(`Database ${dbName} doesnt exist`));
});
} else {
upgradeTransaction.onerror = eventRejectHandler(reject);
var oldVer = e3.oldVersion > Math.pow(2, 62) ? 0 : e3.oldVersion;
wasCreated = oldVer < 1;
db._novip.idbdb = req.result;
runUpgraders(db, oldVer / 10, upgradeTransaction, reject);
}
}, reject);
req.onsuccess = wrap(() => {
upgradeTransaction = null;
const idbdb = db._novip.idbdb = req.result;
const objectStoreNames = slice(idbdb.objectStoreNames);
if (objectStoreNames.length > 0)
try {
const tmpTrans = idbdb.transaction(safariMultiStoreFix(objectStoreNames), "readonly");
if (state.autoSchema)
readGlobalSchema(db, idbdb, tmpTrans);
else {
adjustToExistingIndexNames(db, db._dbSchema, tmpTrans);
if (!verifyInstalledSchema(db, tmpTrans)) {
console.warn(`Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.`);
}
}
generateMiddlewareStacks(db, tmpTrans);
} catch (e3) {
}
connections.push(db);
idbdb.onversionchange = wrap((ev) => {
state.vcFired = true;
db.on("versionchange").fire(ev);
});
idbdb.onclose = wrap((ev) => {
db.on("close").fire(ev);
});
if (wasCreated)
_onDatabaseCreated(db._deps, dbName);
resolve();
}, reject);
}))]).then(() => {
throwIfCancelled();
state.onReadyBeingFired = [];
return DexiePromise.resolve(vip(() => db.on.ready.fire(db.vip))).then(function fireRemainders() {
if (state.onReadyBeingFired.length > 0) {
let remainders = state.onReadyBeingFired.reduce(promisableChain, nop);
state.onReadyBeingFired = [];
return DexiePromise.resolve(vip(() => remainders(db.vip))).then(fireRemainders);
}
});
}).finally(() => {
state.onReadyBeingFired = null;
state.isBeingOpened = false;
}).then(() => {
return db;
}).catch((err) => {
state.dbOpenError = err;
try {
upgradeTransaction && upgradeTransaction.abort();
} catch (_a) {
}
if (openCanceller === state.openCanceller) {
db._close();
}
return rejection(err);
}).finally(() => {
state.openComplete = true;
resolveDbReady();
});
}
function awaitIterator(iterator) {
var callNext = (result) => iterator.next(result), doThrow = (error) => iterator.throw(error), onSuccess = step(callNext), onError = step(doThrow);
function step(getNext) {
return (val) => {
var next = getNext(val), value = next.value;
return next.done ? value : !value || typeof value.then !== "function" ? isArray(value) ? Promise.all(value).then(onSuccess, onError) : onSuccess(value) : value.then(onSuccess, onError);
};
}
return step(callNext)();
}
function extractTransactionArgs(mode, _tableArgs_, scopeFunc) {
var i4 = arguments.length;
if (i4 < 2)
throw new exceptions.InvalidArgument("Too few arguments");
var args = new Array(i4 - 1);
while (--i4)
args[i4 - 1] = arguments[i4];
scopeFunc = args.pop();
var tables = flatten(args);
return [mode, tables, scopeFunc];
}
function enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFunc) {
return DexiePromise.resolve().then(() => {
const transless = PSD.transless || PSD;
const trans = db._createTransaction(mode, storeNames, db._dbSchema, parentTransaction);
const zoneProps = {
trans,
transless
};
if (parentTransaction) {
trans.idbtrans = parentTransaction.idbtrans;
} else {
try {
trans.create();
db._state.PR1398_maxLoop = 3;
} catch (ex) {
if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
console.warn("Dexie: Need to reopen db");
db._close();
return db.open().then(() => enterTransactionScope(db, mode, storeNames, null, scopeFunc));
}
return rejection(ex);
}
}
const scopeFuncIsAsync = isAsyncFunction(scopeFunc);
if (scopeFuncIsAsync) {
incrementExpectedAwaits();
}
let returnValue;
const promiseFollowed = DexiePromise.follow(() => {
returnValue = scopeFunc.call(trans, trans);
if (returnValue) {
if (scopeFuncIsAsync) {
var decrementor = decrementExpectedAwaits.bind(null, null);
returnValue.then(decrementor, decrementor);
} else if (typeof returnValue.next === "function" && typeof returnValue.throw === "function") {
returnValue = awaitIterator(returnValue);
}
}
}, zoneProps);
return (returnValue && typeof returnValue.then === "function" ? DexiePromise.resolve(returnValue).then((x4) => trans.active ? x4 : rejection(new exceptions.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))) : promiseFollowed.then(() => returnValue)).then((x4) => {
if (parentTransaction)
trans._resolve();
return trans._completion.then(() => x4);
}).catch((e3) => {
trans._reject(e3);
return rejection(e3);
});
});
}
function pad(a3, value, count) {
const result = isArray(a3) ? a3.slice() : [a3];
for (let i4 = 0; i4 < count; ++i4)
result.push(value);
return result;
}
function createVirtualIndexMiddleware(down) {
return {
...down,
table(tableName) {
const table = down.table(tableName);
const { schema } = table;
const indexLookup = {};
const allVirtualIndexes = [];
function addVirtualIndexes(keyPath, keyTail, lowLevelIndex) {
const keyPathAlias = getKeyPathAlias(keyPath);
const indexList = indexLookup[keyPathAlias] = indexLookup[keyPathAlias] || [];
const keyLength = keyPath == null ? 0 : typeof keyPath === "string" ? 1 : keyPath.length;
const isVirtual = keyTail > 0;
const virtualIndex = {
...lowLevelIndex,
isVirtual,
keyTail,
keyLength,
extractKey: getKeyExtractor(keyPath),
unique: !isVirtual && lowLevelIndex.unique
};
indexList.push(virtualIndex);
if (!virtualIndex.isPrimaryKey) {
allVirtualIndexes.push(virtualIndex);
}
if (keyLength > 1) {
const virtualKeyPath = keyLength === 2 ? keyPath[0] : keyPath.slice(0, keyLength - 1);
addVirtualIndexes(virtualKeyPath, keyTail + 1, lowLevelIndex);
}
indexList.sort((a3, b3) => a3.keyTail - b3.keyTail);
return virtualIndex;
}
const primaryKey = addVirtualIndexes(schema.primaryKey.keyPath, 0, schema.primaryKey);
indexLookup[":id"] = [primaryKey];
for (const index of schema.indexes) {
addVirtualIndexes(index.keyPath, 0, index);
}
function findBestIndex(keyPath) {
const result2 = indexLookup[getKeyPathAlias(keyPath)];
return result2 && result2[0];
}
function translateRange(range, keyTail) {
return {
type: range.type === 1 ? 2 : range.type,
lower: pad(range.lower, range.lowerOpen ? down.MAX_KEY : down.MIN_KEY, keyTail),
lowerOpen: true,
upper: pad(range.upper, range.upperOpen ? down.MIN_KEY : down.MAX_KEY, keyTail),
upperOpen: true
};
}
function translateRequest(req) {
const index = req.query.index;
return index.isVirtual ? {
...req,
query: {
index,
range: translateRange(req.query.range, index.keyTail)
}
} : req;
}
const result = {
...table,
schema: {
...schema,
primaryKey,
indexes: allVirtualIndexes,
getIndexByKeyPath: findBestIndex
},
count(req) {
return table.count(translateRequest(req));
},
query(req) {
return table.query(translateRequest(req));
},
openCursor(req) {
const { keyTail, isVirtual, keyLength } = req.query.index;
if (!isVirtual)
return table.openCursor(req);
function createVirtualCursor(cursor) {
function _continue(key) {
key != null ? cursor.continue(pad(key, req.reverse ? down.MAX_KEY : down.MIN_KEY, keyTail)) : req.unique ? cursor.continue(cursor.key.slice(0, keyLength).concat(req.reverse ? down.MIN_KEY : down.MAX_KEY, keyTail)) : cursor.continue();
}
const virtualCursor = Object.create(cursor, {
continue: { value: _continue },
continuePrimaryKey: {
value(key, primaryKey2) {
cursor.continuePrimaryKey(pad(key, down.MAX_KEY, keyTail), primaryKey2);
}
},
primaryKey: {
get() {
return cursor.primaryKey;
}
},
key: {
get() {
const key = cursor.key;
return keyLength === 1 ? key[0] : key.slice(0, keyLength);
}
},
value: {
get() {
return cursor.value;
}
}
});
return virtualCursor;
}
return table.openCursor(translateRequest(req)).then((cursor) => cursor && createVirtualCursor(cursor));
}
};
return result;
}
};
}
var virtualIndexMiddleware = {
stack: "dbcore",
name: "VirtualIndexMiddleware",
level: 1,
create: createVirtualIndexMiddleware
};
function getObjectDiff(a3, b3, rv, prfx) {
rv = rv || {};
prfx = prfx || "";
keys(a3).forEach((prop) => {
if (!hasOwn(b3, prop)) {
rv[prfx + prop] = void 0;
} else {
var ap = a3[prop], bp = b3[prop];
if (typeof ap === "object" && typeof bp === "object" && ap && bp) {
const apTypeName = toStringTag(ap);
const bpTypeName = toStringTag(bp);
if (apTypeName !== bpTypeName) {
rv[prfx + prop] = b3[prop];
} else if (apTypeName === "Object") {
getObjectDiff(ap, bp, rv, prfx + prop + ".");
} else if (ap !== bp) {
rv[prfx + prop] = b3[prop];
}
} else if (ap !== bp)
rv[prfx + prop] = b3[prop];
}
});
keys(b3).forEach((prop) => {
if (!hasOwn(a3, prop)) {
rv[prfx + prop] = b3[prop];
}
});
return rv;
}
function getEffectiveKeys(primaryKey, req) {
if (req.type === "delete")
return req.keys;
return req.keys || req.values.map(primaryKey.extractKey);
}
var hooksMiddleware = {
stack: "dbcore",
name: "HooksMiddleware",
level: 2,
create: (downCore) => ({
...downCore,
table(tableName) {
const downTable = downCore.table(tableName);
const { primaryKey } = downTable.schema;
const tableMiddleware = {
...downTable,
mutate(req) {
const dxTrans = PSD.trans;
const { deleting, creating, updating } = dxTrans.table(tableName).hook;
switch (req.type) {
case "add":
if (creating.fire === nop)
break;
return dxTrans._promise("readwrite", () => addPutOrDelete(req), true);
case "put":
if (creating.fire === nop && updating.fire === nop)
break;
return dxTrans._promise("readwrite", () => addPutOrDelete(req), true);
case "delete":
if (deleting.fire === nop)
break;
return dxTrans._promise("readwrite", () => addPutOrDelete(req), true);
case "deleteRange":
if (deleting.fire === nop)
break;
return dxTrans._promise("readwrite", () => deleteRange(req), true);
}
return downTable.mutate(req);
function addPutOrDelete(req2) {
const dxTrans2 = PSD.trans;
const keys2 = req2.keys || getEffectiveKeys(primaryKey, req2);
if (!keys2)
throw new Error("Keys missing");
req2 = req2.type === "add" || req2.type === "put" ? { ...req2, keys: keys2 } : { ...req2 };
if (req2.type !== "delete")
req2.values = [...req2.values];
if (req2.keys)
req2.keys = [...req2.keys];
return getExistingValues(downTable, req2, keys2).then((existingValues) => {
const contexts = keys2.map((key, i4) => {
const existingValue = existingValues[i4];
const ctx = { onerror: null, onsuccess: null };
if (req2.type === "delete") {
deleting.fire.call(ctx, key, existingValue, dxTrans2);
} else if (req2.type === "add" || existingValue === void 0) {
const generatedPrimaryKey = creating.fire.call(ctx, key, req2.values[i4], dxTrans2);
if (key == null && generatedPrimaryKey != null) {
key = generatedPrimaryKey;
req2.keys[i4] = key;
if (!primaryKey.outbound) {
setByKeyPath(req2.values[i4], primaryKey.keyPath, key);
}
}
} else {
const objectDiff = getObjectDiff(existingValue, req2.values[i4]);
const additionalChanges = updating.fire.call(ctx, objectDiff, key, existingValue, dxTrans2);
if (additionalChanges) {
const requestedValue = req2.values[i4];
Object.keys(additionalChanges).forEach((keyPath) => {
if (hasOwn(requestedValue, keyPath)) {
requestedValue[keyPath] = additionalChanges[keyPath];
} else {
setByKeyPath(requestedValue, keyPath, additionalChanges[keyPath]);
}
});
}
}
return ctx;
});
return downTable.mutate(req2).then(({ failures, results, numFailures, lastResult }) => {
for (let i4 = 0; i4 < keys2.length; ++i4) {
const primKey = results ? results[i4] : keys2[i4];
const ctx = contexts[i4];
if (primKey == null) {
ctx.onerror && ctx.onerror(failures[i4]);
} else {
ctx.onsuccess && ctx.onsuccess(
req2.type === "put" && existingValues[i4] ? req2.values[i4] : primKey
);
}
}
return { failures, results, numFailures, lastResult };
}).catch((error) => {
contexts.forEach((ctx) => ctx.onerror && ctx.onerror(error));
return Promise.reject(error);
});
});
}
function deleteRange(req2) {
return deleteNextChunk(req2.trans, req2.range, 1e4);
}
function deleteNextChunk(trans, range, limit) {
return downTable.query({ trans, values: false, query: { index: primaryKey, range }, limit }).then(({ result }) => {
return addPutOrDelete({ type: "delete", keys: result, trans }).then((res) => {
if (res.numFailures > 0)
return Promise.reject(res.failures[0]);
if (result.length < limit) {
return { failures: [], numFailures: 0, lastResult: void 0 };
} else {
return deleteNextChunk(trans, { ...range, lower: result[result.length - 1], lowerOpen: true }, limit);
}
});
});
}
}
};
return tableMiddleware;
}
})
};
function getExistingValues(table, req, effectiveKeys) {
return req.type === "add" ? Promise.resolve([]) : table.getMany({ trans: req.trans, keys: effectiveKeys, cache: "immutable" });
}
function getFromTransactionCache(keys2, cache, clone) {
try {
if (!cache)
return null;
if (cache.keys.length < keys2.length)
return null;
const result = [];
for (let i4 = 0, j4 = 0; i4 < cache.keys.length && j4 < keys2.length; ++i4) {
if (cmp(cache.keys[i4], keys2[j4]) !== 0)
continue;
result.push(clone ? deepClone(cache.values[i4]) : cache.values[i4]);
++j4;
}
return result.length === keys2.length ? result : null;
} catch (_a) {
return null;
}
}
var cacheExistingValuesMiddleware = {
stack: "dbcore",
level: -1,
create: (core) => {
return {
table: (tableName) => {
const table = core.table(tableName);
return {
...table,
getMany: (req) => {
if (!req.cache) {
return table.getMany(req);
}
const cachedResult = getFromTransactionCache(req.keys, req.trans["_cache"], req.cache === "clone");
if (cachedResult) {
return DexiePromise.resolve(cachedResult);
}
return table.getMany(req).then((res) => {
req.trans["_cache"] = {
keys: req.keys,
values: req.cache === "clone" ? deepClone(res) : res
};
return res;
});
},
mutate: (req) => {
if (req.type !== "add")
req.trans["_cache"] = null;
return table.mutate(req);
}
};
}
};
}
};
function isEmptyRange(node) {
return !("from" in node);
}
var RangeSet = function(fromOrTree, to) {
if (this) {
extend(this, arguments.length ? { d: 1, from: fromOrTree, to: arguments.length > 1 ? to : fromOrTree } : { d: 0 });
} else {
const rv = new RangeSet();
if (fromOrTree && "d" in fromOrTree) {
extend(rv, fromOrTree);
}
return rv;
}
};
props(RangeSet.prototype, {
add(rangeSet) {
mergeRanges(this, rangeSet);
return this;
},
addKey(key) {
addRange(this, key, key);
return this;
},
addKeys(keys2) {
keys2.forEach((key) => addRange(this, key, key));
return this;
},
[iteratorSymbol]() {
return getRangeSetIterator(this);
}
});
function addRange(target, from, to) {
const diff = cmp(from, to);
if (isNaN(diff))
return;
if (diff > 0)
throw RangeError();
if (isEmptyRange(target))
return extend(target, { from, to, d: 1 });
const left = target.l;
const right = target.r;
if (cmp(to, target.from) < 0) {
left ? addRange(left, from, to) : target.l = { from, to, d: 1, l: null, r: null };
return rebalance(target);
}
if (cmp(from, target.to) > 0) {
right ? addRange(right, from, to) : target.r = { from, to, d: 1, l: null, r: null };
return rebalance(target);
}
if (cmp(from, target.from) < 0) {
target.from = from;
target.l = null;
target.d = right ? right.d + 1 : 1;
}
if (cmp(to, target.to) > 0) {
target.to = to;
target.r = null;
target.d = target.l ? target.l.d + 1 : 1;
}
const rightWasCutOff = !target.r;
if (left && !target.l) {
mergeRanges(target, left);
}
if (right && rightWasCutOff) {
mergeRanges(target, right);
}
}
function mergeRanges(target, newSet) {
function _addRangeSet(target2, { from, to, l: l3, r: r3 }) {
addRange(target2, from, to);
if (l3)
_addRangeSet(target2, l3);
if (r3)
_addRangeSet(target2, r3);
}
if (!isEmptyRange(newSet))
_addRangeSet(target, newSet);
}
function rangesOverlap(rangeSet1, rangeSet2) {
const i1 = getRangeSetIterator(rangeSet2);
let nextResult1 = i1.next();
if (nextResult1.done)
return false;
let a3 = nextResult1.value;
const i22 = getRangeSetIterator(rangeSet1);
let nextResult2 = i22.next(a3.from);
let b3 = nextResult2.value;
while (!nextResult1.done && !nextResult2.done) {
if (cmp(b3.from, a3.to) <= 0 && cmp(b3.to, a3.from) >= 0)
return true;
cmp(a3.from, b3.from) < 0 ? a3 = (nextResult1 = i1.next(b3.from)).value : b3 = (nextResult2 = i22.next(a3.from)).value;
}
return false;
}
function getRangeSetIterator(node) {
let state = isEmptyRange(node) ? null : { s: 0, n: node };
return {
next(key) {
const keyProvided = arguments.length > 0;
while (state) {
switch (state.s) {
case 0:
state.s = 1;
if (keyProvided) {
while (state.n.l && cmp(key, state.n.from) < 0)
state = { up: state, n: state.n.l, s: 1 };
} else {
while (state.n.l)
state = { up: state, n: state.n.l, s: 1 };
}
case 1:
state.s = 2;
if (!keyProvided || cmp(key, state.n.to) <= 0)
return { value: state.n, done: false };
case 2:
if (state.n.r) {
state.s = 3;
state = { up: state, n: state.n.r, s: 0 };
continue;
}
case 3:
state = state.up;
}
}
return { done: true };
}
};
}
function rebalance(target) {
var _a, _b;
const diff = (((_a = target.r) === null || _a === void 0 ? void 0 : _a.d) || 0) - (((_b = target.l) === null || _b === void 0 ? void 0 : _b.d) || 0);
const r3 = diff > 1 ? "r" : diff < -1 ? "l" : "";
if (r3) {
const l3 = r3 === "r" ? "l" : "r";
const rootClone = { ...target };
const oldRootRight = target[r3];
target.from = oldRootRight.from;
target.to = oldRootRight.to;
target[r3] = oldRootRight[r3];
rootClone[r3] = oldRootRight[l3];
target[l3] = rootClone;
rootClone.d = computeDepth(rootClone);
}
target.d = computeDepth(target);
}
function computeDepth({ r: r3, l: l3 }) {
return (r3 ? l3 ? Math.max(r3.d, l3.d) : r3.d : l3 ? l3.d : 0) + 1;
}
var observabilityMiddleware = {
stack: "dbcore",
level: 0,
create: (core) => {
const dbName = core.schema.name;
const FULL_RANGE = new RangeSet(core.MIN_KEY, core.MAX_KEY);
return {
...core,
table: (tableName) => {
const table = core.table(tableName);
const { schema } = table;
const { primaryKey } = schema;
const { extractKey, outbound } = primaryKey;
const tableClone = {
...table,
mutate: (req) => {
const trans = req.trans;
const mutatedParts = trans.mutatedParts || (trans.mutatedParts = {});
const getRangeSet = (indexName) => {
const part = `idb://${dbName}/${tableName}/${indexName}`;
return mutatedParts[part] || (mutatedParts[part] = new RangeSet());
};
const pkRangeSet = getRangeSet("");
const delsRangeSet = getRangeSet(":dels");
const { type: type2 } = req;
let [keys2, newObjs] = req.type === "deleteRange" ? [req.range] : req.type === "delete" ? [req.keys] : req.values.length < 50 ? [[], req.values] : [];
const oldCache = req.trans["_cache"];
return table.mutate(req).then((res) => {
if (isArray(keys2)) {
if (type2 !== "delete")
keys2 = res.results;
pkRangeSet.addKeys(keys2);
const oldObjs = getFromTransactionCache(keys2, oldCache);
if (!oldObjs && type2 !== "add") {
delsRangeSet.addKeys(keys2);
}
if (oldObjs || newObjs) {
trackAffectedIndexes(getRangeSet, schema, oldObjs, newObjs);
}
} else if (keys2) {
const range = { from: keys2.lower, to: keys2.upper };
delsRangeSet.add(range);
pkRangeSet.add(range);
} else {
pkRangeSet.add(FULL_RANGE);
delsRangeSet.add(FULL_RANGE);
schema.indexes.forEach((idx) => getRangeSet(idx.name).add(FULL_RANGE));
}
return res;
});
}
};
const getRange = ({ query: { index, range } }) => {
var _a, _b;
return [
index,
new RangeSet((_a = range.lower) !== null && _a !== void 0 ? _a : core.MIN_KEY, (_b = range.upper) !== null && _b !== void 0 ? _b : core.MAX_KEY)
];
};
const readSubscribers = {
get: (req) => [primaryKey, new RangeSet(req.key)],
getMany: (req) => [primaryKey, new RangeSet().addKeys(req.keys)],
count: getRange,
query: getRange,
openCursor: getRange
};
keys(readSubscribers).forEach((method) => {
tableClone[method] = function(req) {
const { subscr } = PSD;
if (subscr) {
const getRangeSet = (indexName) => {
const part = `idb://${dbName}/${tableName}/${indexName}`;
return subscr[part] || (subscr[part] = new RangeSet());
};
const pkRangeSet = getRangeSet("");
const delsRangeSet = getRangeSet(":dels");
const [queriedIndex, queriedRanges] = readSubscribers[method](req);
getRangeSet(queriedIndex.name || "").add(queriedRanges);
if (!queriedIndex.isPrimaryKey) {
if (method === "count") {
delsRangeSet.add(FULL_RANGE);
} else {
const keysPromise = method === "query" && outbound && req.values && table.query({
...req,
values: false
});
return table[method].apply(this, arguments).then((res) => {
if (method === "query") {
if (outbound && req.values) {
return keysPromise.then(({ result: resultingKeys }) => {
pkRangeSet.addKeys(resultingKeys);
return res;
});
}
const pKeys = req.values ? res.result.map(extractKey) : res.result;
if (req.values) {
pkRangeSet.addKeys(pKeys);
} else {
delsRangeSet.addKeys(pKeys);
}
} else if (method === "openCursor") {
const cursor = res;
const wantValues = req.values;
return cursor && Object.create(cursor, {
key: {
get() {
delsRangeSet.addKey(cursor.primaryKey);
return cursor.key;
}
},
primaryKey: {
get() {
const pkey = cursor.primaryKey;
delsRangeSet.addKey(pkey);
return pkey;
}
},
value: {
get() {
wantValues && pkRangeSet.addKey(cursor.primaryKey);
return cursor.value;
}
}
});
}
return res;
});
}
}
}
return table[method].apply(this, arguments);
};
});
return tableClone;
}
};
}
};
function trackAffectedIndexes(getRangeSet, schema, oldObjs, newObjs) {
function addAffectedIndex(ix) {
const rangeSet = getRangeSet(ix.name || "");
function extractKey(obj) {
return obj != null ? ix.extractKey(obj) : null;
}
const addKeyOrKeys = (key) => ix.multiEntry && isArray(key) ? key.forEach((key2) => rangeSet.addKey(key2)) : rangeSet.addKey(key);
(oldObjs || newObjs).forEach((_3, i4) => {
const oldKey = oldObjs && extractKey(oldObjs[i4]);
const newKey = newObjs && extractKey(newObjs[i4]);
if (cmp(oldKey, newKey) !== 0) {
if (oldKey != null)
addKeyOrKeys(oldKey);
if (newKey != null)
addKeyOrKeys(newKey);
}
});
}
schema.indexes.forEach(addAffectedIndex);
}
var Dexie$1 = class {
constructor(name, options) {
this._middlewares = {};
this.verno = 0;
const deps = Dexie$1.dependencies;
this._options = options = {
addons: Dexie$1.addons,
autoOpen: true,
indexedDB: deps.indexedDB,
IDBKeyRange: deps.IDBKeyRange,
...options
};
this._deps = {
indexedDB: options.indexedDB,
IDBKeyRange: options.IDBKeyRange
};
const { addons } = options;
this._dbSchema = {};
this._versions = [];
this._storeNames = [];
this._allTables = {};
this.idbdb = null;
this._novip = this;
const state = {
dbOpenError: null,
isBeingOpened: false,
onReadyBeingFired: null,
openComplete: false,
dbReadyResolve: nop,
dbReadyPromise: null,
cancelOpen: nop,
openCanceller: null,
autoSchema: true,
PR1398_maxLoop: 3
};
state.dbReadyPromise = new DexiePromise((resolve) => {
state.dbReadyResolve = resolve;
});
state.openCanceller = new DexiePromise((_3, reject) => {
state.cancelOpen = reject;
});
this._state = state;
this.name = name;
this.on = Events(this, "populate", "blocked", "versionchange", "close", { ready: [promisableChain, nop] });
this.on.ready.subscribe = override(this.on.ready.subscribe, (subscribe) => {
return (subscriber, bSticky) => {
Dexie$1.vip(() => {
const state2 = this._state;
if (state2.openComplete) {
if (!state2.dbOpenError)
DexiePromise.resolve().then(subscriber);
if (bSticky)
subscribe(subscriber);
} else if (state2.onReadyBeingFired) {
state2.onReadyBeingFired.push(subscriber);
if (bSticky)
subscribe(subscriber);
} else {
subscribe(subscriber);
const db = this;
if (!bSticky)
subscribe(function unsubscribe() {
db.on.ready.unsubscribe(subscriber);
db.on.ready.unsubscribe(unsubscribe);
});
}
});
};
});
this.Collection = createCollectionConstructor(this);
this.Table = createTableConstructor(this);
this.Transaction = createTransactionConstructor(this);
this.Version = createVersionConstructor(this);
this.WhereClause = createWhereClauseConstructor(this);
this.on("versionchange", (ev) => {
if (ev.newVersion > 0)
console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`);
else
console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`);
this.close();
});
this.on("blocked", (ev) => {
if (!ev.newVersion || ev.newVersion < ev.oldVersion)
console.warn(`Dexie.delete('${this.name}') was blocked`);
else
console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${ev.oldVersion / 10}`);
});
this._maxKey = getMaxKey(options.IDBKeyRange);
this._createTransaction = (mode, storeNames, dbschema, parentTransaction) => new this.Transaction(mode, storeNames, dbschema, this._options.chromeTransactionDurability, parentTransaction);
this._fireOnBlocked = (ev) => {
this.on("blocked").fire(ev);
connections.filter((c4) => c4.name === this.name && c4 !== this && !c4._state.vcFired).map((c4) => c4.on("versionchange").fire(ev));
};
this.use(virtualIndexMiddleware);
this.use(hooksMiddleware);
this.use(observabilityMiddleware);
this.use(cacheExistingValuesMiddleware);
this.vip = Object.create(this, { _vip: { value: true } });
addons.forEach((addon) => addon(this));
}
version(versionNumber) {
if (isNaN(versionNumber) || versionNumber < 0.1)
throw new exceptions.Type(`Given version is not a positive number`);
versionNumber = Math.round(versionNumber * 10) / 10;
if (this.idbdb || this._state.isBeingOpened)
throw new exceptions.Schema("Cannot add version when database is open");
this.verno = Math.max(this.verno, versionNumber);
const versions = this._versions;
var versionInstance = versions.filter((v3) => v3._cfg.version === versionNumber)[0];
if (versionInstance)
return versionInstance;
versionInstance = new this.Version(versionNumber);
versions.push(versionInstance);
versions.sort(lowerVersionFirst);
versionInstance.stores({});
this._state.autoSchema = false;
return versionInstance;
}
_whenReady(fn2) {
return this.idbdb && (this._state.openComplete || PSD.letThrough || this._vip) ? fn2() : new DexiePromise((resolve, reject) => {
if (this._state.openComplete) {
return reject(new exceptions.DatabaseClosed(this._state.dbOpenError));
}
if (!this._state.isBeingOpened) {
if (!this._options.autoOpen) {
reject(new exceptions.DatabaseClosed());
return;
}
this.open().catch(nop);
}
this._state.dbReadyPromise.then(resolve, reject);
}).then(fn2);
}
use({ stack, create, level, name }) {
if (name)
this.unuse({ stack, name });
const middlewares = this._middlewares[stack] || (this._middlewares[stack] = []);
middlewares.push({ stack, create, level: level == null ? 10 : level, name });
middlewares.sort((a3, b3) => a3.level - b3.level);
return this;
}
unuse({ stack, name, create }) {
if (stack && this._middlewares[stack]) {
this._middlewares[stack] = this._middlewares[stack].filter((mw) => create ? mw.create !== create : name ? mw.name !== name : false);
}
return this;
}
open() {
return dexieOpen(this);
}
_close() {
const state = this._state;
const idx = connections.indexOf(this);
if (idx >= 0)
connections.splice(idx, 1);
if (this.idbdb) {
try {
this.idbdb.close();
} catch (e3) {
}
this._novip.idbdb = null;
}
state.dbReadyPromise = new DexiePromise((resolve) => {
state.dbReadyResolve = resolve;
});
state.openCanceller = new DexiePromise((_3, reject) => {
state.cancelOpen = reject;
});
}
close() {
this._close();
const state = this._state;
this._options.autoOpen = false;
state.dbOpenError = new exceptions.DatabaseClosed();
if (state.isBeingOpened)
state.cancelOpen(state.dbOpenError);
}
delete() {
const hasArguments = arguments.length > 0;
const state = this._state;
return new DexiePromise((resolve, reject) => {
const doDelete = () => {
this.close();
var req = this._deps.indexedDB.deleteDatabase(this.name);
req.onsuccess = wrap(() => {
_onDatabaseDeleted(this._deps, this.name);
resolve();
});
req.onerror = eventRejectHandler(reject);
req.onblocked = this._fireOnBlocked;
};
if (hasArguments)
throw new exceptions.InvalidArgument("Arguments not allowed in db.delete()");
if (state.isBeingOpened) {
state.dbReadyPromise.then(doDelete);
} else {
doDelete();
}
});
}
backendDB() {
return this.idbdb;
}
isOpen() {
return this.idbdb !== null;
}
hasBeenClosed() {
const dbOpenError = this._state.dbOpenError;
return dbOpenError && dbOpenError.name === "DatabaseClosed";
}
hasFailed() {
return this._state.dbOpenError !== null;
}
dynamicallyOpened() {
return this._state.autoSchema;
}
get tables() {
return keys(this._allTables).map((name) => this._allTables[name]);
}
transaction() {
const args = extractTransactionArgs.apply(this, arguments);
return this._transaction.apply(this, args);
}
_transaction(mode, tables, scopeFunc) {
let parentTransaction = PSD.trans;
if (!parentTransaction || parentTransaction.db !== this || mode.indexOf("!") !== -1)
parentTransaction = null;
const onlyIfCompatible = mode.indexOf("?") !== -1;
mode = mode.replace("!", "").replace("?", "");
let idbMode, storeNames;
try {
storeNames = tables.map((table) => {
var storeName = table instanceof this.Table ? table.name : table;
if (typeof storeName !== "string")
throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
return storeName;
});
if (mode == "r" || mode === READONLY)
idbMode = READONLY;
else if (mode == "rw" || mode == READWRITE)
idbMode = READWRITE;
else
throw new exceptions.InvalidArgument("Invalid transaction mode: " + mode);
if (parentTransaction) {
if (parentTransaction.mode === READONLY && idbMode === READWRITE) {
if (onlyIfCompatible) {
parentTransaction = null;
} else
throw new exceptions.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
}
if (parentTransaction) {
storeNames.forEach((storeName) => {
if (parentTransaction && parentTransaction.storeNames.indexOf(storeName) === -1) {
if (onlyIfCompatible) {
parentTransaction = null;
} else
throw new exceptions.SubTransaction("Table " + storeName + " not included in parent transaction.");
}
});
}
if (onlyIfCompatible && parentTransaction && !parentTransaction.active) {
parentTransaction = null;
}
}
} catch (e3) {
return parentTransaction ? parentTransaction._promise(null, (_3, reject) => {
reject(e3);
}) : rejection(e3);
}
const enterTransaction = enterTransactionScope.bind(null, this, idbMode, storeNames, parentTransaction, scopeFunc);
return parentTransaction ? parentTransaction._promise(idbMode, enterTransaction, "lock") : PSD.trans ? usePSD(PSD.transless, () => this._whenReady(enterTransaction)) : this._whenReady(enterTransaction);
}
table(tableName) {
if (!hasOwn(this._allTables, tableName)) {
throw new exceptions.InvalidTable(`Table ${tableName} does not exist`);
}
return this._allTables[tableName];
}
};
var symbolObservable = typeof Symbol !== "undefined" && "observable" in Symbol ? Symbol.observable : "@@observable";
var Observable = class {
constructor(subscribe) {
this._subscribe = subscribe;
}
subscribe(x4, error, complete) {
return this._subscribe(!x4 || typeof x4 === "function" ? { next: x4, error, complete } : x4);
}
[symbolObservable]() {
return this;
}
};
function extendObservabilitySet(target, newSet) {
keys(newSet).forEach((part) => {
const rangeSet = target[part] || (target[part] = new RangeSet());
mergeRanges(rangeSet, newSet[part]);
});
return target;
}
function liveQuery(querier) {
return new Observable((observer) => {
const scopeFuncIsAsync = isAsyncFunction(querier);
function execute(subscr) {
if (scopeFuncIsAsync) {
incrementExpectedAwaits();
}
const exec = () => newScope(querier, { subscr, trans: null });
const rv = PSD.trans ? usePSD(PSD.transless, exec) : exec();
if (scopeFuncIsAsync) {
rv.then(decrementExpectedAwaits, decrementExpectedAwaits);
}
return rv;
}
let closed = false;
let accumMuts = {};
let currentObs = {};
const subscription = {
get closed() {
return closed;
},
unsubscribe: () => {
closed = true;
globalEvents.storagemutated.unsubscribe(mutationListener);
}
};
observer.start && observer.start(subscription);
let querying = false, startedListening = false;
function shouldNotify() {
return keys(currentObs).some((key) => accumMuts[key] && rangesOverlap(accumMuts[key], currentObs[key]));
}
const mutationListener = (parts) => {
extendObservabilitySet(accumMuts, parts);
if (shouldNotify()) {
doQuery();
}
};
const doQuery = () => {
if (querying || closed)
return;
accumMuts = {};
const subscr = {};
const ret = execute(subscr);
if (!startedListening) {
globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, mutationListener);
startedListening = true;
}
querying = true;
Promise.resolve(ret).then((result) => {
querying = false;
if (closed)
return;
if (shouldNotify()) {
doQuery();
} else {
accumMuts = {};
currentObs = subscr;
observer.next && observer.next(result);
}
}, (err) => {
querying = false;
observer.error && observer.error(err);
subscription.unsubscribe();
});
};
doQuery();
return subscription;
});
}
var domDeps;
try {
domDeps = {
indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,
IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange
};
} catch (e3) {
domDeps = { indexedDB: null, IDBKeyRange: null };
}
var Dexie = Dexie$1;
props(Dexie, {
...fullNameExceptions,
delete(databaseName) {
const db = new Dexie(databaseName, { addons: [] });
return db.delete();
},
exists(name) {
return new Dexie(name, { addons: [] }).open().then((db) => {
db.close();
return true;
}).catch("NoSuchDatabaseError", () => false);
},
getDatabaseNames(cb) {
try {
return getDatabaseNames(Dexie.dependencies).then(cb);
} catch (_a) {
return rejection(new exceptions.MissingAPI());
}
},
defineClass() {
function Class(content) {
extend(this, content);
}
return Class;
},
ignoreTransaction(scopeFunc) {
return PSD.trans ? usePSD(PSD.transless, scopeFunc) : scopeFunc();
},
vip,
async: function(generatorFn) {
return function() {
try {
var rv = awaitIterator(generatorFn.apply(this, arguments));
if (!rv || typeof rv.then !== "function")
return DexiePromise.resolve(rv);
return rv;
} catch (e3) {
return rejection(e3);
}
};
},
spawn: function(generatorFn, args, thiz) {
try {
var rv = awaitIterator(generatorFn.apply(thiz, args || []));
if (!rv || typeof rv.then !== "function")
return DexiePromise.resolve(rv);
return rv;
} catch (e3) {
return rejection(e3);
}
},
currentTransaction: {
get: () => PSD.trans || null
},
waitFor: function(promiseOrFunction, optionalTimeout) {
const promise = DexiePromise.resolve(typeof promiseOrFunction === "function" ? Dexie.ignoreTransaction(promiseOrFunction) : promiseOrFunction).timeout(optionalTimeout || 6e4);
return PSD.trans ? PSD.trans.waitFor(promise) : promise;
},
Promise: DexiePromise,
debug: {
get: () => debug,
set: (value) => {
setDebug(value, value === "dexie" ? () => true : dexieStackFrameFilter);
}
},
derive,
extend,
props,
override,
Events,
on: globalEvents,
liveQuery,
extendObservabilitySet,
getByKeyPath,
setByKeyPath,
delByKeyPath,
shallowClone,
deepClone,
getObjectDiff,
cmp,
asap: asap$1,
minKey,
addons: [],
connections,
errnames,
dependencies: domDeps,
semVer: DEXIE_VERSION,
version: DEXIE_VERSION.split(".").map((n3) => parseInt(n3)).reduce((p3, c4, i4) => p3 + c4 / Math.pow(10, i4 * 2))
});
Dexie.maxKey = getMaxKey(Dexie.dependencies.IDBKeyRange);
if (typeof dispatchEvent !== "undefined" && typeof addEventListener !== "undefined") {
globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, (updatedParts) => {
if (!propagatingLocally) {
let event;
if (isIEOrEdge) {
event = document.createEvent("CustomEvent");
event.initCustomEvent(STORAGE_MUTATED_DOM_EVENT_NAME, true, true, updatedParts);
} else {
event = new CustomEvent(STORAGE_MUTATED_DOM_EVENT_NAME, {
detail: updatedParts
});
}
propagatingLocally = true;
dispatchEvent(event);
propagatingLocally = false;
}
});
addEventListener(STORAGE_MUTATED_DOM_EVENT_NAME, ({ detail }) => {
if (!propagatingLocally) {
propagateLocally(detail);
}
});
}
function propagateLocally(updateParts) {
let wasMe = propagatingLocally;
try {
propagatingLocally = true;
globalEvents.storagemutated.fire(updateParts);
} finally {
propagatingLocally = wasMe;
}
}
var propagatingLocally = false;
if (typeof BroadcastChannel !== "undefined") {
const bc = new BroadcastChannel(STORAGE_MUTATED_DOM_EVENT_NAME);
if (typeof bc.unref === "function") {
bc.unref();
}
globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, (changedParts) => {
if (!propagatingLocally) {
bc.postMessage(changedParts);
}
});
bc.onmessage = (ev) => {
if (ev.data)
propagateLocally(ev.data);
};
} else if (typeof self !== "undefined" && typeof navigator !== "undefined") {
globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, (changedParts) => {
try {
if (!propagatingLocally) {
if (typeof localStorage !== "undefined") {
localStorage.setItem(STORAGE_MUTATED_DOM_EVENT_NAME, JSON.stringify({
trig: Math.random(),
changedParts
}));
}
if (typeof self["clients"] === "object") {
[...self["clients"].matchAll({ includeUncontrolled: true })].forEach((client) => client.postMessage({
type: STORAGE_MUTATED_DOM_EVENT_NAME,
changedParts
}));
}
}
} catch (_a) {
}
});
if (typeof addEventListener !== "undefined") {
addEventListener("storage", (ev) => {
if (ev.key === STORAGE_MUTATED_DOM_EVENT_NAME) {
const data = JSON.parse(ev.newValue);
if (data)
propagateLocally(data.changedParts);
}
});
}
const swContainer = self.document && navigator.serviceWorker;
if (swContainer) {
swContainer.addEventListener("message", propagateMessageLocally);
}
}
function propagateMessageLocally({ data }) {
if (data && data.type === STORAGE_MUTATED_DOM_EVENT_NAME) {
propagateLocally(data.changedParts);
}
}
DexiePromise.rejectionMapper = mapError;
setDebug(debug, dexieStackFrameFilter);
// src/utils.ts
var import_msgreader = __toESM(require_msgreader());
var import_obsidian = require("obsidian");
// node_modules/js-base64/base64.mjs
var version = "3.7.5";
var VERSION = version;
var _hasatob = typeof atob === "function";
var _hasbtoa = typeof btoa === "function";
var _hasBuffer = typeof Buffer === "function";
var _TD = typeof TextDecoder === "function" ? new TextDecoder() : void 0;
var _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
var b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var b64chs = Array.prototype.slice.call(b64ch);
var b64tab = ((a3) => {
let tab = {};
a3.forEach((c4, i4) => tab[c4] = i4);
return tab;
})(b64chs);
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
var _fromCC = String.fromCharCode.bind(String);
var _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
var _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
var _tidyB64 = (s4) => s4.replace(/[^A-Za-z0-9\+\/]/g, "");
var btoaPolyfill = (bin) => {
let u32, c0, c1, c22, asc = "";
const pad2 = bin.length % 3;
for (let i4 = 0; i4 < bin.length; ) {
if ((c0 = bin.charCodeAt(i4++)) > 255 || (c1 = bin.charCodeAt(i4++)) > 255 || (c22 = bin.charCodeAt(i4++)) > 255)
throw new TypeError("invalid character found");
u32 = c0 << 16 | c1 << 8 | c22;
asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
}
return pad2 ? asc.slice(0, pad2 - 3) + "===".substring(pad2) : asc;
};
var _btoa = _hasbtoa ? (bin) => btoa(bin) : _hasBuffer ? (bin) => Buffer.from(bin, "binary").toString("base64") : btoaPolyfill;
var _fromUint8Array = _hasBuffer ? (u8a) => Buffer.from(u8a).toString("base64") : (u8a) => {
const maxargs = 4096;
let strs = [];
for (let i4 = 0, l3 = u8a.length; i4 < l3; i4 += maxargs) {
strs.push(_fromCC.apply(null, u8a.subarray(i4, i4 + maxargs)));
}
return _btoa(strs.join(""));
};
var fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
var cb_utob = (c4) => {
if (c4.length < 2) {
var cc = c4.charCodeAt(0);
return cc < 128 ? c4 : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
} else {
var cc = 65536 + (c4.charCodeAt(0) - 55296) * 1024 + (c4.charCodeAt(1) - 56320);
return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
}
};
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var utob = (u3) => u3.replace(re_utob, cb_utob);
var _encode = _hasBuffer ? (s4) => Buffer.from(s4, "utf8").toString("base64") : _TE ? (s4) => _fromUint8Array(_TE.encode(s4)) : (s4) => _btoa(utob(s4));
var encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
var encodeURI = (src) => encode(src, true);
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
var cb_btou = (cccc) => {
switch (cccc.length) {
case 4:
var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset = cp - 65536;
return _fromCC((offset >>> 10) + 55296) + _fromCC((offset & 1023) + 56320);
case 3:
return _fromCC((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2));
default:
return _fromCC((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1));
}
};
var btou = (b3) => b3.replace(re_btou, cb_btou);
var atobPolyfill = (asc) => {
asc = asc.replace(/\s+/g, "");
if (!b64re.test(asc))
throw new TypeError("malformed base64.");
asc += "==".slice(2 - (asc.length & 3));
let u24, bin = "", r1, r22;
for (let i4 = 0; i4 < asc.length; ) {
u24 = b64tab[asc.charAt(i4++)] << 18 | b64tab[asc.charAt(i4++)] << 12 | (r1 = b64tab[asc.charAt(i4++)]) << 6 | (r22 = b64tab[asc.charAt(i4++)]);
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255) : r22 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255) : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
}
return bin;
};
var _atob = _hasatob ? (asc) => atob(_tidyB64(asc)) : _hasBuffer ? (asc) => Buffer.from(asc, "base64").toString("binary") : atobPolyfill;
var _toUint8Array = _hasBuffer ? (a3) => _U8Afrom(Buffer.from(a3, "base64")) : (a3) => _U8Afrom(_atob(a3).split("").map((c4) => c4.charCodeAt(0)));
var toUint8Array = (a3) => _toUint8Array(_unURI(a3));
var _decode = _hasBuffer ? (a3) => Buffer.from(a3, "base64").toString("utf8") : _TD ? (a3) => _TD.decode(_toUint8Array(a3)) : (a3) => btou(_atob(a3));
var _unURI = (a3) => _tidyB64(a3.replace(/[-_]/g, (m0) => m0 == "-" ? "+" : "/"));
var decode = (src) => _decode(_unURI(src));
var isValid = (src) => {
if (typeof src !== "string")
return false;
const s4 = src.replace(/\s+/g, "").replace(/={0,2}$/, "");
return !/[^\s0-9a-zA-Z\+/]/.test(s4) || !/[^\s0-9a-zA-Z\-_]/.test(s4);
};
var _noEnum = (v3) => {
return {
value: v3,
enumerable: false,
writable: true,
configurable: true
};
};
var extendString = function() {
const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
_add("fromBase64", function() {
return decode(this);
});
_add("toBase64", function(urlsafe) {
return encode(this, urlsafe);
});
_add("toBase64URI", function() {
return encode(this, true);
});
_add("toBase64URL", function() {
return encode(this, true);
});
_add("toUint8Array", function() {
return toUint8Array(this);
});
};
var extendUint8Array = function() {
const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
_add("toBase64", function(urlsafe) {
return fromUint8Array(this, urlsafe);
});
_add("toBase64URI", function() {
return fromUint8Array(this, true);
});
_add("toBase64URL", function() {
return fromUint8Array(this, true);
});
};
var extendBuiltins = () => {
extendString();
extendUint8Array();
};
var gBase64 = {
version,
VERSION,
atob: _atob,
atobPolyfill,
btoa: _btoa,
btoaPolyfill,
fromBase64: decode,
toBase64: encode,
encode,
encodeURI,
encodeURL: encodeURI,
utob,
btou,
decode,
isValid,
fromUint8Array,
toUint8Array,
extendString,
extendUint8Array,
extendBuiltins
};
// node_modules/eml-parse-js/lib/bundle.esm.js
var import_text_encoding = __toESM(require_text_encoding());
var encode2 = function(str, fromCharset) {
if (fromCharset === void 0) {
fromCharset = "utf-8";
}
return new import_text_encoding.TextEncoder(fromCharset).encode(str);
};
var arr2str = function(arr) {
var CHUNK_SZ = 32768;
var strs = [];
for (var i4 = 0; i4 < arr.length; i4 += CHUNK_SZ) {
strs.push(String.fromCharCode.apply(null, arr.subarray(i4, i4 + CHUNK_SZ)));
}
return strs.join("");
};
function decode2(buf, fromCharset) {
if (fromCharset === void 0) {
fromCharset = "utf-8";
}
var charsets = [
{ charset: normalizeCharset(fromCharset), fatal: false },
{ charset: "utf-8", fatal: true },
{ charset: "iso-8859-15", fatal: false }
];
for (var _i = 0, charsets_1 = charsets; _i < charsets_1.length; _i++) {
var _a = charsets_1[_i], charset = _a.charset, fatal = _a.fatal;
try {
return new import_text_encoding.TextDecoder(charset, { fatal }).decode(buf);
} catch (e3) {
}
}
return arr2str(buf);
}
var convert = function(data, fromCharset) {
return typeof data === "string" ? encode2(data) : encode2(decode2(data, fromCharset));
};
function normalizeCharset(charset) {
if (charset === void 0) {
charset = "utf-8";
}
var match;
if (match = charset.match(/^utf[-_]?(\d+)$/i)) {
return "UTF-" + match[1];
}
if (match = charset.match(/^win[-_]?(\d+)$/i)) {
return "WINDOWS-" + match[1];
}
if (match = charset.match(/^latin[-_]?(\d+)$/i)) {
return "ISO-8859-" + match[1];
}
return charset;
}
function getCharsetName(charset) {
return charset.toLowerCase().replace(/[^0-9a-z]/g, "");
}
function guid() {
return "xxxxxxxxxxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c4) {
var r3 = Math.random() * 16 | 0, v3 = c4 == "x" ? r3 : r3 & 3 | 8;
return v3.toString(16);
}).replace("-", "");
}
function wrap2(s4, i4) {
var a3 = [];
do {
a3.push(s4.substring(0, i4));
} while ((s4 = s4.substring(i4, s4.length)) != "");
return a3.join("\r\n");
}
function mimeDecode(str, fromCharset) {
if (str === void 0) {
str = "";
}
if (fromCharset === void 0) {
fromCharset = "UTF-8";
}
var encodedBytesCount = (str.match(/=[\da-fA-F]{2}/g) || []).length;
var buffer = new Uint8Array(str.length - encodedBytesCount * 2);
for (var i4 = 0, len = str.length, bufferPos = 0; i4 < len; i4++) {
var hex = str.substr(i4 + 1, 2);
var chr = str.charAt(i4);
if (chr === "=" && hex && /[\da-fA-F]{2}/.test(hex)) {
buffer[bufferPos++] = parseInt(hex, 16);
i4 += 2;
} else {
buffer[bufferPos++] = chr.charCodeAt(0);
}
}
return decode2(buffer, fromCharset);
}
var GB2312UTF8 = {
Dig2Dec: function(s) {
var retV = 0;
if (s.length == 4) {
for (var i = 0; i < 4; i++) {
retV += eval(s.charAt(i)) * Math.pow(2, 3 - i);
}
return retV;
}
return -1;
},
Hex2Utf8: function(s) {
var retS = "";
var tempS = "";
var ss = "";
if (s.length == 16) {
tempS = "1110" + s.substring(0, 4);
tempS += "10" + s.substring(4, 10);
tempS += "10" + s.substring(10, 16);
var sss = "0123456789ABCDEF";
for (var i = 0; i < 3; i++) {
retS += "%";
ss = tempS.substring(i * 8, (eval(i.toString()) + 1) * 8);
retS += sss.charAt(this.Dig2Dec(ss.substring(0, 4)));
retS += sss.charAt(this.Dig2Dec(ss.substring(4, 8)));
}
return retS;
}
return "";
},
Dec2Dig: function(n1) {
var s4 = "";
var n22 = 0;
for (var i4 = 0; i4 < 4; i4++) {
n22 = Math.pow(2, 3 - i4);
if (n1 >= n22) {
s4 += "1";
n1 = n1 - n22;
} else {
s4 += "0";
}
}
return s4;
},
Str2Hex: function(s) {
var c = "";
var n;
var ss = "0123456789ABCDEF";
var digS = "";
for (var i = 0; i < s.length; i++) {
c = s.charAt(i);
n = ss.indexOf(c);
digS += this.Dec2Dig(eval(n.toString()));
}
return digS;
},
GB2312ToUTF8: function(s1) {
var s4 = escape(s1);
var sa = s4.split("%");
var retV2 = "";
if (sa[0] != "") {
retV2 = sa[0];
}
for (var i4 = 1; i4 < sa.length; i4++) {
if (sa[i4].substring(0, 1) == "u") {
retV2 += this.Hex2Utf8(this.Str2Hex(sa[i4].substring(1, 5)));
if (sa[i4].length) {
retV2 += sa[i4].substring(5);
}
} else {
retV2 += unescape("%" + sa[i4]);
if (sa[i4].length) {
retV2 += sa[i4].substring(5);
}
}
}
return retV2;
},
UTF8ToGB2312: function(str1) {
var substr = "";
var a3 = "";
var b3 = "";
var c4 = "";
var i4 = -1;
i4 = str1.indexOf("%");
if (i4 == -1) {
return str1;
}
while (i4 != -1) {
if (i4 < 3) {
substr = substr + str1.substr(0, i4 - 1);
str1 = str1.substr(i4 + 1, str1.length - i4);
a3 = str1.substr(0, 2);
str1 = str1.substr(2, str1.length - 2);
if ((parseInt("0x" + a3) & 128) === 0) {
substr = substr + String.fromCharCode(parseInt("0x" + a3));
} else if ((parseInt("0x" + a3) & 224) === 192) {
b3 = str1.substr(1, 2);
str1 = str1.substr(3, str1.length - 3);
var widechar = (parseInt("0x" + a3) & 31) << 6;
widechar = widechar | parseInt("0x" + b3) & 63;
substr = substr + String.fromCharCode(widechar);
} else {
b3 = str1.substr(1, 2);
str1 = str1.substr(3, str1.length - 3);
c4 = str1.substr(1, 2);
str1 = str1.substr(3, str1.length - 3);
var widechar = (parseInt("0x" + a3) & 15) << 12;
widechar = widechar | (parseInt("0x" + b3) & 63) << 6;
widechar = widechar | parseInt("0x" + c4) & 63;
substr = substr + String.fromCharCode(widechar);
}
} else {
substr = substr + str1.substring(0, i4);
str1 = str1.substring(i4);
}
i4 = str1.indexOf("%");
}
return substr + str1;
}
};
var verbose = false;
var defaultCharset = "utf-8";
function createBoundary() {
return "----=" + guid();
}
function toEmailAddress(data) {
var email = "";
if (typeof data === "undefined")
;
else if (typeof data === "string") {
email = data;
} else if (typeof data === "object") {
if (Array.isArray(data)) {
email += data.map(function(item) {
var str = "";
if (item.name) {
str += '"' + item.name.replace(/^"|"\s*$/g, "") + '" ';
}
if (item.email) {
str += "<" + item.email + ">";
}
return str;
}).filter(function(a3) {
return a3;
}).join(", ");
} else {
if (data) {
if (data.name) {
email += '"' + data.name.replace(/^"|"\s*$/g, "") + '" ';
}
if (data.email) {
email += "<" + data.email + ">";
}
}
}
}
return email;
}
function getBoundary(contentType) {
var match = /boundary="?(.+?)"?(\s*;[\s\S]*)?$/g.exec(contentType);
return match ? match[1] : void 0;
}
function getCharset(contentType) {
var match = /charset\s*=\W*([\w\-]+)/g.exec(contentType);
return match ? match[1] : void 0;
}
function getEmailAddress(raw) {
var list = [];
var parts = raw.match(/('[^']*')|[^,]+/g);
if (!parts) {
return list;
}
for (var i4 = 0; i4 < parts.length; i4++) {
var address = {
name: "",
email: ""
};
var partsStr = unquoteString(parts[i4]);
if (/^'.*'$/g.test(partsStr)) {
address.name = partsStr.replace(/'/g, "").trim();
i4++;
}
var regex = /^(.*?)(\s*\<(.*?)\>)$/g;
var match = regex.exec(partsStr);
if (match) {
var name = match[1].replace(/'/g, "").trim();
if (name && name.length) {
address.name = name;
}
address.email = match[3].trim();
list.push(address);
} else {
address.email = partsStr.trim();
list.push(address);
}
}
if (list.length === 0) {
return null;
}
if (list.length === 1) {
return list[0];
}
return list;
}
function decodeJoint(str) {
var match = /=\?([^?]+)\?(B|Q)\?(.+?)(\?=)/gi.exec(str);
if (match) {
var charset = getCharsetName(match[1] || defaultCharset);
var type2 = match[2].toUpperCase();
var value = match[3];
if (type2 === "B") {
if (charset === "utf8") {
return decode2(encode2(gBase64.fromBase64(value.replace(/\r?\n/g, ""))), "utf8");
} else {
return decode2(gBase64.toUint8Array(value.replace(/\r?\n/g, "")), charset);
}
} else if (type2 === "Q") {
return unquotePrintable(value, charset, true);
}
}
return str;
}
function unquoteString(str) {
var regex = /=\?([^?]+)\?(B|Q)\?(.+?)(\?=)/gi;
var decodedString = str || "";
var spinOffMatch = decodedString.match(regex);
if (spinOffMatch) {
spinOffMatch.forEach(function(spin) {
decodedString = decodedString.replace(spin, decodeJoint(spin));
});
}
return decodedString.replace(/\r?\n/g, "");
}
function unquotePrintable(value, charset, qEncoding) {
if (qEncoding === void 0) {
qEncoding = false;
}
var rawString = value.replace(/[\t ]+$/gm, "").replace(/=(?:\r?\n|$)/g, "");
if (qEncoding) {
rawString = rawString.replace(/_/g, decode2(new Uint8Array([32]), charset));
}
return mimeDecode(rawString, charset);
}
function parse(eml, options, callback) {
if (typeof options === "function" && typeof callback === "undefined") {
callback = options;
options = null;
}
if (typeof options !== "object") {
options = { headersOnly: false };
}
var error;
var result = {};
try {
if (typeof eml !== "string") {
throw new Error('Argument "eml" expected to be string!');
}
var lines = eml.split(/\r?\n/);
result = parseRecursive(lines, 0, result, options);
} catch (e3) {
error = e3;
}
callback && callback(error, result);
return error || result || new Error("read EML failed!");
}
function parseRecursive(lines, start, parent, options) {
var _a, _b, _c;
var boundary = null;
var lastHeaderName = "";
var findBoundary = "";
var insideBody = false;
var insideBoundary = false;
var isMultiHeader = false;
var isMultipart = false;
parent.headers = {};
function complete(boundary2) {
boundary2.part = {};
parseRecursive(boundary2.lines, 0, boundary2.part, options);
delete boundary2.lines;
}
for (var i4 = start; i4 < lines.length; i4++) {
var line = lines[i4];
if (!insideBody) {
if (line == "") {
insideBody = true;
if (options && options.headersOnly) {
break;
}
var ct = parent.headers["Content-Type"];
if (ct && /^multipart\//g.test(ct)) {
var b3 = getBoundary(ct);
if (b3 && b3.length) {
findBoundary = b3;
isMultipart = true;
parent.body = [];
}
}
continue;
}
var match = /^\s+([^\r\n]+)/g.exec(line);
if (match) {
if (isMultiHeader) {
parent.headers[lastHeaderName][parent.headers[lastHeaderName].length - 1] += "\r\n" + match[1];
} else {
parent.headers[lastHeaderName] += "\r\n" + match[1];
}
continue;
}
match = /^([\w\d\-]+):\s*([^\r\n]*)/gi.exec(line);
if (match) {
lastHeaderName = match[1];
if (parent.headers[lastHeaderName]) {
isMultiHeader = true;
if (typeof parent.headers[lastHeaderName] == "string") {
parent.headers[lastHeaderName] = [parent.headers[lastHeaderName]];
}
parent.headers[lastHeaderName].push(match[2]);
} else {
isMultiHeader = false;
parent.headers[lastHeaderName] = match[2];
}
continue;
}
} else {
if (isMultipart) {
if (line.indexOf("--" + findBoundary) == 0 && !/\-\-(\r?\n)?$/g.test(line)) {
insideBoundary = true;
if (boundary && boundary.lines) {
complete(boundary);
}
var match = /^\-\-([^\r\n]+)(\r?\n)?$/g.exec(line);
boundary = { boundary: match[1], lines: [] };
parent.body.push(boundary);
continue;
}
if (insideBoundary) {
if (((_a = boundary) === null || _a === void 0 ? void 0 : _a.boundary) && lines[i4 - 1] == "" && line.indexOf("--" + findBoundary + "--") == 0) {
insideBoundary = false;
complete(boundary);
continue;
}
if (((_b = boundary) === null || _b === void 0 ? void 0 : _b.boundary) && line.indexOf("--" + findBoundary + "--") == 0) {
continue;
}
(_c = boundary) === null || _c === void 0 ? void 0 : _c.lines.push(line);
}
} else {
parent.body = lines.splice(i4).join("\r\n");
break;
}
}
}
if (parent.body && parent.body.length && parent.body[parent.body.length - 1].lines) {
complete(parent.body[parent.body.length - 1]);
}
return parent;
}
function completeBoundary(boundary) {
if (!boundary || !boundary.boundary) {
return null;
}
var lines = boundary.lines || [];
var result = {
boundary: boundary.boundary,
part: {
headers: {}
}
};
var lastHeaderName = "";
var insideBody = false;
var childBoundary;
for (var index = 0; index < lines.length; index++) {
var line = lines[index];
if (!insideBody) {
if (line === "") {
insideBody = true;
continue;
}
var match = /^([\w\d\-]+):\s*([^\r\n]*)/gi.exec(line);
if (match) {
lastHeaderName = match[1];
result.part.headers[lastHeaderName] = match[2];
continue;
}
var lineMatch = /^\s+([^\r\n]+)/g.exec(line);
if (lineMatch) {
result.part.headers[lastHeaderName] += "\r\n" + lineMatch[1];
continue;
}
} else {
var match = /^\-\-([^\r\n]+)(\r?\n)?$/g.exec(line);
var childBoundaryStr = getBoundary(result.part.headers["Content-Type"] || result.part.headers["Content-type"]);
if (match && line.indexOf("--" + childBoundaryStr) === 0 && !childBoundary) {
childBoundary = { boundary: match ? match[1] : "", lines: [] };
continue;
} else if (!!childBoundary && childBoundary.boundary) {
if (lines[index - 1] === "" && line.indexOf("--" + childBoundary.boundary) === 0) {
var child = completeBoundary(childBoundary);
if (child) {
if (Array.isArray(result.part.body)) {
result.part.body.push(child);
} else {
result.part.body = [child];
}
} else {
result.part.body = childBoundary.lines.join("\r\n");
}
if (!!lines[index + 1]) {
childBoundary.lines = [];
continue;
}
if (line.indexOf("--" + childBoundary.boundary + "--") === 0 && lines[index + 1] === "") {
childBoundary = void 0;
break;
}
}
childBoundary.lines.push(line);
} else {
result.part.body = lines.splice(index).join("\r\n");
break;
}
}
}
return result;
}
function build(data, options, callback) {
if (typeof options === "function" && typeof callback === "undefined") {
callback = options;
options = null;
}
var error;
var eml = "";
var EOL = "\r\n";
try {
if (!data) {
throw new Error('Argument "data" expected to be an object! or string');
}
if (typeof data === "string") {
var readResult = read(data);
if (typeof readResult === "string") {
throw new Error(readResult);
} else if (readResult instanceof Error) {
throw readResult;
} else {
data = readResult;
}
}
if (!data.headers) {
throw new Error('Argument "data" expected to be has headers');
}
if (typeof data.subject === "string") {
data.headers["Subject"] = data.subject;
}
if (typeof data.from !== "undefined") {
data.headers["From"] = toEmailAddress(data.from);
}
if (typeof data.to !== "undefined") {
data.headers["To"] = toEmailAddress(data.to);
}
if (typeof data.cc !== "undefined") {
data.headers["Cc"] = toEmailAddress(data.cc);
}
var emlBoundary = getBoundary(data.headers["Content-Type"] || data.headers["Content-type"] || "");
var hasBoundary = false;
var boundary = createBoundary();
var multipartBoundary = "";
if (data.multipartAlternative) {
multipartBoundary = "" + (getBoundary(data.multipartAlternative["Content-Type"]) || "");
hasBoundary = true;
}
if (emlBoundary) {
boundary = emlBoundary;
hasBoundary = true;
} else {
data.headers["Content-Type"] = data.headers["Content-type"] || "multipart/mixed;" + EOL + 'boundary="' + boundary + '"';
}
var keys2 = Object.keys(data.headers);
for (var i4 = 0; i4 < keys2.length; i4++) {
var key = keys2[i4];
var value = data.headers[key];
if (typeof value === "undefined") {
continue;
} else if (typeof value === "string") {
eml += key + ": " + value.replace(/\r?\n/g, EOL + " ") + EOL;
} else {
for (var j4 = 0; j4 < value.length; j4++) {
eml += key + ": " + value[j4].replace(/\r?\n/g, EOL + " ") + EOL;
}
}
}
if (data.multipartAlternative) {
eml += EOL;
eml += "--" + emlBoundary + EOL;
eml += "Content-Type: " + data.multipartAlternative["Content-Type"].replace(/\r?\n/g, EOL + " ") + EOL;
}
eml += EOL;
if (data.text) {
if (typeof options === "object" && !!options && options.encode && data.textheaders) {
eml += "--" + boundary + EOL;
for (var key in data.textheaders) {
if (data.textheaders.hasOwnProperty(key)) {
eml += key + ": " + data.textheaders[key].replace(/\r?\n/g, EOL + " ");
}
}
} else if (hasBoundary) {
eml += "--" + (multipartBoundary ? multipartBoundary : boundary) + EOL;
eml += 'Content-Type: text/plain; charset="utf-8"' + EOL;
}
eml += EOL + data.text;
eml += EOL;
}
if (data.html) {
if (typeof options === "object" && !!options && options.encode && data.textheaders) {
eml += "--" + boundary + EOL;
for (var key in data.textheaders) {
if (data.textheaders.hasOwnProperty(key)) {
eml += key + ": " + data.textheaders[key].replace(/\r?\n/g, EOL + " ");
}
}
} else if (hasBoundary) {
eml += "--" + (multipartBoundary ? multipartBoundary : boundary) + EOL;
eml += 'Content-Type: text/html; charset="utf-8"' + EOL;
}
if (verbose) {
console.info("line 765 " + hasBoundary + ", emlBoundary: " + emlBoundary + ", multipartBoundary: " + multipartBoundary + ", boundary: " + boundary);
}
eml += EOL + data.html;
eml += EOL;
}
if (data.attachments) {
for (var i4 = 0; i4 < data.attachments.length; i4++) {
var attachment = data.attachments[i4];
eml += "--" + boundary + EOL;
eml += "Content-Type: " + (attachment.contentType.replace(/\r?\n/g, EOL + " ") || "application/octet-stream") + EOL;
eml += "Content-Transfer-Encoding: base64" + EOL;
eml += "Content-Disposition: " + (attachment.inline ? "inline" : "attachment") + '; filename="' + (attachment.filename || attachment.name || "attachment_" + (i4 + 1)) + '"' + EOL;
if (attachment.cid) {
eml += "Content-ID: <" + attachment.cid + ">" + EOL;
}
eml += EOL;
if (typeof attachment.data === "string") {
var content = gBase64.toBase64(attachment.data);
eml += wrap2(content, 72) + EOL;
} else {
var content = decode2(attachment.data);
eml += wrap2(content, 72) + EOL;
}
eml += EOL;
}
}
if (hasBoundary) {
eml += "--" + boundary + "--" + EOL;
}
} catch (e3) {
error = e3;
}
callback && callback(error, eml);
return error || eml;
}
function read(eml, options, callback) {
if (typeof options === "function" && typeof callback === "undefined") {
callback = options;
options = null;
}
var error;
var result;
function _append(headers, content, result2) {
var contentType = headers["Content-Type"] || headers["Content-type"];
var contentDisposition = headers["Content-Disposition"];
var charset = getCharsetName(getCharset(contentType) || defaultCharset);
var encoding = headers["Content-Transfer-Encoding"] || headers["Content-transfer-encoding"];
if (typeof encoding === "string") {
encoding = encoding.toLowerCase();
}
if (encoding === "base64") {
if (contentType && contentType.indexOf("gbk") >= 0) {
content = encode2(GB2312UTF8.GB2312ToUTF8(content.replace(/\r?\n/g, "")));
} else {
content = encode2(content.replace(/\r?\n/g, ""));
}
} else if (encoding === "quoted-printable") {
content = unquotePrintable(content, charset);
} else if (encoding && charset !== "utf8" && encoding.search(/binary|8bit/) === 0) {
content = decode2(content, charset);
}
if (!contentDisposition && contentType && contentType.indexOf("text/html") >= 0) {
if (typeof content !== "string") {
content = decode2(content, charset);
}
var htmlContent = content.replace(/\r\n|(&quot;)/g, "").replace(/\"/g, '"');
try {
if (encoding === "base64") {
htmlContent = gBase64.decode(htmlContent);
} else if (gBase64.btoa(gBase64.atob(htmlContent)) == htmlContent) {
htmlContent = gBase64.atob(htmlContent);
}
} catch (error2) {
console.error(error2);
}
if (result2.html) {
result2.html += htmlContent;
} else {
result2.html = htmlContent;
}
result2.htmlheaders = {
"Content-Type": contentType,
"Content-Transfer-Encoding": encoding || ""
};
} else if (!contentDisposition && contentType && contentType.indexOf("text/plain") >= 0) {
if (typeof content !== "string") {
content = decode2(content, charset);
}
if (encoding === "base64") {
content = gBase64.decode(content);
}
if (result2.text) {
result2.text += content;
} else {
result2.text = content;
}
result2.textheaders = {
"Content-Type": contentType,
"Content-Transfer-Encoding": encoding || ""
};
} else {
if (!result2.attachments) {
result2.attachments = [];
}
var attachment = {};
var id = headers["Content-ID"] || headers["Content-Id"];
if (id) {
attachment.id = id;
}
var NameContainer = ["Content-Disposition", "Content-Type", "Content-type"];
var result_name = void 0;
for (var _i = 0, NameContainer_1 = NameContainer; _i < NameContainer_1.length; _i++) {
var key = NameContainer_1[_i];
var name = headers[key];
if (name) {
result_name = name.replace(/(\s|'|utf-8|\*[0-9]\*)/g, "").split(";").map(function(v3) {
return /name[\*]?="?(.+?)"?$/gi.exec(v3);
}).reduce(function(a3, b3) {
if (b3 && b3[1]) {
a3 += b3[1];
}
return a3;
}, "");
if (result_name) {
break;
}
}
}
if (result_name) {
attachment.name = decodeURI(result_name);
}
var ct = headers["Content-Type"] || headers["Content-type"];
if (ct) {
attachment.contentType = ct;
}
var cd = headers["Content-Disposition"];
if (cd) {
attachment.inline = /^\s*inline/g.test(cd);
}
attachment.data = content;
attachment.data64 = decode2(content, charset);
result2.attachments.push(attachment);
}
}
function _read(data) {
if (!data) {
return "no data";
}
try {
var result_1 = {};
if (!data.headers) {
throw new Error("data does't has headers");
}
if (data.headers["Date"]) {
result_1.date = new Date(data.headers["Date"]);
}
if (data.headers["Subject"]) {
result_1.subject = unquoteString(data.headers["Subject"]);
}
if (data.headers["From"]) {
result_1.from = getEmailAddress(data.headers["From"]);
}
if (data.headers["To"]) {
result_1.to = getEmailAddress(data.headers["To"]);
}
if (data.headers["CC"]) {
result_1.cc = getEmailAddress(data.headers["CC"]);
}
if (data.headers["Cc"]) {
result_1.cc = getEmailAddress(data.headers["Cc"]);
}
result_1.headers = data.headers;
var boundary = null;
var ct = data.headers["Content-Type"] || data.headers["Content-type"];
if (ct && /^multipart\//g.test(ct)) {
var b3 = getBoundary(ct);
if (b3 && b3.length) {
boundary = b3;
}
}
if (boundary && Array.isArray(data.body)) {
for (var i4 = 0; i4 < data.body.length; i4++) {
var boundaryBlock = data.body[i4];
if (!boundaryBlock) {
continue;
}
if (typeof boundaryBlock.part === "undefined") {
verbose && console.warn("Warning: undefined b.part");
} else if (typeof boundaryBlock.part === "string") {
result_1.data = boundaryBlock.part;
} else {
if (typeof boundaryBlock.part.body === "undefined") {
verbose && console.warn("Warning: undefined b.part.body");
} else if (typeof boundaryBlock.part.body === "string") {
_append(boundaryBlock.part.headers, boundaryBlock.part.body, result_1);
} else {
var currentHeaders = boundaryBlock.part.headers;
var currentHeadersContentType = currentHeaders["Content-Type"] || currentHeaders["Content-type"];
if (verbose) {
console.log("line 969 currentHeadersContentType: " + currentHeadersContentType);
}
if (currentHeadersContentType && currentHeadersContentType.indexOf("multipart") >= 0 && !result_1.multipartAlternative) {
result_1.multipartAlternative = {
"Content-Type": currentHeadersContentType
};
}
for (var j4 = 0; j4 < boundaryBlock.part.body.length; j4++) {
var selfBoundary = boundaryBlock.part.body[j4];
if (typeof selfBoundary === "string") {
result_1.data = selfBoundary;
continue;
}
var headers = selfBoundary.part.headers;
var content = selfBoundary.part.body;
if (Array.isArray(content)) {
content.forEach(function(bound) {
_append(bound.part.headers, bound.part.body, result_1);
});
} else {
_append(headers, content, result_1);
}
}
}
}
}
} else if (typeof data.body === "string") {
_append(data.headers, data.body, result_1);
}
return result_1;
} catch (e3) {
return e3;
}
}
if (typeof eml === "string") {
var parseResult = parse(eml, options);
if (typeof parseResult === "string" || parseResult instanceof Error) {
error = parseResult;
} else {
var readResult = _read(parseResult);
if (typeof readResult === "string" || readResult instanceof Error) {
error = readResult;
} else {
result = readResult;
}
}
} else if (typeof eml === "object") {
var readResult = _read(eml);
if (typeof readResult === "string" || readResult instanceof Error) {
error = readResult;
} else {
result = readResult;
}
} else {
error = new Error("Missing EML file content!");
}
callback && callback(error, result);
return error || result || new Error("read EML failed!");
}
// src/utils.ts
var import_dayjs = __toESM(require_dayjs_min());
var getMsgContent = async (params) => {
const { plugin, msgFile } = params;
if (msgFile.extension === "msg") {
let msgFileBuffer = await plugin.app.vault.readBinary(params.msgFile);
let msgReader = new import_msgreader.MSGReader(msgFileBuffer);
let fileData = msgReader.getFileData();
let creationTime = getMsgDate({ rawHeaders: fileData.headers });
return {
senderName: dataOrEmpty(fileData.senderName),
senderEmail: dataOrEmpty(fileData.senderEmail),
recipients: getCustomRecipients(fileData.recipients ? fileData.recipients : []),
creationTime: typeof creationTime === "string" ? creationTime : (0, import_dayjs.default)(creationTime).format("ddd, D MMM YYYY HH:mm:ss"),
subject: dataOrEmpty(fileData.subject),
body: dataOrEmpty(fileData.body),
attachments: extractMSGAttachments({
msgReader,
fileDataAttachments: fileData.attachments
})
};
} else if (msgFile.extension === "eml") {
let readedEmlJson = await readEmlFile({ emlFile: msgFile, plugin });
let sender = parseEmlSender({ senderText: readedEmlJson.headers.From });
return {
senderName: sender.senderName,
senderEmail: sender.senderEmail,
recipients: parseEMLRecipients({ readEmlJson: readedEmlJson }),
creationTime: (0, import_dayjs.default)(readedEmlJson.date).format("ddd, D MMM YYYY HH:mm:ss"),
subject: dataOrEmpty(readedEmlJson.subject),
body: cleanEMLBody({ text: readedEmlJson.text }),
attachments: extractEMLAttachments({ emlFileReadJson: readedEmlJson })
};
}
};
function parseHeaders(params) {
const { headers } = params;
var parsedHeaders = {};
if (!headers)
return parsedHeaders;
var headerRegEx = /(.*)\: (.*)/g;
let m3;
while (m3 = headerRegEx.exec(headers)) {
parsedHeaders[m3[1]] = m3[2];
}
return parsedHeaders;
}
function getMsgDate(params) {
const { rawHeaders } = params;
var headers = parseHeaders({ headers: rawHeaders });
if (!headers["Date"]) {
return "-";
}
return new Date(headers["Date"]);
}
var cleanEMLBody = (params) => {
if (!params.text)
return "";
let cleanTxt = params.text.replace(/\r\n\r\n/g, "\r\n\r\n \r\n\r\n");
const pattern = /\[cid:.*?\]/g;
return cleanTxt.replace(pattern, "");
};
var readEmlFile = async (params) => {
const { emlFile, plugin } = params;
let emlFileRead = await plugin.app.vault.read(emlFile);
return new Promise((resolve, reject) => {
read(emlFileRead, (err, ReadedEMLJson) => {
if (err) {
reject(err);
} else {
resolve(ReadedEMLJson);
}
});
});
};
var parseEmlSender = (params) => {
let { senderText } = params;
if (senderText === "" || senderText === void 0 || senderText === null) {
return { senderName: "", senderEmail: "" };
}
senderText = senderText.replace(/"/g, "");
const regex = /^([^<]+) <([^>]+)>$/;
const match = regex.exec(senderText);
if (!match)
return { senderName: "", senderEmail: "" };
const [, senderName, senderEmail] = match;
return { senderName, senderEmail };
};
var parseEMLRecipients = (params) => {
const { readEmlJson } = params;
let emlTo = dataOrEmpty(readEmlJson.headers.To);
let emlCC = dataOrEmpty(readEmlJson.headers.CC);
let recipientsText = emlTo + (emlCC === "" ? "" : ", " + emlCC);
let recipientsTextSplit = recipientsText.split(">,");
const regex = /"([^"]+)"\s*<?([^>\s]+)>?/;
let msgRecipients = [];
for (let recipientText of recipientsTextSplit) {
const match = recipientText.match(regex);
if (match) {
const name = match[1] || match[3];
const email = match[2] || match[4];
msgRecipients.push({ name, email });
}
}
return msgRecipients;
};
var extractMSGAttachments = (params) => {
const { msgReader, fileDataAttachments } = params;
let msgAttachments = [];
for (let [index, fileDataAttachment] of fileDataAttachments.entries()) {
let attRead = msgReader.getAttachment(index);
msgAttachments.push({
fileName: attRead.fileName,
fileExtension: fileDataAttachment.extension,
fileBase64: attRead.content ? uint8ArrayToBase64(attRead.content) : null
});
}
return msgAttachments;
};
var extractEMLAttachments = (params) => {
const { emlFileReadJson } = params;
if (emlFileReadJson.attachments && emlFileReadJson.attachments.length > 0) {
let attachments = [];
for (let attachment of params.emlFileReadJson.attachments) {
let fileNameParts = attachment.name.split(".");
let extension = fileNameParts[fileNameParts.length - 1];
attachments.push({
fileName: attachment.name,
fileExtension: "." + extension,
fileBase64: attachment.data64
});
}
return attachments;
} else {
return [];
}
};
var getCustomRecipients = (recipients) => {
if (recipients && recipients.length > 0) {
let customRecipients = [];
for (let recipient of recipients) {
customRecipients.push({
name: dataOrEmpty(recipient.name),
email: dataOrEmpty(recipient.email)
});
}
return customRecipients;
} else {
return [];
}
};
var dataOrEmpty = (data) => {
return data ? data : "";
};
var replaceNewLinesAndCarriages = (txt) => {
return txt == null ? void 0 : txt.replace(/[\r\n]+/g, "");
};
var getFileName = (filePath) => {
var index = filePath.lastIndexOf("/");
if (index !== -1)
return filePath.substring(index + 1);
return filePath;
};
var openFile = (params) => {
const { file, plugin, newLeaf, leafBySplit } = params;
let leaf = plugin.app.workspace.getLeaf(newLeaf);
if (!newLeaf && leafBySplit)
leaf = plugin.app.workspace.createLeafBySplit(leaf, "vertical");
plugin.app.workspace.setActiveLeaf(leaf, { focus: true });
leaf.openFile(file, { eState: { focus: true } });
};
var openFileInNewTab = (params) => {
openFile({ file: params.file, plugin: params.plugin, newLeaf: true });
};
function isMouseEvent(e3) {
return e3 && "screenX" in e3;
}
function base64ToArrayBuffer(base64) {
var binary_string = window.atob(base64);
var len = binary_string.length;
var bytes = new Uint8Array(len);
for (var i4 = 0; i4 < len; i4++) {
bytes[i4] = binary_string.charCodeAt(i4);
}
return bytes;
}
function uint8ArrayToBase64(uint8Array) {
return gBase64.fromUint8Array(uint8Array);
}
// src/database.ts
var import_fuzzysort = __toESM(require_fuzzysort());
var MsgHandlerDatabase = class extends Dexie$1 {
constructor() {
super("MsgHandlerDatabase");
this.version(1).stores({
dbMessageContents: "++id, senderName, senderEmail, recipients, subject, body, &filePath, mtime"
});
}
};
var pluginDb = new MsgHandlerDatabase();
var updateFilePathOfAllRecords = async (params) => {
const { oldValue, newValue } = params;
await pluginDb.dbMessageContents.where("filePath").equals(oldValue).modify({
filePath: newValue
});
};
var getAllDBMessageContents = async () => {
return await pluginDb.dbMessageContents.toArray();
};
var getDBMessageContentsByPath = async (params) => {
const { filePath } = params;
return await pluginDb.dbMessageContents.where("filePath").equals(filePath).toArray();
};
var createDBMessageContent = async (params) => {
const { msgContent, file } = params;
await pluginDb.dbMessageContents.add({
senderName: msgContent.senderName,
senderEmail: msgContent.senderEmail,
recipients: msgContent.recipients,
creationTime: msgContent.creationTime,
body: msgContent.body,
subject: msgContent.subject,
filePath: file.path,
mtime: file.stat.mtime
});
};
var deleteDBMessageContentById = async (params) => {
if (params.id) {
await pluginDb.dbMessageContents.delete(params.id);
}
};
var syncDatabaseWithVaultFiles = async (params) => {
const { plugin } = params;
let msgFiles = plugin.app.vault.getFiles().filter((f3) => plugin.acceptedExtensions.contains(f3.extension));
let dbMsgContents = await getAllDBMessageContents();
for (let dbMsgContent of dbMsgContents) {
if (!msgFiles.some((f3) => f3.path == dbMsgContent.filePath)) {
await deleteDBMessageContentById({ id: dbMsgContent.id });
}
}
for (let msgFile of msgFiles) {
if (!dbMsgContents.some((c4) => c4.filePath === msgFile.path)) {
let msgContent = await getMsgContent({ plugin, msgFile });
await createDBMessageContent({
msgContent,
file: msgFile
});
}
}
};
var searchMsgFilesWithKey = async (params) => {
let allDBMessageContents = await getAllDBMessageContents();
let searchConvenientMessageContents = allDBMessageContents.map(
(messageContent) => ({
...messageContent,
recipients: messageContent.recipients.map((r3) => r3.name + " <" + r3.email + ">").join(", ")
})
);
const results = import_fuzzysort.default.go(
params.key,
searchConvenientMessageContents,
{
keys: ["senderName", "senderEmail", "subject", "body", "recipients"],
threshold: -2e4,
scoreFn: (a3) => {
var _a, _b, _c, _d, _e;
const searchKey = params.key.toLowerCase();
const exactMatch = ((_a = a3[0]) == null ? void 0 : _a.target.toLowerCase().includes(searchKey)) || ((_b = a3[1]) == null ? void 0 : _b.target.toLowerCase().includes(searchKey)) || ((_c = a3[2]) == null ? void 0 : _c.target.toLowerCase().includes(searchKey)) || ((_d = a3[3]) == null ? void 0 : _d.target.toLowerCase().includes(searchKey)) || ((_e = a3[4]) == null ? void 0 : _e.target.toLowerCase().includes(searchKey));
if (exactMatch) {
return 0;
} else {
let senderNameScore = a3[0] ? a3[0].score : -1e5;
let senderEmailScore = a3[1] ? a3[1].score : -1e5;
let subjectScore = a3[2] ? a3[2].score : -1e5;
let bodyScore = a3[3] ? a3[3].score : -1e5;
let recipientsScore = a3[4] ? a3[4].score : -1e5;
return Math.max(senderNameScore, senderEmailScore, subjectScore, bodyScore, recipientsScore);
}
}
}
);
return results;
};
var getHighlightedPartOfSearchResult = (params) => {
const { highlightedResult, searchKey } = params;
let maxSearchDisplayLength = 120;
if (highlightedResult.length < maxSearchDisplayLength) {
return highlightedResult;
} else {
const firstMarkIndex = highlightedResult.indexOf('<mark class="oz-highlight">');
const lastMarkIndex = highlightedResult.lastIndexOf("</mark>");
if (firstMarkIndex === -1 || lastMarkIndex === -1)
return highlightedResult;
const searchKeyLength = searchKey.length;
const lengthAfterHighlight = highlightedResult.length - (lastMarkIndex + 7);
const leftUsageLength = maxSearchDisplayLength - searchKeyLength;
const eachSideUsageLength = Math.floor(leftUsageLength / 2);
let startIndex = 0;
let startMissing = 0;
if (firstMarkIndex > eachSideUsageLength) {
startIndex = firstMarkIndex - eachSideUsageLength;
} else {
startMissing = eachSideUsageLength - firstMarkIndex;
}
let endIndex = highlightedResult.length - 1;
if (lengthAfterHighlight > eachSideUsageLength) {
endIndex = lastMarkIndex + 7 + eachSideUsageLength;
let endLeftPlace = highlightedResult.length - 1 - endIndex;
if (endLeftPlace > startMissing) {
endIndex += startMissing;
} else {
endIndex = highlightedResult.length - 1;
}
} else {
let endMissing = eachSideUsageLength - lengthAfterHighlight;
if (endMissing > 0) {
if (startIndex > endMissing) {
startIndex = startIndex - endMissing;
} else {
startIndex = 0;
}
}
}
return "..." + highlightedResult.substring(startIndex, endIndex) + "...";
}
};
// src/components/search/index.tsx
var import_obsidian2 = require("obsidian");
function SearchViewComponent(params) {
const { plugin } = params;
const [searchKey, setSearchKey] = p2();
const [searchResults, setSearchResults] = p2();
const [allOpenStatus, setAllOpenStatus] = p2();
const promiseQueueRef = _2([]);
h2(() => {
const runPromiseQueue = async () => {
while (promiseQueueRef.current.length > 0) {
const nextPromise = promiseQueueRef.current[0];
try {
await nextPromise();
} catch (error) {
if (plugin.settings.logEnabled)
console.log("Search promise failed", error);
} finally {
promiseQueueRef.current.shift();
}
}
};
if (searchKey === "" || searchKey === null || searchKey === void 0) {
setSearchResults(null);
} else {
promiseQueueRef.current.push(runSearch);
runPromiseQueue();
}
}, [searchKey]);
const handleInputChange = (event) => {
const newSearchKey = event.target.value;
setSearchKey(newSearchKey);
};
const runSearch = async () => {
let currentSearchResults = [];
let results = await searchMsgFilesWithKey({ key: searchKey });
for (let result of results) {
let indexOfMaxScore = null;
let exactMatch = false;
const exactMatchIndex = result.findIndex(
(r3) => r3 == null ? void 0 : r3.target.toLowerCase().includes(searchKey.toLowerCase())
);
if (exactMatchIndex !== -1) {
indexOfMaxScore = exactMatchIndex;
exactMatch = true;
} else {
const scores = result.map((r3) => {
var _a;
return (_a = r3 == null ? void 0 : r3.score) != null ? _a : -1e5;
});
indexOfMaxScore = scores.reduce(
(maxIndex, score, index) => score > scores[maxIndex] ? index : maxIndex,
0
);
}
let highlightedResult = null;
if (exactMatch) {
let indexOfSearchMatch = result[indexOfMaxScore].target.toLowerCase().indexOf(searchKey.toLowerCase());
let lengthOfSearchKey = searchKey.length;
let originalTextOfSearchKey = result[indexOfMaxScore].target.substring(
indexOfSearchMatch,
indexOfSearchMatch + lengthOfSearchKey
);
highlightedResult = result[indexOfMaxScore].target.replace(
originalTextOfSearchKey,
'<mark class="oz-highlight">' + originalTextOfSearchKey + "</mark>"
);
} else {
highlightedResult = import_fuzzysort2.default.highlight(
result[indexOfMaxScore],
'<mark class="oz-highlight">',
"</mark>"
);
}
if (highlightedResult) {
highlightedResult = getHighlightedPartOfSearchResult({
highlightedResult: replaceNewLinesAndCarriages(highlightedResult),
searchKey
});
}
currentSearchResults.push({
result,
highlightedResult
});
}
setSearchResults(currentSearchResults);
};
return /* @__PURE__ */ Sn.createElement("div", null, /* @__PURE__ */ Sn.createElement("div", { className: "oz-msg-handler-actions-items oz-msg-handler-header-fixed" }, /* @__PURE__ */ Sn.createElement(
CgChevronDoubleUp,
{
className: "oz-msg-handler-action-button",
"aria-label": "Collapse All",
onClick: () => setAllOpenStatus("closed"),
size: 20
}
), /* @__PURE__ */ Sn.createElement(
CgChevronDoubleDown,
{
className: "oz-msg-handler-action-button",
"aria-label": "Expand All",
onClick: () => setAllOpenStatus("open"),
size: 20
}
)), /* @__PURE__ */ Sn.createElement("div", { className: "oz-searchbox-container" }, /* @__PURE__ */ Sn.createElement(
"input",
{
type: "text",
placeholder: "Provide a search key",
value: searchKey,
onChange: handleInputChange
}
)), /* @__PURE__ */ Sn.createElement("div", { className: "search-result-container" }, searchResults && (searchResults.length > 0 ? searchResults.map((searchResult) => {
return /* @__PURE__ */ Sn.createElement(
SearchResultFileMatch,
{
searchResult,
allOpenStatus,
plugin
}
);
}) : /* @__PURE__ */ Sn.createElement("div", { className: "search-empty-state" }, "No matches found"))));
}
var SearchResultFileMatch = (params) => {
var _a;
const { searchResult, allOpenStatus, plugin } = params;
const [open, setOpen] = p2(true);
h2(() => {
if (allOpenStatus === "open") {
setOpen(true);
} else if (allOpenStatus === "closed") {
setOpen(false);
}
}, [allOpenStatus]);
const getCurrentAbstractFile = () => {
return plugin.app.vault.getAbstractFileByPath(searchResult.result.obj.filePath);
};
const openFileClicked = (e3) => {
let file = getCurrentAbstractFile();
if (file) {
openFile({
file,
plugin,
newLeaf: (e3.ctrlKey || e3.metaKey) && !(e3.shiftKey || e3.altKey),
leafBySplit: (e3.ctrlKey || e3.metaKey) && (e3.shiftKey || e3.altKey)
});
}
};
const onAuxClick = (e3) => {
let file = getCurrentAbstractFile();
if (e3.button === 1 && file)
openFileInNewTab({ plugin, file });
};
const triggerContextMenu = (e3) => {
const fileMenu = new import_obsidian2.Menu();
const filePath = searchResult.result.obj.filePath;
const file = plugin.app.vault.getAbstractFileByPath(filePath);
if (file) {
plugin.app.workspace.trigger("file-menu", fileMenu, file, "file-explorer");
if (isMouseEvent) {
fileMenu.showAtPosition({ x: e3.pageX, y: e3.pageY });
}
}
};
return /* @__PURE__ */ Sn.createElement("div", { key: searchResult.result.obj.filePath, className: "tree-item search-result" }, /* @__PURE__ */ Sn.createElement("div", { className: "tree-item-self search-result-file-title is-clickable" }, /* @__PURE__ */ Sn.createElement("div", { className: "tree-item-icon collapse-icon" }, open ? /* @__PURE__ */ Sn.createElement(MdKeyboardArrowDown, { onClick: () => setOpen(false) }) : /* @__PURE__ */ Sn.createElement(MdKeyboardArrowRight, { onClick: () => setOpen(true) })), /* @__PURE__ */ Sn.createElement(
"div",
{
className: "tree-item-inner",
onClick: openFileClicked,
onAuxClick,
onContextMenu: triggerContextMenu
},
getFileName(searchResult.result.obj.filePath)
)), open && ((_a = searchResult.highlightedResult) == null ? void 0 : _a.length) > 0 && /* @__PURE__ */ Sn.createElement("div", { className: "search-result-file-matches" }, /* @__PURE__ */ Sn.createElement(
"div",
{
className: "search-result-file-match",
onClick: openFileClicked,
dangerouslySetInnerHTML: { __html: searchResult.highlightedResult }
}
)));
};
// node_modules/react-icons/hi/index.esm.js
function HiChevronDoubleLeft(props2) {
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M15.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 010 1.414zm-6 0a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 011.414 1.414L5.414 10l4.293 4.293a1 1 0 010 1.414z", "clipRule": "evenodd" } }] })(props2);
}
function HiChevronDoubleRight(props2) {
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M10.293 15.707a1 1 0 010-1.414L14.586 10l-4.293-4.293a1 1 0 111.414-1.414l5 5a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0z", "clipRule": "evenodd" } }, { "tag": "path", "attr": { "fillRule": "evenodd", "d": "M4.293 15.707a1 1 0 010-1.414L8.586 10 4.293 5.707a1 1 0 011.414-1.414l5 5a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0z", "clipRule": "evenodd" } }] })(props2);
}
// src/modals.ts
var import_obsidian3 = require("obsidian");
var FolderToSaveSuggestionModal = class extends import_obsidian3.FuzzySuggestModal {
constructor(app, fileToSave, fileName) {
super(app);
this.fileName = fileName;
if (typeof fileToSave === "string") {
fileToSave = base64ToArrayBuffer(fileToSave);
}
this.fileToSave = fileToSave;
}
getItemText(item) {
return item.path;
}
getItems() {
return getAllFoldersInVault(this.app);
}
onChooseItem(item, evt) {
this.app.vault.createBinary(item.path + "/" + this.fileName, this.fileToSave);
}
};
function getAllFoldersInVault(app) {
let folders = [];
let rootFolder = app.vault.getRoot();
folders.push(rootFolder);
function recursiveFx(folder) {
for (let child of folder.children) {
if (child instanceof import_obsidian3.TFolder) {
let childFolder = child;
folders.push(childFolder);
if (childFolder.children)
recursiveFx(childFolder);
}
}
}
recursiveFx(rootFolder);
return folders;
}
// src/components/renderer/index.tsx
function RendererViewComponent(params) {
const { plugin, fileToRender } = params;
const [messageContent, setMessageContent] = p2();
h2(() => {
getMsgContent({ plugin, msgFile: fileToRender }).then((msgContent) => {
setMessageContent(msgContent);
});
}, []);
return messageContent && /* @__PURE__ */ Sn.createElement(Sn.Fragment, null, /* @__PURE__ */ Sn.createElement(MSGHeaderComponent, { messageContent }), /* @__PURE__ */ Sn.createElement(MSGBodyComponent, { messageContent }), messageContent.attachments.length > 0 && /* @__PURE__ */ Sn.createElement(MSGAttachmentsComponent, { messageAttachments: messageContent.attachments, plugin }));
}
var MSGHeaderComponent = (params) => {
const { messageContent } = params;
const [open, setOpen] = p2(true);
const toggleOpen = () => setOpen(!open);
return /* @__PURE__ */ Sn.createElement(Sn.Fragment, null, /* @__PURE__ */ Sn.createElement("h3", { onClick: toggleOpen, className: "oz-cursor-pointer oz-msg-header-name" }, /* @__PURE__ */ Sn.createElement(ToggleIndicator, { open }), "Message Header"), open && /* @__PURE__ */ Sn.createElement("div", { className: "oz-msg-handler-header" }, /* @__PURE__ */ Sn.createElement("strong", null, "From"), ": ", messageContent.senderName, " <", /* @__PURE__ */ Sn.createElement(
"a",
{
"aria-label": "mailTo:" + messageContent.senderEmail,
href: "mailTo:" + messageContent.senderEmail,
target: "_blank",
className: "external-link",
rel: "noopener"
},
messageContent.senderEmail
), ">", /* @__PURE__ */ Sn.createElement("br", null), /* @__PURE__ */ Sn.createElement("strong", null, "Recipients"), ": ", /* @__PURE__ */ Sn.createElement(RecipientList, { recipients: messageContent.recipients }), " ", /* @__PURE__ */ Sn.createElement("br", null), /* @__PURE__ */ Sn.createElement("strong", null, "Sent"), ": ", messageContent.creationTime, " ", /* @__PURE__ */ Sn.createElement("br", null), /* @__PURE__ */ Sn.createElement("strong", null, "Subject"), ": ", messageContent.subject));
};
var MSGBodyComponent = (params) => {
const { messageContent } = params;
const cleanMsgBody = (txt) => txt.replace(/[\r\n]+/g, "</br>");
const [open, setOpen] = p2(true);
const toggleOpen = () => setOpen(!open);
return /* @__PURE__ */ Sn.createElement(Sn.Fragment, null, /* @__PURE__ */ Sn.createElement("h3", { onClick: toggleOpen, className: "oz-cursor-pointer oz-msg-attachments-body-name" }, /* @__PURE__ */ Sn.createElement(ToggleIndicator, { open }), "Message Body"), open && /* @__PURE__ */ Sn.createElement(
"div",
{
className: "oz-msg-handler-body",
dangerouslySetInnerHTML: { __html: cleanMsgBody(messageContent.body) }
}
));
};
var MSGAttachmentsComponent = (params) => {
const { messageAttachments, plugin } = params;
const [open, setOpen] = p2(true);
const toggleOpen = () => setOpen(!open);
return /* @__PURE__ */ Sn.createElement(Sn.Fragment, null, /* @__PURE__ */ Sn.createElement("h3", { onClick: toggleOpen, className: "oz-cursor-pointer oz-msg-attachments-header-name" }, /* @__PURE__ */ Sn.createElement(ToggleIndicator, { open }), "Attachments"), open && /* @__PURE__ */ Sn.createElement("div", { className: "oz-msg-handler-attachments" }, messageAttachments.map((attachment) => {
return /* @__PURE__ */ Sn.createElement(
MSGSingleAttachmentComponent,
{
key: attachment.fileName,
messageAttachment: attachment,
plugin
}
);
})));
};
var MSGSingleAttachmentComponent = (params) => {
const { messageAttachment, plugin } = params;
const [open, setOpen] = p2(false);
const toggleOpen = () => setOpen(!open);
const saveFileToVault = () => {
let modal = new FolderToSaveSuggestionModal(
plugin.app,
messageAttachment.fileBase64,
messageAttachment.fileName
);
modal.open();
};
const imgExtensions = [".png", "png", ".jpg", "jpg", ".jpeg", "jpeg"];
return /* @__PURE__ */ Sn.createElement("div", { className: "oz-msg-single-attachment-wrapper" }, /* @__PURE__ */ Sn.createElement("div", { onClick: toggleOpen, className: "oz-cursor-pointer oz-msg-attachment-name" }, imgExtensions.includes(messageAttachment.fileExtension) ? /* @__PURE__ */ Sn.createElement(ToggleIndicator, { open }) : /* @__PURE__ */ Sn.createElement(MdClose, { className: "msg-handler-react-icon" }), messageAttachment.fileName, /* @__PURE__ */ Sn.createElement("button", { onClick: saveFileToVault }, "Save File to Vault")), open && /* @__PURE__ */ Sn.createElement("div", { className: "oz-msg-attachment-display" }, imgExtensions.includes(messageAttachment.fileExtension) && /* @__PURE__ */ Sn.createElement("img", { src: `data:image/jpeg;base64,${messageAttachment.fileBase64}` })));
};
var RecipientList = (params) => {
const { recipients } = params;
const [open, setOpen] = p2();
const moreThanOneRecipient = recipients.length > 1;
h2(() => setOpen(!moreThanOneRecipient), []);
return /* @__PURE__ */ Sn.createElement(Sn.Fragment, null, moreThanOneRecipient && (open ? /* @__PURE__ */ Sn.createElement(
HiChevronDoubleLeft,
{
className: "msg-handler-react-icon",
onClick: () => setOpen(false),
size: "18"
}
) : /* @__PURE__ */ Sn.createElement(
HiChevronDoubleRight,
{
className: "msg-handler-react-icon",
onClick: () => setOpen(true),
size: "18"
}
)), open && recipients.map((recipient) => {
return /* @__PURE__ */ Sn.createElement("span", { id: recipient.email }, recipient.name, " <", /* @__PURE__ */ Sn.createElement(
"a",
{
"aria-label": "mailTo:" + recipient.email,
href: "mailTo:" + recipient.email,
target: "_blank",
className: "external-link",
rel: "noopener"
},
recipient.email
), ">", recipients.length > 1 ? "; " : "");
}));
};
var ToggleIndicator = (params) => {
const { open } = params;
return open ? /* @__PURE__ */ Sn.createElement(MdKeyboardArrowDown, { className: "msg-handler-react-icon" }) : /* @__PURE__ */ Sn.createElement(MdKeyboardArrowRight, { className: "msg-handler-react-icon" });
};
// src/view.tsx
var renderMsgFileToElement = async (params) => {
const { msgFile, targetEl, plugin } = params;
return new Promise((resolve, reject) => {
Sn.render(
/* @__PURE__ */ Sn.createElement("div", { className: "msg-handler-plugin-renderer" }, /* @__PURE__ */ Sn.createElement(RendererViewComponent, { plugin, fileToRender: msgFile })),
targetEl,
() => resolve()
);
});
};
var RENDER_VIEW_TYPE = "msg-handler-view";
var MsgHandlerView = class extends import_obsidian4.FileView {
constructor(leaf, plugin) {
super(leaf);
this.plugin = plugin;
}
getViewType() {
return RENDER_VIEW_TYPE;
}
destroy() {
Sn.unmountComponentAtNode(this.contentEl);
}
async onLoadFile(file) {
this.constructMessageRenderView({ fileToRender: file });
this.fileToRender = file;
}
async constructMessageRenderView(params) {
this.destroy();
await renderMsgFileToElement({
msgFile: params.fileToRender,
targetEl: this.contentEl,
plugin: this.plugin
});
}
async onClose() {
this.plugin.cleanLoadedBlobs({ all: false, forMsgFile: this.fileToRender });
}
async onUnloadFile(file) {
this.contentEl.innerHTML = "";
super.onUnloadFile(file);
}
};
var SEARCH_VIEW_DISPLAY_TEXT = "MSG Handler Search";
var SEARCH_VIEW_TYPE = "msg-handler-search-view";
var ICON = "MSG_HANDLER_ENVELOPE_ICON";
var MsgHandlerSearchView = class extends import_obsidian4.ItemView {
constructor(leaf, plugin) {
super(leaf);
this.plugin = plugin;
}
getViewType() {
return SEARCH_VIEW_TYPE;
}
getDisplayText() {
return SEARCH_VIEW_DISPLAY_TEXT;
}
getIcon() {
return ICON;
}
destroy() {
Sn.unmountComponentAtNode(this.contentEl);
}
async onClose() {
this.destroy();
}
async onOpen() {
this.destroy();
this.constructMsgSearchView();
}
constructMsgSearchView() {
this.destroy();
Sn.render(
/* @__PURE__ */ Sn.createElement("div", { className: "msg-handler-plugin-search" }, /* @__PURE__ */ Sn.createElement(SearchViewComponent, { plugin: this.plugin })),
this.contentEl
);
}
};
// src/icons.ts
var MSG_HANDLER_ENVELOPE_ICON = `<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V10.85l1.24.72h.01q.1.07.18.18.07.12.07.25zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.8v-2.73zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z"/></svg>`;
// src/settings.ts
var import_obsidian5 = require("obsidian");
var DEFAULT_SETTINGS = {
searchEnabled: true,
logEnabled: false
};
var MSGHandlerPluginSettingsTab = class extends import_obsidian5.PluginSettingTab {
constructor(app, plugin) {
super(app, plugin);
this.plugin = plugin;
}
display() {
let { containerEl } = this;
const tipDiv = containerEl.createDiv("tip");
tipDiv.addClass("oz-msg-handler-tip-div");
const tipLink = tipDiv.createEl("a", { href: "https://revolut.me/ozante" });
const tipImg = tipLink.createEl("img", {
attr: {
src: "https://raw.githubusercontent.com/ozntel/file-tree-alternative/main/images/tip%20the%20artist_v2.png"
}
});
tipImg.height = 55;
const coffeeDiv = containerEl.createDiv("coffee");
coffeeDiv.addClass("oz-msg-handler-coffee-div");
const coffeeLink = coffeeDiv.createEl("a", { href: "https://ko-fi.com/L3L356V6Q" });
const coffeeImg = coffeeLink.createEl("img", {
attr: {
src: "https://cdn.ko-fi.com/cdn/kofi2.png?v=3"
}
});
coffeeImg.height = 45;
let headerSettings = containerEl.createEl("h1");
headerSettings.innerText = "MSG Handler Settings";
new import_obsidian5.Setting(containerEl).setName("MSG Search View").setDesc("Turn on if you want automatically to be opened Search View after each vault/plugin refresh").addToggle(
(toggle) => toggle.setValue(this.plugin.settings.searchEnabled).onChange((value) => {
this.plugin.settings.searchEnabled = value;
this.plugin.saveSettings();
if (value) {
this.plugin.openMsgHandlerSearchLeaf({ showAfterAttach: true });
} else {
this.plugin.detachMsgHandlerSearchLeaf();
}
})
);
new import_obsidian5.Setting(containerEl).setName("Plugin Logs in Console").setDesc("Turn on if you want to see the plugin logs within the console for actions").addToggle(
(toggle) => toggle.setValue(this.plugin.settings.logEnabled).onChange((value) => {
this.plugin.settings.logEnabled = value;
this.plugin.saveSettings();
})
);
}
};
// src/main.ts
var MsgHandlerPlugin = class extends import_obsidian6.Plugin {
constructor() {
super(...arguments);
this.acceptedExtensions = ["msg", "eml"];
this.ribbonIconEl = void 0;
// @API - SHARED WITH OZAN'S IMAGE IN EDITOR - DO NOT CHANGE OR SYNC BEFORE
this.renderMSG = async (params) => {
const { msgFile, targetEl } = params;
await renderMsgFileToElement({
msgFile,
targetEl,
plugin: this
});
};
// @API - SHARED WITH OZAN'S IMAGE IN EDITOR - DO NOT CHANGE OR SYNC BEFORE
this.cleanLoadedBlobs = (params) => {
};
this.openMsgHandlerSearchLeaf = async (params) => {
const { showAfterAttach } = params;
let leafs = this.app.workspace.getLeavesOfType(SEARCH_VIEW_TYPE);
if (leafs.length === 0) {
let leaf = this.app.workspace.getLeftLeaf(false);
await leaf.setViewState({ type: SEARCH_VIEW_TYPE });
if (showAfterAttach)
this.app.workspace.revealLeaf(leaf);
} else {
if (showAfterAttach && leafs.length > 0) {
this.app.workspace.revealLeaf(leafs[0]);
}
}
};
this.detachMsgHandlerSearchLeaf = () => {
let leafs = this.app.workspace.getLeavesOfType(SEARCH_VIEW_TYPE);
for (let leaf of leafs) {
leaf.view.destroy();
leaf.detach();
}
};
this.registerMsgExtensionView = () => {
try {
this.registerExtensions(this.acceptedExtensions, RENDER_VIEW_TYPE);
} catch (err) {
if (this.settings.logEnabled)
console.log("Msg file extension renderer was already registered");
}
};
/* --------------- EVENT HANDLERS FOR VAULT FILE CHANGES -------------- */
/**
* This function is created to handle "create" event for vault
* @param file
*/
this.handleFileCreate = async (file) => {
if (this.acceptedExtensions.contains(file.extension)) {
let dbMsgContents = await getDBMessageContentsByPath({ filePath: file.path });
if (dbMsgContents.length === 0) {
let msgContent = await getMsgContent({ plugin: this, msgFile: file });
createDBMessageContent({
msgContent,
file
});
if (this.settings.logEnabled)
console.log(`DB Index Record is created for ${file.path}`);
}
}
};
/**
* This function is created to handle "delete" event for vault
* @param file
*/
this.handleFileDelete = async (file) => {
if (this.acceptedExtensions.contains(file.extension)) {
let dbMsgContents = await getDBMessageContentsByPath({ filePath: file.path });
if (dbMsgContents.length > 0) {
for (let dbMsgContent of dbMsgContents) {
await deleteDBMessageContentById({ id: dbMsgContent.id });
if (this.settings.logEnabled)
console.log(`DB Index Record is deleted for ${file.path}`);
}
}
}
};
/**
* This function is created to handle "rename" event for vault
* @param file
* @param oldPath
*/
this.handleFileRename = async (file, oldPath) => {
await updateFilePathOfAllRecords({ oldValue: oldPath, newValue: file.path });
if (this.settings.logEnabled)
console.log(`DB Index Record is updated for ${file.path}`);
};
}
async onload() {
(0, import_obsidian6.addIcon)(ICON, MSG_HANDLER_ENVELOPE_ICON);
this.addSettingTab(new MSGHandlerPluginSettingsTab(this.app, this));
await this.loadSettings();
this.registerView(RENDER_VIEW_TYPE, (leaf) => {
return new MsgHandlerView(leaf, this);
});
this.registerView(SEARCH_VIEW_TYPE, (leaf) => {
return new MsgHandlerSearchView(leaf, this);
});
this.registerMsgExtensionView();
this.app.workspace.onLayoutReady(() => {
syncDatabaseWithVaultFiles({ plugin: this }).then(() => {
if (this.settings.logEnabled)
console.log("Vault DB Sync is completed for MSG Files");
});
this.openMsgHandlerSearchLeaf({ showAfterAttach: false });
});
this.registerMarkdownPostProcessor((el, ctx) => {
let msgElement = el.querySelector('.internal-embed[src$=".eml"]') || el.querySelector('.internal-embed[src$=".msg"]');
if (msgElement) {
let src = msgElement.getAttribute("src");
if (src) {
let msgFile = this.app.metadataCache.getFirstLinkpathDest(src, ctx.sourcePath);
if (msgFile) {
let parentMsgElement = msgElement.parentElement;
msgElement.remove();
let wrapperDiv = parentMsgElement.createEl("div");
wrapperDiv.addClass("oz-msg-handler-preview-render");
this.renderMSG({
msgFile,
targetEl: wrapperDiv
});
}
}
}
});
this.addCommand({
id: "reveal-msg-handler-search-leaf",
name: "Reveal Search Leaf",
callback: () => {
this.openMsgHandlerSearchLeaf({ showAfterAttach: true });
}
});
this.app.vault.on("create", this.handleFileCreate);
this.app.vault.on("delete", this.handleFileDelete);
this.app.vault.on("rename", this.handleFileRename);
this.ribbonIconEl = this.addRibbonIcon(ICON, "MSG Handler", async () => {
await this.openMsgHandlerSearchLeaf({ showAfterAttach: true });
});
}
onunload() {
this.app.vault.off("create", this.handleFileCreate);
this.app.vault.off("delete", this.handleFileDelete);
this.app.vault.off("rename", this.handleFileRename);
}
async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
}
async saveSettings() {
await this.saveData(this.settings);
}
};