{ "version": 3, "sources": ["../src_libs/tom-select.complete.js", "dockets.js", "../src/dockets_track.js", "../src/matter_widget.js", "../src/dockets.mjs"], "sourcesContent": ["/**\n* Tom Select v2.2.2\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n*/\n\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.TomSelect = factory());\n})(this, (function () { 'use strict';\n\n\t/**\n\t * MicroEvent - to make any js object an event emitter\n\t *\n\t * - pure javascript - server compatible, browser compatible\n\t * - dont rely on the browser doms\n\t * - super simple - you get it immediatly, no mistery, no magic involved\n\t *\n\t * @author Jerome Etienne (https://github.com/jeromeetienne)\n\t */\n\n\t/**\n\t * Execute callback for each event in space separated list of event names\n\t *\n\t */\n\tfunction forEvents(events, callback) {\n\t events.split(/\\s+/).forEach(event => {\n\t callback(event);\n\t });\n\t}\n\n\tclass MicroEvent {\n\t constructor() {\n\t this._events = void 0;\n\t this._events = {};\n\t }\n\n\t on(events, fct) {\n\t forEvents(events, event => {\n\t const event_array = this._events[event] || [];\n\t event_array.push(fct);\n\t this._events[event] = event_array;\n\t });\n\t }\n\n\t off(events, fct) {\n\t var n = arguments.length;\n\n\t if (n === 0) {\n\t this._events = {};\n\t return;\n\t }\n\n\t forEvents(events, event => {\n\t if (n === 1) {\n\t delete this._events[event];\n\t return;\n\t }\n\n\t const event_array = this._events[event];\n\t if (event_array === undefined) return;\n\t event_array.splice(event_array.indexOf(fct), 1);\n\t this._events[event] = event_array;\n\t });\n\t }\n\n\t trigger(events, ...args) {\n\t var self = this;\n\t forEvents(events, event => {\n\t const event_array = self._events[event];\n\t if (event_array === undefined) return;\n\t event_array.forEach(fct => {\n\t fct.apply(self, args);\n\t });\n\t });\n\t }\n\n\t}\n\n\t/**\n\t * microplugin.js\n\t * Copyright (c) 2013 Brian Reavis & contributors\n\t *\n\t * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this\n\t * file except in compliance with the License. You may obtain a copy of the License at:\n\t * http://www.apache.org/licenses/LICENSE-2.0\n\t *\n\t * Unless required by applicable law or agreed to in writing, software distributed under\n\t * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n\t * ANY KIND, either express or implied. See the License for the specific language\n\t * governing permissions and limitations under the License.\n\t *\n\t * @author Brian Reavis \n\t */\n\tfunction MicroPlugin(Interface) {\n\t Interface.plugins = {};\n\t return class extends Interface {\n\t constructor(...args) {\n\t super(...args);\n\t this.plugins = {\n\t names: [],\n\t settings: {},\n\t requested: {},\n\t loaded: {}\n\t };\n\t }\n\n\t /**\n\t * Registers a plugin.\n\t *\n\t * @param {function} fn\n\t */\n\t static define(name, fn) {\n\t Interface.plugins[name] = {\n\t 'name': name,\n\t 'fn': fn\n\t };\n\t }\n\t /**\n\t * Initializes the listed plugins (with options).\n\t * Acceptable formats:\n\t *\n\t * List (without options):\n\t * ['a', 'b', 'c']\n\t *\n\t * List (with options):\n\t * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]\n\t *\n\t * Hash (with options):\n\t * {'a': { ... }, 'b': { ... }, 'c': { ... }}\n\t *\n\t * @param {array|object} plugins\n\t */\n\n\n\t initializePlugins(plugins) {\n\t var key, name;\n\t const self = this;\n\t const queue = [];\n\n\t if (Array.isArray(plugins)) {\n\t plugins.forEach(plugin => {\n\t if (typeof plugin === 'string') {\n\t queue.push(plugin);\n\t } else {\n\t self.plugins.settings[plugin.name] = plugin.options;\n\t queue.push(plugin.name);\n\t }\n\t });\n\t } else if (plugins) {\n\t for (key in plugins) {\n\t if (plugins.hasOwnProperty(key)) {\n\t self.plugins.settings[key] = plugins[key];\n\t queue.push(key);\n\t }\n\t }\n\t }\n\n\t while (name = queue.shift()) {\n\t self.require(name);\n\t }\n\t }\n\n\t loadPlugin(name) {\n\t var self = this;\n\t var plugins = self.plugins;\n\t var plugin = Interface.plugins[name];\n\n\t if (!Interface.plugins.hasOwnProperty(name)) {\n\t throw new Error('Unable to find \"' + name + '\" plugin');\n\t }\n\n\t plugins.requested[name] = true;\n\t plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);\n\t plugins.names.push(name);\n\t }\n\t /**\n\t * Initializes a plugin.\n\t *\n\t */\n\n\n\t require(name) {\n\t var self = this;\n\t var plugins = self.plugins;\n\n\t if (!self.plugins.loaded.hasOwnProperty(name)) {\n\t if (plugins.requested[name]) {\n\t throw new Error('Plugin has circular dependency (\"' + name + '\")');\n\t }\n\n\t self.loadPlugin(name);\n\t }\n\n\t return plugins.loaded[name];\n\t }\n\n\t };\n\t}\n\n\t/*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */\n\t/**\n\t * Convert array of strings to a regular expression\n\t *\tex ['ab','a'] => (?:ab|a)\n\t * \tex ['a','b'] => [ab]\n\t * @param {string[]} chars\n\t * @return {string}\n\t */\n\tconst arrayToPattern = chars => {\n\t chars = chars.filter(Boolean);\n\n\t if (chars.length < 2) {\n\t return chars[0] || '';\n\t }\n\n\t return maxValueLength(chars) == 1 ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';\n\t};\n\t/**\n\t * @param {string[]} array\n\t * @return {string}\n\t */\n\n\tconst sequencePattern = array => {\n\t if (!hasDuplicates(array)) {\n\t return array.join('');\n\t }\n\n\t let pattern = '';\n\t let prev_char_count = 0;\n\n\t const prev_pattern = () => {\n\t if (prev_char_count > 1) {\n\t pattern += '{' + prev_char_count + '}';\n\t }\n\t };\n\n\t array.forEach((char, i) => {\n\t if (char === array[i - 1]) {\n\t prev_char_count++;\n\t return;\n\t }\n\n\t prev_pattern();\n\t pattern += char;\n\t prev_char_count = 1;\n\t });\n\t prev_pattern();\n\t return pattern;\n\t};\n\t/**\n\t * Convert array of strings to a regular expression\n\t *\tex ['ab','a'] => (?:ab|a)\n\t * \tex ['a','b'] => [ab]\n\t * @param {Set} chars\n\t * @return {string}\n\t */\n\n\tconst setToPattern = chars => {\n\t let array = toArray(chars);\n\t return arrayToPattern(array);\n\t};\n\t/**\n\t *\n\t * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values\n\t * @param {any[]} array\n\t */\n\n\tconst hasDuplicates = array => {\n\t return new Set(array).size !== array.length;\n\t};\n\t/**\n\t * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error\n\t * @param {string} str\n\t * @return {string}\n\t */\n\n\tconst escape_regex = str => {\n\t return (str + '').replace(/([\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\|\\}\\\\])/gu, '\\\\$1');\n\t};\n\t/**\n\t * Return the max length of array values\n\t * @param {string[]} array\n\t *\n\t */\n\n\tconst maxValueLength = array => {\n\t return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);\n\t};\n\t/**\n\t * @param {string} str\n\t */\n\n\tconst unicodeLength = str => {\n\t return toArray(str).length;\n\t};\n\t/**\n\t * @param {any} p\n\t * @return {any[]}\n\t */\n\n\tconst toArray = p => Array.from(p);\n\n\t/*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */\n\t/**\n\t * Get all possible combinations of substrings that add up to the given string\n\t * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string\n\t * @param {string} input\n\t * @return {string[][]}\n\t */\n\tconst allSubstrings = input => {\n\t if (input.length === 1) return [[input]];\n\t /** @type {string[][]} */\n\n\t let result = [];\n\t const start = input.substring(1);\n\t const suba = allSubstrings(start);\n\t suba.forEach(function (subresult) {\n\t let tmp = subresult.slice(0);\n\t tmp[0] = input.charAt(0) + tmp[0];\n\t result.push(tmp);\n\t tmp = subresult.slice(0);\n\t tmp.unshift(input.charAt(0));\n\t result.push(tmp);\n\t });\n\t return result;\n\t};\n\n\t/*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */\n\n\t/**\n\t * @typedef {{[key:string]:string}} TUnicodeMap\n\t * @typedef {{[key:string]:Set}} TUnicodeSets\n\t * @typedef {[[number,number]]} TCodePoints\n\t * @typedef {{folded:string,composed:string,code_point:number}} TCodePointObj\n\t * @typedef {{start:number,end:number,length:number,substr:string}} TSequencePart\n\t */\n\t/** @type {TCodePoints} */\n\n\tconst code_points = [[0, 65535]];\n\tconst accent_pat = '[\\u0300-\\u036F\\u{b7}\\u{2be}\\u{2bc}]';\n\t/** @type {TUnicodeMap} */\n\n\tlet unicode_map;\n\t/** @type {RegExp} */\n\n\tlet multi_char_reg;\n\tconst max_char_length = 3;\n\t/** @type {TUnicodeMap} */\n\n\tconst latin_convert = {};\n\t/** @type {TUnicodeMap} */\n\n\tconst latin_condensed = {\n\t '/': '\u2044\u2215',\n\t '0': '\u07C0',\n\t \"a\": \"\u2C65\u0250\u0251\",\n\t \"aa\": \"\uA733\",\n\t \"ae\": \"\u00E6\u01FD\u01E3\",\n\t \"ao\": \"\uA735\",\n\t \"au\": \"\uA737\",\n\t \"av\": \"\uA739\uA73B\",\n\t \"ay\": \"\uA73D\",\n\t \"b\": \"\u0180\u0253\u0183\",\n\t \"c\": \"\uA73F\u0188\u023C\u2184\",\n\t \"d\": \"\u0111\u0257\u0256\u1D05\u018C\uABB7\u0501\u0266\",\n\t \"e\": \"\u025B\u01DD\u1D07\u0247\",\n\t \"f\": \"\uA77C\u0192\",\n\t \"g\": \"\u01E5\u0260\uA7A1\u1D79\uA77F\u0262\",\n\t \"h\": \"\u0127\u2C68\u2C76\u0265\",\n\t \"i\": \"\u0268\u0131\",\n\t \"j\": \"\u0249\u0237\",\n\t \"k\": \"\u0199\u2C6A\uA741\uA743\uA745\uA7A3\",\n\t \"l\": \"\u0142\u019A\u026B\u2C61\uA749\uA747\uA781\u026D\",\n\t \"m\": \"\u0271\u026F\u03FB\",\n\t \"n\": \"\uA7A5\u019E\u0272\uA791\u1D0E\u043B\u0509\",\n\t \"o\": \"\u00F8\u01FF\u0254\u0275\uA74B\uA74D\u1D11\",\n\t \"oe\": \"\u0153\",\n\t \"oi\": \"\u01A3\",\n\t \"oo\": \"\uA74F\",\n\t \"ou\": \"\u0223\",\n\t \"p\": \"\u01A5\u1D7D\uA751\uA753\uA755\u03C1\",\n\t \"q\": \"\uA757\uA759\u024B\",\n\t \"r\": \"\u024D\u027D\uA75B\uA7A7\uA783\",\n\t \"s\": \"\u00DF\u023F\uA7A9\uA785\u0282\",\n\t \"t\": \"\u0167\u01AD\u0288\u2C66\uA787\",\n\t \"th\": \"\u00FE\",\n\t \"tz\": \"\uA729\",\n\t \"u\": \"\u0289\",\n\t \"v\": \"\u028B\uA75F\u028C\",\n\t \"vy\": \"\uA761\",\n\t \"w\": \"\u2C73\",\n\t \"y\": \"\u01B4\u024F\u1EFF\",\n\t \"z\": \"\u01B6\u0225\u0240\u2C6C\uA763\",\n\t \"hv\": \"\u0195\"\n\t};\n\n\tfor (let latin in latin_condensed) {\n\t let unicode = latin_condensed[latin] || '';\n\n\t for (let i = 0; i < unicode.length; i++) {\n\t let char = unicode.substring(i, i + 1);\n\t latin_convert[char] = latin;\n\t }\n\t}\n\n\tconst convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');\n\t/**\n\t * Initialize the unicode_map from the give code point ranges\n\t *\n\t * @param {TCodePoints=} _code_points\n\t */\n\n\tconst initialize = _code_points => {\n\t if (unicode_map !== undefined) return;\n\t unicode_map = generateMap(_code_points || code_points);\n\t};\n\t/**\n\t * Helper method for normalize a string\n\t * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize\n\t * @param {string} str\n\t * @param {string} form\n\t */\n\n\tconst normalize = (str, form = 'NFKD') => str.normalize(form);\n\t/**\n\t * Remove accents without reordering string\n\t * calling str.normalize('NFKD') on \\u{594}\\u{595}\\u{596} becomes \\u{596}\\u{594}\\u{595}\n\t * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703\n\t * @param {string} str\n\t * @return {string}\n\t */\n\n\tconst asciifold = str => {\n\t return toArray(str).reduce(\n\t /**\n\t * @param {string} result\n\t * @param {string} char\n\t */\n\t (result, char) => {\n\t return result + _asciifold(char);\n\t }, '');\n\t};\n\t/**\n\t * @param {string} str\n\t * @return {string}\n\t */\n\n\tconst _asciifold = str => {\n\t str = normalize(str).toLowerCase().replace(convert_pat, (\n\t /** @type {string} */\n\t char) => {\n\t return latin_convert[char] || '';\n\t }); //return str;\n\n\t return normalize(str, 'NFC');\n\t};\n\t/**\n\t * Generate a list of unicode variants from the list of code points\n\t * @param {TCodePoints} code_points\n\t * @yield {TCodePointObj}\n\t */\n\n\tfunction* generator(code_points) {\n\t for (const [code_point_min, code_point_max] of code_points) {\n\t for (let i = code_point_min; i <= code_point_max; i++) {\n\t let composed = String.fromCharCode(i);\n\t let folded = asciifold(composed);\n\n\t if (folded == composed.toLowerCase()) {\n\t continue;\n\t } // skip when folded is a string longer than 3 characters long\n\t // bc the resulting regex patterns will be long\n\t // eg:\n\t // folded \u0635\u0644\u0649 \u0627\u0644\u0644\u0647 \u0639\u0644\u064A\u0647 \u0648\u0633\u0644\u0645 length 18 code point 65018\n\t // folded \u062C\u0644 \u062C\u0644\u0627\u0644\u0647 length 8 code point 65019\n\n\n\t if (folded.length > max_char_length) {\n\t continue;\n\t }\n\n\t if (folded.length == 0) {\n\t continue;\n\t }\n\n\t yield {\n\t folded: folded,\n\t composed: composed,\n\t code_point: i\n\t };\n\t }\n\t }\n\t}\n\t/**\n\t * Generate a unicode map from the list of code points\n\t * @param {TCodePoints} code_points\n\t * @return {TUnicodeSets}\n\t */\n\n\tconst generateSets = code_points => {\n\t /** @type {{[key:string]:Set}} */\n\t const unicode_sets = {};\n\t /**\n\t * @param {string} folded\n\t * @param {string} to_add\n\t */\n\n\t const addMatching = (folded, to_add) => {\n\t /** @type {Set} */\n\t const folded_set = unicode_sets[folded] || new Set();\n\t const patt = new RegExp('^' + setToPattern(folded_set) + '$', 'iu');\n\n\t if (to_add.match(patt)) {\n\t return;\n\t }\n\n\t folded_set.add(escape_regex(to_add));\n\t unicode_sets[folded] = folded_set;\n\t };\n\n\t for (let value of generator(code_points)) {\n\t addMatching(value.folded, value.folded);\n\t addMatching(value.folded, value.composed);\n\t }\n\n\t return unicode_sets;\n\t};\n\t/**\n\t * Generate a unicode map from the list of code points\n\t * ae => (?:(?:ae|\u00C6|\u01FC|\u01E2)|(?:A|\u24B6|\uFF21...)(?:E|\u025B|\u24BA...))\n\t *\n\t * @param {TCodePoints} code_points\n\t * @return {TUnicodeMap}\n\t */\n\n\tconst generateMap = code_points => {\n\t /** @type {TUnicodeSets} */\n\t const unicode_sets = generateSets(code_points);\n\t /** @type {TUnicodeMap} */\n\n\t const unicode_map = {};\n\t /** @type {string[]} */\n\n\t let multi_char = [];\n\n\t for (let folded in unicode_sets) {\n\t let set = unicode_sets[folded];\n\n\t if (set) {\n\t unicode_map[folded] = setToPattern(set);\n\t }\n\n\t if (folded.length > 1) {\n\t multi_char.push(escape_regex(folded));\n\t }\n\t }\n\n\t multi_char.sort((a, b) => b.length - a.length);\n\t const multi_char_patt = arrayToPattern(multi_char);\n\t multi_char_reg = new RegExp('^' + multi_char_patt, 'u');\n\t return unicode_map;\n\t};\n\t/**\n\t * Map each element of an array from it's folded value to all possible unicode matches\n\t * @param {string[]} strings\n\t * @param {number} min_replacement\n\t * @return {string}\n\t */\n\n\tconst mapSequence = (strings, min_replacement = 1) => {\n\t let chars_replaced = 0;\n\t strings = strings.map(str => {\n\t if (unicode_map[str]) {\n\t chars_replaced += str.length;\n\t }\n\n\t return unicode_map[str] || str;\n\t });\n\n\t if (chars_replaced >= min_replacement) {\n\t return sequencePattern(strings);\n\t }\n\n\t return '';\n\t};\n\t/**\n\t * Convert a short string and split it into all possible patterns\n\t * Keep a pattern only if min_replacement is met\n\t *\n\t * 'abc'\n\t * \t\t=> [['abc'],['ab','c'],['a','bc'],['a','b','c']]\n\t *\t\t=> ['abc-pattern','ab-c-pattern'...]\n\t *\n\t *\n\t * @param {string} str\n\t * @param {number} min_replacement\n\t * @return {string}\n\t */\n\n\tconst substringsToPattern = (str, min_replacement = 1) => {\n\t min_replacement = Math.max(min_replacement, str.length - 1);\n\t return arrayToPattern(allSubstrings(str).map(sub_pat => {\n\t return mapSequence(sub_pat, min_replacement);\n\t }));\n\t};\n\t/**\n\t * Convert an array of sequences into a pattern\n\t * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)\n\t *\n\t * @param {Sequence[]} sequences\n\t * @param {boolean} all\n\t */\n\n\tconst sequencesToPattern = (sequences, all = true) => {\n\t let min_replacement = sequences.length > 1 ? 1 : 0;\n\t return arrayToPattern(sequences.map(sequence => {\n\t let seq = [];\n\t const len = all ? sequence.length() : sequence.length() - 1;\n\n\t for (let j = 0; j < len; j++) {\n\t seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));\n\t }\n\n\t return sequencePattern(seq);\n\t }));\n\t};\n\t/**\n\t * Return true if the sequence is already in the sequences\n\t * @param {Sequence} needle_seq\n\t * @param {Sequence[]} sequences\n\t */\n\n\n\tconst inSequences = (needle_seq, sequences) => {\n\t for (const seq of sequences) {\n\t if (seq.start != needle_seq.start || seq.end != needle_seq.end) {\n\t continue;\n\t }\n\n\t if (seq.substrs.join('') !== needle_seq.substrs.join('')) {\n\t continue;\n\t }\n\n\t let needle_parts = needle_seq.parts;\n\t /**\n\t * @param {TSequencePart} part\n\t */\n\n\t const filter = part => {\n\t for (const needle_part of needle_parts) {\n\t if (needle_part.start === part.start && needle_part.substr === part.substr) {\n\t return false;\n\t }\n\n\t if (part.length == 1 || needle_part.length == 1) {\n\t continue;\n\t } // check for overlapping parts\n\t // a = ['::=','==']\n\t // b = ['::','===']\n\t // a = ['r','sm']\n\t // b = ['rs','m']\n\n\n\t if (part.start < needle_part.start && part.end > needle_part.start) {\n\t return true;\n\t }\n\n\t if (needle_part.start < part.start && needle_part.end > part.start) {\n\t return true;\n\t }\n\t }\n\n\t return false;\n\t };\n\n\t let filtered = seq.parts.filter(filter);\n\n\t if (filtered.length > 0) {\n\t continue;\n\t }\n\n\t return true;\n\t }\n\n\t return false;\n\t};\n\n\tclass Sequence {\n\t constructor() {\n\t /** @type {TSequencePart[]} */\n\t this.parts = [];\n\t /** @type {string[]} */\n\n\t this.substrs = [];\n\t this.start = 0;\n\t this.end = 0;\n\t }\n\t /**\n\t * @param {TSequencePart|undefined} part\n\t */\n\n\n\t add(part) {\n\t if (part) {\n\t this.parts.push(part);\n\t this.substrs.push(part.substr);\n\t this.start = Math.min(part.start, this.start);\n\t this.end = Math.max(part.end, this.end);\n\t }\n\t }\n\n\t last() {\n\t return this.parts[this.parts.length - 1];\n\t }\n\n\t length() {\n\t return this.parts.length;\n\t }\n\t /**\n\t * @param {number} position\n\t * @param {TSequencePart} last_piece\n\t */\n\n\n\t clone(position, last_piece) {\n\t let clone = new Sequence();\n\t let parts = JSON.parse(JSON.stringify(this.parts));\n\t let last_part = parts.pop();\n\n\t for (const part of parts) {\n\t clone.add(part);\n\t }\n\n\t let last_substr = last_piece.substr.substring(0, position - last_part.start);\n\t let clone_last_len = last_substr.length;\n\t clone.add({\n\t start: last_part.start,\n\t end: last_part.start + clone_last_len,\n\t length: clone_last_len,\n\t substr: last_substr\n\t });\n\t return clone;\n\t }\n\n\t}\n\t/**\n\t * Expand a regular expression pattern to include unicode variants\n\t * \teg /a/ becomes /a\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250\u0251A\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F/\n\t *\n\t * Issue:\n\t * \uFE8A\uFE8B [ '\uFE8A = \\\\u{fe8a}', '\uFE8B = \\\\u{fe8b}' ]\n\t *\tbecomes:\t\u064A\u0654\u064A\u0654 [ '\u064A = \\\\u{64a}', '\u0654 = \\\\u{654}', '\u064A = \\\\u{64a}', '\u0654 = \\\\u{654}' ]\n\t *\n\t *\t\u0130\u0132 = IIJ = \u2161J\n\t *\n\t * \t1/2/4\n\t *\n\t * @param {string} str\n\t * @return {string|undefined}\n\t */\n\n\n\tconst getPattern = str => {\n\t initialize();\n\t str = asciifold(str);\n\t let pattern = '';\n\t let sequences = [new Sequence()];\n\n\t for (let i = 0; i < str.length; i++) {\n\t let substr = str.substring(i);\n\t let match = substr.match(multi_char_reg);\n\t const char = str.substring(i, i + 1);\n\t const match_str = match ? match[0] : null; // loop through sequences\n\t // add either the char or multi_match\n\n\t let overlapping = [];\n\t let added_types = new Set();\n\n\t for (const sequence of sequences) {\n\t const last_piece = sequence.last();\n\n\t if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {\n\t // if we have a multi match\n\t if (match_str) {\n\t const len = match_str.length;\n\t sequence.add({\n\t start: i,\n\t end: i + len,\n\t length: len,\n\t substr: match_str\n\t });\n\t added_types.add('1');\n\t } else {\n\t sequence.add({\n\t start: i,\n\t end: i + 1,\n\t length: 1,\n\t substr: char\n\t });\n\t added_types.add('2');\n\t }\n\t } else if (match_str) {\n\t let clone = sequence.clone(i, last_piece);\n\t const len = match_str.length;\n\t clone.add({\n\t start: i,\n\t end: i + len,\n\t length: len,\n\t substr: match_str\n\t });\n\t overlapping.push(clone);\n\t } else {\n\t // don't add char\n\t // adding would create invalid patterns: 234 => [2,34,4]\n\t added_types.add('3');\n\t }\n\t } // if we have overlapping\n\n\n\t if (overlapping.length > 0) {\n\t // ['ii','iii'] before ['i','i','iii']\n\t overlapping = overlapping.sort((a, b) => {\n\t return a.length() - b.length();\n\t });\n\n\t for (let clone of overlapping) {\n\t // don't add if we already have an equivalent sequence\n\t if (inSequences(clone, sequences)) {\n\t continue;\n\t }\n\n\t sequences.push(clone);\n\t }\n\n\t continue;\n\t } // if we haven't done anything unique\n\t // clean up the patterns\n\t // helps keep patterns smaller\n\t // if str = 'r\u20A8\u33A7aarss', pattern will be 446 instead of 655\n\n\n\t if (i > 0 && added_types.size == 1 && !added_types.has('3')) {\n\t pattern += sequencesToPattern(sequences, false);\n\t let new_seq = new Sequence();\n\t const old_seq = sequences[0];\n\n\t if (old_seq) {\n\t new_seq.add(old_seq.last());\n\t }\n\n\t sequences = [new_seq];\n\t }\n\t }\n\n\t pattern += sequencesToPattern(sequences, true);\n\t return pattern;\n\t};\n\n\t/*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */\n\n\t/**\n\t * A property getter resolving dot-notation\n\t * @param {Object} obj The root object to fetch property on\n\t * @param {String} name The optionally dotted property name to fetch\n\t * @return {Object} The resolved property value\n\t */\n\tconst getAttr = (obj, name) => {\n\t if (!obj) return;\n\t return obj[name];\n\t};\n\t/**\n\t * A property getter resolving dot-notation\n\t * @param {Object} obj The root object to fetch property on\n\t * @param {String} name The optionally dotted property name to fetch\n\t * @return {Object} The resolved property value\n\t */\n\n\tconst getAttrNesting = (obj, name) => {\n\t if (!obj) return;\n\t var part,\n\t names = name.split(\".\");\n\n\t while ((part = names.shift()) && (obj = obj[part]));\n\n\t return obj;\n\t};\n\t/**\n\t * Calculates how close of a match the\n\t * given value is against a search token.\n\t *\n\t */\n\n\tconst scoreValue = (value, token, weight) => {\n\t var score, pos;\n\t if (!value) return 0;\n\t value = value + '';\n\t if (token.regex == null) return 0;\n\t pos = value.search(token.regex);\n\t if (pos === -1) return 0;\n\t score = token.string.length / value.length;\n\t if (pos === 0) score += 0.5;\n\t return score * weight;\n\t};\n\t/**\n\t * Cast object property to an array if it exists and has a value\n\t *\n\t */\n\n\tconst propToArray = (obj, key) => {\n\t var value = obj[key];\n\t if (typeof value == 'function') return value;\n\n\t if (value && !Array.isArray(value)) {\n\t obj[key] = [value];\n\t }\n\t};\n\t/**\n\t * Iterates over arrays and hashes.\n\t *\n\t * ```\n\t * iterate(this.items, function(item, id) {\n\t * // invoked for each item\n\t * });\n\t * ```\n\t *\n\t */\n\n\tconst iterate$1 = (object, callback) => {\n\t if (Array.isArray(object)) {\n\t object.forEach(callback);\n\t } else {\n\t for (var key in object) {\n\t if (object.hasOwnProperty(key)) {\n\t callback(object[key], key);\n\t }\n\t }\n\t }\n\t};\n\tconst cmp = (a, b) => {\n\t if (typeof a === 'number' && typeof b === 'number') {\n\t return a > b ? 1 : a < b ? -1 : 0;\n\t }\n\n\t a = asciifold(a + '').toLowerCase();\n\t b = asciifold(b + '').toLowerCase();\n\t if (a > b) return 1;\n\t if (b > a) return -1;\n\t return 0;\n\t};\n\n\t/*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */\n\n\t/**\n\t * sifter.js\n\t * Copyright (c) 2013\u20132020 Brian Reavis & contributors\n\t *\n\t * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this\n\t * file except in compliance with the License. You may obtain a copy of the License at:\n\t * http://www.apache.org/licenses/LICENSE-2.0\n\t *\n\t * Unless required by applicable law or agreed to in writing, software distributed under\n\t * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n\t * ANY KIND, either express or implied. See the License for the specific language\n\t * governing permissions and limitations under the License.\n\t *\n\t * @author Brian Reavis \n\t */\n\n\tclass Sifter {\n\t // []|{};\n\n\t /**\n\t * Textually searches arrays and hashes of objects\n\t * by property (or multiple properties). Designed\n\t * specifically for autocomplete.\n\t *\n\t */\n\t constructor(items, settings) {\n\t this.items = void 0;\n\t this.settings = void 0;\n\t this.items = items;\n\t this.settings = settings || {\n\t diacritics: true\n\t };\n\t }\n\n\t /**\n\t * Splits a search string into an array of individual\n\t * regexps to be used to match results.\n\t *\n\t */\n\t tokenize(query, respect_word_boundaries, weights) {\n\t if (!query || !query.length) return [];\n\t const tokens = [];\n\t const words = query.split(/\\s+/);\n\t var field_regex;\n\n\t if (weights) {\n\t field_regex = new RegExp('^(' + Object.keys(weights).map(escape_regex).join('|') + ')\\:(.*)$');\n\t }\n\n\t words.forEach(word => {\n\t let field_match;\n\t let field = null;\n\t let regex = null; // look for \"field:query\" tokens\n\n\t if (field_regex && (field_match = word.match(field_regex))) {\n\t field = field_match[1];\n\t word = field_match[2];\n\t }\n\n\t if (word.length > 0) {\n\t if (this.settings.diacritics) {\n\t regex = getPattern(word) || null;\n\t } else {\n\t regex = escape_regex(word);\n\t }\n\n\t if (regex && respect_word_boundaries) regex = \"\\\\b\" + regex;\n\t }\n\n\t tokens.push({\n\t string: word,\n\t regex: regex ? new RegExp(regex, 'iu') : null,\n\t field: field\n\t });\n\t });\n\t return tokens;\n\t }\n\n\t /**\n\t * Returns a function to be used to score individual results.\n\t *\n\t * Good matches will have a higher score than poor matches.\n\t * If an item is not a match, 0 will be returned by the function.\n\t *\n\t * @returns {T.ScoreFn}\n\t */\n\t getScoreFunction(query, options) {\n\t var search = this.prepareSearch(query, options);\n\t return this._getScoreFunction(search);\n\t }\n\t /**\n\t * @returns {T.ScoreFn}\n\t *\n\t */\n\n\n\t _getScoreFunction(search) {\n\t const tokens = search.tokens,\n\t token_count = tokens.length;\n\n\t if (!token_count) {\n\t return function () {\n\t return 0;\n\t };\n\t }\n\n\t const fields = search.options.fields,\n\t weights = search.weights,\n\t field_count = fields.length,\n\t getAttrFn = search.getAttrFn;\n\n\t if (!field_count) {\n\t return function () {\n\t return 1;\n\t };\n\t }\n\t /**\n\t * Calculates the score of an object\n\t * against the search query.\n\t *\n\t */\n\n\n\t const scoreObject = function () {\n\t if (field_count === 1) {\n\t return function (token, data) {\n\t const field = fields[0].field;\n\t return scoreValue(getAttrFn(data, field), token, weights[field] || 1);\n\t };\n\t }\n\n\t return function (token, data) {\n\t var sum = 0; // is the token specific to a field?\n\n\t if (token.field) {\n\t const value = getAttrFn(data, token.field);\n\n\t if (!token.regex && value) {\n\t sum += 1 / field_count;\n\t } else {\n\t sum += scoreValue(value, token, 1);\n\t }\n\t } else {\n\t iterate$1(weights, (weight, field) => {\n\t sum += scoreValue(getAttrFn(data, field), token, weight);\n\t });\n\t }\n\n\t return sum / field_count;\n\t };\n\t }();\n\n\t if (token_count === 1) {\n\t return function (data) {\n\t return scoreObject(tokens[0], data);\n\t };\n\t }\n\n\t if (search.options.conjunction === 'and') {\n\t return function (data) {\n\t var score,\n\t sum = 0;\n\n\t for (let token of tokens) {\n\t score = scoreObject(token, data);\n\t if (score <= 0) return 0;\n\t sum += score;\n\t }\n\n\t return sum / token_count;\n\t };\n\t } else {\n\t return function (data) {\n\t var sum = 0;\n\t iterate$1(tokens, token => {\n\t sum += scoreObject(token, data);\n\t });\n\t return sum / token_count;\n\t };\n\t }\n\t }\n\n\t /**\n\t * Returns a function that can be used to compare two\n\t * results, for sorting purposes. If no sorting should\n\t * be performed, `null` will be returned.\n\t *\n\t * @return function(a,b)\n\t */\n\t getSortFunction(query, options) {\n\t var search = this.prepareSearch(query, options);\n\t return this._getSortFunction(search);\n\t }\n\n\t _getSortFunction(search) {\n\t var implicit_score,\n\t sort_flds = [];\n\t const self = this,\n\t options = search.options,\n\t sort = !search.query && options.sort_empty ? options.sort_empty : options.sort;\n\n\t if (typeof sort == 'function') {\n\t return sort.bind(this);\n\t }\n\t /**\n\t * Fetches the specified sort field value\n\t * from a search result item.\n\t *\n\t */\n\n\n\t const get_field = function get_field(name, result) {\n\t if (name === '$score') return result.score;\n\t return search.getAttrFn(self.items[result.id], name);\n\t }; // parse options\n\n\n\t if (sort) {\n\t for (let s of sort) {\n\t if (search.query || s.field !== '$score') {\n\t sort_flds.push(s);\n\t }\n\t }\n\t } // the \"$score\" field is implied to be the primary\n\t // sort field, unless it's manually specified\n\n\n\t if (search.query) {\n\t implicit_score = true;\n\n\t for (let fld of sort_flds) {\n\t if (fld.field === '$score') {\n\t implicit_score = false;\n\t break;\n\t }\n\t }\n\n\t if (implicit_score) {\n\t sort_flds.unshift({\n\t field: '$score',\n\t direction: 'desc'\n\t });\n\t } // without a search.query, all items will have the same score\n\n\t } else {\n\t sort_flds = sort_flds.filter(fld => fld.field !== '$score');\n\t } // build function\n\n\n\t const sort_flds_count = sort_flds.length;\n\n\t if (!sort_flds_count) {\n\t return null;\n\t }\n\n\t return function (a, b) {\n\t var result, field;\n\n\t for (let sort_fld of sort_flds) {\n\t field = sort_fld.field;\n\t let multiplier = sort_fld.direction === 'desc' ? -1 : 1;\n\t result = multiplier * cmp(get_field(field, a), get_field(field, b));\n\t if (result) return result;\n\t }\n\n\t return 0;\n\t };\n\t }\n\n\t /**\n\t * Parses a search query and returns an object\n\t * with tokens and fields ready to be populated\n\t * with results.\n\t *\n\t */\n\t prepareSearch(query, optsUser) {\n\t const weights = {};\n\t var options = Object.assign({}, optsUser);\n\t propToArray(options, 'sort');\n\t propToArray(options, 'sort_empty'); // convert fields to new format\n\n\t if (options.fields) {\n\t propToArray(options, 'fields');\n\t const fields = [];\n\t options.fields.forEach(field => {\n\t if (typeof field == 'string') {\n\t field = {\n\t field: field,\n\t weight: 1\n\t };\n\t }\n\n\t fields.push(field);\n\t weights[field.field] = 'weight' in field ? field.weight : 1;\n\t });\n\t options.fields = fields;\n\t }\n\n\t return {\n\t options: options,\n\t query: query.toLowerCase().trim(),\n\t tokens: this.tokenize(query, options.respect_word_boundaries, weights),\n\t total: 0,\n\t items: [],\n\t weights: weights,\n\t getAttrFn: options.nesting ? getAttrNesting : getAttr\n\t };\n\t }\n\n\t /**\n\t * Searches through all items and returns a sorted array of matches.\n\t *\n\t */\n\t search(query, options) {\n\t var self = this,\n\t score,\n\t search;\n\t search = this.prepareSearch(query, options);\n\t options = search.options;\n\t query = search.query; // generate result scoring function\n\n\t const fn_score = options.score || self._getScoreFunction(search); // perform search and sort\n\n\n\t if (query.length) {\n\t iterate$1(self.items, (item, id) => {\n\t score = fn_score(item);\n\n\t if (options.filter === false || score > 0) {\n\t search.items.push({\n\t 'score': score,\n\t 'id': id\n\t });\n\t }\n\t });\n\t } else {\n\t iterate$1(self.items, (_, id) => {\n\t search.items.push({\n\t 'score': 1,\n\t 'id': id\n\t });\n\t });\n\t }\n\n\t const fn_sort = self._getSortFunction(search);\n\n\t if (fn_sort) search.items.sort(fn_sort); // apply limits\n\n\t search.total = search.items.length;\n\n\t if (typeof options.limit === 'number') {\n\t search.items = search.items.slice(0, options.limit);\n\t }\n\n\t return search;\n\t }\n\n\t}\n\n\t/**\n\t * Iterates over arrays and hashes.\n\t *\n\t * ```\n\t * iterate(this.items, function(item, id) {\n\t * // invoked for each item\n\t * });\n\t * ```\n\t *\n\t */\n\n\tconst iterate = (object, callback) => {\n\t if (Array.isArray(object)) {\n\t object.forEach(callback);\n\t } else {\n\t for (var key in object) {\n\t if (object.hasOwnProperty(key)) {\n\t callback(object[key], key);\n\t }\n\t }\n\t }\n\t};\n\n\t/**\n\t * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n\t * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n\t *\n\t * param query should be {}\n\t */\n\n\tconst getDom = query => {\n\t if (query.jquery) {\n\t return query[0];\n\t }\n\n\t if (query instanceof HTMLElement) {\n\t return query;\n\t }\n\n\t if (isHtmlString(query)) {\n\t var tpl = document.createElement('template');\n\t tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\n\t return tpl.content.firstChild;\n\t }\n\n\t return document.querySelector(query);\n\t};\n\tconst isHtmlString = arg => {\n\t if (typeof arg === 'string' && arg.indexOf('<') > -1) {\n\t return true;\n\t }\n\n\t return false;\n\t};\n\tconst escapeQuery = query => {\n\t return query.replace(/['\"\\\\]/g, '\\\\$&');\n\t};\n\t/**\n\t * Dispatch an event\n\t *\n\t */\n\n\tconst triggerEvent = (dom_el, event_name) => {\n\t var event = document.createEvent('HTMLEvents');\n\t event.initEvent(event_name, true, false);\n\t dom_el.dispatchEvent(event);\n\t};\n\t/**\n\t * Apply CSS rules to a dom element\n\t *\n\t */\n\n\tconst applyCSS = (dom_el, css) => {\n\t Object.assign(dom_el.style, css);\n\t};\n\t/**\n\t * Add css classes\n\t *\n\t */\n\n\tconst addClasses = (elmts, ...classes) => {\n\t var norm_classes = classesArray(classes);\n\t elmts = castAsArray(elmts);\n\t elmts.map(el => {\n\t norm_classes.map(cls => {\n\t el.classList.add(cls);\n\t });\n\t });\n\t};\n\t/**\n\t * Remove css classes\n\t *\n\t */\n\n\tconst removeClasses = (elmts, ...classes) => {\n\t var norm_classes = classesArray(classes);\n\t elmts = castAsArray(elmts);\n\t elmts.map(el => {\n\t norm_classes.map(cls => {\n\t el.classList.remove(cls);\n\t });\n\t });\n\t};\n\t/**\n\t * Return arguments\n\t *\n\t */\n\n\tconst classesArray = args => {\n\t var classes = [];\n\t iterate(args, _classes => {\n\t if (typeof _classes === 'string') {\n\t _classes = _classes.trim().split(/[\\11\\12\\14\\15\\40]/);\n\t }\n\n\t if (Array.isArray(_classes)) {\n\t classes = classes.concat(_classes);\n\t }\n\t });\n\t return classes.filter(Boolean);\n\t};\n\t/**\n\t * Create an array from arg if it's not already an array\n\t *\n\t */\n\n\tconst castAsArray = arg => {\n\t if (!Array.isArray(arg)) {\n\t arg = [arg];\n\t }\n\n\t return arg;\n\t};\n\t/**\n\t * Get the closest node to the evt.target matching the selector\n\t * Stops at wrapper\n\t *\n\t */\n\n\tconst parentMatch = (target, selector, wrapper) => {\n\t if (wrapper && !wrapper.contains(target)) {\n\t return;\n\t }\n\n\t while (target && target.matches) {\n\t if (target.matches(selector)) {\n\t return target;\n\t }\n\n\t target = target.parentNode;\n\t }\n\t};\n\t/**\n\t * Get the first or last item from an array\n\t *\n\t * > 0 - right (last)\n\t * <= 0 - left (first)\n\t *\n\t */\n\n\tconst getTail = (list, direction = 0) => {\n\t if (direction > 0) {\n\t return list[list.length - 1];\n\t }\n\n\t return list[0];\n\t};\n\t/**\n\t * Return true if an object is empty\n\t *\n\t */\n\n\tconst isEmptyObject = obj => {\n\t return Object.keys(obj).length === 0;\n\t};\n\t/**\n\t * Get the index of an element amongst sibling nodes of the same type\n\t *\n\t */\n\n\tconst nodeIndex = (el, amongst) => {\n\t if (!el) return -1;\n\t amongst = amongst || el.nodeName;\n\t var i = 0;\n\n\t while (el = el.previousElementSibling) {\n\t if (el.matches(amongst)) {\n\t i++;\n\t }\n\t }\n\n\t return i;\n\t};\n\t/**\n\t * Set attributes of an element\n\t *\n\t */\n\n\tconst setAttr = (el, attrs) => {\n\t iterate(attrs, (val, attr) => {\n\t if (val == null) {\n\t el.removeAttribute(attr);\n\t } else {\n\t el.setAttribute(attr, '' + val);\n\t }\n\t });\n\t};\n\t/**\n\t * Replace a node\n\t */\n\n\tconst replaceNode = (existing, replacement) => {\n\t if (existing.parentNode) existing.parentNode.replaceChild(replacement, existing);\n\t};\n\n\t/**\n\t * highlight v3 | MIT license | Johann Burkard \n\t * Highlights arbitrary terms in a node.\n\t *\n\t * - Modified by Marshal 2011-6-24 (added regex)\n\t * - Modified by Brian Reavis 2012-8-27 (cleanup)\n\t */\n\tconst highlight = (element, regex) => {\n\t if (regex === null) return; // convet string to regex\n\n\t if (typeof regex === 'string') {\n\t if (!regex.length) return;\n\t regex = new RegExp(regex, 'i');\n\t } // Wrap matching part of text node with highlighting , e.g.\n\t // Soccer -> Soccer for regex = /soc/i\n\n\n\t const highlightText = node => {\n\t var match = node.data.match(regex);\n\n\t if (match && node.data.length > 0) {\n\t var spannode = document.createElement('span');\n\t spannode.className = 'highlight';\n\t var middlebit = node.splitText(match.index);\n\t middlebit.splitText(match[0].length);\n\t var middleclone = middlebit.cloneNode(true);\n\t spannode.appendChild(middleclone);\n\t replaceNode(middlebit, spannode);\n\t return 1;\n\t }\n\n\t return 0;\n\t }; // Recurse element node, looking for child text nodes to highlight, unless element\n\t // is childless,