UNPKG

indexeddbshim

Version:
1 lines 794 kB
{"version":3,"file":"indexeddbshim-UnicodeIdentifiers-node.cjs","sources":["../node_modules/eventtargeter/dist/index-es.js","../src/CFG.js","../src/unicode-regex.js","../src/util.js","../src/Event.js","../src/IDBVersionChangeEvent.js","../src/DOMException.js","../src/IDBRequest.js","../node_modules/sync-promise-expanded/index.js","../src/cmp.js","../src/Key.js","../src/IDBKeyRange.js","../src/DOMStringList.js","../src/IDBTransaction.js","../node_modules/typeson-registry/dist/index.min.js","../src/Sca.js","../src/IDBIndex.js","../src/IDBObjectStore.js","../src/IDBDatabase.js","../src/IDBFactory.js","../src/IDBCursor.js","../src/setGlobalVars.js","../node_modules/immediate/lib/nextTick.js","../node_modules/immediate/lib/queueMicrotask.js","../node_modules/immediate/lib/mutation.js","../node_modules/immediate/lib/messageChannel.js","../node_modules/immediate/lib/stateChange.js","../node_modules/immediate/lib/timeout.js","../node_modules/immediate/lib/index.js","../node_modules/tiny-queue/index.js","../node_modules/noop-fn/index.js","../node_modules/websql-configurable/lib/websql/WebSQLResultSet.js","../node_modules/websql-configurable/lib/websql/WebSQLTransaction.js","../node_modules/websql-configurable/lib/websql/WebSQLDatabase.js","../node_modules/websql-configurable/lib/custom.js","../node_modules/file-uri-to-path/index.js","../node_modules/bindings/bindings.js","../node_modules/sqlite3/lib/sqlite3-binding.js","../node_modules/sqlite3/lib/trace.js","../node_modules/sqlite3/lib/sqlite3.js","../node_modules/websql-configurable/lib/sqlite/SQLiteResult.js","../node_modules/websql-configurable/lib/sqlite/SQLiteDatabase.js","../src/nodeWebSQL.js","../src/UnicodeIdentifiers.js","../src/node-UnicodeIdentifiers.js"],"sourcesContent":["function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, _typeof(obj);\n}\n\n/* eslint-disable n/no-sync -- Want sync naming */\n/* eslint-disable no-restricted-syntax -- Instanceof checks */\n/* eslint-disable unicorn/no-this-assignment -- TS */\n\n/**\n * @typedef {number} Integer\n */\n\n/**\n * @callback InvokeCurrentListeners\n * @param {AllListeners} listeners\n * @param {EventWithProps} eventCopy\n * @param {string} type\n * @param {boolean} [checkOnListeners]\n * @returns {boolean}\n */\n\n/**\n * @typedef {{\n * defaultSync?: boolean,\n * extraProperties?: string[],\n * legacyOutputDidListenersThrowFlag?: boolean\n * }} CustomOptions\n */\n/**\n * @typedef {{\n * __legacyOutputDidListenersThrowError: unknown,\n * target: EventTarget & {\n * invokeCurrentListeners: InvokeCurrentListeners,\n * _earlyListeners: AllListeners,\n * _listeners: AllListeners,\n * _lateListeners: AllListeners,\n * _defaultListeners: AllListeners\n * },\n * composed: boolean,\n * currentTarget: EventTarget,\n * eventPhase: 0|1|2|3\n * defaultPrevented: boolean,\n * type: string,\n * bubbles: boolean,\n * cancelable: boolean,\n * isTrusted: boolean,\n * timeStamp: Integer,\n * initEvent: (type: string, bubbles: boolean, cancelable: boolean) => void,\n * preventDefault: () => void,\n * composedPath: () => void,\n * detail: any,\n * initCustomEvent: (\n * type: string, canBubble: boolean, cancelable: boolean,\n * detail: any\n * ) => void\n * }} EventWithProps\n */\n\n// Todo: Switch to ES6 classes\n\nvar phases = {\n NONE: 0,\n CAPTURING_PHASE: 1,\n AT_TARGET: 2,\n BUBBLING_PHASE: 3\n};\nvar ShimDOMException = typeof DOMException === 'undefined'\n// Todo: Better polyfill (if even needed here)\n/* eslint-disable no-shadow -- Polyfill */\n// eslint-disable-next-line operator-linebreak -- TS/JSDoc needs\n?\n/**\n * @param {string} msg\n * @param {string} name\n * @returns {Error}\n */\nfunction DOMException(msg, name) {\n // No need for `toString` as same as for `Error`\n /* eslint-enable no-shadow -- Polyfill */\n var err = new Error(msg);\n err.name = name;\n return err;\n} : DOMException;\nvar ev = new WeakMap();\nvar evCfg = new WeakMap();\n\n// Todo: Set _ev argument outside of this function\n\n/* eslint-disable func-name-matching -- Shim vs. Polyfill */\n/* eslint-disable no-shadow -- Polyfilling */\n/**\n* We use an adapter class rather than a proxy not only for compatibility\n* but also since we have to clone native event properties anyways in order\n* to properly set `target`, etc.\n* The regular DOM method `dispatchEvent` won't work with this polyfill as\n* it expects a native event.\n* @class\n* @param {string} type\n*/\nvar ShimEvent = /** @type {unknown} */function Event(type) {\n var _this = this;\n /* eslint-enable func-name-matching -- Shim vs. Polyfill */\n /* eslint-enable no-shadow -- Polyfilling */\n // For WebIDL checks of function's `length`, we check `arguments` for the optional arguments\n // @ts-expect-error\n this[Symbol.toStringTag] = 'Event';\n this.toString = function () {\n return '[object Event]';\n };\n // eslint-disable-next-line prefer-rest-params -- Don't want to change signature\n var _arguments = Array.prototype.slice.call(arguments),\n evInit = _arguments[1],\n _ev = _arguments[2];\n if (!arguments.length) {\n throw new TypeError(\"Failed to construct 'Event': 1 argument required, but only 0 present.\");\n }\n evInit = evInit || {};\n _ev = _ev || {};\n\n /** @type {EventWithProps} */\n var _evCfg = {};\n if ('composed' in evInit) {\n _evCfg.composed = evInit.composed;\n }\n\n // _evCfg.isTrusted = true; // We are not always using this for user-created events\n // _evCfg.timeStamp = new Date().valueOf(); // This is no longer a timestamp, but monotonic (elapsed?)\n\n ev.set(this, _ev);\n evCfg.set(this, _evCfg);\n var that = /** @type {unknown} */this;\n /** @type {ShimEvent} */\n that.initEvent(type, evInit.bubbles, evInit.cancelable);\n ['target', 'currentTarget', 'eventPhase', 'defaultPrevented'].forEach(function (pr) {\n var prop = /** @type {\"target\"|\"currentTarget\"|\"eventPhase\"|\"defaultPrevented\"} */\n pr;\n Object.defineProperty(_this, prop, {\n get: function get() {\n return (/* prop in _evCfg && */_evCfg[prop] !== undefined ? _evCfg[prop] : prop in _ev ? _ev[prop] :\n // Defaults\n prop === 'eventPhase' ? 0 : prop === 'defaultPrevented' ? false : null\n );\n }\n });\n });\n var props = [\n // Event\n 'type', 'bubbles', 'cancelable',\n // Defaults to false\n 'isTrusted', 'timeStamp', 'initEvent',\n // Other event properties (not used by our code)\n 'composedPath', 'composed'];\n if (this.toString() === '[object CustomEvent]') {\n props.push('detail', 'initCustomEvent');\n }\n Object.defineProperties(this, props.reduce(function (obj, pr) {\n var prop =\n /**\n * @type {\"type\"|\"bubbles\"|\"cancelable\"|\"isTrusted\"|\n * \"timeStamp\"|\"initEvent\"|\"composedPath\"|\"composed\"|\n * \"detail\"|\"initCustomEvent\"\n * }\n */\n pr;\n obj[prop] = {\n get: function get() {\n return prop in _evCfg ? _evCfg[prop] : prop in _ev ? _ev[prop] : ['bubbles', 'cancelable', 'composed'].includes(prop) ? false : undefined;\n }\n };\n return obj;\n }, /** @type {{[key: string]: any}} */{}));\n};\n\n// @ts-expect-error Casting doesn't work\nShimEvent.prototype.preventDefault = function () {\n // @ts-expect-error Needed for exporting\n if (!(this instanceof ShimEvent)) {\n throw new TypeError('Illegal invocation');\n }\n var _ev = ev.get(this);\n var _evCfg = evCfg.get(this);\n if (this.cancelable && !_evCfg._passive) {\n _evCfg.defaultPrevented = true;\n if (typeof _ev.preventDefault === 'function') {\n // Prevent any predefined defaults\n _ev.preventDefault();\n }\n }\n};\n\n// @ts-expect-error Casting doesn't work\nShimEvent.prototype.stopImmediatePropagation = function () {\n var _evCfg = evCfg.get(this);\n _evCfg._stopImmediatePropagation = true;\n};\n\n// @ts-expect-error Casting doesn't work\nShimEvent.prototype.stopPropagation = function () {\n var _evCfg = evCfg.get(this);\n _evCfg._stopPropagation = true;\n};\n\n// @ts-expect-error Casting doesn't work\nShimEvent.prototype.initEvent = function (type, bubbles, cancelable) {\n // Chrome currently has function length 1 only but WebIDL says 3\n // const bubbles = arguments[1];\n // const cancelable = arguments[2];\n var _evCfg = evCfg.get(this);\n if (_evCfg._dispatched) {\n return;\n }\n Object.defineProperty(this, 'type', {\n enumerable: true,\n configurable: true,\n get: function get() {\n return type;\n }\n });\n Object.defineProperty(this, 'bubbles', {\n enumerable: true,\n configurable: true,\n get: function get() {\n return bubbles;\n }\n });\n Object.defineProperty(this, 'cancelable', {\n enumerable: true,\n configurable: true,\n get: function get() {\n return cancelable;\n }\n });\n _evCfg.type = type;\n if (bubbles !== undefined) {\n _evCfg.bubbles = bubbles;\n }\n if (cancelable !== undefined) {\n _evCfg.cancelable = cancelable;\n }\n};\n['type', 'target', 'currentTarget'].forEach(function (prop) {\n // @ts-expect-error Casting doesn't work\n Object.defineProperty(ShimEvent.prototype, prop, {\n enumerable: true,\n configurable: true,\n get: function get() {\n throw new TypeError('Illegal invocation');\n }\n });\n});\n['eventPhase', 'defaultPrevented', 'bubbles', 'cancelable', 'timeStamp'].forEach(function (prop) {\n // @ts-expect-error Casting doesn't work\n Object.defineProperty(ShimEvent.prototype, prop, {\n enumerable: true,\n configurable: true,\n get: function get() {\n throw new TypeError('Illegal invocation');\n }\n });\n});\n['NONE', 'CAPTURING_PHASE', 'AT_TARGET', 'BUBBLING_PHASE'].forEach(function (prop, i) {\n Object.defineProperty(ShimEvent, prop, {\n enumerable: true,\n writable: false,\n value: i\n });\n // @ts-expect-error Casting doesn't work\n Object.defineProperty(ShimEvent.prototype, prop, {\n writable: false,\n value: i\n });\n});\n// @ts-expect-error Casting doesn't work\nShimEvent[Symbol.toStringTag] = 'Function';\n\n// @ts-expect-error Casting doesn't work\nShimEvent.prototype[Symbol.toStringTag] = 'EventPrototype';\nObject.defineProperty(ShimEvent, 'prototype', {\n writable: false\n});\n\n/* eslint-disable func-name-matching -- Polyfill */\n/* eslint-disable no-shadow -- Polyfill */\n/**\n * @class\n * @param {string} type\n */\nvar ShimCustomEvent = /** @type {unknown} */function CustomEvent(type) {\n /* eslint-enable func-name-matching -- Polyfill */\n /* eslint-enable no-shadow -- Polyfill */\n\n // eslint-disable-next-line prefer-rest-params -- Keep signature\n var _arguments2 = Array.prototype.slice.call(arguments),\n evInit = _arguments2[1],\n _ev = _arguments2[2];\n // @ts-expect-error Casting doesn't work\n ShimEvent.call(this, type, evInit, _ev);\n // @ts-expect-error\n this[Symbol.toStringTag] = 'CustomEvent';\n this.toString = function () {\n return '[object CustomEvent]';\n };\n // var _evCfg = evCfg.get(this);\n evInit = evInit || {};\n // @ts-ignore\n this.initCustomEvent(type, evInit.bubbles, evInit.cancelable, 'detail' in evInit ? evInit.detail : null);\n};\n// @ts-expect-error Casting doesn't work\nObject.defineProperty(ShimCustomEvent.prototype, 'constructor', {\n enumerable: false,\n writable: true,\n configurable: true,\n value: ShimCustomEvent\n});\n// @ts-expect-error Casting doesn't work\nShimCustomEvent.prototype.initCustomEvent = function (type, bubbles, cancelable, detail) {\n // @ts-expect-error Needed for exporting\n if (!(this instanceof ShimCustomEvent)) {\n throw new TypeError('Illegal invocation');\n }\n var _evCfg = evCfg.get(this);\n // @ts-expect-error Casting doesn't work\n ShimCustomEvent.call(this, type, {\n bubbles: bubbles,\n cancelable: cancelable,\n detail: detail\n // eslint-disable-next-line prefer-rest-params -- Keep signature\n }, arguments[4]);\n if (_evCfg._dispatched) {\n return;\n }\n if (detail !== undefined) {\n _evCfg.detail = detail;\n }\n Object.defineProperty(this, 'detail', {\n get: function get() {\n return _evCfg.detail;\n }\n });\n};\n// @ts-expect-error Casting doesn't work\nShimCustomEvent[Symbol.toStringTag] = 'Function';\n// @ts-expect-error Casting doesn't work\nShimCustomEvent.prototype[Symbol.toStringTag] = 'CustomEventPrototype';\n\n// @ts-expect-error Casting doesn't work\nObject.defineProperty(ShimCustomEvent.prototype, 'detail', {\n enumerable: true,\n configurable: true,\n get: function get() {\n throw new TypeError('Illegal invocation');\n }\n});\nObject.defineProperty(ShimCustomEvent, 'prototype', {\n writable: false\n});\n\n/**\n *\n * @param {EventWithProps} e\n * @returns {EventWithProps}\n */\nfunction copyEvent(e) {\n var bubbles = e.bubbles,\n cancelable = e.cancelable,\n detail = e.detail,\n type = e.type;\n if ('detail' in e) {\n // @ts-expect-error Casting doesn't work\n return new ShimCustomEvent(type, {\n bubbles: bubbles,\n cancelable: cancelable,\n detail: detail\n }, e);\n }\n // @ts-expect-error Casting doesn't work\n return new ShimEvent(type, {\n bubbles: bubbles,\n cancelable: cancelable\n }, e);\n}\n\n/**\n* @typedef {object} ListenerOptions\n* @property {boolean} [once] Remove listener after invoking once\n* @property {boolean} [passive] Don't allow `preventDefault`\n* @property {boolean} [capture] Use `_children` and set `eventPhase`\n*/\n\n/**\n* @typedef {object} ListenerAndOptions\n* @property {Listener} listener\n* @property {ListenerOptions} options\n*/\n\n/**\n* @typedef {object} ListenerInfo\n* @property {ListenerAndOptions[]} listenersByTypeOptions\n* @property {ListenerOptions} options\n* @property {ListenerAndOptions[]} listenersByType\n*/\n\n/**\n* @callback Listener\n* @param {EventWithProps} e\n* @returns {boolean}\n*/\n\n/**\n * Keys are event types.\n * @typedef {{[key: string]: Listener[]}} Listeners\n */\n\n/**\n * @typedef {{\n * [type: string]: ListenerAndOptions[]\n * }} AllListeners\n */\n\n/**\n *\n * @param {AllListeners} listeners\n * @param {string} type\n * @param {boolean|ListenerOptions} options\n * @returns {ListenerInfo}\n */\nfunction getListenersOptions(listeners, type, options) {\n var listenersByType = listeners[type];\n if (listenersByType === undefined) listeners[type] = listenersByType = [];\n var opts = typeof options === 'boolean' ? {\n capture: options\n } : options || {};\n var stringifiedOptions = JSON.stringify(opts);\n var listenersByTypeOptions = listenersByType.filter(function (obj) {\n return stringifiedOptions === JSON.stringify(obj.options);\n });\n return {\n listenersByTypeOptions: listenersByTypeOptions,\n options: opts,\n listenersByType: listenersByType\n };\n}\nvar methods = {\n /**\n * @param {AllListeners} listeners\n * @param {Listener} listener\n * @param {string} type\n * @param {boolean|ListenerOptions} options\n * @returns {void}\n */\n addListener: function addListener(listeners, listener, type, options) {\n var listenersOptions = getListenersOptions(listeners, type, options);\n var listenersByTypeOptions = listenersOptions.listenersByTypeOptions;\n options = listenersOptions.options;\n var listenersByType = listenersOptions.listenersByType;\n if (listenersByTypeOptions.some(function (l) {\n return l.listener === listener;\n })) return;\n listenersByType.push({\n listener: listener,\n options: options\n });\n },\n /**\n * @param {AllListeners} listeners\n * @param {Listener} listener\n * @param {string} type\n * @param {boolean|ListenerOptions} options\n * @returns {void}\n */\n removeListener: function removeListener(listeners, listener, type, options) {\n var listenersOptions = getListenersOptions(listeners, type, options);\n var listenersByType = listenersOptions.listenersByType;\n var stringifiedOptions = JSON.stringify(listenersOptions.options);\n listenersByType.some(function (l, i) {\n if (l.listener === listener && stringifiedOptions === JSON.stringify(l.options)) {\n listenersByType.splice(i, 1);\n if (!listenersByType.length) delete listeners[type];\n return true;\n }\n return false;\n });\n },\n /**\n *\n * @param {AllListeners} listeners\n * @param {Listener} listener\n * @param {string} type\n * @param {boolean|ListenerOptions} options\n * @returns {boolean}\n */\n hasListener: function hasListener(listeners, listener, type, options) {\n var listenersOptions = getListenersOptions(listeners, type, options);\n var listenersByTypeOptions = listenersOptions.listenersByTypeOptions;\n return listenersByTypeOptions.some(function (l) {\n return l.listener === listener;\n });\n }\n};\n\n/* eslint-disable no-shadow -- Polyfill */\n/**\n * @class\n */\nfunction EventTarget() {\n /* eslint-enable no-shadow -- Polyfill */\n throw new TypeError('Illegal constructor');\n}\n\n/**\n * @typedef {\"addEarlyEventListener\"|\"removeEarlyEventListener\"|\"hasEarlyEventListener\"|\n * \"addEventListener\"|\"removeEventListener\"|\"hasEventListener\"|\n * \"addLateEventListener\"|\"removeLateEventListener\"|\"hasLateEventListener\"|\n * \"addDefaultEventListener\"|\"removeDefaultEventListener\"|\"hasDefaultEventListener\"\n * } ListenerName\n */\nObject.assign(EventTarget.prototype, ['Early', '', 'Late', 'Default'].reduce(function ( /** @type {{[key: string]: Function}} */\nobj, listenerType) {\n ['add', 'remove', 'has'].forEach(function (method) {\n var mainMethod = /** @type {ListenerName} */method + listenerType + 'EventListener';\n /**\n * @param {string} type\n * @param {Listener|{handleEvent: Listener}} listener\n * @this {EventTarget & {\n * _earlyListeners: AllListeners,\n * _listeners: AllListeners,\n * _lateListeners: AllListeners,\n * _defaultListeners: AllListeners,\n * }}\n * @returns {boolean|void}\n */\n obj[mainMethod] = function (type, listener) {\n // eslint-disable-next-line prefer-rest-params -- Keep signature\n var options = arguments[2]; // We keep the listener `length` as per WebIDL\n if (arguments.length < 2) throw new TypeError('2 or more arguments required');\n if (typeof type !== 'string') {\n // @ts-expect-error It's ok to construct\n throw new ShimDOMException('UNSPECIFIED_EVENT_TYPE_ERR', 'UNSPECIFIED_EVENT_TYPE_ERR');\n }\n try {\n // As per code such as the following, handleEvent may throw,\n // but is uncaught\n // https://github.com/web-platform-tests/wpt/blob/master/IndexedDB/fire-error-event-exception.html#L54-L56\n if ('handleEvent' in listener && listener.handleEvent.bind) {\n listener = listener.handleEvent.bind(listener);\n }\n } catch (err) {\n // eslint-disable-next-line no-console -- Feedback to user\n console.log('Uncaught `handleEvent` error', err);\n }\n var arrStr = /** @type {\"_earlyListeners\"|\"_listeners\"|\"_lateListeners\"|\"_defaultListeners\"} */\n '_' + listenerType.toLowerCase() + (listenerType === '' ? 'l' : 'L') + 'isteners';\n if (!this[arrStr]) {\n Object.defineProperty(this, arrStr, {\n value: {}\n });\n }\n var meth = /** @type {\"addListener\"|\"removeListener\"|\"hasListener\"} */\n method + 'Listener';\n return methods[meth](this[arrStr], /** @type {Listener} */listener, type, options);\n };\n });\n return obj;\n}, {}));\nObject.assign(EventTarget.prototype, {\n _legacyOutputDidListenersThrowCheck: undefined,\n /**\n * @param {CustomOptions} customOptions\n * @this {EventTarget.prototype}\n * @returns {void}\n */\n __setOptions: function __setOptions(customOptions) {\n customOptions = customOptions || {};\n // Todo: Make into event properties?\n this._defaultSync = customOptions.defaultSync;\n this._extraProperties = customOptions.extraProperties || [];\n if (customOptions.legacyOutputDidListenersThrowFlag) {\n // IndexedDB\n this._legacyOutputDidListenersThrowCheck = true;\n this._extraProperties.push('__legacyOutputDidListenersThrowError');\n }\n },\n /**\n * @param {ShimEvent} e\n * @this {EventTarget & {\n * _dispatchEvent: (e: ShimEvent|ShimCustomEvent, setTarget: boolean) => boolean,\n * }}\n * @returns {boolean}\n */\n dispatchEvent: function dispatchEvent(e) {\n return this._dispatchEvent(e, true);\n },\n /**\n * @param {EventWithProps} e\n * @param {boolean} setTarget\n * @this {EventTarget.prototype & {\n * _earlyListeners: AllListeners,\n * _listeners: AllListeners,\n * _lateListeners: AllListeners,\n * _defaultListeners: AllListeners,\n * }}\n * @returns {boolean}\n */\n _dispatchEvent: function _dispatchEvent(e, setTarget) {\n var _this2 = this;\n ['early', '', 'late', 'default'].forEach(function (listenerType) {\n var arrStr = /** @type {\"_earlyListeners\"|\"_listeners\"|\"_lateListeners\"|\"_defaultListeners\"} */\n '_' + listenerType + (listenerType === '' ? 'l' : 'L') + 'isteners';\n if (!_this2[arrStr]) {\n Object.defineProperty(_this2, arrStr, {\n value: {}\n });\n }\n });\n var _evCfg = evCfg.get(e);\n if (_evCfg && setTarget && _evCfg._dispatched) {\n // @ts-expect-error It's ok to construct\n throw new ShimDOMException('The object is in an invalid state.', 'InvalidStateError');\n }\n\n /** @type {EventWithProps} */\n var eventCopy;\n if (_evCfg) {\n eventCopy = e;\n } else {\n eventCopy = copyEvent(e);\n _evCfg = evCfg.get(eventCopy);\n _evCfg._dispatched = true;\n\n /** @type {string[]} */\n this._extraProperties.forEach(function (prop) {\n if (prop in e) {\n /** @type {{[key: string]: any}} */eventCopy[prop] = /** @type {{[key: string]: any}} */e[prop]; // Todo: Put internal to `ShimEvent`?\n }\n });\n }\n\n var _eventCopy = eventCopy,\n type = _eventCopy.type;\n\n /**\n *\n * @returns {void}\n */\n function finishEventDispatch() {\n _evCfg.eventPhase = phases.NONE;\n _evCfg.currentTarget = null;\n delete _evCfg._children;\n }\n /**\n *\n * @returns {void}\n */\n function invokeDefaults() {\n // Ignore stopPropagation from defaults\n _evCfg._stopImmediatePropagation = undefined;\n _evCfg._stopPropagation = undefined;\n // We check here for whether we should invoke since may have changed since timeout (if late listener prevented default)\n if (!eventCopy.defaultPrevented || !_evCfg.cancelable) {\n // 2nd check should be redundant\n _evCfg.eventPhase = phases.AT_TARGET; // Temporarily set before we invoke default listeners\n eventCopy.target.invokeCurrentListeners(eventCopy.target._defaultListeners, eventCopy, type);\n }\n finishEventDispatch();\n }\n var continueEventDispatch = function continueEventDispatch() {\n // Ignore stop propagation of user now\n _evCfg._stopImmediatePropagation = undefined;\n _evCfg._stopPropagation = undefined;\n if (!_this2._defaultSync) {\n setTimeout(invokeDefaults, 0);\n } else invokeDefaults();\n _evCfg.eventPhase = phases.AT_TARGET; // Temporarily set before we invoke late listeners\n // Sync default might have stopped\n if (!_evCfg._stopPropagation) {\n _evCfg._stopImmediatePropagation = undefined;\n _evCfg._stopPropagation = undefined;\n // We could allow stopPropagation by only executing upon (_evCfg._stopPropagation)\n eventCopy.target.invokeCurrentListeners(eventCopy.target._lateListeners, eventCopy, type);\n }\n finishEventDispatch();\n return !eventCopy.defaultPrevented;\n };\n if (setTarget) _evCfg.target = this;\n switch ('eventPhase' in eventCopy && eventCopy.eventPhase) {\n case phases.CAPTURING_PHASE:\n {\n if (_evCfg._stopPropagation) {\n return continueEventDispatch();\n }\n this.invokeCurrentListeners(this._listeners, eventCopy, type);\n var child = _evCfg._children && _evCfg._children.length && _evCfg._children.pop();\n if (!child || child === eventCopy.target) {\n _evCfg.eventPhase = phases.AT_TARGET;\n }\n if (child) child._defaultSync = this._defaultSync;\n return (child || this)._dispatchEvent(eventCopy, false);\n }\n case phases.AT_TARGET:\n if (_evCfg._stopPropagation) {\n return continueEventDispatch();\n }\n this.invokeCurrentListeners(this._listeners, eventCopy, type, true);\n if (!_evCfg.bubbles) {\n return continueEventDispatch();\n }\n _evCfg.eventPhase = phases.BUBBLING_PHASE;\n return this._dispatchEvent(eventCopy, false);\n case phases.BUBBLING_PHASE:\n {\n if (_evCfg._stopPropagation) {\n return continueEventDispatch();\n }\n var parent = this.__getParent && this.__getParent();\n if (!parent) {\n return continueEventDispatch();\n }\n parent.invokeCurrentListeners(parent._listeners, eventCopy, type, true);\n parent._defaultSync = this._defaultSync;\n return parent._dispatchEvent(eventCopy, false);\n }\n case phases.NONE:\n default:\n {\n _evCfg.eventPhase = phases.AT_TARGET; // Temporarily set before we invoke early listeners\n this.invokeCurrentListeners(this._earlyListeners, eventCopy, type);\n if (!('__getParent' in this)) {\n _evCfg.eventPhase = phases.AT_TARGET;\n return this._dispatchEvent(eventCopy, false);\n }\n\n /* eslint-disable consistent-this -- Readability */\n var par = this;\n var root_ = this;\n /* eslint-enable consistent-this -- Readability */\n while (par.__getParent && (par = par.__getParent()) !== null) {\n if (!_evCfg._children) {\n _evCfg._children = [];\n }\n _evCfg._children.push(root_);\n root_ = par;\n }\n root_._defaultSync = this._defaultSync;\n _evCfg.eventPhase = phases.CAPTURING_PHASE;\n return root_._dispatchEvent(eventCopy, false);\n }\n }\n },\n /**\n * @type {InvokeCurrentListeners}\n * @this {EventTarget.prototype & {[key: string]: Listener}}\n */\n invokeCurrentListeners: function invokeCurrentListeners(listeners, eventCopy, type, checkOnListeners) {\n var _this3 = this;\n var _evCfg = evCfg.get(eventCopy);\n _evCfg.currentTarget = this;\n var listOpts = getListenersOptions(listeners, type, {});\n // eslint-disable-next-line unicorn/prefer-spread -- Performance?\n var listenersByType = listOpts.listenersByType.concat();\n var dummyIPos = listenersByType.length ? 1 : 0;\n listenersByType.some(function (listenerObj, i) {\n var onListener = checkOnListeners ? _this3['on' + type] : null;\n if (_evCfg._stopImmediatePropagation) return true;\n if (i === dummyIPos && typeof onListener === 'function') {\n // We don't splice this in as could be overwritten; executes here per\n // https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:event-handlers-14\n _this3.tryCatch(eventCopy, function () {\n var ret = onListener.call(eventCopy.currentTarget, eventCopy);\n if (ret === false) {\n eventCopy.preventDefault();\n }\n });\n }\n var options = listenerObj.options;\n var once = options.once,\n passive = options.passive,\n capture = options.capture;\n _evCfg._passive = passive;\n if (capture && eventCopy.target !== eventCopy.currentTarget && eventCopy.eventPhase === phases.CAPTURING_PHASE || eventCopy.eventPhase === phases.AT_TARGET || !capture && eventCopy.target !== eventCopy.currentTarget && eventCopy.eventPhase === phases.BUBBLING_PHASE) {\n var listener = listenerObj.listener;\n _this3.tryCatch(eventCopy, function () {\n listener.call(eventCopy.currentTarget, eventCopy);\n });\n if (once) {\n _this3.removeEventListener(type, listener, options);\n }\n }\n return false;\n });\n this.tryCatch(eventCopy, function () {\n var onListener = checkOnListeners ? _this3['on' + type] : null;\n if (typeof onListener === 'function' && listenersByType.length < 2) {\n var ret = onListener.call(eventCopy.currentTarget, eventCopy); // Won't have executed if too short\n if (ret === false) {\n eventCopy.preventDefault();\n }\n }\n });\n return !eventCopy.defaultPrevented;\n },\n /* eslint-disable promise/prefer-await-to-callbacks -- Try-catch */\n /**\n * @param {EventWithProps} evt\n * @param {() => void} cb\n * @returns {void}\n */\n tryCatch: function tryCatch(evt, cb) {\n /* eslint-enable promise/prefer-await-to-callbacks -- Try-catch */\n try {\n // Per MDN: Exceptions thrown by event handlers are reported\n // as uncaught exceptions; the event handlers run on a nested\n // callstack: they block the caller until they complete, but\n // exceptions do not propagate to the caller.\n // eslint-disable-next-line promise/prefer-await-to-callbacks, n/callback-return -- Try-catch\n cb();\n } catch (err) {\n this.triggerErrorEvent(err, evt);\n }\n },\n /**\n * @param {unknown} err\n * @param {EventWithProps} evt\n * @returns {void}\n */\n triggerErrorEvent: function triggerErrorEvent(err, evt) {\n var error = err;\n if (typeof err === 'string') {\n error = new Error('Uncaught exception: ' + err);\n }\n var triggerGlobalErrorEvent;\n var useNodeImpl = false;\n if (typeof window === 'undefined' || typeof ErrorEvent === 'undefined' || window && (typeof window === \"undefined\" ? \"undefined\" : _typeof(window)) === 'object' && !window.dispatchEvent) {\n useNodeImpl = true;\n triggerGlobalErrorEvent = function triggerGlobalErrorEvent() {\n setTimeout(function () {\n // Node won't be able to catch in this way if we throw in the main thread\n // console.log(err); // Should we auto-log for user?\n throw error; // Let user listen to `process.on('uncaughtException', (err) => {});`\n });\n };\n } else {\n triggerGlobalErrorEvent = function triggerGlobalErrorEvent() {\n // See https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror\n // and https://github.com/w3c/IndexedDB/issues/49\n\n // Note that a regular Event will properly trigger\n // `window.addEventListener('error')` handlers, but it will not trigger\n // `window.onerror` as per https://html.spec.whatwg.org/multipage/webappapis.html#handler-onerror\n // Note also that the following line won't handle `window.addEventListener` handlers\n // if (window.onerror) window.onerror(error.message, err.fileName, err.lineNumber, error.columnNumber, error);\n\n // `ErrorEvent` properly triggers `window.onerror` and `window.addEventListener('error')` handlers\n var errEv = new ErrorEvent('error', {\n error: err,\n message: /** @type {Error} */error.message || '',\n // We can't get the actually useful user's values!\n filename: /** @type {Error & {fileName: string}} */error.fileName || '',\n lineno: /** @type {Error & {lineNumber: Integer}} */error.lineNumber || 0,\n colno: /** @type {Error & {columnNumber: Integer}} */error.columnNumber || 0\n });\n window.dispatchEvent(errEv);\n // console.log(err); // Should we auto-log for user?\n };\n }\n\n // Todo: This really should always run here but as we can't set the global\n // `window` (e.g., using jsdom) since `setGlobalVars` becomes unable to\n // shim `indexedDB` in such a case currently (apparently due to\n // <https://github.com/axemclion/IndexedDBShim/issues/280>), we can't\n // avoid the above Node implementation (which, while providing some\n // fallback mechanism, is unstable)\n if (!useNodeImpl || !this._legacyOutputDidListenersThrowCheck) triggerGlobalErrorEvent();\n\n // See https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke and\n // https://github.com/w3c/IndexedDB/issues/140 (also https://github.com/w3c/IndexedDB/issues/49 )\n if (this._legacyOutputDidListenersThrowCheck) {\n evt.__legacyOutputDidListenersThrowError = error;\n }\n }\n});\nEventTarget.prototype[Symbol.toStringTag] = 'EventTargetPrototype';\nObject.defineProperty(EventTarget, 'prototype', {\n writable: false\n});\nvar ShimEventTarget = EventTarget;\nvar EventTargetFactory = {\n /**\n * @param {CustomOptions} customOptions\n * @returns {EventTarget}\n */\n createInstance: function createInstance(customOptions) {\n /* eslint-disable func-name-matching -- Shim vs. Polyfill */\n /* eslint-disable no-shadow -- Polyfill */\n /**\n * @class\n * @this {typeof ShimEventTarget.prototype}\n */\n var ET = /** @type {unknown} */function EventTarget() {\n /* eslint-enable no-shadow -- Polyfill */\n /* eslint-enable func-name-matching -- Shim vs. Polyfill */\n this.__setOptions(customOptions);\n };\n // @ts-expect-error Casting doesn't work\n ET.prototype = ShimEventTarget.prototype;\n // @ts-expect-error Casting doesn't work\n return new ET();\n }\n};\nEventTarget.ShimEvent = ShimEvent;\nEventTarget.ShimCustomEvent = ShimCustomEvent;\nEventTarget.ShimDOMException = ShimDOMException;\nEventTarget.ShimEventTarget = EventTarget;\nEventTarget.EventTargetFactory = EventTargetFactory;\n\n/**\n * @returns {void}\n */\nfunction setPrototypeOfCustomEvent() {\n // TODO: IDL needs but reported as slow!\n Object.setPrototypeOf(ShimCustomEvent, /** @type {object} */ShimEvent);\n // @ts-expect-error How to overcome?\n Object.setPrototypeOf(ShimCustomEvent.prototype, ShimEvent.prototype);\n}\n\nexport { EventTargetFactory, ShimCustomEvent, ShimDOMException, ShimEvent, EventTarget as ShimEventTarget, setPrototypeOfCustomEvent };\n","/* eslint-disable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/147 */\n/**\n * @typedef {T[keyof T]} ValueOf<T>\n * @template T\n */\n/* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/147 */\n\n/**\n * @typedef {{unlink: (path: string, cb: import('fs').NoParamCallback) => void}} FSApi\n */\n\n/**\n * @typedef {{\n * DEBUG: boolean,\n * cacheDatabaseInstances: boolean,\n * autoName: boolean,\n * fullIDLSupport: boolean,\n * checkOrigin: boolean,\n * cursorPreloadPackSize: number,\n * UnicodeIDStart: string,\n * UnicodeIDContinue: string,\n * registerSCA: (\n * preset: import('typeson').Preset\n * ) => import('typeson').Preset,\n * avoidAutoShim: boolean,\n * win: {\n * openDatabase: (name: string, version: string, displayName: string, estimatedSize: number) => import('websql-configurable').default\n * },\n * DEFAULT_DB_SIZE: number,\n * useSQLiteIndexes: boolean,\n * fs: FSApi,\n * addNonIDBGlobals: boolean,\n * replaceNonIDBGlobals: boolean,\n * escapeDatabaseName: (name: string) => string,\n * unescapeDatabaseName: (name: string) => string,\n * databaseCharacterEscapeList: string|false,\n * databaseNameLengthLimit: number|false,\n * escapeNFDForDatabaseNames: boolean,\n * addSQLiteExtension: boolean,\n * memoryDatabase: string,\n * deleteDatabaseFiles: boolean,\n * databaseBasePath: string,\n * sysDatabaseBasePath: string,\n * sqlBusyTimeout: number,\n * sqlTrace: () => void,\n * sqlProfile: () => void,\n * createIndexes: boolean\n * }} ConfigValues\n */\n\n/**\n * @typedef {ValueOf<ConfigValues>} ConfigValue\n */\n\n/** @type {{[key: string]: ConfigValue}} */\nconst map = {};\n\nconst CFG = /** @type {ConfigValues} */ ({});\n\n/**\n * @typedef {keyof ConfigValues} KeyofConfigValues\n */\n\n/**\n * @typedef {KeyofConfigValues[]} Config\n */\n\n/** @type {Config} */\n([\n // Boolean for verbose reporting\n 'DEBUG', // Effectively defaults to false (ignored unless `true`)\n\n // Boolean (effectively defaults to true) on whether to cache WebSQL\n // `openDatabase` instances\n 'cacheDatabaseInstances',\n\n // Boolean on whether to auto-name databases (based on an\n // auto-increment) when the empty string is supplied; useful with\n // `memoryDatabase`; defaults to `false` which means the empty string\n // will be used as the (valid) database name\n 'autoName',\n\n // Determines whether the slow-performing `Object.setPrototypeOf`\n // calls required for full WebIDL compliance will be used. Probably\n // only needed for testing or environments where full introspection\n // on class relationships is required; see\n // http://stackoverflow.com/questions/41927589/rationales-consequences-of-webidl-class-inheritance-requirements\n 'fullIDLSupport', // Effectively defaults to false (ignored unless `true`)\n\n // Boolean on whether to perform origin checks in `IDBFactory` methods\n // Effectively defaults to `true` (must be set to `false` to cancel checks)\n 'checkOrigin',\n\n // Used by `IDBCursor` continue methods for number of records to cache;\n // Defaults to 100\n 'cursorPreloadPackSize',\n\n // See optional API (`shimIndexedDB.__setUnicodeIdentifiers`);\n // or just use the Unicode builds which invoke this method\n // automatically using the large, fully spec-compliant, regular\n // expression strings of `src/UnicodeIdentifiers.js`)\n // In the non-Unicode builds, defaults to /[$A-Z_a-z]/\n 'UnicodeIDStart',\n // In the non-Unicode builds, defaults to /[$0-9A-Z_a-z]/\n 'UnicodeIDContinue',\n\n // Used by SCA.js for optional restructuring of typeson-registry\n // Structured Cloning Algorithm; should only be needed for ensuring data\n // created in 3.* versions of IndexedDBShim continue to work; see the\n // library `typeson-registry-sca-reverter` to get a function to do this\n 'registerSCA',\n\n // BROWSER-SPECIFIC CONFIG\n 'avoidAutoShim', // Where WebSQL is detected but where `indexedDB` is\n // missing or poor support is known (non-Chrome Android or\n // non-Safari iOS9), the shim will be auto-applied without\n // `shimIndexedDB.__useShim()`. Set this to `true` to avoid forcing\n // the shim for such cases.\n\n // -----------SQL CONFIG----------\n // Object (`window` in the browser) on which there may be an\n // `openDatabase` method (if any) for WebSQL. (The browser\n // throws if attempting to call `openDatabase` without the window\n // so this is why the config doesn't just allow the function.)\n // Defaults to `window` or `self` in browser builds or\n // a singleton object with the `openDatabase` method set to\n // the \"websql\" package in Node.\n 'win',\n\n // For internal `openDatabase` calls made by `IDBFactory` methods;\n // per the WebSQL spec, \"User agents are expected to use the display name\n // and the estimated database size to optimize the user experience.\n // For example, a user agent could use the estimated size to suggest an\n // initial quota to the user. This allows a site that is aware that it\n // will try to use hundreds of megabytes to declare this upfront, instead\n // of the user agent prompting the user for permission to increase the\n // quota every five megabytes.\"\n // Defaults to (4 * 1024 * 1024) or (25 * 1024 * 1024) in Safari\n 'DEFAULT_DB_SIZE',\n // Whether to create indexes on SQLite tables (and also whether to try\n // dropping)\n // Effectively defaults to `false` (ignored unless `true`)\n 'useSQLiteIndexes',\n\n // NODE-IMPINGING SETTINGS (created for sake of limitations in Node\n // or desktop file system implementation but applied by default in\n // browser for parity)\n\n // File system module with `unlink` to remove deleted database files\n 'fs',\n\n // Used when setting global shims to determine whether to try to add\n // other globals shimmed by the library (`ShimDOMException`,\n // `ShimDOMStringList`, `ShimEvent`, `ShimCustomEvent`, `ShimEventTarget`)\n // Effectively defaults to `false` (ignored unless `true`)\n 'addNonIDBGlobals',\n // Used when setting global shims to determine whether to try to overwrite\n // other globals shimmed by the library (`DOMException`, `DOMStringList`,\n // `Event`, `CustomEvent`, `EventTarget`)\n // Effectively defaults to `false` (ignored unless `true`)\n 'replaceNonIDBGlobals',\n\n // Overcoming limitations with node-sqlite3/storing database name on\n // file systems\n // https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\n // Defaults to prefixing database with `D_`, escaping\n // `databaseCharacterEscapeList`, escaping NUL, and\n // escaping upper case letters, as well as enforcing\n // `databaseNameLengthLimit`\n 'escapeDatabaseName',\n // Not used internally; usable as a convenience method\n 'unescapeDatabaseName',\n\n // Defaults to global regex representing the following\n // (characters nevertheless commonly reserved in modern,\n // Unicode-supporting systems): 0x00-0x1F 0x7F \" * / : < > ? \\ |\n 'databaseCharacterEscapeList',\n // Defaults to 254 (shortest typical modern file length limit)\n 'databaseNameLengthLimit',\n\n // Boolean defaulting to true on whether to escape NFD-escaping\n // characters to avoid clashes on MacOS which performs NFD on files\n 'escapeNFDForDatabaseNames',\n\n // Boolean on whether to add the `.sqlite` extension to file names;\n // defaults to `true`\n 'addSQLiteExtension',\n // Various types of in-memory databases that can auto-delete\n [\n 'memoryDatabase',\n /**\n * @param {string} val\n * @throws {TypeError}\n * @returns {void}\n */\n (val) => {\n if (!(/^(?::memory:|file::memory:(\\?[^#]*)?(#.*)?)?$/u).test(\n /** @type {string} */ (val)\n )) {\n throw new TypeError(\n '`memoryDatabase` must be the empty string, \":memory:\", or a ' +\n '\"file::memory:[?queryString][#hash] URL\".'\n );\n }\n }\n ],\n\n // NODE-SPECIFIC CONFIG\n // Boolean on whether to delete the database file itself after\n // `deleteDatabase`; defaults to `true` as the database will be empty\n 'deleteDatabaseFiles',\n 'databaseBasePath',\n 'sysDatabaseBasePath',\n\n // NODE-SPECIFIC WEBSQL CONFIG\n 'sqlBusyTimeout', // Defaults to 1000\n 'sqlTrace', // Callback not used by default\n 'sqlProfile', // Callback not used by default\n\n 'createIndexes'\n]).forEach((prop) => {\n /** @type {(val: any) => void} */\n let validator;\n if (Array.isArray(prop)) {\n [prop, validator] = prop;\n }\n Object.defineProperty(CFG, prop, {\n get () {\n return map[prop];\n },\n set (val) {\n if (validator) {\n validator(val);\n }\n map[prop] = val;\n }\n });\n});\n\nexport default CFG;\n","// @ts-nocheck\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nvar regex$1;\nvar hasRequiredRegex;\n\nfunction requireRegex () {\n\tif (hasRequiredRegex) return regex$1;\n\thasRequiredRegex = 1;\n\tregex$1=/[\\xC0-\\xC5\\xC7-\\xCF\\xD1-\\xD6\\xD9-\\xDD\\xE0-\\xE5\\xE7-\\xEF\\xF1-\\xF6\\xF9-\\xFD\\xFF-\\u010F\\u0112-\\u0125\\u0128-\\u0130\\u0134-\\u0137\\u0139-\\u013E\\u0143-\\u0148\\u014C-\\u0151\\u0154-\\u0165\\u0168-\\u017E\\u01A0\\u01A1\\u01AF\\u01B0\\u01CD-\\u01DC\\u01DE-\\u01E3\\u01E6-\\u01F0\\u01F4\\u01F5\\u01F8-\\u021B\\u021E\\u021F\\u0226-\\u0233\\u0344\\u0385\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u0390\\u03AA-\\u03B0\\u03CA-\\u03CE\\u03D3\\u03D4\\u0400\\u0401\\u0403\\u0407\\u040C-\\u040E\\u0419\\u0439\\u0450\\u0451\\u0453\\u0457\\u045C-\\u045E\\u0476\\u0477\\u04C1\\u04C2\\u04D0-\\u04D3\\u04D6\\u04D7\\u04DA-\\u04DF\\u04E2-\\u04E7\\u04EA-\\u04F5\\u04F8\\u04F9\\u0622-\\u0626\\u06C0\\u06C2\\u06D3\\u0929\\u0931\\u0934\\u0958-\\u095F\\u09CB\\u09CC\\u09DC\\u09DD\\u09DF\\u0A33\\u0A36\\u0A59-\\u0A5B\\u0A5E\\u0B48\\u0B4B\\u0B4C\\u0B5C\\u0B5D\\u0B94\\u0BCA-\\u0BCC\\u0C48\\u0CC0\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0D4A-\\u0D4C\\u0DDA\\u0DDC-\\u0DDE\\u0F43\\u0F4D\\u0F52\\u0F57\\u0F5C\\u0F69\\u0F73\\u0F75\\u0F76\\u0F78\\u0F81\\u0F93\\u0F9D\\u0FA2\\u0FA7\\u0FAC\\u0FB9\\u1026\\u1B06\\u1B08\\u1B0A\\u1B0C\\u1B0E\\u1B12\\u1B3B\\u1B3D\\u1B40\\u1B41\\u1B43\\u1E00-\\u1E99\\u1E9B\\u1EA0-\\u1EF9\\u1F00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FC1-\\u1FC4\\u1FC6-\\u1FD3\\u1FD6-\\u1FDB\\u1FDD-\\u1FEE\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u212B\\u219A\\u219B\\u21AE\\u21CD-\\u21CF\\u2204\\u2209\\u220C\\u2224\\u2226\\u2241\\u2244\\u2247\\u2249\\u2260\\u2262\\u226D-\\u2271\\u2274\\u2275\\u2278\\u2279\\u2280\\u2281\\u2284\\u2285\\u2288\\u2289\\u22AC-\\u22AF\\u22E0-\\u22E3\\u22EA-\\u22ED\\u2ADC\\u304C\\u304E\\u3050\\u3052\\u3054\\u3056\\u3058\\u305A\\u305C\\u305E\\u3060\\u3062\\u3065\\u3067\\u3069\\u3070\\u3071\\u3073\\u3074\\u3076\\u3077\\u3079\\u307A\\u307C\\u307D\\u3094\\u309E\\u30AC\\u30AE\\u30B0\\u30B2\\u30B4\\u30B6\\u30B8\\u30BA\\u30BC\\u30BE\\u30C0\\u30C2\\u30C5\\u30C7\\u30C9\\u30D0\\u30D1\\u30D3\\u30D4\\u30D6\\u30D7\\u30D9\\u30DA\\u30DC\\u30DD\\u30F4\\u30F7-\\u30FA\\u30FE\\uAC00-\\uD7A3\\uFB1D\\uFB1F\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFB4E]|\\uD801[\\uDDC9\\uDDE4]|\\uD804[\\uDC9A\\uDC9C\\uDCAB\\uDD2E\\uDD2F\\uDF4B\\uDF4C\\uDF83\\uDF85\\uDF8E\\uDF91\\uDFC5\\uDFC7\\uDFC8]|\\uD805[\\uDCBB\\uDCBC\\uDCBE\\uDDBA\\uDDBB]|\\uD806\\uDD38|\\uD818[\\uDD21-\\uDD28]|\\uD81B[\\uDD68-\\uDD6A]|\\uD834[\\uDD5E-\\uDD64\\uDDBB-\\uDDC0]/;\n\treturn regex$1;\n}\n\nvar regexExports = requireRegex();\nvar regex = /*@__PURE__*/getDefaultExportFromCjs(regexExports);\n\nexport { regex as default };\n","/* eslint-disable new-cap -- ToString is how it is defined */\n/* eslint-disable sonarjs/no-control-regex -- Needed */\nimport CFG from './CFG.js';\nimport expandsOnNFD from './unicode-regex.js';\n\n/**\n * @typedef {number} Integer\n */\n\n/**\n * @param {string} arg\n * @returns {string}\n */\nfunction escapeUnmatchedSurrogates (arg) {\n // http://stackoverflow.com/a/6701665/271577\n return arg.replaceAll(\n /([\\uD800-\\uDBFF])(?![\\uDC00-\\uDFFF])|(^|[^\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])/gu,\n function (_, unmatchedHighSurrogate, precedingLow, unmatchedLowSurrogate) {\n // Could add a corresponding surrogate for compatibility with `node-sqlite3`: http://bugs.python.org/issue12569 and http://stackoverflow.com/a/6701665/271577\n // but Chrome having problems\n if (unmatchedHighSurrogate) {\n return '^2' + unmatchedHighSurrogate.codePointAt()\n .toString(16).padStart(4, '0');\n }\n return (precedingLow || '') + '^3' +\n unmatchedLowSurrogate.codePointAt().toString(16).padStart(4, '0');\n }\n );\n}\n\n/**\n * @param {string} arg\n * @returns {string}\n */\nfunction escapeNameForSQLiteIdentifier (arg) {\n // http://stackoverflow.com/a/6701665/271577\n return '_' + // Prevent empty string\n escapeUnmatchedSurrogates(\n arg.replaceAll('^', '^^') // Escape our escape\n // http://www.sqlite.org/src/tktview?name=57c971fc74\n .replaceAll('\\0', '^0')\n // We need to avoid identifiers being treated as duplicates based on SQLite's ASCII-only case-insensitive table and column names\n // (For SQL in general, however, see http://stackoverflow.com/a/17215009/271577\n // See also https://www.sqlite.org/faq.html#q18 re: Unicode (non-ASCII) case-insensitive not working\n .replaceAll(/([A-Z])/gu, '^$1')\n );\n}\n\n/**\n * The escaping of unmatched surrogates was needed by Chrome but not Node.\n * @param {string} arg\n * @returns {string}\n */\nfunction escapeSQLiteStatement (arg) {\n return escapeUnmatchedSurrogates(arg.replaceAll('^', '^^').replaceAll('\\0', '^0'));\n}\n\n/**\n * @param {string} arg\n * @returns {string}\n */\nfunction unescapeSQLiteResponse (arg) {\n return unescapeUnmatchedSurrogates(arg)\n .replaceAll(/(\\^+)0/gu, (_, esc) => {\n return esc.length % 2\n ? esc.slice(1) + '\\0'\n : _;\n })\n .replaceAll('^^', '^');\n}\n\n/**\n * @param {string} arg\n * @returns {string}\n */\nfunction sqlEscape (arg) {\n // https://www.sqlite.org/lang_keywords.html\n // http://stackoverflow.com/a/6701665/2