(function(global2, factory) { typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@b.s/txn"), require("@b.s/incremental"), require("vue")) : typeof define === "function" && define.amd ? define(["exports", "@b.s/txn", "@b.s/incremental", "vue"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["Vue Qwery"] = {}, global2.txn, global2.incremental, global2.Vue)); })(this, function(exports2, txn, incremental, vue) { "use strict";var __accessCheck = (obj, member, msg) => { if (!member.has(obj)) throw TypeError("Cannot " + msg); }; var __privateGet = (obj, member, getter) => { __accessCheck(obj, member, "read from private field"); return getter ? getter.call(obj) : member.get(obj); }; var __privateAdd = (obj, member, value) => { if (member.has(obj)) throw TypeError("Cannot add the same private member more than once"); member instanceof WeakSet ? member.add(obj) : member.set(obj, value); }; var __privateSet = (obj, member, value, setter) => { __accessCheck(obj, member, "write to private field"); setter ? setter.call(obj, value) : member.set(obj, value); return value; }; var _requests, _a, _instance; var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; } function listCacheClear$1() { this.__data__ = []; this.size = 0; } var _listCacheClear = listCacheClear$1; function eq$4(value, other) { return value === other || value !== value && other !== other; } var eq_1 = eq$4; var eq$3 = eq_1; function assocIndexOf$4(array, key) { var length = array.length; while (length--) { if (eq$3(array[length][0], key)) { return length; } } return -1; } var _assocIndexOf = assocIndexOf$4; var assocIndexOf$3 = _assocIndexOf; var arrayProto = Array.prototype; var splice = arrayProto.splice; function listCacheDelete$1(key) { var data = this.__data__, index = assocIndexOf$3(data, key); if (index < 0) { return false; } var lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { splice.call(data, index, 1); } --this.size; return true; } var _listCacheDelete = listCacheDelete$1; var assocIndexOf$2 = _assocIndexOf; function listCacheGet$1(key) { var data = this.__data__, index = assocIndexOf$2(data, key); return index < 0 ? void 0 : data[index][1]; } var _listCacheGet = listCacheGet$1; var assocIndexOf$1 = _assocIndexOf; function listCacheHas$1(key) { return assocIndexOf$1(this.__data__, key) > -1; } var _listCacheHas = listCacheHas$1; var assocIndexOf = _assocIndexOf; function listCacheSet$1(key, value) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { ++this.size; data.push([key, value]); } else { data[index][1] = value; } return this; } var _listCacheSet = listCacheSet$1; var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet; function ListCache$4(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } ListCache$4.prototype.clear = listCacheClear; ListCache$4.prototype["delete"] = listCacheDelete; ListCache$4.prototype.get = listCacheGet; ListCache$4.prototype.has = listCacheHas; ListCache$4.prototype.set = listCacheSet; var _ListCache = ListCache$4; var ListCache$3 = _ListCache; function stackClear$1() { this.__data__ = new ListCache$3(); this.size = 0; } var _stackClear = stackClear$1; function stackDelete$1(key) { var data = this.__data__, result = data["delete"](key); this.size = data.size; return result; } var _stackDelete = stackDelete$1; function stackGet$1(key) { return this.__data__.get(key); } var _stackGet = stackGet$1; function stackHas$1(key) { return this.__data__.has(key); } var _stackHas = stackHas$1; var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; var _freeGlobal = freeGlobal$1; var freeGlobal = _freeGlobal; var freeSelf = typeof self == "object" && self && self.Object === Object && self; var root$4 = freeGlobal || freeSelf || Function("return this")(); var _root = root$4; var root$3 = _root; var Symbol$3 = root$3.Symbol; var _Symbol = Symbol$3; var Symbol$2 = _Symbol; var objectProto$a = Object.prototype; var hasOwnProperty$8 = objectProto$a.hasOwnProperty; var nativeObjectToString$1 = objectProto$a.toString; var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0; function getRawTag$1(value) { var isOwn = hasOwnProperty$8.call(value, symToStringTag$1), tag = value[symToStringTag$1]; try { value[symToStringTag$1] = void 0; var unmasked = true; } catch (e) { } var result = nativeObjectToString$1.call(value); if (unmasked) { if (isOwn) { value[symToStringTag$1] = tag; } else { delete value[symToStringTag$1]; } } return result; } var _getRawTag = getRawTag$1; var objectProto$9 = Object.prototype; var nativeObjectToString = objectProto$9.toString; function objectToString$1(value) { return nativeObjectToString.call(value); } var _objectToString = objectToString$1; var Symbol$1 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString; var nullTag = "[object Null]", undefinedTag = "[object Undefined]"; var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0; function baseGetTag$4(value) { if (value == null) { return value === void 0 ? undefinedTag : nullTag; } return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); } var _baseGetTag = baseGetTag$4; function isObject$7(value) { var type = typeof value; return value != null && (type == "object" || type == "function"); } var isObject_1 = isObject$7; var baseGetTag$3 = _baseGetTag, isObject$6 = isObject_1; var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]"; function isFunction$3(value) { if (!isObject$6(value)) { return false; } var tag = baseGetTag$3(value); return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag; } var isFunction_1 = isFunction$3; var root$2 = _root; var coreJsData$1 = root$2["__core-js_shared__"]; var _coreJsData = coreJsData$1; var coreJsData = _coreJsData; var maskSrcKey = function() { var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); return uid ? "Symbol(src)_1." + uid : ""; }(); function isMasked$1(func) { return !!maskSrcKey && maskSrcKey in func; } var _isMasked = isMasked$1; var funcProto$2 = Function.prototype; var funcToString$2 = funcProto$2.toString; function toSource$1(func) { if (func != null) { try { return funcToString$2.call(func); } catch (e) { } try { return func + ""; } catch (e) { } } return ""; } var _toSource = toSource$1; var isFunction$2 = isFunction_1, isMasked = _isMasked, isObject$5 = isObject_1, toSource = _toSource; var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; var reIsHostCtor = /^\[object .+?Constructor\]$/; var funcProto$1 = Function.prototype, objectProto$8 = Object.prototype; var funcToString$1 = funcProto$1.toString; var hasOwnProperty$7 = objectProto$8.hasOwnProperty; var reIsNative = RegExp( "^" + funcToString$1.call(hasOwnProperty$7).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" ); function baseIsNative$1(value) { if (!isObject$5(value) || isMasked(value)) { return false; } var pattern = isFunction$2(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource(value)); } var _baseIsNative = baseIsNative$1; function getValue$1(object, key) { return object == null ? void 0 : object[key]; } var _getValue = getValue$1; var baseIsNative = _baseIsNative, getValue = _getValue; function getNative$3(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : void 0; } var _getNative = getNative$3; var getNative$2 = _getNative, root$1 = _root; var Map$3 = getNative$2(root$1, "Map"); var _Map = Map$3; var getNative$1 = _getNative; var nativeCreate$4 = getNative$1(Object, "create"); var _nativeCreate = nativeCreate$4; var nativeCreate$3 = _nativeCreate; function hashClear$1() { this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {}; this.size = 0; } var _hashClear = hashClear$1; function hashDelete$1(key) { var result = this.has(key) && delete this.__data__[key]; this.size -= result ? 1 : 0; return result; } var _hashDelete = hashDelete$1; var nativeCreate$2 = _nativeCreate; var HASH_UNDEFINED$1 = "__lodash_hash_undefined__"; var objectProto$7 = Object.prototype; var hasOwnProperty$6 = objectProto$7.hasOwnProperty; function hashGet$1(key) { var data = this.__data__; if (nativeCreate$2) { var result = data[key]; return result === HASH_UNDEFINED$1 ? void 0 : result; } return hasOwnProperty$6.call(data, key) ? data[key] : void 0; } var _hashGet = hashGet$1; var nativeCreate$1 = _nativeCreate; var objectProto$6 = Object.prototype; var hasOwnProperty$5 = objectProto$6.hasOwnProperty; function hashHas$1(key) { var data = this.__data__; return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$5.call(data, key); } var _hashHas = hashHas$1; var nativeCreate = _nativeCreate; var HASH_UNDEFINED = "__lodash_hash_undefined__"; function hashSet$1(key, value) { var data = this.__data__; this.size += this.has(key) ? 0 : 1; data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value; return this; } var _hashSet = hashSet$1; var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet; function Hash$1(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } Hash$1.prototype.clear = hashClear; Hash$1.prototype["delete"] = hashDelete; Hash$1.prototype.get = hashGet; Hash$1.prototype.has = hashHas; Hash$1.prototype.set = hashSet; var _Hash = Hash$1; var Hash = _Hash, ListCache$2 = _ListCache, Map$2 = _Map; function mapCacheClear$1() { this.size = 0; this.__data__ = { "hash": new Hash(), "map": new (Map$2 || ListCache$2)(), "string": new Hash() }; } var _mapCacheClear = mapCacheClear$1; function isKeyable$1(value) { var type = typeof value; return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null; } var _isKeyable = isKeyable$1; var isKeyable = _isKeyable; function getMapData$4(map, key) { var data = map.__data__; return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; } var _getMapData = getMapData$4; var getMapData$3 = _getMapData; function mapCacheDelete$1(key) { var result = getMapData$3(this, key)["delete"](key); this.size -= result ? 1 : 0; return result; } var _mapCacheDelete = mapCacheDelete$1; var getMapData$2 = _getMapData; function mapCacheGet$1(key) { return getMapData$2(this, key).get(key); } var _mapCacheGet = mapCacheGet$1; var getMapData$1 = _getMapData; function mapCacheHas$1(key) { return getMapData$1(this, key).has(key); } var _mapCacheHas = mapCacheHas$1; var getMapData = _getMapData; function mapCacheSet$1(key, value) { var data = getMapData(this, key), size = data.size; data.set(key, value); this.size += data.size == size ? 0 : 1; return this; } var _mapCacheSet = mapCacheSet$1; var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet; function MapCache$1(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } MapCache$1.prototype.clear = mapCacheClear; MapCache$1.prototype["delete"] = mapCacheDelete; MapCache$1.prototype.get = mapCacheGet; MapCache$1.prototype.has = mapCacheHas; MapCache$1.prototype.set = mapCacheSet; var _MapCache = MapCache$1; var ListCache$1 = _ListCache, Map$1 = _Map, MapCache = _MapCache; var LARGE_ARRAY_SIZE = 200; function stackSet$1(key, value) { var data = this.__data__; if (data instanceof ListCache$1) { var pairs = data.__data__; if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) { pairs.push([key, value]); this.size = ++data.size; return this; } data = this.__data__ = new MapCache(pairs); } data.set(key, value); this.size = data.size; return this; } var _stackSet = stackSet$1; var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet; function Stack$1(entries) { var data = this.__data__ = new ListCache(entries); this.size = data.size; } Stack$1.prototype.clear = stackClear; Stack$1.prototype["delete"] = stackDelete; Stack$1.prototype.get = stackGet; Stack$1.prototype.has = stackHas; Stack$1.prototype.set = stackSet; var _Stack = Stack$1; var getNative = _getNative; var defineProperty$2 = function() { try { var func = getNative(Object, "defineProperty"); func({}, "", {}); return func; } catch (e) { } }(); var _defineProperty = defineProperty$2; var defineProperty$1 = _defineProperty; function baseAssignValue$3(object, key, value) { if (key == "__proto__" && defineProperty$1) { defineProperty$1(object, key, { "configurable": true, "enumerable": true, "value": value, "writable": true }); } else { object[key] = value; } } var _baseAssignValue = baseAssignValue$3; var baseAssignValue$2 = _baseAssignValue, eq$2 = eq_1; function assignMergeValue$2(object, key, value) { if (value !== void 0 && !eq$2(object[key], value) || value === void 0 && !(key in object)) { baseAssignValue$2(object, key, value); } } var _assignMergeValue = assignMergeValue$2; function createBaseFor$1(fromRight) { return function(object, iteratee, keysFunc) { var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length; while (length--) { var key = props[fromRight ? length : ++index]; if (iteratee(iterable[key], key, iterable) === false) { break; } } return object; }; } var _createBaseFor = createBaseFor$1; var createBaseFor = _createBaseFor; var baseFor$1 = createBaseFor(); var _baseFor = baseFor$1; var _cloneBuffer = { exports: {} }; _cloneBuffer.exports; (function(module2, exports3) { var root2 = _root; var freeExports = exports3 && !exports3.nodeType && exports3; var freeModule = freeExports && true && module2 && !module2.nodeType && module2; var moduleExports = freeModule && freeModule.exports === freeExports; var Buffer2 = moduleExports ? root2.Buffer : void 0, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0; function cloneBuffer2(buffer, isDeep) { if (isDeep) { return buffer.slice(); } var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); buffer.copy(result); return result; } module2.exports = cloneBuffer2; })(_cloneBuffer, _cloneBuffer.exports); var _cloneBufferExports = _cloneBuffer.exports; var root = _root; var Uint8Array$1 = root.Uint8Array; var _Uint8Array = Uint8Array$1; var Uint8Array2 = _Uint8Array; function cloneArrayBuffer$1(arrayBuffer) { var result = new arrayBuffer.constructor(arrayBuffer.byteLength); new Uint8Array2(result).set(new Uint8Array2(arrayBuffer)); return result; } var _cloneArrayBuffer = cloneArrayBuffer$1; var cloneArrayBuffer = _cloneArrayBuffer; function cloneTypedArray$1(typedArray, isDeep) { var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } var _cloneTypedArray = cloneTypedArray$1; function copyArray$1(source, array) { var index = -1, length = source.length; array || (array = Array(length)); while (++index < length) { array[index] = source[index]; } return array; } var _copyArray = copyArray$1; var isObject$4 = isObject_1; var objectCreate = Object.create; var baseCreate$1 = /* @__PURE__ */ function() { function object() { } return function(proto) { if (!isObject$4(proto)) { return {}; } if (objectCreate) { return objectCreate(proto); } object.prototype = proto; var result = new object(); object.prototype = void 0; return result; }; }(); var _baseCreate = baseCreate$1; function overArg$1(func, transform) { return function(arg) { return func(transform(arg)); }; } var _overArg = overArg$1; var overArg = _overArg; var getPrototype$2 = overArg(Object.getPrototypeOf, Object); var _getPrototype = getPrototype$2; var objectProto$5 = Object.prototype; function isPrototype$2(value) { var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$5; return value === proto; } var _isPrototype = isPrototype$2; var baseCreate = _baseCreate, getPrototype$1 = _getPrototype, isPrototype$1 = _isPrototype; function initCloneObject$1(object) { return typeof object.constructor == "function" && !isPrototype$1(object) ? baseCreate(getPrototype$1(object)) : {}; } var _initCloneObject = initCloneObject$1; function isObjectLike$5(value) { return value != null && typeof value == "object"; } var isObjectLike_1 = isObjectLike$5; var baseGetTag$2 = _baseGetTag, isObjectLike$4 = isObjectLike_1; var argsTag$1 = "[object Arguments]"; function baseIsArguments$1(value) { return isObjectLike$4(value) && baseGetTag$2(value) == argsTag$1; } var _baseIsArguments = baseIsArguments$1; var baseIsArguments = _baseIsArguments, isObjectLike$3 = isObjectLike_1; var objectProto$4 = Object.prototype; var hasOwnProperty$4 = objectProto$4.hasOwnProperty; var propertyIsEnumerable = objectProto$4.propertyIsEnumerable; var isArguments$2 = baseIsArguments(/* @__PURE__ */ function() { return arguments; }()) ? baseIsArguments : function(value) { return isObjectLike$3(value) && hasOwnProperty$4.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); }; var isArguments_1 = isArguments$2; var isArray$2 = Array.isArray; var isArray_1 = isArray$2; var MAX_SAFE_INTEGER$1 = 9007199254740991; function isLength$2(value) { return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1; } var isLength_1 = isLength$2; var isFunction$1 = isFunction_1, isLength$1 = isLength_1; function isArrayLike$3(value) { return value != null && isLength$1(value.length) && !isFunction$1(value); } var isArrayLike_1 = isArrayLike$3; var isArrayLike$2 = isArrayLike_1, isObjectLike$2 = isObjectLike_1; function isArrayLikeObject$1(value) { return isObjectLike$2(value) && isArrayLike$2(value); } var isArrayLikeObject_1 = isArrayLikeObject$1; var isBuffer$2 = { exports: {} }; function stubFalse() { return false; } var stubFalse_1 = stubFalse; isBuffer$2.exports; (function(module2, exports3) { var root2 = _root, stubFalse2 = stubFalse_1; var freeExports = exports3 && !exports3.nodeType && exports3; var freeModule = freeExports && true && module2 && !module2.nodeType && module2; var moduleExports = freeModule && freeModule.exports === freeExports; var Buffer2 = moduleExports ? root2.Buffer : void 0; var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0; var isBuffer2 = nativeIsBuffer || stubFalse2; module2.exports = isBuffer2; })(isBuffer$2, isBuffer$2.exports); var isBufferExports = isBuffer$2.exports; var baseGetTag$1 = _baseGetTag, getPrototype = _getPrototype, isObjectLike$1 = isObjectLike_1; var objectTag$1 = "[object Object]"; var funcProto = Function.prototype, objectProto$3 = Object.prototype; var funcToString = funcProto.toString; var hasOwnProperty$3 = objectProto$3.hasOwnProperty; var objectCtorString = funcToString.call(Object); function isPlainObject$1(value) { if (!isObjectLike$1(value) || baseGetTag$1(value) != objectTag$1) { return false; } var proto = getPrototype(value); if (proto === null) { return true; } var Ctor = hasOwnProperty$3.call(proto, "constructor") && proto.constructor; return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; } var isPlainObject_1 = isPlainObject$1; var baseGetTag = _baseGetTag, isLength = isLength_1, isObjectLike = isObjectLike_1; var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", weakMapTag = "[object WeakMap]"; var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; var typedArrayTags = {}; typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; function baseIsTypedArray$1(value) { return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } var _baseIsTypedArray = baseIsTypedArray$1; function baseUnary$1(func) { return function(value) { return func(value); }; } var _baseUnary = baseUnary$1; var _nodeUtil = { exports: {} }; _nodeUtil.exports; (function(module2, exports3) { var freeGlobal2 = _freeGlobal; var freeExports = exports3 && !exports3.nodeType && exports3; var freeModule = freeExports && true && module2 && !module2.nodeType && module2; var moduleExports = freeModule && freeModule.exports === freeExports; var freeProcess = moduleExports && freeGlobal2.process; var nodeUtil2 = function() { try { var types = freeModule && freeModule.require && freeModule.require("util").types; if (types) { return types; } return freeProcess && freeProcess.binding && freeProcess.binding("util"); } catch (e) { } }(); module2.exports = nodeUtil2; })(_nodeUtil, _nodeUtil.exports); var _nodeUtilExports = _nodeUtil.exports; var baseIsTypedArray = _baseIsTypedArray, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports; var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; var isTypedArray$2 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; var isTypedArray_1 = isTypedArray$2; function safeGet$2(object, key) { if (key === "constructor" && typeof object[key] === "function") { return; } if (key == "__proto__") { return; } return object[key]; } var _safeGet = safeGet$2; var baseAssignValue$1 = _baseAssignValue, eq$1 = eq_1; var objectProto$2 = Object.prototype; var hasOwnProperty$2 = objectProto$2.hasOwnProperty; function assignValue$1(object, key, value) { var objValue = object[key]; if (!(hasOwnProperty$2.call(object, key) && eq$1(objValue, value)) || value === void 0 && !(key in object)) { baseAssignValue$1(object, key, value); } } var _assignValue = assignValue$1; var assignValue = _assignValue, baseAssignValue = _baseAssignValue; function copyObject$1(source, props, object, customizer) { var isNew = !object; object || (object = {}); var index = -1, length = props.length; while (++index < length) { var key = props[index]; var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0; if (newValue === void 0) { newValue = source[key]; } if (isNew) { baseAssignValue(object, key, newValue); } else { assignValue(object, key, newValue); } } return object; } var _copyObject = copyObject$1; function baseTimes$1(n, iteratee) { var index = -1, result = Array(n); while (++index < n) { result[index] = iteratee(index); } return result; } var _baseTimes = baseTimes$1; var MAX_SAFE_INTEGER = 9007199254740991; var reIsUint = /^(?:0|[1-9]\d*)$/; function isIndex$2(value, length) { var type = typeof value; length = length == null ? MAX_SAFE_INTEGER : length; return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); } var _isIndex = isIndex$2; var baseTimes = _baseTimes, isArguments$1 = isArguments_1, isArray$1 = isArray_1, isBuffer$1 = isBufferExports, isIndex$1 = _isIndex, isTypedArray$1 = isTypedArray_1; var objectProto$1 = Object.prototype; var hasOwnProperty$1 = objectProto$1.hasOwnProperty; function arrayLikeKeys$1(value, inherited) { var isArr = isArray$1(value), isArg = !isArr && isArguments$1(value), isBuff = !isArr && !isArg && isBuffer$1(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { if ((inherited || hasOwnProperty$1.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. isIndex$1(key, length)))) { result.push(key); } } return result; } var _arrayLikeKeys = arrayLikeKeys$1; function nativeKeysIn$1(object) { var result = []; if (object != null) { for (var key in Object(object)) { result.push(key); } } return result; } var _nativeKeysIn = nativeKeysIn$1; var isObject$3 = isObject_1, isPrototype = _isPrototype, nativeKeysIn = _nativeKeysIn; var objectProto = Object.prototype; var hasOwnProperty = objectProto.hasOwnProperty; function baseKeysIn$1(object) { if (!isObject$3(object)) { return nativeKeysIn(object); } var isProto = isPrototype(object), result = []; for (var key in object) { if (!(key == "constructor" && (isProto || !hasOwnProperty.call(object, key)))) { result.push(key); } } return result; } var _baseKeysIn = baseKeysIn$1; var arrayLikeKeys = _arrayLikeKeys, baseKeysIn = _baseKeysIn, isArrayLike$1 = isArrayLike_1; function keysIn$2(object) { return isArrayLike$1(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); } var keysIn_1 = keysIn$2; var copyObject = _copyObject, keysIn$1 = keysIn_1; function toPlainObject$1(value) { return copyObject(value, keysIn$1(value)); } var toPlainObject_1 = toPlainObject$1; var assignMergeValue$1 = _assignMergeValue, cloneBuffer = _cloneBufferExports, cloneTypedArray = _cloneTypedArray, copyArray = _copyArray, initCloneObject = _initCloneObject, isArguments = isArguments_1, isArray = isArray_1, isArrayLikeObject = isArrayLikeObject_1, isBuffer = isBufferExports, isFunction = isFunction_1, isObject$2 = isObject_1, isPlainObject = isPlainObject_1, isTypedArray = isTypedArray_1, safeGet$1 = _safeGet, toPlainObject = toPlainObject_1; function baseMergeDeep$1(object, source, key, srcIndex, mergeFunc, customizer, stack) { var objValue = safeGet$1(object, key), srcValue = safeGet$1(source, key), stacked = stack.get(srcValue); if (stacked) { assignMergeValue$1(object, key, stacked); return; } var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : void 0; var isCommon = newValue === void 0; if (isCommon) { var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue); newValue = srcValue; if (isArr || isBuff || isTyped) { if (isArray(objValue)) { newValue = objValue; } else if (isArrayLikeObject(objValue)) { newValue = copyArray(objValue); } else if (isBuff) { isCommon = false; newValue = cloneBuffer(srcValue, true); } else if (isTyped) { isCommon = false; newValue = cloneTypedArray(srcValue, true); } else { newValue = []; } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { newValue = objValue; if (isArguments(objValue)) { newValue = toPlainObject(objValue); } else if (!isObject$2(objValue) || isFunction(objValue)) { newValue = initCloneObject(srcValue); } } else { isCommon = false; } } if (isCommon) { stack.set(srcValue, newValue); mergeFunc(newValue, srcValue, srcIndex, customizer, stack); stack["delete"](srcValue); } assignMergeValue$1(object, key, newValue); } var _baseMergeDeep = baseMergeDeep$1; var Stack = _Stack, assignMergeValue = _assignMergeValue, baseFor = _baseFor, baseMergeDeep = _baseMergeDeep, isObject$1 = isObject_1, keysIn = keysIn_1, safeGet = _safeGet; function baseMerge$1(object, source, srcIndex, customizer, stack) { if (object === source) { return; } baseFor(source, function(srcValue, key) { stack || (stack = new Stack()); if (isObject$1(srcValue)) { baseMergeDeep(object, source, key, srcIndex, baseMerge$1, customizer, stack); } else { var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : void 0; if (newValue === void 0) { newValue = srcValue; } assignMergeValue(object, key, newValue); } }, keysIn); } var _baseMerge = baseMerge$1; function identity$2(value) { return value; } var identity_1 = identity$2; function apply$1(func, thisArg, args) { switch (args.length) { case 0: return func.call(thisArg); case 1: return func.call(thisArg, args[0]); case 2: return func.call(thisArg, args[0], args[1]); case 3: return func.call(thisArg, args[0], args[1], args[2]); } return func.apply(thisArg, args); } var _apply = apply$1; var apply = _apply; var nativeMax = Math.max; function overRest$1(func, start, transform) { start = nativeMax(start === void 0 ? func.length - 1 : start, 0); return function() { var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length); while (++index < length) { array[index] = args[start + index]; } index = -1; var otherArgs = Array(start + 1); while (++index < start) { otherArgs[index] = args[index]; } otherArgs[start] = transform(array); return apply(func, this, otherArgs); }; } var _overRest = overRest$1; function constant$1(value) { return function() { return value; }; } var constant_1 = constant$1; var constant = constant_1, defineProperty = _defineProperty, identity$1 = identity_1; var baseSetToString$1 = !defineProperty ? identity$1 : function(func, string) { return defineProperty(func, "toString", { "configurable": true, "enumerable": false, "value": constant(string), "writable": true }); }; var _baseSetToString = baseSetToString$1; var HOT_COUNT = 800, HOT_SPAN = 16; var nativeNow = Date.now; function shortOut$1(func) { var count = 0, lastCalled = 0; return function() { var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled); lastCalled = stamp; if (remaining > 0) { if (++count >= HOT_COUNT) { return arguments[0]; } } else { count = 0; } return func.apply(void 0, arguments); }; } var _shortOut = shortOut$1; var baseSetToString = _baseSetToString, shortOut = _shortOut; var setToString$1 = shortOut(baseSetToString); var _setToString = setToString$1; var identity = identity_1, overRest = _overRest, setToString = _setToString; function baseRest$1(func, start) { return setToString(overRest(func, start, identity), func + ""); } var _baseRest = baseRest$1; var eq = eq_1, isArrayLike = isArrayLike_1, isIndex = _isIndex, isObject = isObject_1; function isIterateeCall$1(value, index, object) { if (!isObject(object)) { return false; } var type = typeof index; if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) { return eq(object[index], value); } return false; } var _isIterateeCall = isIterateeCall$1; var baseRest = _baseRest, isIterateeCall = _isIterateeCall; function createAssigner$1(assigner) { return baseRest(function(object, sources) { var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : void 0, guard = length > 2 ? sources[2] : void 0; customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : void 0; if (guard && isIterateeCall(sources[0], sources[1], guard)) { customizer = length < 3 ? void 0 : customizer; length = 1; } object = Object(object); while (++index < length) { var source = sources[index]; if (source) { assigner(object, source, index, customizer); } } return object; }); } var _createAssigner = createAssigner$1; var baseMerge = _baseMerge, createAssigner = _createAssigner; var merge = createAssigner(function(object, source, srcIndex) { baseMerge(object, source, srcIndex); }); var merge_1 = merge; const merge$1 = /* @__PURE__ */ getDefaultExportFromCjs(merge_1); function noop$1() { } var noop_1 = noop$1; const noop$2 = /* @__PURE__ */ getDefaultExportFromCjs(noop_1); var createWeakMergeCache = () => new Proxy(/* @__PURE__ */ new Map(), { get: (target, p) => { const value = Reflect.get(target, p); if (p === "set" && typeof value === "function") { return new Proxy(value.bind(target), { apply: (set2, thisArg, args) => { const [key, value2] = args; if (value2 && typeof value2 === "object") { const existingValue = target.has(key) ? target.get(key) : /* @__PURE__ */ Object.create(null); const unwrapped = existingValue instanceof WeakRef ? existingValue.deref() ?? /* @__PURE__ */ Object.create(null) : existingValue; const merged = merge$1(unwrapped, value2); return Reflect.apply(set2, thisArg, [ key, new WeakRef(merged) ]); } return Reflect.apply(set2, thisArg, args); } }); } if (p === "get" && typeof value === "function") { return new Proxy(value.bind(target), { apply: (get2, thisArg, args) => { const [key] = args; if (!target.has(key)) return null; const value2 = Reflect.apply(get2, thisArg, [key]); if (value2 instanceof WeakRef) { const unwrapped = value2.deref(); if (!unwrapped) { target.delete(key); } return unwrapped ?? null; } return value2 ?? null; } }); } if (typeof value === "function") { return value.bind(target); } return value; } }); var isBrowser = () => Boolean( typeof window !== "undefined" && window.document && window.document.createElement ); var NetworkMode = /* @__PURE__ */ ((NetworkMode2) => { NetworkMode2[NetworkMode2["Offline"] = 0] = "Offline"; NetworkMode2[NetworkMode2["Online"] = 1] = "Online"; return NetworkMode2; })(NetworkMode || {}); var makeOnBroadcast = (qwery, { fetchPolicy, queryKey, cache, rerender }) => async (event) => { var _a2, _b; const awaitedQwery = await qwery; if (!awaitedQwery) { return; } if (event.data.id === awaitedQwery.id) { return; } const options = { isPersisted: true, isBroadcasted: true }; if (queryKey && fetchPolicy !== "network-only") { (_a2 = cache == null ? void 0 : cache.setCachedValue) == null ? void 0 : _a2.call(cache, queryKey)(event.data.next); } (_b = awaitedQwery.crdt) == null ? void 0 : _b.dispatch(event.data.next, options); rerender(); }; var makeOnWindowFocus = (qwery) => async () => { const awaitedQwery = await qwery; if (!awaitedQwery) { return; } await awaitedQwery.reset(); }; var createId = () => Math.random().toString(32).substring(2); var resources$1 = { circularAffects: (queryKey) => `Qwery with key \`${queryKey.toString()}\` circularly affects itself ` }; var MAP = /* @__PURE__ */ new WeakMap(); var has = (key) => MAP.has(key); var set = (key, value) => { const existing = MAP.has(key) ? get(key) : []; existing.push(value); MAP.set(key, existing); }; var get = (key) => MAP.get(key); var WEAK_KEYS = /* @__PURE__ */ new Map(); var toWeakKey = (queryKey) => { if (WEAK_KEYS.has(queryKey)) { return WEAK_KEYS.get(queryKey); } const weakKey = [queryKey]; WEAK_KEYS.set(queryKey, weakKey); return weakKey; }; var makeOnChange = ({ base = noop$2, throwErrors, queryKey, fetchPolicy, broadcast, rerender, onBroadcast, onCacheUpdate }) => new Proxy(base, { apply: (base2, thisArg, args) => { const [next] = args; const result = Reflect.apply(base2, thisArg, args); const isAsync = result instanceof Promise; const isSync = !result; const shouldBroadcast = queryKey && broadcast; const shouldUpdateCache = queryKey && fetchPolicy && fetchPolicy !== "network-only"; if (isAsync && throwErrors) { result.catch((reason) => { throw reason; }); } if (isSync) { if (shouldBroadcast) { onBroadcast == null ? void 0 : onBroadcast(next); } if (shouldUpdateCache) { onCacheUpdate == null ? void 0 : onCacheUpdate(next); } rerender == null ? void 0 : rerender(); } return result; } }); var makeOnSuccess = ({ base = noop$2, queryKey, fetchPolicy, broadcast, rerender, onBroadcast, onCacheUpdate }) => new Proxy(base, { apply: (base2, thisArg, args) => { const next = args.at(0); const merged = Reflect.apply(base2, thisArg, args); const final = merged || next; const shouldBroadcast = queryKey && broadcast; const shouldUpdateCache = queryKey && fetchPolicy && fetchPolicy !== "network-only"; if (shouldBroadcast) { onBroadcast == null ? void 0 : onBroadcast(final); } if (shouldUpdateCache) { onCacheUpdate == null ? void 0 : onCacheUpdate(final); } rerender == null ? void 0 : rerender(); return merged; } }); var makeOnError = ({ base = noop$2, queryKey, fetchPolicy, broadcast, rerender, onBroadcast, onCacheUpdate }) => new Proxy(base, { apply: (base2, thisArg, args) => { const previous = args.at(1); Reflect.apply(base2, thisArg, args); const shouldBroadcast = queryKey && broadcast; const shouldUpdateCache = queryKey && fetchPolicy && fetchPolicy !== "network-only"; if (shouldBroadcast) { onBroadcast == null ? void 0 : onBroadcast(previous); } if (shouldUpdateCache) { onCacheUpdate == null ? void 0 : onCacheUpdate(previous); } rerender == null ? void 0 : rerender(); } }); var makeDispatch = ({ base, queryKey, fetchPolicy, broadcast, affects, onBroadcast, onCacheUpdate, rerender }) => new Proxy(base, { apply: (base2, thisArg, args) => { const options = args.at(1); const result = Reflect.apply(base2, thisArg, args); if (options == null ? void 0 : options.isPersisted) { const shouldUpdateCache = queryKey && fetchPolicy && fetchPolicy !== "network-only"; if (!options.isBroadcasted && broadcast) { onBroadcast == null ? void 0 : onBroadcast(result); } if (shouldUpdateCache) { onCacheUpdate == null ? void 0 : onCacheUpdate(result); } rerender == null ? void 0 : rerender(); } if (queryKey && (options == null ? void 0 : options.triggeredBy) === queryKey.toString()) { console.trace(resources$1.circularAffects(queryKey == null ? void 0 : queryKey.toString())); } else if (queryKey && (options == null ? void 0 : options.triggeredBy) !== queryKey.toString()) { affects == null ? void 0 : affects.forEach((affected) => { const weakKey = toWeakKey(affected.toString()); if (affected.toString() === queryKey.toString() || !has(weakKey)) { return; } const allResetsForKey = get(weakKey); allResetsForKey.forEach((reset) => { reset((options == null ? void 0 : options.triggeredBy) ?? queryKey.toString()); }); }); } return result; } }); var createQwery = ({ fetchPolicy, queryKey: originalQueryKey, initialValue, onChange, onSuccess, onError, broadcast, cache, rerender, debug, abortController = new AbortController(), refetch, affects, throwErrors }) => { const queryKey = Array.isArray(originalQueryKey) ? originalQueryKey.sort( (a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b), void 0, { sensitivity: "base" }) ) : originalQueryKey; const id = createId(); const channel = !queryKey || !broadcast ? null : new BroadcastChannel(queryKey.toString()); const makeOnCacheUpdate = () => { if (!queryKey) { return; } return cache == null ? void 0 : cache.makeOnChange(queryKey.toString()); }; const onBroadcast = (value) => channel == null ? void 0 : channel.postMessage({ id, next: value }); const onCacheUpdate = makeOnCacheUpdate(); const crdt = incremental.createCRDT({ initialValue, onChange: makeOnChange({ base: onChange, throwErrors, queryKey, fetchPolicy, broadcast, rerender, onBroadcast, onCacheUpdate }), onSuccess: makeOnSuccess({ base: onSuccess, queryKey, fetchPolicy, broadcast, rerender, onBroadcast, onCacheUpdate }), onError: makeOnError({ base: onError, queryKey, fetchPolicy, broadcast, rerender, onBroadcast, onCacheUpdate }), trackVersions: debug }); Object.assign(crdt, { dispatch: makeDispatch({ base: crdt.dispatch, queryKey, fetchPolicy, broadcast, affects, onBroadcast, onCacheUpdate, rerender }) }); const reset = (triggeredBy) => { const reset2 = refetch == null ? void 0 : refetch(abortController.signal); if (reset2 instanceof Promise) { reset2.then((result) => { crdt.dispatch(result, { isPersisted: true, triggeredBy }); }); return; } crdt.dispatch(reset2, { isPersisted: true, triggeredBy }); }; if (queryKey) { set(toWeakKey(queryKey.toString()), reset); } return { id, crdt, abortController, channel, reset }; }; var subscribeQwery = (qwery, subscribe) => { if (!qwery) { return; } const proxiedDispatch = new Proxy(qwery.crdt.dispatch, { apply: (dispatch, thisArg, args) => { const subscribeOptions = { isPersisted: true, isBroadcasted: true }; const result = Reflect.apply(dispatch, thisArg, [ args[0], subscribeOptions ]); return result; } }); const maybeUnsubscribe = subscribe == null ? void 0 : subscribe( proxiedDispatch, qwery.abortController.signal ); const unsubscribe = () => { if (maybeUnsubscribe instanceof Promise) { return void maybeUnsubscribe.then((unsubscribe2) => unsubscribe2 == null ? void 0 : unsubscribe2()); } return maybeUnsubscribe == null ? void 0 : maybeUnsubscribe(); }; return unsubscribe; }; var computeInitialQweryValue = async ({ fetchPolicy, initialValue, queryKey, cache, abortController, requestManager }) => { var _a2, _b; if (fetchPolicy === "network-only") { if (initialValue instanceof Function) { const fetchedValue = await initialValue(abortController.signal); return fetchedValue; } return initialValue; } const cachedValue = queryKey ? await ((_a2 = cache == null ? void 0 : cache.getCachedValue) == null ? void 0 : _a2.call(cache, queryKey)) : null; if (initialValue instanceof Function) { if (cachedValue && fetchPolicy === "cache-first") { return cachedValue; } const inflightRequest = queryKey && (requestManager == null ? void 0 : requestManager.has(queryKey)) ? requestManager.get(queryKey) : null; let fetchedValue = inflightRequest ?? initialValue(abortController.signal); if (fetchedValue instanceof Promise) { if (queryKey && !inflightRequest) { fetchedValue = fetchedValue.then((result) => { var _a3; if (queryKey) { (_a3 = cache == null ? void 0 : cache.setCachedValue) == null ? void 0 : _a3.call(cache, queryKey)(result); requestManager == null ? void 0 : requestManager.delete(queryKey); return (cache == null ? void 0 : cache.getCachedValue(queryKey)) ?? result; } return result; }); requestManager == null ? void 0 : requestManager.set(queryKey, fetchedValue); } return cachedValue ?? await fetchedValue; } if (queryKey) { (_b = cache == null ? void 0 : cache.setCachedValue) == null ? void 0 : _b.call(cache, queryKey)(fetchedValue); return (cache == null ? void 0 : cache.getCachedValue(queryKey)) ?? fetchedValue; } return fetchedValue; } return cachedValue ?? initialValue; }; var RequestManager = (_a = class { constructor() { __privateAdd(this, _requests, void 0); __privateSet(this, _requests, /* @__PURE__ */ new Map()); } static get instance() { if (!__privateGet(_a, _instance)) { __privateSet(_a, _instance, new _a()); } return __privateGet(_a, _instance); } has(queryKey) { return __privateGet(this, _requests).has(queryKey.toString()); } get(queryKey) { const existingRequest = __privateGet(this, _requests).get(queryKey == null ? void 0 : queryKey.toString()); return existingRequest; } set(queryKey, value) { __privateGet(this, _requests).set(queryKey.toString(), value); } delete(queryKey) { __privateGet(this, _requests).delete(queryKey.toString()); } }, _requests = new WeakMap(), _instance = new WeakMap(), __privateAdd(_a, _instance, void 0), _a); var toAsyncIterable = async function* (f, ms, signal) { signal == null ? void 0 : signal.addEventListener("abort", () => { throw new Error("Aborted"); }); for (let i = 0; i < Infinity; i++) { const result = f(signal); yield result; await sleep(ms); } }; var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); var createNoOpCache = () => ({ has: () => false, get: () => void 0, set: () => void 0, delete: () => void 0 }); var makeMonitor = (update) => (fetchFn, options = /* @__PURE__ */ Object.create(null)) => { const id = createId(); return incremental.makeMonitoredFetch({ ...options, fetchFn, onFetching: (isFetching) => update((allFetchStatus) => { var _a2; return { ...allFetchStatus, [id]: { isFetching, count: (((_a2 = allFetchStatus[id]) == null ? void 0 : _a2.count) ?? 0) + 1 / 2 } }; }) }); }; var restoreScroll = () => { const currentPath = window.location.pathname; const savedScroll = sessionStorage.getItem(currentPath) ? JSON.parse(sessionStorage.getItem(currentPath)) : null; if (savedScroll) { window.scrollTo({ left: savedScroll.scrollX, top: savedScroll.scrollY }); } }; var makeOnScroll = () => { const onScroll = () => { const currentPath = window.location.pathname; sessionStorage.setItem( currentPath, JSON.stringify({ scrollX: window.scrollX, scrollY: window.scrollY }) ); }; return onScroll; }; var BatchedOptionsSymbol = Symbol("QweryBatched"); var makeBatched = ({ executor, decomposer, scheduler: defaultScheduler }) => { const pending = []; const abortController = new AbortController(); const batchedExecutor = async (...args) => { const options = isBatchedOptions(args.at(-1)) ? args.at(-1) : null; const argsWithoutOptions = (options == null ? void 0 : options.immediate) ? args.slice(0, -1) : args; pending.push(...argsWithoutOptions); if (options == null ? void 0 : options.immediate) { abortController.abort(); } const scheduler = (options == null ? void 0 : options.immediate) ? immediateScheduler : defaultScheduler; const result = await scheduler( executor, pending, abortController.signal ); const decomposed = decomposer(result, ...argsWithoutOptions); return decomposed; }; return batchedExecutor; }; var immediate = (batchedExecutor) => batchedExecutor(createBatchedOptions({ immediate: true })); var makeIntervalScheduler = (ms) => { let isWaiting = false; let pendingExecution = Promise.resolve(); return (executor, pending, abortSignal) => { if (isWaiting) { return pendingExecution; } isWaiting = !isWaiting; pendingExecution = pendingExecution.then( () => new Promise((resolve, reject) => { const timeout = setTimeout(() => { try { const consumed = pending.splice(0, Infinity); resolve(executor(consumed)); } catch (error) { reject(error); } }, ms); abortSignal == null ? void 0 : abortSignal.addEventListener("abort", () => { if (!pending.length) { return; } clearTimeout(timeout); reject(new Error("Aborted")); }); }) ); pendingExecution = pendingExecution.then((result) => { isWaiting = !isWaiting; return result; }).catch((error) => { isWaiting = !isWaiting; throw error; }); return pendingExecution; }; }; var makeSizeScheduler = (minimumSize) => { let externalResolve = null; let externalReject = null; let pendingExecution = Promise.resolve(); return (executor, pending, abortSignal) => { abortSignal == null ? void 0 : abortSignal.addEventListener("abort", () => { if (!pending.length) { return; } externalReject == null ? void 0 : externalReject(new Error("Aborted")); }); if (pending.length < minimumSize) { const next = new Promise((resolve, reject) => { externalResolve = resolve; externalReject = reject; }); pendingExecution = pendingExecution.then(() => next); return pendingExecution; } try { const consumed = pending.splice(0, Infinity); externalResolve == null ? void 0 : externalResolve(executor(consumed)); } catch (error) { externalReject == null ? void 0 : externalReject(error); } return pendingExecution; }; }; var isBatchedOptions = (x) => Boolean(x == null ? void 0 : x[BatchedOptionsSymbol]); var createBatchedOptions = (options) => ({ [BatchedOptionsSymbol]: true, ...options }); var immediateScheduler = (executor, pending) => { const consumed = pending.splice(0, Infinity); return executor(consumed); }; const QweryContext = Symbol("QweryContext"); const provideQweryContext = (...args) => { const isObjectParams = typeof args.at(0) === "object"; const store = isObjectParams ? args.at(0).store : args.at(0); const requestManager = isObjectParams ? args.at(0).requestManager : args.at(1); const createCacheProvider = () => { if (isBrowser() && !store) { return incremental.createCacheProvider(createNoOpCache()); } const selectedStore = store ?? createWeakMergeCache(); return incremental.createCacheProvider(selectedStore); }; const context = { cache: createCacheProvider(), requestManager }; return vue.provide(QweryContext, context); }; const useQweryContext = () => { if (!vue.hasInjectionContext()) { return; } return vue.inject(QweryContext, /* @__PURE__ */ Object.create(null)); }; const useMonitoredFetch = () => { const allFetchStatus = vue.ref(/* @__PURE__ */ Object.create(null)); const update = (f) => { const next = f(allFetchStatus.value); allFetchStatus.value = next; }; const monitor = makeMonitor(update); return { isFetching: vue.computed( () => Object.keys(allFetchStatus.value).length > 0 ? Object.values(allFetchStatus.value).some( ({ isFetching }) => isFetching ) : false ), isInitialFetch: vue.computed( () => Object.keys(allFetchStatus.value).length > 0 ? Object.values(allFetchStatus.value).some( ({ isFetching, count }) => isFetching && count < 1 ) : false ), monitor }; }; const useNetworkMode = ({ ping = "https://captive.apple.com/hotspot-detect.html" } = /* @__PURE__ */ Object.create(null)) => { const isConnected = vue.ref(true); const isOnline = () => { isConnected.value = true; }; const isOffline = () => { isConnected.value = false; }; vue.onMounted(() => { fetch(ping).then(isOnline).catch(isOffline); window.addEventListener("online", isOnline); window.addEventListener("offline", isOffline); }); vue.onUpdated(() => { fetch(ping).then(isOnline).catch(isOffline); }); vue.onUnmounted(() => { window.removeEventListener("online", isOnline); window.removeEventListener("offline", isOffline); }); return { connectionStatus: vue.computed( () => isConnected.value ? NetworkMode.Online : NetworkMode.Offline ), isOnline, isOffline }; }; const useRememberScroll = () => { if (!isBrowser()) { return; } const onScroll = makeOnScroll(); vue.onMounted(() => { restoreScroll(); window.addEventListener("scroll", onScroll); }); vue.onUnmounted(() => { window.removeEventListener("scroll", onScroll); }); }; const resources = { multipleWritableBroadcasting: (queryKey) => [ `A writable instance of a broadcasting Qwery with the query key \`${queryKey.toString()}\` exists`, `This instance will be readonly` ].join("\n").concat("\n"), multipleWritableBroadcastingDisabledDispatch: (queryKey) => [ `A writable instance of a broadcasting Qwery with the query key \`${queryKey.toString()}\` exists`, "Dispatch is noop" ].join("\n").concat("\n") }; const BROADCASTING = /* @__PURE__ */ new Set(); const useQwery = ({ fetchPolicy = "cache-first", queryKey, initialValue, placeholder, onChange = noop, onSuccess = noop, onError = noop, subscribe, debug = false, refetchOnWindowFocus = false, broadcast = false, suspense = false, enabled = true, affects, requestManager, throwErrors = suspense }) => { const { cache, requestManager: globalRequestManager } = useQweryContext() ?? /* @__PURE__ */ Object.create(null); const abortController = new AbortController(); const isBroadcasting = (queryKey2) => queryKey2 && broadcast; const isMutating = () => onChange !== noop || refetchOnWindowFocus; let isDispatchDisabled = false; const qwery = vue.shallowRef(null); useRememberScroll(); const rerender = () => { qweryPromise.then((result) => { qwery.value = { ...result ?? /* @__PURE__ */ Object.create(null) }; }); }; const onCreateQwery = () => { if (queryKey !== null && queryKey !== void 0 && isBroadcasting(queryKey)) { if (BROADCASTING.has(queryKey.toString()) && onChange !== noop) { console.debug( new Error(resources.multipleWritableBroadcasting(queryKey)) ); } BROADCASTING.add(queryKey == null ? void 0 : queryKey.toString()); } }; const create = async () => { if (!enabled) { return; } const cachedValueOrInitialValue = await computeInitialQweryValue({ fetchPolicy, initialValue, queryKey, cache, abortController, requestManager: requestManager ?? globalRequestManager }); if (!cachedValueOrInitialValue) { return; } if (isBroadcasting(queryKey) && isMutating() && BROADCASTING.has(queryKey == null ? void 0 : queryKey.toString())) { isDispatchDisabled = true; } const _qwery = createQwery({ fetchPolicy, queryKey, initialValue: cachedValueOrInitialValue, onChange: isBroadcasting(queryKey) && isMutating() && BROADCASTING.has(queryKey == null ? void 0 : queryKey.toString()) ? noop : onChange, onSuccess: isBroadcasting(queryKey) && isMutating() && BROADCASTING.has(queryKey == null ? void 0 : queryKey.toString()) ? noop : onSuccess, onError: isBroadcasting(queryKey) && isMutating() && BROADCASTING.has(queryKey == null ? void 0 : queryKey.toString()) ? noop : onError, broadcast, suspense, cache, rerender, debug, abortController, refetch: typeof initialValue === "function" ? initialValue : null, affects, throwErrors }); qwery.value = _qwery; onCreateQwery(); return _qwery; }; const qweryPromise = create(); const subscription = async () => { const awaitedQwery = await qweryPromise; return subscribeQwery(awaitedQwery, subscribe); }; const unsubscribePromise = subscription(); vue.onUnmounted(() => { BROADCASTING.delete(queryKey == null ? void 0 : queryKey.toString()); abortController.abort(); unsubscribePromise.then((unsubscribe) => unsubscribe == null ? void 0 : unsubscribe()); }); const onBroadcast = makeOnBroadcast(qweryPromise, { fetchPolicy, queryKey, cache, rerender }); vue.onMounted(() => { qweryPromise.then((qwery2) => { var _a2; void ((_a2 = qwery2 == null ? void 0 : qwery2.channel) == null ? void 0 : _a2.addEventListener("message", onBroadcast)); }); }); vue.onUnmounted(() => { qweryPromise.then((qwery2) => { var _a2; void ((_a2 = qwery2 == null ? void 0 : qwery2.channel) == null ? void 0 : _a2.removeEventListener("message", onBroadcast)); }); }); const onWindowFocus = makeOnWindowFocus(qweryPromise); vue.onMounted(() => { if (!refetchOnWindowFocus) { return; } window.addEventListener("focus", onWindowFocus); }); vue.onUnmounted(() => { if (!refetchOnWindowFocus || isBroadcasting(queryKey) && isMutating()) { return; } window.removeEventListener("focus", onWindowFocus); }); const disabledDispatch = () => { console.trace( resources.multipleWritableBroadcastingDisabledDispatch( queryKey ) ); }; const dispatch = new Proxy(noop, { apply: (noop2, _thisArg, args) => { var _a2, _b; if (isDispatchDisabled) { return disabledDispatch(); } if (!((_b = (_a2 = qwery.value) == null ? void 0 : _a2.crdt) == null ? void 0 : _b.dispatch)) { return noop2(); } return qwery.value.crdt.dispatch(...args); } }); const reset = new Proxy(noop, { apply: (noop2) => { var _a2; if (!((_a2 = qwery.value) == null ? void 0 : _a2.reset)) { return noop2(); } return qwery.value.reset(); } }); if (suspense) { return qweryPromise.then((result) => ({ data: vue.computed( () => { var _a2; return ((_a2 = qwery.value) == null ? void 0 : _a2.crdt.data) ?? (result == null ? void 0 : result.crdt.data) ?? (typeof initialValue !== "function" ? initialValue : null) ?? placeholder ?? null; } ), dispatch, versions: vue.computed( () => { var _a2; return ((_a2 = qwery.value) == null ? void 0 : _a2.crdt.versions) ?? (result == null ? void 0 : result.crdt.versions); } ), reset })); } return { data: vue.computed( () => { var _a2, _b; return ((_b = (_a2 = qwery.value) == null ? void 0 : _a2.crdt) == null ? void 0 : _b.data) ?? (typeof initialValue !== "function" ? initialValue : null) ?? placeholder ?? null; } ), dispatch, versions: vue.computed(() => { var _a2, _b; return (_b = (_a2 = qwery.value) == null ? void 0 : _a2.crdt) == null ? void 0 : _b.versions; }), reset }; }; const noop = () => void 0; Object.defineProperty(exports2, "createTransaction", { enumerable: true, get: () => txn.createTransaction }); Object.defineProperty(exports2, "diff", { enumerable: true, get: () => incremental.diff }); Object.defineProperty(exports2, "makeMonitoredFetch", { enumerable: true, get: () => incremental.makeMonitoredFetch }); Object.defineProperty(exports2, "makeRetry", { enumerable: true, get: () => incremental.makeRetry }); exports2.NetworkMode = NetworkMode; exports2.QweryContext = QweryContext; exports2.RequestManager = RequestManager; exports2.immediate = immediate; exports2.isBrowser = isBrowser; exports2.makeBatched = makeBatched; exports2.makeIntervalScheduler = makeIntervalScheduler; exports2.makeSizeScheduler = makeSizeScheduler; exports2.provideQweryContext = provideQweryContext; exports2.toAsyncIterable = toAsyncIterable; exports2.useMonitoredFetch = useMonitoredFetch; exports2.useNetworkMode = useNetworkMode; exports2.useQwery = useQwery; exports2.useQweryContext = useQweryContext; exports2.useRememberScroll = useRememberScroll; Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" }); }); //# sourceMappingURL=vue-qwery.umd.cjs.map