{"version":3,"sources":["webpack:///./src/app/components/ui/dateutils.js","webpack:///./node_modules/dexie/dist/dexie.mjs","webpack:///./src/app/db.js","webpack:///./src/app/pages/PushNotificationManagementPage.js","webpack:///./src/app/static/general/hag-static-page.jpg","webpack:///./src/app/pages/BookmarksPage.js","webpack:///./src/app/components/ui/articleutils.js","webpack:///./src/app/components/StyledLink.js"],"names":["formatAgo","date","full","published","Date","seconds","Math","floor","interval","toLocaleDateString","year","month","day","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__spreadArray","to","from","pack","ar","l","Array","slice","concat","_global","globalThis","self","window","global","keys","isArray","extend","obj","extension","forEach","key","Promise","getProto","getPrototypeOf","_hasOwn","hasOwn","prop","props","proto","Reflect","ownKeys","setProp","defineProperty","functionOrGetSet","options","get","set","configurable","value","writable","derive","Child","Parent","create","bind","getOwnPropertyDescriptor","getPropertyDescriptor","_slice","args","start","end","override","origFunc","overridedFactory","assert","b","Error","asap$1","fn","setImmediate","setTimeout","arrayToObject","array","extractor","reduce","result","item","nameAndValue","getByKeyPath","keyPath","rv","val","push","period","indexOf","innerObj","substr","undefined","setByKeyPath","isFrozen","currentKeyPath","remainingKeyPath","isNaN","parseInt","splice","shallowClone","m","flatten","a","intrinsicTypeNames","split","map","num","filter","intrinsicTypes","x","circularRefs","deepClone","any","WeakMap","innerDeepClone","constructor","toString","toStringTag","o","iteratorSymbol","Symbol","iterator","getIteratorOf","NO_CHAR_ARRAY","getArrayOf","arrayLike","it","next","done","isAsyncFunction","debug","location","test","href","setDebug","libraryFilter","NEEDS_THROW_FOR_STACK","stack","getErrorWithStack","e","prettyStack","exception","numIgnoredFrames","name","message","frame","join","idbDomErrorNames","errorList","defaultTexts","VersionChanged","DatabaseClosed","Abort","TransactionInactive","MissingAPI","DexieError","msg","_e","getMultiErrorMessage","failures","v","ModifyError","successCount","failedKeys","BulkError","pos","failuresByPos","_stack","errnames","BaseException","exceptions","fullName","msgOrInner","inner","Syntax","SyntaxError","Type","TypeError","Range","RangeError","exceptionMap","fullNameExceptions","nop","mirror","pureFunctionChain","f1","f2","callBoth","on1","on2","hookCreatingChain","res","onsuccess","onerror","res2","hookDeletingChain","hookUpdatingChain","modifications","reverseStoppableEventChain","promisableChain","then","thiz","INTERNAL","_a$1","globalP","resolve","crypto","subtle","nativeP","digest","Uint8Array","resolvedNativePromise","nativePromiseProto","resolvedGlobalPromise","nativePromiseThen","NativePromise","patchGlobalPromise","stack_being_generated","schedulePhysicalTick","physicalTick","MutationObserver","hiddenDiv","document","createElement","observe","attributes","setAttribute","asap","callback","microtickQueue","needsNewPhysicalTick","isOutsideMicroTick","unhandledErrors","rejectingErrors","currentFulfiller","rejectionMapper","globalPSD","id","ref","unhandleds","onunhandled","globalError","pgp","env","finalize","uh","PSD","numScheduledCalls","tickFinalizers","DexiePromise","_listeners","onuncatched","_lib","psd","_PSD","_stackHolder","_prev","_numPrev","_state","_value","handleRejection","executePromiseTask","thenProp","microTaskId","totalEchoes","onFulfilled","onRejected","_this","possibleAwait","cleanup","decrementExpectedAwaits","reject","propagateToListener","Listener","nativeAwaitCompatibleWrap","linkToPreviousPromise","zone","promise","shouldExecuteTick","beginMicroTickScope","_then","propagateAllListeners","endMicroTickScope","ex","reason","_promise","tryCatch","origProp","some","addPossiblyUnhandledError","listeners","len","finalizePhysicalTick","listener","cb","callListener","ret","markErrorAsHandled","prev","numPrev","wasRootExec","callbacks","unhandledErrs","finalizers","PromiseReject","wrap","errorCatcher","outerScope","switchToZone","catch","type","handler","err","finally","onFinally","getStack","stacks","limit","errorName","failure","timeout","ms","Infinity","handle","Timeout","clearTimeout","snapShot","all","values","onPossibleParallellAsync","remaining","race","newPSD","newScope","usePSD","scheduler","follow","zoneProps","finalizer","run_at_end_of_this_or_next_physical_tick","allSettled","possiblePromises","results","status","AggregateError","task","awaits","echoes","taskCounter","zoneStack","zoneEchoes","zone_id_counter","a1","a2","parent","globalEnv","PromiseProp","nthen","getPatchedPromiseThen","gthen","incrementExpectedAwaits","possiblePromise","rejection","zoneEnterEcho","targetZone","zoneLeaveEcho","pop","bEnteringZone","currentZone","enqueueNativeMicroTask","GlobalPromise_1","targetEnv","GlobalPromise","a3","job","outerZone","origThen","onResolved","event","eventData","createEvent","initEvent","CustomEvent","detail","dispatchEvent","PromiseRejectionEvent","onunhandledrejection","_","defaultPrevented","console","warn","maxString","String","fromCharCode","INVALID_KEY_ARGUMENT","connections","isIEOrEdge","navigator","userAgent","hasIEDeleteObjectStoreBug","hangsOnDeleteLargeKeyRange","dexieStackFrameFilter","combine","filter1","filter2","AnyRange","lower","lowerOpen","upper","upperOpen","workaroundForUndefinedPrimKey","Table","_trans","mode","writeLocked","trans","_tx","tableName","checkTableInTransaction","schema","NotFound","idbtrans","db","transless","tempTransaction","storeNames","idbdb","openComplete","letThrough","_vip","_createTransaction","_dbSchema","PR1398_maxLoop","InvalidState","isOpen","_close","open","_completion","dbOpenError","isBeingOpened","_options","autoOpen","dbReadyPromise","keyOrCrit","where","first","core","hook","reading","fire","indexOrCrit","WhereClause","keyPaths","equals","compoundIndex","indexes","primKey","ix","compound","every","_maxKey","kp","JSON","stringify","idxByName","idb","_deps","indexedDB","cmp","_a","prevIndex","prevFilterFn","index","multi","idx","filterFunction","toCollection","and","count","thenShortcut","offset","numRows","each","toArray","Collection","orderBy","reverse","mapToClass","mappedClass","readHook","unsubscribe","defineClass","content","add","auto","objToAdd","mutate","numFailures","lastResult","update","keyOrObject","modify","InvalidArgument","put","delete","clear","range","bulkGet","getMany","bulkAdd","objects","keysOrOptions","wantResults","allKeys","numObjects","objectsToAdd","bulkPut","objectsToPut","bulkDelete","numKeys","Events","ctx","evs","eventName","subscriber","subscribe","addEventType","chainFunction","defaultFunction","addConfiguredEvents","context","subscribers","cfg","makeClassConstructor","isPlainKeyRange","ignoreLimitFilter","algorithm","or","justLimit","replayFilter","addFilter","addReplayFilter","factory","isLimitFilter","curr","getIndexOrStore","coreSchema","isPrimKey","primaryKey","getIndexByKeyPath","Schema","openCursor","coreTable","keysOnly","dir","unique","query","iter","coreTrans","set_1","union","cursor","advance","stop","fail","_iterate","iterate","valueMapper","cursorPromise","wrappedFn","c","continue","advancer","ta","tb","NaN","al","bl","compareUint8Arrays","getUint8Array","compareArrays","ArrayBuffer","isView","tsTag","buffer","byteOffset","byteLength","_read","_ctx","error","table","_write","_addAlgorithm","clone","raw","min","sortBy","parts","lastPart","lastIndex","getval","order","sorter","aVal","bVal","sort","valueMapper_1","a_1","offsetLeft","rowsLeft","until","bIncludeStopEntry","last","isMatch","indexName","_ondirectionchange","desc","eachKey","eachUniqueKey","eachPrimaryKey","primaryKeys","uniqueKeys","firstKey","lastKey","distinct","strKey","found","changes","modifyer","anythingModified","outbound","extractKey","modifyChunkSize","totalFailures","applyMutateResult","expectedCount","_i","nextChunk","cache","addValues","putValues","putKeys","deleteKeys","origValue","ctx_1","criteria","deleteCallback","changeSpec","coreRange","simpleCompare","simpleCompareReverse","collectionOrWhereClause","T","collection","emptyCollection","whereClause","rangeEqual","nextCasing","lowerKey","upperNeedle","lowerNeedle","llp","lwrKeyChar","addIgnoreCaseAlgorithm","match","needles","suffix","compare","upperNeedles","lowerNeedles","direction","nextKeySuffix","needlesLen","initDirection","toUpperCase","toLowerCase","upperFactory","lowerFactory","needleBounds","needle","nb","createRange","firstPossibleNeedle","lowestPossibleCasing","casing","enumerable","between","includeLower","includeUpper","_cmp","above","aboveOrEqual","below","belowOrEqual","startsWith","str","startsWithIgnoreCase","equalsIgnoreCase","anyOfIgnoreCase","startsWithAnyOfIgnoreCase","anyOf","_ascending","_descending","notEqual","inAnyRange","includeLowers","includeUppers","noneOf","ranges","ascending","descending","_min","max","_max","sortDirection","rangeSorter","newRange","rangePos","keyIsBeyondCurrentEntry","keyIsBeforeCurrentEntry","checkKey","keyWithinCurrentRange","startsWithAnyOf","eventRejectHandler","preventDefault","target","stopPropagation","globalEvents","Transaction","_lock","_reculock","lockOwnerFor","_unlock","_blockedFuncs","_locked","fnAndPSD","shift","OpenFailed","active","transaction","durability","chromeTransactionDurability","ev","_reject","onabort","on","oncomplete","_resolve","storagemutated","bWriteLock","ReadOnly","_root","waitFor","promiseLike","root","_waitingFor","_waitingQueue","store","objectStore","spin","_spinCount","currentWaitPromise","abort","memoizedTables","_memoizedTables","tableSchema","transactionBoundTable","createIndexSpec","src","nameFromKeyPath","createTableSchema","getMaxKey","IdbKeyRange","only","getKeyExtractor","getSinglePathKeyExtractor","arrayify","_id_counter","getKeyPathAlias","createDBCore","tmpTrans","makeIDBKeyRange","upperBound","lowerBound","bound","tables","objectStoreNames","autoIncrement","indexByKeyPath","isPrimaryKey","indexNames","multiEntry","hasGetAll","extractSchema","isAddOrPut","req","reqs","errorHandler","args1","args2","keyCount","callbackCount","successHandler","_pos","request","nonInfinitLimit","source","idbKeyRange","getAll","getAllKeys","count_1","req_1","openKeyCursor","result_1","___id","_cursorContinue","_cursorContinuePrimaryKey","continuePrimaryKey","_cursorAdvance","doThrowCursorIsStopped","gotOne","iterationPromise","resolveIteration","rejectIteration","guardedCallback","createDbCoreTable","tableMap","MIN_KEY","MAX_KEY","createMiddlewareStacks","middlewares","IDBKeyRange","dbcore","stackImpl","down","createMiddlewareStack","generateMiddlewareStacks","_novip","_middlewares","tbl","setApiOnPlace","objs","tableNames","dbschema","propDesc","removeTablesApi","lowerVersionFirst","_cfg","version","runUpgraders","oldVersion","idbUpgradeTrans","globalSchema","_storeNames","rejectTransaction","createTable","populate","queue","versions","_versions","buildGlobalSchema","anyContentUpgraderHasRun","runQueue","oldSchema","newSchema","adjustToExistingIndexNames","diff","getSchemaDiff","tuple","change","recreate","Upgrade","store_1","addIndex","deleteIndex","del","idxName","contentUpgrade","upgradeSchema_1","returnValue_1","contentUpgradeIsAsync_1","promiseFollowed","decrementor","storeName","deleteObjectStore","deleteRemovedTables","contains","updateTablesAndIndexes","oldDef","newDef","def","oldIndexes","newIndexes","oldIdx","newIdx","createObjectStore","createIndex","j","idbindex","_hasGetAll","dexieName","indexSpec","WorkerGlobalScope","Version","_parseStoresSpec","stores","outSchema","indexNum","trim","replace","storesSource","storesSpec","_allTables","upgrade","upgradeFunction","getDbNamesTable","dbNamesDB","Dexie$1","addons","dbnames","hasDatabasesNative","databases","_onDatabaseDeleted","vip","idbReady","intervalId","userAgentData","tryIdb","setInterval","clearInterval","dexieOpen","state","openCanceller","throwIfCancelled","resolveDbReady","dbReadyResolve","upgradeTransaction","wasCreated","dbName","autoSchema","round","verno","onblocked","_fireOnBlocked","onupgradeneeded","allowEmptyDB","close","delreq","deleteDatabase","NoSuchDatabase","oldVer","pow","readGlobalSchema","ch","verifyInstalledSchema","onversionchange","vcFired","onclose","_onDatabaseCreated","onReadyBeingFired","ready","fireRemainders","remainders_1","awaitIterator","callNext","onSuccess","step","onError","throw","getNext","extractTransactionArgs","_tableArgs_","scopeFunc","enterTransactionScope","parentTransaction","returnValue","scopeFuncIsAsync","PrematureCommit","pad","virtualIndexMiddleware","level","indexLookup","allVirtualIndexes","addVirtualIndexes","keyTail","lowLevelIndex","keyPathAlias","indexList","keyLength","isVirtual","virtualIndex","translateRequest","createVirtualCursor","getObjectDiff","prfx","ap","bp","apTypeName","hooksMiddleware","downCore","downTable","dxTrans","deleting","creating","updating","addPutOrDelete","deleteNextChunk","deleteRange","getEffectiveKeys","effectiveKeys","getExistingValues","existingValues","contexts","existingValue","generatedPrimaryKey","objectDiff","additionalChanges_1","requestedValue_1","getFromTransactionCache","cacheExistingValuesMiddleware","cachedResult","isEmptyRange","node","RangeSet","fromOrTree","d","addRange","left","right","r","rebalance","rightWasCutOff","mergeRanges","newSet","_addRangeSet","getRangeSetIterator","keyProvided","up","_b","rootClone","oldRootRight","computeDepth","rangeSet","addKey","addKeys","observabilityMiddleware","FULL_RANGE","tableClone","mutatedParts","getRangeSet","part","pkRangeSet","delsRangeSet","newObjs","oldCache","oldObjs","addKeyOrKeys","oldKey","newKey","trackAffectedIndexes","getRange","_c","_d","readSubscribers","method","subscr","pkRangeSet_1","delsRangeSet_1","queriedIndex","queriedRanges","keysPromise_1","resultingKeys","pKeys","cursor_1","wantValues_1","pkey","domDeps","Dexie","deps","dependencies","cancelOpen","bSticky","db_1","keyRangeGenerator","keyRange","whereCtx","readingHook","createCollectionConstructor","createTableConstructor","complete","wasActive","createTransactionConstructor","versionNumber","createVersionConstructor","orCollection","_IDBKeyRange","createWhereClauseConstructor","newVersion","use","addon","versionInstance","_whenReady","unuse","mw","hasArguments","doDelete","backendDB","hasBeenClosed","hasFailed","dynamicallyOpened","_transaction","idbMode","onlyIfCompatible","SubTransaction","enterTransaction","InvalidTable","symbolObservable","observable","Observable","_subscribe","extendObservabilitySet","mozIndexedDB","webkitIndexedDB","msIndexedDB","webkitIDBKeyRange","propagateLocally","updateParts","wasMe","propagatingLocally","databaseName","exists","getDatabaseNames","infos","info","ignoreTransaction","async","generatorFn","spawn","currentTransaction","promiseOrFunction","optionalTimeout","liveQuery","querier","observer","closed","accumMuts","currentObs","subscription","mutationListener","querying","startedListening","shouldNotify","rangeSet1","rangeSet2","i1","nextResult1","i2","nextResult2","rangesOverlap","doQuery","exec","execute","delByKeyPath","minKey","semVer","maxKey","addEventListener","updatedParts","event_1","initCustomEvent","BroadcastChannel","bc_1","unref","changedParts","postMessage","onmessage","data","localStorage","setItem","trig","random","matchAll","includeUncontrolled","client","parse","newValue","swContainer","serviceWorker","domError","bm","messages","NotifiedArticles","_ref","uuids","_useState","useState","articles","setArticles","useEffect","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_context","uuid","fetchArticleAPI","sent","fetchArticles","__jsx","className","article","Fragment","StyledLink","keyProp","getCanonical","display","gap","gridTemplateColumns","headline","author","ImageOrNoImage","image","getImage","width","getImageSize","alt","shape","noImage","NoImage","TopicItem","_ref3","topic","subscribed","toggleSubscribed","registration","setSubscription","setHelpPopupVisible","htmlFor","position","onChange","permissions","titleKey","process","axios","post","qs","headers","log","pushManager","userVisibleOnly","applicationServerKey","urlB64ToUint8Array","subscribeConcept","checked","PrivatePushNotificationsManagementPage","_useState2","topicsDict","setTopicsDict","_useState3","Map","setSubscribed","_useState4","pushedArticles","setPushedArticles","_useState5","_useState6","setRegistration","_useState7","helpPopupVisible","generalTopic","getRegistration","reg","getSubscription","sub","setCookie","toISOString","days","endpoint","toggleSliders","dict","previousTopic","currentTopic","firstType","handleUnfollowAll","_ref4","_callee3","topics","newSubscribed","_context3","_ref5","_callee2","_context2","_x3","abrupt","_x","_x2","React","Popup","visible","popupLogo","color","justifycontent","Link","onClick","NotificationImg","topicType","connect","dispatch","bindActionCreators","isBrowser","module","exports","BookmarkedArticles","withRouter","sectionPageView","bookmarkedArticles","setBookmarkedArticles","entries","entry","section","pathname","BookmarkImg","urlify","Urlify","addEToUmlauts","szToSs","spaces","nonPrintable","toLower","ImageSizes","hero","featured","primary","slider","normal","contentKey","size","images","videos","url","thumbnailURL","getTeaser","teaserHeadline","children"],"mappings":";yHAOO,SAASA,EAAWC,EAAMC,GAC/B,IAAMC,EAAY,IAAIC,KAAKH,GACrBI,EAAUC,KAAKC,OAAO,IAAIH,KAASD,GAAa,KAClDK,EAAWF,KAAKC,MAAMF,EAAU,OACpC,OAAIG,EAAW,EACNL,EAAUM,mBAAmB,QAAS,CAC3CC,KAAM,UAAWC,MAAO,QAASC,IAAK,aAG1CJ,EAAWF,KAAKC,MAAMF,EAAU,QAChB,EACPG,EAAW,KAAON,EAAO,OAAS,KAE3CM,EAAWF,KAAKC,MAAMF,EAAU,KACjB,EACNG,EAAW,KAAON,EAAO,OAAS,IAEpCI,KAAKC,MAAMF,GAAW,KAAOH,EAAO,OAAS,IAvBtD,mC,0GCwBA,IAAIW,EAAW,WAQX,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,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AAKC,UAAU,eACbD,EAAA,SAAG,mEACHA,EAAA,SAAG,0I,kCCzDb,wJAEMkH,EAFN,OAEeC,EAAOnvC,OAAO,CAC3BovC,eAAe,EACfC,QAAQ,EACRC,OAAQ,IACRC,aAAc,GACdC,SAAS,EACTra,MAAM,IAGFsa,EAAa,CACjBC,KAAM,IACNC,SAAU,IACVC,QAAS,IACTC,OAAQ,IACRC,OAAQ,IACRjuC,KAAM,IAGD,SAASymC,EAAcJ,GAC5B,OAAKA,EAAQQ,SAGNR,EAAQ6G,QAAU,IAAMG,EAAOhH,EAAQQ,SAAStT,QAAQ,KAAM,UAAUA,QAAQ,MAAO,KAAO,IAAM8S,EAAQ6H,WAF1G7H,EAAQ6H,WAKZ,SAAS/G,EAAcgH,GAE5B,OADkBP,EAAWO,IAASA,EAIjC,SAASlH,EAAUZ,GAExB,OADcA,EAAQW,OAAUX,EAAQ+H,QAAU/H,EAAQ+H,OAAO,IAAQ/H,EAAQgI,QAAU,CAAEC,IAAKjI,EAAQgI,OAAO,GAAGE,cAS/G,SAASC,EAAWnI,GACzB,OAAOA,EAAQoI,iB,6FClCFlI,IANI,SAAHrB,GAAA,IAAMkB,EAASlB,EAATkB,UAAW3qC,EAAEypC,EAAFzpC,GAAI+qC,EAAOtB,EAAPsB,QAASjT,EAAO2R,EAAP3R,QAAS2Y,EAAOhH,EAAPgH,QAASwC,EAAQxJ,EAARwJ,SAAQ,OAAOvI,EAAC8F,OAAI,CAACrvC,IAAK4pC,EAAS/qC,GAAIA,EAAI83B,QAASA,EAAS2Y,QAASA,EAAS9F,UAAWA,GAAYsI","file":"static/js/pages-BookmarksPage.4bed3081.chunk.js","sourcesContent":["\nexport function formatDate (date, short) {\n  return new Date(date).toLocaleDateString('en-US', {\n    year: 'numeric', month: short ? 'short' : 'long', day: 'numeric'\n  })\n}\n\nexport function formatAgo (date, full) {\n  const published = new Date(date)\n  const seconds = Math.floor((new Date() - published) / 1000)\n  let interval = Math.floor(seconds / 43200)\n  if (interval > 1) {\n    return published.toLocaleDateString('en-US', {\n      year: 'numeric', month: 'short', day: 'numeric'\n    })\n  }\n  interval = Math.floor(seconds / 3600)\n  if (interval >= 1) {\n    return interval + 'h' + (full ? ' ago' : '')\n  }\n  interval = Math.floor(seconds / 60)\n  if (interval > 1) {\n    return interval + 'm' + (full ? ' ago' : '')\n  }\n  return Math.floor(seconds) + 's' + (full ? ' ago' : '')\n}\n","/*\n * Dexie.js - a minimalistic wrapper for IndexedDB\n * ===============================================\n *\n * By David Fahlander, david.fahlander@gmail.com\n *\n * Version 3.2.3, Mon Jan 23 2023\n *\n * https://dexie.org\n *\n * Apache License Version 2.0, January 2004, http://www.apache.org/licenses/\n */\n \n/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nvar __assign = function() {\n    __assign = Object.assign || function __assign(t) {\n        for (var s, i = 1, n = arguments.length; i < n; i++) {\n            s = arguments[i];\n            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n        }\n        return t;\n    };\n    return __assign.apply(this, arguments);\n};\nfunction __spreadArray(to, from, pack) {\n    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n        if (ar || !(i in from)) {\n            if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n            ar[i] = from[i];\n        }\n    }\n    return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nvar _global = typeof globalThis !== 'undefined' ? globalThis :\n    typeof self !== 'undefined' ? self :\n        typeof window !== 'undefined' ? window :\n            global;\n\nvar keys = Object.keys;\nvar isArray = Array.isArray;\nif (typeof Promise !== 'undefined' && !_global.Promise) {\n    _global.Promise = Promise;\n}\nfunction extend(obj, extension) {\n    if (typeof extension !== 'object')\n        return obj;\n    keys(extension).forEach(function (key) {\n        obj[key] = extension[key];\n    });\n    return obj;\n}\nvar getProto = Object.getPrototypeOf;\nvar _hasOwn = {}.hasOwnProperty;\nfunction hasOwn(obj, prop) {\n    return _hasOwn.call(obj, prop);\n}\nfunction props(proto, extension) {\n    if (typeof extension === 'function')\n        extension = extension(getProto(proto));\n    (typeof Reflect === \"undefined\" ? keys : Reflect.ownKeys)(extension).forEach(function (key) {\n        setProp(proto, key, extension[key]);\n    });\n}\nvar defineProperty = Object.defineProperty;\nfunction setProp(obj, prop, functionOrGetSet, options) {\n    defineProperty(obj, prop, extend(functionOrGetSet && hasOwn(functionOrGetSet, \"get\") && typeof functionOrGetSet.get === 'function' ?\n        { get: functionOrGetSet.get, set: functionOrGetSet.set, configurable: true } :\n        { value: functionOrGetSet, configurable: true, writable: true }, options));\n}\nfunction derive(Child) {\n    return {\n        from: function (Parent) {\n            Child.prototype = Object.create(Parent.prototype);\n            setProp(Child.prototype, \"constructor\", Child);\n            return {\n                extend: props.bind(null, Child.prototype)\n            };\n        }\n    };\n}\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\nfunction getPropertyDescriptor(obj, prop) {\n    var pd = getOwnPropertyDescriptor(obj, prop);\n    var proto;\n    return pd || (proto = getProto(obj)) && getPropertyDescriptor(proto, prop);\n}\nvar _slice = [].slice;\nfunction slice(args, start, end) {\n    return _slice.call(args, start, end);\n}\nfunction override(origFunc, overridedFactory) {\n    return overridedFactory(origFunc);\n}\nfunction assert(b) {\n    if (!b)\n        throw new Error(\"Assertion Failed\");\n}\nfunction asap$1(fn) {\n    if (_global.setImmediate)\n        setImmediate(fn);\n    else\n        setTimeout(fn, 0);\n}\nfunction arrayToObject(array, extractor) {\n    return array.reduce(function (result, item, i) {\n        var nameAndValue = extractor(item, i);\n        if (nameAndValue)\n            result[nameAndValue[0]] = nameAndValue[1];\n        return result;\n    }, {});\n}\nfunction tryCatch(fn, onerror, args) {\n    try {\n        fn.apply(null, args);\n    }\n    catch (ex) {\n        onerror && onerror(ex);\n    }\n}\nfunction getByKeyPath(obj, keyPath) {\n    if (hasOwn(obj, keyPath))\n        return obj[keyPath];\n    if (!keyPath)\n        return obj;\n    if (typeof keyPath !== 'string') {\n        var rv = [];\n        for (var i = 0, l = keyPath.length; i < l; ++i) {\n            var val = getByKeyPath(obj, keyPath[i]);\n            rv.push(val);\n        }\n        return rv;\n    }\n    var period = keyPath.indexOf('.');\n    if (period !== -1) {\n        var innerObj = obj[keyPath.substr(0, period)];\n        return innerObj === undefined ? undefined : getByKeyPath(innerObj, keyPath.substr(period + 1));\n    }\n    return undefined;\n}\nfunction setByKeyPath(obj, keyPath, value) {\n    if (!obj || keyPath === undefined)\n        return;\n    if ('isFrozen' in Object && Object.isFrozen(obj))\n        return;\n    if (typeof keyPath !== 'string' && 'length' in keyPath) {\n        assert(typeof value !== 'string' && 'length' in value);\n        for (var i = 0, l = keyPath.length; i < l; ++i) {\n            setByKeyPath(obj, keyPath[i], value[i]);\n        }\n    }\n    else {\n        var period = keyPath.indexOf('.');\n        if (period !== -1) {\n            var currentKeyPath = keyPath.substr(0, period);\n            var remainingKeyPath = keyPath.substr(period + 1);\n            if (remainingKeyPath === \"\")\n                if (value === undefined) {\n                    if (isArray(obj) && !isNaN(parseInt(currentKeyPath)))\n                        obj.splice(currentKeyPath, 1);\n                    else\n                        delete obj[currentKeyPath];\n                }\n                else\n                    obj[currentKeyPath] = value;\n            else {\n                var innerObj = obj[currentKeyPath];\n                if (!innerObj || !hasOwn(obj, currentKeyPath))\n                    innerObj = (obj[currentKeyPath] = {});\n                setByKeyPath(innerObj, remainingKeyPath, value);\n            }\n        }\n        else {\n            if (value === undefined) {\n                if (isArray(obj) && !isNaN(parseInt(keyPath)))\n                    obj.splice(keyPath, 1);\n                else\n                    delete obj[keyPath];\n            }\n            else\n                obj[keyPath] = value;\n        }\n    }\n}\nfunction delByKeyPath(obj, keyPath) {\n    if (typeof keyPath === 'string')\n        setByKeyPath(obj, keyPath, undefined);\n    else if ('length' in keyPath)\n        [].map.call(keyPath, function (kp) {\n            setByKeyPath(obj, kp, undefined);\n        });\n}\nfunction shallowClone(obj) {\n    var rv = {};\n    for (var m in obj) {\n        if (hasOwn(obj, m))\n            rv[m] = obj[m];\n    }\n    return rv;\n}\nvar concat = [].concat;\nfunction flatten(a) {\n    return concat.apply([], a);\n}\nvar intrinsicTypeNames = \"Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey\"\n    .split(',').concat(flatten([8, 16, 32, 64].map(function (num) { return [\"Int\", \"Uint\", \"Float\"].map(function (t) { return t + num + \"Array\"; }); }))).filter(function (t) { return _global[t]; });\nvar intrinsicTypes = intrinsicTypeNames.map(function (t) { return _global[t]; });\narrayToObject(intrinsicTypeNames, function (x) { return [x, true]; });\nvar circularRefs = null;\nfunction deepClone(any) {\n    circularRefs = typeof WeakMap !== 'undefined' && new WeakMap();\n    var rv = innerDeepClone(any);\n    circularRefs = null;\n    return rv;\n}\nfunction innerDeepClone(any) {\n    if (!any || typeof any !== 'object')\n        return any;\n    var rv = circularRefs && circularRefs.get(any);\n    if (rv)\n        return rv;\n    if (isArray(any)) {\n        rv = [];\n        circularRefs && circularRefs.set(any, rv);\n        for (var i = 0, l = any.length; i < l; ++i) {\n            rv.push(innerDeepClone(any[i]));\n        }\n    }\n    else if (intrinsicTypes.indexOf(any.constructor) >= 0) {\n        rv = any;\n    }\n    else {\n        var proto = getProto(any);\n        rv = proto === Object.prototype ? {} : Object.create(proto);\n        circularRefs && circularRefs.set(any, rv);\n        for (var prop in any) {\n            if (hasOwn(any, prop)) {\n                rv[prop] = innerDeepClone(any[prop]);\n            }\n        }\n    }\n    return rv;\n}\nvar toString = {}.toString;\nfunction toStringTag(o) {\n    return toString.call(o).slice(8, -1);\n}\nvar iteratorSymbol = typeof Symbol !== 'undefined' ?\n    Symbol.iterator :\n    '@@iterator';\nvar getIteratorOf = typeof iteratorSymbol === \"symbol\" ? function (x) {\n    var i;\n    return x != null && (i = x[iteratorSymbol]) && i.apply(x);\n} : function () { return null; };\nvar NO_CHAR_ARRAY = {};\nfunction getArrayOf(arrayLike) {\n    var i, a, x, it;\n    if (arguments.length === 1) {\n        if (isArray(arrayLike))\n            return arrayLike.slice();\n        if (this === NO_CHAR_ARRAY && typeof arrayLike === 'string')\n            return [arrayLike];\n        if ((it = getIteratorOf(arrayLike))) {\n            a = [];\n            while ((x = it.next()), !x.done)\n                a.push(x.value);\n            return a;\n        }\n        if (arrayLike == null)\n            return [arrayLike];\n        i = arrayLike.length;\n        if (typeof i === 'number') {\n            a = new Array(i);\n            while (i--)\n                a[i] = arrayLike[i];\n            return a;\n        }\n        return [arrayLike];\n    }\n    i = arguments.length;\n    a = new Array(i);\n    while (i--)\n        a[i] = arguments[i];\n    return a;\n}\nvar isAsyncFunction = typeof Symbol !== 'undefined'\n    ? function (fn) { return fn[Symbol.toStringTag] === 'AsyncFunction'; }\n    : function () { return false; };\n\nvar debug = typeof location !== 'undefined' &&\n    /^(http|https):\\/\\/(localhost|127\\.0\\.0\\.1)/.test(location.href);\nfunction setDebug(value, filter) {\n    debug = value;\n    libraryFilter = filter;\n}\nvar libraryFilter = function () { return true; };\nvar NEEDS_THROW_FOR_STACK = !new Error(\"\").stack;\nfunction getErrorWithStack() {\n    if (NEEDS_THROW_FOR_STACK)\n        try {\n            getErrorWithStack.arguments;\n            throw new Error();\n        }\n        catch (e) {\n            return e;\n        }\n    return new Error();\n}\nfunction prettyStack(exception, numIgnoredFrames) {\n    var stack = exception.stack;\n    if (!stack)\n        return \"\";\n    numIgnoredFrames = (numIgnoredFrames || 0);\n    if (stack.indexOf(exception.name) === 0)\n        numIgnoredFrames += (exception.name + exception.message).split('\\n').length;\n    return stack.split('\\n')\n        .slice(numIgnoredFrames)\n        .filter(libraryFilter)\n        .map(function (frame) { return \"\\n\" + frame; })\n        .join('');\n}\n\nvar dexieErrorNames = [\n    'Modify',\n    'Bulk',\n    'OpenFailed',\n    'VersionChange',\n    'Schema',\n    'Upgrade',\n    'InvalidTable',\n    'MissingAPI',\n    'NoSuchDatabase',\n    'InvalidArgument',\n    'SubTransaction',\n    'Unsupported',\n    'Internal',\n    'DatabaseClosed',\n    'PrematureCommit',\n    'ForeignAwait'\n];\nvar idbDomErrorNames = [\n    'Unknown',\n    'Constraint',\n    'Data',\n    'TransactionInactive',\n    'ReadOnly',\n    'Version',\n    'NotFound',\n    'InvalidState',\n    'InvalidAccess',\n    'Abort',\n    'Timeout',\n    'QuotaExceeded',\n    'Syntax',\n    'DataClone'\n];\nvar errorList = dexieErrorNames.concat(idbDomErrorNames);\nvar defaultTexts = {\n    VersionChanged: \"Database version changed by other database connection\",\n    DatabaseClosed: \"Database has been closed\",\n    Abort: \"Transaction aborted\",\n    TransactionInactive: \"Transaction has already completed or failed\",\n    MissingAPI: \"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb\"\n};\nfunction DexieError(name, msg) {\n    this._e = getErrorWithStack();\n    this.name = name;\n    this.message = msg;\n}\nderive(DexieError).from(Error).extend({\n    stack: {\n        get: function () {\n            return this._stack ||\n                (this._stack = this.name + \": \" + this.message + prettyStack(this._e, 2));\n        }\n    },\n    toString: function () { return this.name + \": \" + this.message; }\n});\nfunction getMultiErrorMessage(msg, failures) {\n    return msg + \". Errors: \" + Object.keys(failures)\n        .map(function (key) { return failures[key].toString(); })\n        .filter(function (v, i, s) { return s.indexOf(v) === i; })\n        .join('\\n');\n}\nfunction ModifyError(msg, failures, successCount, failedKeys) {\n    this._e = getErrorWithStack();\n    this.failures = failures;\n    this.failedKeys = failedKeys;\n    this.successCount = successCount;\n    this.message = getMultiErrorMessage(msg, failures);\n}\nderive(ModifyError).from(DexieError);\nfunction BulkError(msg, failures) {\n    this._e = getErrorWithStack();\n    this.name = \"BulkError\";\n    this.failures = Object.keys(failures).map(function (pos) { return failures[pos]; });\n    this.failuresByPos = failures;\n    this.message = getMultiErrorMessage(msg, failures);\n}\nderive(BulkError).from(DexieError);\nvar errnames = errorList.reduce(function (obj, name) { return (obj[name] = name + \"Error\", obj); }, {});\nvar BaseException = DexieError;\nvar exceptions = errorList.reduce(function (obj, name) {\n    var fullName = name + \"Error\";\n    function DexieError(msgOrInner, inner) {\n        this._e = getErrorWithStack();\n        this.name = fullName;\n        if (!msgOrInner) {\n            this.message = defaultTexts[name] || fullName;\n            this.inner = null;\n        }\n        else if (typeof msgOrInner === 'string') {\n            this.message = \"\" + msgOrInner + (!inner ? '' : '\\n ' + inner);\n            this.inner = inner || null;\n        }\n        else if (typeof msgOrInner === 'object') {\n            this.message = msgOrInner.name + \" \" + msgOrInner.message;\n            this.inner = msgOrInner;\n        }\n    }\n    derive(DexieError).from(BaseException);\n    obj[name] = DexieError;\n    return obj;\n}, {});\nexceptions.Syntax = SyntaxError;\nexceptions.Type = TypeError;\nexceptions.Range = RangeError;\nvar exceptionMap = idbDomErrorNames.reduce(function (obj, name) {\n    obj[name + \"Error\"] = exceptions[name];\n    return obj;\n}, {});\nfunction mapError(domError, message) {\n    if (!domError || domError instanceof DexieError || domError instanceof TypeError || domError instanceof SyntaxError || !domError.name || !exceptionMap[domError.name])\n        return domError;\n    var rv = new exceptionMap[domError.name](message || domError.message, domError);\n    if (\"stack\" in domError) {\n        setProp(rv, \"stack\", { get: function () {\n                return this.inner.stack;\n            } });\n    }\n    return rv;\n}\nvar fullNameExceptions = errorList.reduce(function (obj, name) {\n    if ([\"Syntax\", \"Type\", \"Range\"].indexOf(name) === -1)\n        obj[name + \"Error\"] = exceptions[name];\n    return obj;\n}, {});\nfullNameExceptions.ModifyError = ModifyError;\nfullNameExceptions.DexieError = DexieError;\nfullNameExceptions.BulkError = BulkError;\n\nfunction nop() { }\nfunction mirror(val) { return val; }\nfunction pureFunctionChain(f1, f2) {\n    if (f1 == null || f1 === mirror)\n        return f2;\n    return function (val) {\n        return f2(f1(val));\n    };\n}\nfunction callBoth(on1, on2) {\n    return function () {\n        on1.apply(this, arguments);\n        on2.apply(this, arguments);\n    };\n}\nfunction hookCreatingChain(f1, f2) {\n    if (f1 === nop)\n        return f2;\n    return function () {\n        var res = f1.apply(this, arguments);\n        if (res !== undefined)\n            arguments[0] = res;\n        var onsuccess = this.onsuccess,\n        onerror = this.onerror;\n        this.onsuccess = null;\n        this.onerror = null;\n        var res2 = f2.apply(this, arguments);\n        if (onsuccess)\n            this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;\n        if (onerror)\n            this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;\n        return res2 !== undefined ? res2 : res;\n    };\n}\nfunction hookDeletingChain(f1, f2) {\n    if (f1 === nop)\n        return f2;\n    return function () {\n        f1.apply(this, arguments);\n        var onsuccess = this.onsuccess,\n        onerror = this.onerror;\n        this.onsuccess = this.onerror = null;\n        f2.apply(this, arguments);\n        if (onsuccess)\n            this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;\n        if (onerror)\n            this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;\n    };\n}\nfunction hookUpdatingChain(f1, f2) {\n    if (f1 === nop)\n        return f2;\n    return function (modifications) {\n        var res = f1.apply(this, arguments);\n        extend(modifications, res);\n        var onsuccess = this.onsuccess,\n        onerror = this.onerror;\n        this.onsuccess = null;\n        this.onerror = null;\n        var res2 = f2.apply(this, arguments);\n        if (onsuccess)\n            this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;\n        if (onerror)\n            this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;\n        return res === undefined ?\n            (res2 === undefined ? undefined : res2) :\n            (extend(res, res2));\n    };\n}\nfunction reverseStoppableEventChain(f1, f2) {\n    if (f1 === nop)\n        return f2;\n    return function () {\n        if (f2.apply(this, arguments) === false)\n            return false;\n        return f1.apply(this, arguments);\n    };\n}\nfunction promisableChain(f1, f2) {\n    if (f1 === nop)\n        return f2;\n    return function () {\n        var res = f1.apply(this, arguments);\n        if (res && typeof res.then === 'function') {\n            var thiz = this, i = arguments.length, args = new Array(i);\n            while (i--)\n                args[i] = arguments[i];\n            return res.then(function () {\n                return f2.apply(thiz, args);\n            });\n        }\n        return f2.apply(this, arguments);\n    };\n}\n\nvar INTERNAL = {};\nvar LONG_STACKS_CLIP_LIMIT = 100,\nMAX_LONG_STACKS = 20, ZONE_ECHO_LIMIT = 100, _a$1 = typeof Promise === 'undefined' ?\n    [] :\n    (function () {\n        var globalP = Promise.resolve();\n        if (typeof crypto === 'undefined' || !crypto.subtle)\n            return [globalP, getProto(globalP), globalP];\n        var nativeP = crypto.subtle.digest(\"SHA-512\", new Uint8Array([0]));\n        return [\n            nativeP,\n            getProto(nativeP),\n            globalP\n        ];\n    })(), resolvedNativePromise = _a$1[0], nativePromiseProto = _a$1[1], resolvedGlobalPromise = _a$1[2], nativePromiseThen = nativePromiseProto && nativePromiseProto.then;\nvar NativePromise = resolvedNativePromise && resolvedNativePromise.constructor;\nvar patchGlobalPromise = !!resolvedGlobalPromise;\nvar stack_being_generated = false;\nvar schedulePhysicalTick = resolvedGlobalPromise ?\n    function () { resolvedGlobalPromise.then(physicalTick); }\n    :\n        _global.setImmediate ?\n            setImmediate.bind(null, physicalTick) :\n            _global.MutationObserver ?\n                function () {\n                    var hiddenDiv = document.createElement(\"div\");\n                    (new MutationObserver(function () {\n                        physicalTick();\n                        hiddenDiv = null;\n                    })).observe(hiddenDiv, { attributes: true });\n                    hiddenDiv.setAttribute('i', '1');\n                } :\n                function () { setTimeout(physicalTick, 0); };\nvar asap = function (callback, args) {\n    microtickQueue.push([callback, args]);\n    if (needsNewPhysicalTick) {\n        schedulePhysicalTick();\n        needsNewPhysicalTick = false;\n    }\n};\nvar isOutsideMicroTick = true,\nneedsNewPhysicalTick = true,\nunhandledErrors = [],\nrejectingErrors = [],\ncurrentFulfiller = null, rejectionMapper = mirror;\nvar globalPSD = {\n    id: 'global',\n    global: true,\n    ref: 0,\n    unhandleds: [],\n    onunhandled: globalError,\n    pgp: false,\n    env: {},\n    finalize: function () {\n        this.unhandleds.forEach(function (uh) {\n            try {\n                globalError(uh[0], uh[1]);\n            }\n            catch (e) { }\n        });\n    }\n};\nvar PSD = globalPSD;\nvar microtickQueue = [];\nvar numScheduledCalls = 0;\nvar tickFinalizers = [];\nfunction DexiePromise(fn) {\n    if (typeof this !== 'object')\n        throw new TypeError('Promises must be constructed via new');\n    this._listeners = [];\n    this.onuncatched = nop;\n    this._lib = false;\n    var psd = (this._PSD = PSD);\n    if (debug) {\n        this._stackHolder = getErrorWithStack();\n        this._prev = null;\n        this._numPrev = 0;\n    }\n    if (typeof fn !== 'function') {\n        if (fn !== INTERNAL)\n            throw new TypeError('Not a function');\n        this._state = arguments[1];\n        this._value = arguments[2];\n        if (this._state === false)\n            handleRejection(this, this._value);\n        return;\n    }\n    this._state = null;\n    this._value = null;\n    ++psd.ref;\n    executePromiseTask(this, fn);\n}\nvar thenProp = {\n    get: function () {\n        var psd = PSD, microTaskId = totalEchoes;\n        function then(onFulfilled, onRejected) {\n            var _this = this;\n            var possibleAwait = !psd.global && (psd !== PSD || microTaskId !== totalEchoes);\n            var cleanup = possibleAwait && !decrementExpectedAwaits();\n            var rv = new DexiePromise(function (resolve, reject) {\n                propagateToListener(_this, new Listener(nativeAwaitCompatibleWrap(onFulfilled, psd, possibleAwait, cleanup), nativeAwaitCompatibleWrap(onRejected, psd, possibleAwait, cleanup), resolve, reject, psd));\n            });\n            debug && linkToPreviousPromise(rv, this);\n            return rv;\n        }\n        then.prototype = INTERNAL;\n        return then;\n    },\n    set: function (value) {\n        setProp(this, 'then', value && value.prototype === INTERNAL ?\n            thenProp :\n            {\n                get: function () {\n                    return value;\n                },\n                set: thenProp.set\n            });\n    }\n};\nprops(DexiePromise.prototype, {\n    then: thenProp,\n    _then: function (onFulfilled, onRejected) {\n        propagateToListener(this, new Listener(null, null, onFulfilled, onRejected, PSD));\n    },\n    catch: function (onRejected) {\n        if (arguments.length === 1)\n            return this.then(null, onRejected);\n        var type = arguments[0], handler = arguments[1];\n        return typeof type === 'function' ? this.then(null, function (err) {\n            return err instanceof type ? handler(err) : PromiseReject(err);\n        })\n            : this.then(null, function (err) {\n                return err && err.name === type ? handler(err) : PromiseReject(err);\n            });\n    },\n    finally: function (onFinally) {\n        return this.then(function (value) {\n            onFinally();\n            return value;\n        }, function (err) {\n            onFinally();\n            return PromiseReject(err);\n        });\n    },\n    stack: {\n        get: function () {\n            if (this._stack)\n                return this._stack;\n            try {\n                stack_being_generated = true;\n                var stacks = getStack(this, [], MAX_LONG_STACKS);\n                var stack = stacks.join(\"\\nFrom previous: \");\n                if (this._state !== null)\n                    this._stack = stack;\n                return stack;\n            }\n            finally {\n                stack_being_generated = false;\n            }\n        }\n    },\n    timeout: function (ms, msg) {\n        var _this = this;\n        return ms < Infinity ?\n            new DexiePromise(function (resolve, reject) {\n                var handle = setTimeout(function () { return reject(new exceptions.Timeout(msg)); }, ms);\n                _this.then(resolve, reject).finally(clearTimeout.bind(null, handle));\n            }) : this;\n    }\n});\nif (typeof Symbol !== 'undefined' && Symbol.toStringTag)\n    setProp(DexiePromise.prototype, Symbol.toStringTag, 'Dexie.Promise');\nglobalPSD.env = snapShot();\nfunction Listener(onFulfilled, onRejected, resolve, reject, zone) {\n    this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;\n    this.onRejected = typeof onRejected === 'function' ? onRejected : null;\n    this.resolve = resolve;\n    this.reject = reject;\n    this.psd = zone;\n}\nprops(DexiePromise, {\n    all: function () {\n        var values = getArrayOf.apply(null, arguments)\n            .map(onPossibleParallellAsync);\n        return new DexiePromise(function (resolve, reject) {\n            if (values.length === 0)\n                resolve([]);\n            var remaining = values.length;\n            values.forEach(function (a, i) { return DexiePromise.resolve(a).then(function (x) {\n                values[i] = x;\n                if (!--remaining)\n                    resolve(values);\n            }, reject); });\n        });\n    },\n    resolve: function (value) {\n        if (value instanceof DexiePromise)\n            return value;\n        if (value && typeof value.then === 'function')\n            return new DexiePromise(function (resolve, reject) {\n                value.then(resolve, reject);\n            });\n        var rv = new DexiePromise(INTERNAL, true, value);\n        linkToPreviousPromise(rv, currentFulfiller);\n        return rv;\n    },\n    reject: PromiseReject,\n    race: function () {\n        var values = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);\n        return new DexiePromise(function (resolve, reject) {\n            values.map(function (value) { return DexiePromise.resolve(value).then(resolve, reject); });\n        });\n    },\n    PSD: {\n        get: function () { return PSD; },\n        set: function (value) { return PSD = value; }\n    },\n    totalEchoes: { get: function () { return totalEchoes; } },\n    newPSD: newScope,\n    usePSD: usePSD,\n    scheduler: {\n        get: function () { return asap; },\n        set: function (value) { asap = value; }\n    },\n    rejectionMapper: {\n        get: function () { return rejectionMapper; },\n        set: function (value) { rejectionMapper = value; }\n    },\n    follow: function (fn, zoneProps) {\n        return new DexiePromise(function (resolve, reject) {\n            return newScope(function (resolve, reject) {\n                var psd = PSD;\n                psd.unhandleds = [];\n                psd.onunhandled = reject;\n                psd.finalize = callBoth(function () {\n                    var _this = this;\n                    run_at_end_of_this_or_next_physical_tick(function () {\n                        _this.unhandleds.length === 0 ? resolve() : reject(_this.unhandleds[0]);\n                    });\n                }, psd.finalize);\n                fn();\n            }, zoneProps, resolve, reject);\n        });\n    }\n});\nif (NativePromise) {\n    if (NativePromise.allSettled)\n        setProp(DexiePromise, \"allSettled\", function () {\n            var possiblePromises = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);\n            return new DexiePromise(function (resolve) {\n                if (possiblePromises.length === 0)\n                    resolve([]);\n                var remaining = possiblePromises.length;\n                var results = new Array(remaining);\n                possiblePromises.forEach(function (p, i) { return DexiePromise.resolve(p).then(function (value) { return results[i] = { status: \"fulfilled\", value: value }; }, function (reason) { return results[i] = { status: \"rejected\", reason: reason }; })\n                    .then(function () { return --remaining || resolve(results); }); });\n            });\n        });\n    if (NativePromise.any && typeof AggregateError !== 'undefined')\n        setProp(DexiePromise, \"any\", function () {\n            var possiblePromises = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);\n            return new DexiePromise(function (resolve, reject) {\n                if (possiblePromises.length === 0)\n                    reject(new AggregateError([]));\n                var remaining = possiblePromises.length;\n                var failures = new Array(remaining);\n                possiblePromises.forEach(function (p, i) { return DexiePromise.resolve(p).then(function (value) { return resolve(value); }, function (failure) {\n                    failures[i] = failure;\n                    if (!--remaining)\n                        reject(new AggregateError(failures));\n                }); });\n            });\n        });\n}\nfunction executePromiseTask(promise, fn) {\n    try {\n        fn(function (value) {\n            if (promise._state !== null)\n                return;\n            if (value === promise)\n                throw new TypeError('A promise cannot be resolved with itself.');\n            var shouldExecuteTick = promise._lib && beginMicroTickScope();\n            if (value && typeof value.then === 'function') {\n                executePromiseTask(promise, function (resolve, reject) {\n                    value instanceof DexiePromise ?\n                        value._then(resolve, reject) :\n                        value.then(resolve, reject);\n                });\n            }\n            else {\n                promise._state = true;\n                promise._value = value;\n                propagateAllListeners(promise);\n            }\n            if (shouldExecuteTick)\n                endMicroTickScope();\n        }, handleRejection.bind(null, promise));\n    }\n    catch (ex) {\n        handleRejection(promise, ex);\n    }\n}\nfunction handleRejection(promise, reason) {\n    rejectingErrors.push(reason);\n    if (promise._state !== null)\n        return;\n    var shouldExecuteTick = promise._lib && beginMicroTickScope();\n    reason = rejectionMapper(reason);\n    promise._state = false;\n    promise._value = reason;\n    debug && reason !== null && typeof reason === 'object' && !reason._promise && tryCatch(function () {\n        var origProp = getPropertyDescriptor(reason, \"stack\");\n        reason._promise = promise;\n        setProp(reason, \"stack\", {\n            get: function () {\n                return stack_being_generated ?\n                    origProp && (origProp.get ?\n                        origProp.get.apply(reason) :\n                        origProp.value) :\n                    promise.stack;\n            }\n        });\n    });\n    addPossiblyUnhandledError(promise);\n    propagateAllListeners(promise);\n    if (shouldExecuteTick)\n        endMicroTickScope();\n}\nfunction propagateAllListeners(promise) {\n    var listeners = promise._listeners;\n    promise._listeners = [];\n    for (var i = 0, len = listeners.length; i < len; ++i) {\n        propagateToListener(promise, listeners[i]);\n    }\n    var psd = promise._PSD;\n    --psd.ref || psd.finalize();\n    if (numScheduledCalls === 0) {\n        ++numScheduledCalls;\n        asap(function () {\n            if (--numScheduledCalls === 0)\n                finalizePhysicalTick();\n        }, []);\n    }\n}\nfunction propagateToListener(promise, listener) {\n    if (promise._state === null) {\n        promise._listeners.push(listener);\n        return;\n    }\n    var cb = promise._state ? listener.onFulfilled : listener.onRejected;\n    if (cb === null) {\n        return (promise._state ? listener.resolve : listener.reject)(promise._value);\n    }\n    ++listener.psd.ref;\n    ++numScheduledCalls;\n    asap(callListener, [cb, promise, listener]);\n}\nfunction callListener(cb, promise, listener) {\n    try {\n        currentFulfiller = promise;\n        var ret, value = promise._value;\n        if (promise._state) {\n            ret = cb(value);\n        }\n        else {\n            if (rejectingErrors.length)\n                rejectingErrors = [];\n            ret = cb(value);\n            if (rejectingErrors.indexOf(value) === -1)\n                markErrorAsHandled(promise);\n        }\n        listener.resolve(ret);\n    }\n    catch (e) {\n        listener.reject(e);\n    }\n    finally {\n        currentFulfiller = null;\n        if (--numScheduledCalls === 0)\n            finalizePhysicalTick();\n        --listener.psd.ref || listener.psd.finalize();\n    }\n}\nfunction getStack(promise, stacks, limit) {\n    if (stacks.length === limit)\n        return stacks;\n    var stack = \"\";\n    if (promise._state === false) {\n        var failure = promise._value, errorName, message;\n        if (failure != null) {\n            errorName = failure.name || \"Error\";\n            message = failure.message || failure;\n            stack = prettyStack(failure, 0);\n        }\n        else {\n            errorName = failure;\n            message = \"\";\n        }\n        stacks.push(errorName + (message ? \": \" + message : \"\") + stack);\n    }\n    if (debug) {\n        stack = prettyStack(promise._stackHolder, 2);\n        if (stack && stacks.indexOf(stack) === -1)\n            stacks.push(stack);\n        if (promise._prev)\n            getStack(promise._prev, stacks, limit);\n    }\n    return stacks;\n}\nfunction linkToPreviousPromise(promise, prev) {\n    var numPrev = prev ? prev._numPrev + 1 : 0;\n    if (numPrev < LONG_STACKS_CLIP_LIMIT) {\n        promise._prev = prev;\n        promise._numPrev = numPrev;\n    }\n}\nfunction physicalTick() {\n    beginMicroTickScope() && endMicroTickScope();\n}\nfunction beginMicroTickScope() {\n    var wasRootExec = isOutsideMicroTick;\n    isOutsideMicroTick = false;\n    needsNewPhysicalTick = false;\n    return wasRootExec;\n}\nfunction endMicroTickScope() {\n    var callbacks, i, l;\n    do {\n        while (microtickQueue.length > 0) {\n            callbacks = microtickQueue;\n            microtickQueue = [];\n            l = callbacks.length;\n            for (i = 0; i < l; ++i) {\n                var item = callbacks[i];\n                item[0].apply(null, item[1]);\n            }\n        }\n    } while (microtickQueue.length > 0);\n    isOutsideMicroTick = true;\n    needsNewPhysicalTick = true;\n}\nfunction finalizePhysicalTick() {\n    var unhandledErrs = unhandledErrors;\n    unhandledErrors = [];\n    unhandledErrs.forEach(function (p) {\n        p._PSD.onunhandled.call(null, p._value, p);\n    });\n    var finalizers = tickFinalizers.slice(0);\n    var i = finalizers.length;\n    while (i)\n        finalizers[--i]();\n}\nfunction run_at_end_of_this_or_next_physical_tick(fn) {\n    function finalizer() {\n        fn();\n        tickFinalizers.splice(tickFinalizers.indexOf(finalizer), 1);\n    }\n    tickFinalizers.push(finalizer);\n    ++numScheduledCalls;\n    asap(function () {\n        if (--numScheduledCalls === 0)\n            finalizePhysicalTick();\n    }, []);\n}\nfunction addPossiblyUnhandledError(promise) {\n    if (!unhandledErrors.some(function (p) { return p._value === promise._value; }))\n        unhandledErrors.push(promise);\n}\nfunction markErrorAsHandled(promise) {\n    var i = unhandledErrors.length;\n    while (i)\n        if (unhandledErrors[--i]._value === promise._value) {\n            unhandledErrors.splice(i, 1);\n            return;\n        }\n}\nfunction PromiseReject(reason) {\n    return new DexiePromise(INTERNAL, false, reason);\n}\nfunction wrap(fn, errorCatcher) {\n    var psd = PSD;\n    return function () {\n        var wasRootExec = beginMicroTickScope(), outerScope = PSD;\n        try {\n            switchToZone(psd, true);\n            return fn.apply(this, arguments);\n        }\n        catch (e) {\n            errorCatcher && errorCatcher(e);\n        }\n        finally {\n            switchToZone(outerScope, false);\n            if (wasRootExec)\n                endMicroTickScope();\n        }\n    };\n}\nvar task = { awaits: 0, echoes: 0, id: 0 };\nvar taskCounter = 0;\nvar zoneStack = [];\nvar zoneEchoes = 0;\nvar totalEchoes = 0;\nvar zone_id_counter = 0;\nfunction newScope(fn, props, a1, a2) {\n    var parent = PSD, psd = Object.create(parent);\n    psd.parent = parent;\n    psd.ref = 0;\n    psd.global = false;\n    psd.id = ++zone_id_counter;\n    var globalEnv = globalPSD.env;\n    psd.env = patchGlobalPromise ? {\n        Promise: DexiePromise,\n        PromiseProp: { value: DexiePromise, configurable: true, writable: true },\n        all: DexiePromise.all,\n        race: DexiePromise.race,\n        allSettled: DexiePromise.allSettled,\n        any: DexiePromise.any,\n        resolve: DexiePromise.resolve,\n        reject: DexiePromise.reject,\n        nthen: getPatchedPromiseThen(globalEnv.nthen, psd),\n        gthen: getPatchedPromiseThen(globalEnv.gthen, psd)\n    } : {};\n    if (props)\n        extend(psd, props);\n    ++parent.ref;\n    psd.finalize = function () {\n        --this.parent.ref || this.parent.finalize();\n    };\n    var rv = usePSD(psd, fn, a1, a2);\n    if (psd.ref === 0)\n        psd.finalize();\n    return rv;\n}\nfunction incrementExpectedAwaits() {\n    if (!task.id)\n        task.id = ++taskCounter;\n    ++task.awaits;\n    task.echoes += ZONE_ECHO_LIMIT;\n    return task.id;\n}\nfunction decrementExpectedAwaits() {\n    if (!task.awaits)\n        return false;\n    if (--task.awaits === 0)\n        task.id = 0;\n    task.echoes = task.awaits * ZONE_ECHO_LIMIT;\n    return true;\n}\nif (('' + nativePromiseThen).indexOf('[native code]') === -1) {\n    incrementExpectedAwaits = decrementExpectedAwaits = nop;\n}\nfunction onPossibleParallellAsync(possiblePromise) {\n    if (task.echoes && possiblePromise && possiblePromise.constructor === NativePromise) {\n        incrementExpectedAwaits();\n        return possiblePromise.then(function (x) {\n            decrementExpectedAwaits();\n            return x;\n        }, function (e) {\n            decrementExpectedAwaits();\n            return rejection(e);\n        });\n    }\n    return possiblePromise;\n}\nfunction zoneEnterEcho(targetZone) {\n    ++totalEchoes;\n    if (!task.echoes || --task.echoes === 0) {\n        task.echoes = task.id = 0;\n    }\n    zoneStack.push(PSD);\n    switchToZone(targetZone, true);\n}\nfunction zoneLeaveEcho() {\n    var zone = zoneStack[zoneStack.length - 1];\n    zoneStack.pop();\n    switchToZone(zone, false);\n}\nfunction switchToZone(targetZone, bEnteringZone) {\n    var currentZone = PSD;\n    if (bEnteringZone ? task.echoes && (!zoneEchoes++ || targetZone !== PSD) : zoneEchoes && (!--zoneEchoes || targetZone !== PSD)) {\n        enqueueNativeMicroTask(bEnteringZone ? zoneEnterEcho.bind(null, targetZone) : zoneLeaveEcho);\n    }\n    if (targetZone === PSD)\n        return;\n    PSD = targetZone;\n    if (currentZone === globalPSD)\n        globalPSD.env = snapShot();\n    if (patchGlobalPromise) {\n        var GlobalPromise_1 = globalPSD.env.Promise;\n        var targetEnv = targetZone.env;\n        nativePromiseProto.then = targetEnv.nthen;\n        GlobalPromise_1.prototype.then = targetEnv.gthen;\n        if (currentZone.global || targetZone.global) {\n            Object.defineProperty(_global, 'Promise', targetEnv.PromiseProp);\n            GlobalPromise_1.all = targetEnv.all;\n            GlobalPromise_1.race = targetEnv.race;\n            GlobalPromise_1.resolve = targetEnv.resolve;\n            GlobalPromise_1.reject = targetEnv.reject;\n            if (targetEnv.allSettled)\n                GlobalPromise_1.allSettled = targetEnv.allSettled;\n            if (targetEnv.any)\n                GlobalPromise_1.any = targetEnv.any;\n        }\n    }\n}\nfunction snapShot() {\n    var GlobalPromise = _global.Promise;\n    return patchGlobalPromise ? {\n        Promise: GlobalPromise,\n        PromiseProp: Object.getOwnPropertyDescriptor(_global, \"Promise\"),\n        all: GlobalPromise.all,\n        race: GlobalPromise.race,\n        allSettled: GlobalPromise.allSettled,\n        any: GlobalPromise.any,\n        resolve: GlobalPromise.resolve,\n        reject: GlobalPromise.reject,\n        nthen: nativePromiseProto.then,\n        gthen: GlobalPromise.prototype.then\n    } : {};\n}\nfunction usePSD(psd, fn, a1, a2, a3) {\n    var outerScope = PSD;\n    try {\n        switchToZone(psd, true);\n        return fn(a1, a2, a3);\n    }\n    finally {\n        switchToZone(outerScope, false);\n    }\n}\nfunction enqueueNativeMicroTask(job) {\n    nativePromiseThen.call(resolvedNativePromise, job);\n}\nfunction nativeAwaitCompatibleWrap(fn, zone, possibleAwait, cleanup) {\n    return typeof fn !== 'function' ? fn : function () {\n        var outerZone = PSD;\n        if (possibleAwait)\n            incrementExpectedAwaits();\n        switchToZone(zone, true);\n        try {\n            return fn.apply(this, arguments);\n        }\n        finally {\n            switchToZone(outerZone, false);\n            if (cleanup)\n                enqueueNativeMicroTask(decrementExpectedAwaits);\n        }\n    };\n}\nfunction getPatchedPromiseThen(origThen, zone) {\n    return function (onResolved, onRejected) {\n        return origThen.call(this, nativeAwaitCompatibleWrap(onResolved, zone), nativeAwaitCompatibleWrap(onRejected, zone));\n    };\n}\nvar UNHANDLEDREJECTION = \"unhandledrejection\";\nfunction globalError(err, promise) {\n    var rv;\n    try {\n        rv = promise.onuncatched(err);\n    }\n    catch (e) { }\n    if (rv !== false)\n        try {\n            var event, eventData = { promise: promise, reason: err };\n            if (_global.document && document.createEvent) {\n                event = document.createEvent('Event');\n                event.initEvent(UNHANDLEDREJECTION, true, true);\n                extend(event, eventData);\n            }\n            else if (_global.CustomEvent) {\n                event = new CustomEvent(UNHANDLEDREJECTION, { detail: eventData });\n                extend(event, eventData);\n            }\n            if (event && _global.dispatchEvent) {\n                dispatchEvent(event);\n                if (!_global.PromiseRejectionEvent && _global.onunhandledrejection)\n                    try {\n                        _global.onunhandledrejection(event);\n                    }\n                    catch (_) { }\n            }\n            if (debug && event && !event.defaultPrevented) {\n                console.warn(\"Unhandled rejection: \" + (err.stack || err));\n            }\n        }\n        catch (e) { }\n}\nvar rejection = DexiePromise.reject;\n\nfunction tempTransaction(db, mode, storeNames, fn) {\n    if (!db.idbdb || (!db._state.openComplete && (!PSD.letThrough && !db._vip))) {\n        if (db._state.openComplete) {\n            return rejection(new exceptions.DatabaseClosed(db._state.dbOpenError));\n        }\n        if (!db._state.isBeingOpened) {\n            if (!db._options.autoOpen)\n                return rejection(new exceptions.DatabaseClosed());\n            db.open().catch(nop);\n        }\n        return db._state.dbReadyPromise.then(function () { return tempTransaction(db, mode, storeNames, fn); });\n    }\n    else {\n        var trans = db._createTransaction(mode, storeNames, db._dbSchema);\n        try {\n            trans.create();\n            db._state.PR1398_maxLoop = 3;\n        }\n        catch (ex) {\n            if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {\n                console.warn('Dexie: Need to reopen db');\n                db._close();\n                return db.open().then(function () { return tempTransaction(db, mode, storeNames, fn); });\n            }\n            return rejection(ex);\n        }\n        return trans._promise(mode, function (resolve, reject) {\n            return newScope(function () {\n                PSD.trans = trans;\n                return fn(resolve, reject, trans);\n            });\n        }).then(function (result) {\n            return trans._completion.then(function () { return result; });\n        });\n    }\n}\n\nvar DEXIE_VERSION = '3.2.3';\nvar maxString = String.fromCharCode(65535);\nvar minKey = -Infinity;\nvar INVALID_KEY_ARGUMENT = \"Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.\";\nvar STRING_EXPECTED = \"String expected.\";\nvar connections = [];\nvar isIEOrEdge = typeof navigator !== 'undefined' && /(MSIE|Trident|Edge)/.test(navigator.userAgent);\nvar hasIEDeleteObjectStoreBug = isIEOrEdge;\nvar hangsOnDeleteLargeKeyRange = isIEOrEdge;\nvar dexieStackFrameFilter = function (frame) { return !/(dexie\\.js|dexie\\.min\\.js)/.test(frame); };\nvar DBNAMES_DB = '__dbnames';\nvar READONLY = 'readonly';\nvar READWRITE = 'readwrite';\n\nfunction combine(filter1, filter2) {\n    return filter1 ?\n        filter2 ?\n            function () { return filter1.apply(this, arguments) && filter2.apply(this, arguments); } :\n            filter1 :\n        filter2;\n}\n\nvar AnyRange = {\n    type: 3 ,\n    lower: -Infinity,\n    lowerOpen: false,\n    upper: [[]],\n    upperOpen: false\n};\n\nfunction workaroundForUndefinedPrimKey(keyPath) {\n    return typeof keyPath === \"string\" && !/\\./.test(keyPath)\n        ? function (obj) {\n            if (obj[keyPath] === undefined && (keyPath in obj)) {\n                obj = deepClone(obj);\n                delete obj[keyPath];\n            }\n            return obj;\n        }\n        : function (obj) { return obj; };\n}\n\nvar Table =  (function () {\n    function Table() {\n    }\n    Table.prototype._trans = function (mode, fn, writeLocked) {\n        var trans = this._tx || PSD.trans;\n        var tableName = this.name;\n        function checkTableInTransaction(resolve, reject, trans) {\n            if (!trans.schema[tableName])\n                throw new exceptions.NotFound(\"Table \" + tableName + \" not part of transaction\");\n            return fn(trans.idbtrans, trans);\n        }\n        var wasRootExec = beginMicroTickScope();\n        try {\n            return trans && trans.db === this.db ?\n                trans === PSD.trans ?\n                    trans._promise(mode, checkTableInTransaction, writeLocked) :\n                    newScope(function () { return trans._promise(mode, checkTableInTransaction, writeLocked); }, { trans: trans, transless: PSD.transless || PSD }) :\n                tempTransaction(this.db, mode, [this.name], checkTableInTransaction);\n        }\n        finally {\n            if (wasRootExec)\n                endMicroTickScope();\n        }\n    };\n    Table.prototype.get = function (keyOrCrit, cb) {\n        var _this = this;\n        if (keyOrCrit && keyOrCrit.constructor === Object)\n            return this.where(keyOrCrit).first(cb);\n        return this._trans('readonly', function (trans) {\n            return _this.core.get({ trans: trans, key: keyOrCrit })\n                .then(function (res) { return _this.hook.reading.fire(res); });\n        }).then(cb);\n    };\n    Table.prototype.where = function (indexOrCrit) {\n        if (typeof indexOrCrit === 'string')\n            return new this.db.WhereClause(this, indexOrCrit);\n        if (isArray(indexOrCrit))\n            return new this.db.WhereClause(this, \"[\" + indexOrCrit.join('+') + \"]\");\n        var keyPaths = keys(indexOrCrit);\n        if (keyPaths.length === 1)\n            return this\n                .where(keyPaths[0])\n                .equals(indexOrCrit[keyPaths[0]]);\n        var compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter(function (ix) {\n            return ix.compound &&\n                keyPaths.every(function (keyPath) { return ix.keyPath.indexOf(keyPath) >= 0; }) &&\n                ix.keyPath.every(function (keyPath) { return keyPaths.indexOf(keyPath) >= 0; });\n        })[0];\n        if (compoundIndex && this.db._maxKey !== maxString)\n            return this\n                .where(compoundIndex.name)\n                .equals(compoundIndex.keyPath.map(function (kp) { return indexOrCrit[kp]; }));\n        if (!compoundIndex && debug)\n            console.warn(\"The query \" + JSON.stringify(indexOrCrit) + \" on \" + this.name + \" would benefit of a \" +\n                (\"compound index [\" + keyPaths.join('+') + \"]\"));\n        var idxByName = this.schema.idxByName;\n        var idb = this.db._deps.indexedDB;\n        function equals(a, b) {\n            try {\n                return idb.cmp(a, b) === 0;\n            }\n            catch (e) {\n                return false;\n            }\n        }\n        var _a = keyPaths.reduce(function (_a, keyPath) {\n            var prevIndex = _a[0], prevFilterFn = _a[1];\n            var index = idxByName[keyPath];\n            var value = indexOrCrit[keyPath];\n            return [\n                prevIndex || index,\n                prevIndex || !index ?\n                    combine(prevFilterFn, index && index.multi ?\n                        function (x) {\n                            var prop = getByKeyPath(x, keyPath);\n                            return isArray(prop) && prop.some(function (item) { return equals(value, item); });\n                        } : function (x) { return equals(value, getByKeyPath(x, keyPath)); })\n                    : prevFilterFn\n            ];\n        }, [null, null]), idx = _a[0], filterFunction = _a[1];\n        return idx ?\n            this.where(idx.name).equals(indexOrCrit[idx.keyPath])\n                .filter(filterFunction) :\n            compoundIndex ?\n                this.filter(filterFunction) :\n                this.where(keyPaths).equals('');\n    };\n    Table.prototype.filter = function (filterFunction) {\n        return this.toCollection().and(filterFunction);\n    };\n    Table.prototype.count = function (thenShortcut) {\n        return this.toCollection().count(thenShortcut);\n    };\n    Table.prototype.offset = function (offset) {\n        return this.toCollection().offset(offset);\n    };\n    Table.prototype.limit = function (numRows) {\n        return this.toCollection().limit(numRows);\n    };\n    Table.prototype.each = function (callback) {\n        return this.toCollection().each(callback);\n    };\n    Table.prototype.toArray = function (thenShortcut) {\n        return this.toCollection().toArray(thenShortcut);\n    };\n    Table.prototype.toCollection = function () {\n        return new this.db.Collection(new this.db.WhereClause(this));\n    };\n    Table.prototype.orderBy = function (index) {\n        return new this.db.Collection(new this.db.WhereClause(this, isArray(index) ?\n            \"[\" + index.join('+') + \"]\" :\n            index));\n    };\n    Table.prototype.reverse = function () {\n        return this.toCollection().reverse();\n    };\n    Table.prototype.mapToClass = function (constructor) {\n        this.schema.mappedClass = constructor;\n        var readHook = function (obj) {\n            if (!obj)\n                return obj;\n            var res = Object.create(constructor.prototype);\n            for (var m in obj)\n                if (hasOwn(obj, m))\n                    try {\n                        res[m] = obj[m];\n                    }\n                    catch (_) { }\n            return res;\n        };\n        if (this.schema.readHook) {\n            this.hook.reading.unsubscribe(this.schema.readHook);\n        }\n        this.schema.readHook = readHook;\n        this.hook(\"reading\", readHook);\n        return constructor;\n    };\n    Table.prototype.defineClass = function () {\n        function Class(content) {\n            extend(this, content);\n        }\n        return this.mapToClass(Class);\n    };\n    Table.prototype.add = function (obj, key) {\n        var _this = this;\n        var _a = this.schema.primKey, auto = _a.auto, keyPath = _a.keyPath;\n        var objToAdd = obj;\n        if (keyPath && auto) {\n            objToAdd = workaroundForUndefinedPrimKey(keyPath)(obj);\n        }\n        return this._trans('readwrite', function (trans) {\n            return _this.core.mutate({ trans: trans, type: 'add', keys: key != null ? [key] : null, values: [objToAdd] });\n        }).then(function (res) { return res.numFailures ? DexiePromise.reject(res.failures[0]) : res.lastResult; })\n            .then(function (lastResult) {\n            if (keyPath) {\n                try {\n                    setByKeyPath(obj, keyPath, lastResult);\n                }\n                catch (_) { }\n            }\n            return lastResult;\n        });\n    };\n    Table.prototype.update = function (keyOrObject, modifications) {\n        if (typeof keyOrObject === 'object' && !isArray(keyOrObject)) {\n            var key = getByKeyPath(keyOrObject, this.schema.primKey.keyPath);\n            if (key === undefined)\n                return rejection(new exceptions.InvalidArgument(\"Given object does not contain its primary key\"));\n            try {\n                if (typeof modifications !== \"function\") {\n                    keys(modifications).forEach(function (keyPath) {\n                        setByKeyPath(keyOrObject, keyPath, modifications[keyPath]);\n                    });\n                }\n                else {\n                    modifications(keyOrObject, { value: keyOrObject, primKey: key });\n                }\n            }\n            catch (_a) {\n            }\n            return this.where(\":id\").equals(key).modify(modifications);\n        }\n        else {\n            return this.where(\":id\").equals(keyOrObject).modify(modifications);\n        }\n    };\n    Table.prototype.put = function (obj, key) {\n        var _this = this;\n        var _a = this.schema.primKey, auto = _a.auto, keyPath = _a.keyPath;\n        var objToAdd = obj;\n        if (keyPath && auto) {\n            objToAdd = workaroundForUndefinedPrimKey(keyPath)(obj);\n        }\n        return this._trans('readwrite', function (trans) { return _this.core.mutate({ trans: trans, type: 'put', values: [objToAdd], keys: key != null ? [key] : null }); })\n            .then(function (res) { return res.numFailures ? DexiePromise.reject(res.failures[0]) : res.lastResult; })\n            .then(function (lastResult) {\n            if (keyPath) {\n                try {\n                    setByKeyPath(obj, keyPath, lastResult);\n                }\n                catch (_) { }\n            }\n            return lastResult;\n        });\n    };\n    Table.prototype.delete = function (key) {\n        var _this = this;\n        return this._trans('readwrite', function (trans) { return _this.core.mutate({ trans: trans, type: 'delete', keys: [key] }); })\n            .then(function (res) { return res.numFailures ? DexiePromise.reject(res.failures[0]) : undefined; });\n    };\n    Table.prototype.clear = function () {\n        var _this = this;\n        return this._trans('readwrite', function (trans) { return _this.core.mutate({ trans: trans, type: 'deleteRange', range: AnyRange }); })\n            .then(function (res) { return res.numFailures ? DexiePromise.reject(res.failures[0]) : undefined; });\n    };\n    Table.prototype.bulkGet = function (keys) {\n        var _this = this;\n        return this._trans('readonly', function (trans) {\n            return _this.core.getMany({\n                keys: keys,\n                trans: trans\n            }).then(function (result) { return result.map(function (res) { return _this.hook.reading.fire(res); }); });\n        });\n    };\n    Table.prototype.bulkAdd = function (objects, keysOrOptions, options) {\n        var _this = this;\n        var keys = Array.isArray(keysOrOptions) ? keysOrOptions : undefined;\n        options = options || (keys ? undefined : keysOrOptions);\n        var wantResults = options ? options.allKeys : undefined;\n        return this._trans('readwrite', function (trans) {\n            var _a = _this.schema.primKey, auto = _a.auto, keyPath = _a.keyPath;\n            if (keyPath && keys)\n                throw new exceptions.InvalidArgument(\"bulkAdd(): keys argument invalid on tables with inbound keys\");\n            if (keys && keys.length !== objects.length)\n                throw new exceptions.InvalidArgument(\"Arguments objects and keys must have the same length\");\n            var numObjects = objects.length;\n            var objectsToAdd = keyPath && auto ?\n                objects.map(workaroundForUndefinedPrimKey(keyPath)) :\n                objects;\n            return _this.core.mutate({ trans: trans, type: 'add', keys: keys, values: objectsToAdd, wantResults: wantResults })\n                .then(function (_a) {\n                var numFailures = _a.numFailures, results = _a.results, lastResult = _a.lastResult, failures = _a.failures;\n                var result = wantResults ? results : lastResult;\n                if (numFailures === 0)\n                    return result;\n                throw new BulkError(_this.name + \".bulkAdd(): \" + numFailures + \" of \" + numObjects + \" operations failed\", failures);\n            });\n        });\n    };\n    Table.prototype.bulkPut = function (objects, keysOrOptions, options) {\n        var _this = this;\n        var keys = Array.isArray(keysOrOptions) ? keysOrOptions : undefined;\n        options = options || (keys ? undefined : keysOrOptions);\n        var wantResults = options ? options.allKeys : undefined;\n        return this._trans('readwrite', function (trans) {\n            var _a = _this.schema.primKey, auto = _a.auto, keyPath = _a.keyPath;\n            if (keyPath && keys)\n                throw new exceptions.InvalidArgument(\"bulkPut(): keys argument invalid on tables with inbound keys\");\n            if (keys && keys.length !== objects.length)\n                throw new exceptions.InvalidArgument(\"Arguments objects and keys must have the same length\");\n            var numObjects = objects.length;\n            var objectsToPut = keyPath && auto ?\n                objects.map(workaroundForUndefinedPrimKey(keyPath)) :\n                objects;\n            return _this.core.mutate({ trans: trans, type: 'put', keys: keys, values: objectsToPut, wantResults: wantResults })\n                .then(function (_a) {\n                var numFailures = _a.numFailures, results = _a.results, lastResult = _a.lastResult, failures = _a.failures;\n                var result = wantResults ? results : lastResult;\n                if (numFailures === 0)\n                    return result;\n                throw new BulkError(_this.name + \".bulkPut(): \" + numFailures + \" of \" + numObjects + \" operations failed\", failures);\n            });\n        });\n    };\n    Table.prototype.bulkDelete = function (keys) {\n        var _this = this;\n        var numKeys = keys.length;\n        return this._trans('readwrite', function (trans) {\n            return _this.core.mutate({ trans: trans, type: 'delete', keys: keys });\n        }).then(function (_a) {\n            var numFailures = _a.numFailures, lastResult = _a.lastResult, failures = _a.failures;\n            if (numFailures === 0)\n                return lastResult;\n            throw new BulkError(_this.name + \".bulkDelete(): \" + numFailures + \" of \" + numKeys + \" operations failed\", failures);\n        });\n    };\n    return Table;\n}());\n\nfunction Events(ctx) {\n    var evs = {};\n    var rv = function (eventName, subscriber) {\n        if (subscriber) {\n            var i = arguments.length, args = new Array(i - 1);\n            while (--i)\n                args[i - 1] = arguments[i];\n            evs[eventName].subscribe.apply(null, args);\n            return ctx;\n        }\n        else if (typeof (eventName) === 'string') {\n            return evs[eventName];\n        }\n    };\n    rv.addEventType = add;\n    for (var i = 1, l = arguments.length; i < l; ++i) {\n        add(arguments[i]);\n    }\n    return rv;\n    function add(eventName, chainFunction, defaultFunction) {\n        if (typeof eventName === 'object')\n            return addConfiguredEvents(eventName);\n        if (!chainFunction)\n            chainFunction = reverseStoppableEventChain;\n        if (!defaultFunction)\n            defaultFunction = nop;\n        var context = {\n            subscribers: [],\n            fire: defaultFunction,\n            subscribe: function (cb) {\n                if (context.subscribers.indexOf(cb) === -1) {\n                    context.subscribers.push(cb);\n                    context.fire = chainFunction(context.fire, cb);\n                }\n            },\n            unsubscribe: function (cb) {\n                context.subscribers = context.subscribers.filter(function (fn) { return fn !== cb; });\n                context.fire = context.subscribers.reduce(chainFunction, defaultFunction);\n            }\n        };\n        evs[eventName] = rv[eventName] = context;\n        return context;\n    }\n    function addConfiguredEvents(cfg) {\n        keys(cfg).forEach(function (eventName) {\n            var args = cfg[eventName];\n            if (isArray(args)) {\n                add(eventName, cfg[eventName][0], cfg[eventName][1]);\n            }\n            else if (args === 'asap') {\n                var context = add(eventName, mirror, function fire() {\n                    var i = arguments.length, args = new Array(i);\n                    while (i--)\n                        args[i] = arguments[i];\n                    context.subscribers.forEach(function (fn) {\n                        asap$1(function fireEvent() {\n                            fn.apply(null, args);\n                        });\n                    });\n                });\n            }\n            else\n                throw new exceptions.InvalidArgument(\"Invalid event config\");\n        });\n    }\n}\n\nfunction makeClassConstructor(prototype, constructor) {\n    derive(constructor).from({ prototype: prototype });\n    return constructor;\n}\n\nfunction createTableConstructor(db) {\n    return makeClassConstructor(Table.prototype, function Table(name, tableSchema, trans) {\n        this.db = db;\n        this._tx = trans;\n        this.name = name;\n        this.schema = tableSchema;\n        this.hook = db._allTables[name] ? db._allTables[name].hook : Events(null, {\n            \"creating\": [hookCreatingChain, nop],\n            \"reading\": [pureFunctionChain, mirror],\n            \"updating\": [hookUpdatingChain, nop],\n            \"deleting\": [hookDeletingChain, nop]\n        });\n    });\n}\n\nfunction isPlainKeyRange(ctx, ignoreLimitFilter) {\n    return !(ctx.filter || ctx.algorithm || ctx.or) &&\n        (ignoreLimitFilter ? ctx.justLimit : !ctx.replayFilter);\n}\nfunction addFilter(ctx, fn) {\n    ctx.filter = combine(ctx.filter, fn);\n}\nfunction addReplayFilter(ctx, factory, isLimitFilter) {\n    var curr = ctx.replayFilter;\n    ctx.replayFilter = curr ? function () { return combine(curr(), factory()); } : factory;\n    ctx.justLimit = isLimitFilter && !curr;\n}\nfunction addMatchFilter(ctx, fn) {\n    ctx.isMatch = combine(ctx.isMatch, fn);\n}\nfunction getIndexOrStore(ctx, coreSchema) {\n    if (ctx.isPrimKey)\n        return coreSchema.primaryKey;\n    var index = coreSchema.getIndexByKeyPath(ctx.index);\n    if (!index)\n        throw new exceptions.Schema(\"KeyPath \" + ctx.index + \" on object store \" + coreSchema.name + \" is not indexed\");\n    return index;\n}\nfunction openCursor(ctx, coreTable, trans) {\n    var index = getIndexOrStore(ctx, coreTable.schema);\n    return coreTable.openCursor({\n        trans: trans,\n        values: !ctx.keysOnly,\n        reverse: ctx.dir === 'prev',\n        unique: !!ctx.unique,\n        query: {\n            index: index,\n            range: ctx.range\n        }\n    });\n}\nfunction iter(ctx, fn, coreTrans, coreTable) {\n    var filter = ctx.replayFilter ? combine(ctx.filter, ctx.replayFilter()) : ctx.filter;\n    if (!ctx.or) {\n        return iterate(openCursor(ctx, coreTable, coreTrans), combine(ctx.algorithm, filter), fn, !ctx.keysOnly && ctx.valueMapper);\n    }\n    else {\n        var set_1 = {};\n        var union = function (item, cursor, advance) {\n            if (!filter || filter(cursor, advance, function (result) { return cursor.stop(result); }, function (err) { return cursor.fail(err); })) {\n                var primaryKey = cursor.primaryKey;\n                var key = '' + primaryKey;\n                if (key === '[object ArrayBuffer]')\n                    key = '' + new Uint8Array(primaryKey);\n                if (!hasOwn(set_1, key)) {\n                    set_1[key] = true;\n                    fn(item, cursor, advance);\n                }\n            }\n        };\n        return Promise.all([\n            ctx.or._iterate(union, coreTrans),\n            iterate(openCursor(ctx, coreTable, coreTrans), ctx.algorithm, union, !ctx.keysOnly && ctx.valueMapper)\n        ]);\n    }\n}\nfunction iterate(cursorPromise, filter, fn, valueMapper) {\n    var mappedFn = valueMapper ? function (x, c, a) { return fn(valueMapper(x), c, a); } : fn;\n    var wrappedFn = wrap(mappedFn);\n    return cursorPromise.then(function (cursor) {\n        if (cursor) {\n            return cursor.start(function () {\n                var c = function () { return cursor.continue(); };\n                if (!filter || filter(cursor, function (advancer) { return c = advancer; }, function (val) { cursor.stop(val); c = nop; }, function (e) { cursor.fail(e); c = nop; }))\n                    wrappedFn(cursor.value, cursor, function (advancer) { return c = advancer; });\n                c();\n            });\n        }\n    });\n}\n\nfunction cmp(a, b) {\n    try {\n        var ta = type(a);\n        var tb = type(b);\n        if (ta !== tb) {\n            if (ta === 'Array')\n                return 1;\n            if (tb === 'Array')\n                return -1;\n            if (ta === 'binary')\n                return 1;\n            if (tb === 'binary')\n                return -1;\n            if (ta === 'string')\n                return 1;\n            if (tb === 'string')\n                return -1;\n            if (ta === 'Date')\n                return 1;\n            if (tb !== 'Date')\n                return NaN;\n            return -1;\n        }\n        switch (ta) {\n            case 'number':\n            case 'Date':\n            case 'string':\n                return a > b ? 1 : a < b ? -1 : 0;\n            case 'binary': {\n                return compareUint8Arrays(getUint8Array(a), getUint8Array(b));\n            }\n            case 'Array':\n                return compareArrays(a, b);\n        }\n    }\n    catch (_a) { }\n    return NaN;\n}\nfunction compareArrays(a, b) {\n    var al = a.length;\n    var bl = b.length;\n    var l = al < bl ? al : bl;\n    for (var i = 0; i < l; ++i) {\n        var res = cmp(a[i], b[i]);\n        if (res !== 0)\n            return res;\n    }\n    return al === bl ? 0 : al < bl ? -1 : 1;\n}\nfunction compareUint8Arrays(a, b) {\n    var al = a.length;\n    var bl = b.length;\n    var l = al < bl ? al : bl;\n    for (var i = 0; i < l; ++i) {\n        if (a[i] !== b[i])\n            return a[i] < b[i] ? -1 : 1;\n    }\n    return al === bl ? 0 : al < bl ? -1 : 1;\n}\nfunction type(x) {\n    var t = typeof x;\n    if (t !== 'object')\n        return t;\n    if (ArrayBuffer.isView(x))\n        return 'binary';\n    var tsTag = toStringTag(x);\n    return tsTag === 'ArrayBuffer' ? 'binary' : tsTag;\n}\nfunction getUint8Array(a) {\n    if (a instanceof Uint8Array)\n        return a;\n    if (ArrayBuffer.isView(a))\n        return new Uint8Array(a.buffer, a.byteOffset, a.byteLength);\n    return new Uint8Array(a);\n}\n\nvar Collection =  (function () {\n    function Collection() {\n    }\n    Collection.prototype._read = function (fn, cb) {\n        var ctx = this._ctx;\n        return ctx.error ?\n            ctx.table._trans(null, rejection.bind(null, ctx.error)) :\n            ctx.table._trans('readonly', fn).then(cb);\n    };\n    Collection.prototype._write = function (fn) {\n        var ctx = this._ctx;\n        return ctx.error ?\n            ctx.table._trans(null, rejection.bind(null, ctx.error)) :\n            ctx.table._trans('readwrite', fn, \"locked\");\n    };\n    Collection.prototype._addAlgorithm = function (fn) {\n        var ctx = this._ctx;\n        ctx.algorithm = combine(ctx.algorithm, fn);\n    };\n    Collection.prototype._iterate = function (fn, coreTrans) {\n        return iter(this._ctx, fn, coreTrans, this._ctx.table.core);\n    };\n    Collection.prototype.clone = function (props) {\n        var rv = Object.create(this.constructor.prototype), ctx = Object.create(this._ctx);\n        if (props)\n            extend(ctx, props);\n        rv._ctx = ctx;\n        return rv;\n    };\n    Collection.prototype.raw = function () {\n        this._ctx.valueMapper = null;\n        return this;\n    };\n    Collection.prototype.each = function (fn) {\n        var ctx = this._ctx;\n        return this._read(function (trans) { return iter(ctx, fn, trans, ctx.table.core); });\n    };\n    Collection.prototype.count = function (cb) {\n        var _this = this;\n        return this._read(function (trans) {\n            var ctx = _this._ctx;\n            var coreTable = ctx.table.core;\n            if (isPlainKeyRange(ctx, true)) {\n                return coreTable.count({\n                    trans: trans,\n                    query: {\n                        index: getIndexOrStore(ctx, coreTable.schema),\n                        range: ctx.range\n                    }\n                }).then(function (count) { return Math.min(count, ctx.limit); });\n            }\n            else {\n                var count = 0;\n                return iter(ctx, function () { ++count; return false; }, trans, coreTable)\n                    .then(function () { return count; });\n            }\n        }).then(cb);\n    };\n    Collection.prototype.sortBy = function (keyPath, cb) {\n        var parts = keyPath.split('.').reverse(), lastPart = parts[0], lastIndex = parts.length - 1;\n        function getval(obj, i) {\n            if (i)\n                return getval(obj[parts[i]], i - 1);\n            return obj[lastPart];\n        }\n        var order = this._ctx.dir === \"next\" ? 1 : -1;\n        function sorter(a, b) {\n            var aVal = getval(a, lastIndex), bVal = getval(b, lastIndex);\n            return aVal < bVal ? -order : aVal > bVal ? order : 0;\n        }\n        return this.toArray(function (a) {\n            return a.sort(sorter);\n        }).then(cb);\n    };\n    Collection.prototype.toArray = function (cb) {\n        var _this = this;\n        return this._read(function (trans) {\n            var ctx = _this._ctx;\n            if (ctx.dir === 'next' && isPlainKeyRange(ctx, true) && ctx.limit > 0) {\n                var valueMapper_1 = ctx.valueMapper;\n                var index = getIndexOrStore(ctx, ctx.table.core.schema);\n                return ctx.table.core.query({\n                    trans: trans,\n                    limit: ctx.limit,\n                    values: true,\n                    query: {\n                        index: index,\n                        range: ctx.range\n                    }\n                }).then(function (_a) {\n                    var result = _a.result;\n                    return valueMapper_1 ? result.map(valueMapper_1) : result;\n                });\n            }\n            else {\n                var a_1 = [];\n                return iter(ctx, function (item) { return a_1.push(item); }, trans, ctx.table.core).then(function () { return a_1; });\n            }\n        }, cb);\n    };\n    Collection.prototype.offset = function (offset) {\n        var ctx = this._ctx;\n        if (offset <= 0)\n            return this;\n        ctx.offset += offset;\n        if (isPlainKeyRange(ctx)) {\n            addReplayFilter(ctx, function () {\n                var offsetLeft = offset;\n                return function (cursor, advance) {\n                    if (offsetLeft === 0)\n                        return true;\n                    if (offsetLeft === 1) {\n                        --offsetLeft;\n                        return false;\n                    }\n                    advance(function () {\n                        cursor.advance(offsetLeft);\n                        offsetLeft = 0;\n                    });\n                    return false;\n                };\n            });\n        }\n        else {\n            addReplayFilter(ctx, function () {\n                var offsetLeft = offset;\n                return function () { return (--offsetLeft < 0); };\n            });\n        }\n        return this;\n    };\n    Collection.prototype.limit = function (numRows) {\n        this._ctx.limit = Math.min(this._ctx.limit, numRows);\n        addReplayFilter(this._ctx, function () {\n            var rowsLeft = numRows;\n            return function (cursor, advance, resolve) {\n                if (--rowsLeft <= 0)\n                    advance(resolve);\n                return rowsLeft >= 0;\n            };\n        }, true);\n        return this;\n    };\n    Collection.prototype.until = function (filterFunction, bIncludeStopEntry) {\n        addFilter(this._ctx, function (cursor, advance, resolve) {\n            if (filterFunction(cursor.value)) {\n                advance(resolve);\n                return bIncludeStopEntry;\n            }\n            else {\n                return true;\n            }\n        });\n        return this;\n    };\n    Collection.prototype.first = function (cb) {\n        return this.limit(1).toArray(function (a) { return a[0]; }).then(cb);\n    };\n    Collection.prototype.last = function (cb) {\n        return this.reverse().first(cb);\n    };\n    Collection.prototype.filter = function (filterFunction) {\n        addFilter(this._ctx, function (cursor) {\n            return filterFunction(cursor.value);\n        });\n        addMatchFilter(this._ctx, filterFunction);\n        return this;\n    };\n    Collection.prototype.and = function (filter) {\n        return this.filter(filter);\n    };\n    Collection.prototype.or = function (indexName) {\n        return new this.db.WhereClause(this._ctx.table, indexName, this);\n    };\n    Collection.prototype.reverse = function () {\n        this._ctx.dir = (this._ctx.dir === \"prev\" ? \"next\" : \"prev\");\n        if (this._ondirectionchange)\n            this._ondirectionchange(this._ctx.dir);\n        return this;\n    };\n    Collection.prototype.desc = function () {\n        return this.reverse();\n    };\n    Collection.prototype.eachKey = function (cb) {\n        var ctx = this._ctx;\n        ctx.keysOnly = !ctx.isMatch;\n        return this.each(function (val, cursor) { cb(cursor.key, cursor); });\n    };\n    Collection.prototype.eachUniqueKey = function (cb) {\n        this._ctx.unique = \"unique\";\n        return this.eachKey(cb);\n    };\n    Collection.prototype.eachPrimaryKey = function (cb) {\n        var ctx = this._ctx;\n        ctx.keysOnly = !ctx.isMatch;\n        return this.each(function (val, cursor) { cb(cursor.primaryKey, cursor); });\n    };\n    Collection.prototype.keys = function (cb) {\n        var ctx = this._ctx;\n        ctx.keysOnly = !ctx.isMatch;\n        var a = [];\n        return this.each(function (item, cursor) {\n            a.push(cursor.key);\n        }).then(function () {\n            return a;\n        }).then(cb);\n    };\n    Collection.prototype.primaryKeys = function (cb) {\n        var ctx = this._ctx;\n        if (ctx.dir === 'next' && isPlainKeyRange(ctx, true) && ctx.limit > 0) {\n            return this._read(function (trans) {\n                var index = getIndexOrStore(ctx, ctx.table.core.schema);\n                return ctx.table.core.query({\n                    trans: trans,\n                    values: false,\n                    limit: ctx.limit,\n                    query: {\n                        index: index,\n                        range: ctx.range\n                    }\n                });\n            }).then(function (_a) {\n                var result = _a.result;\n                return result;\n            }).then(cb);\n        }\n        ctx.keysOnly = !ctx.isMatch;\n        var a = [];\n        return this.each(function (item, cursor) {\n            a.push(cursor.primaryKey);\n        }).then(function () {\n            return a;\n        }).then(cb);\n    };\n    Collection.prototype.uniqueKeys = function (cb) {\n        this._ctx.unique = \"unique\";\n        return this.keys(cb);\n    };\n    Collection.prototype.firstKey = function (cb) {\n        return this.limit(1).keys(function (a) { return a[0]; }).then(cb);\n    };\n    Collection.prototype.lastKey = function (cb) {\n        return this.reverse().firstKey(cb);\n    };\n    Collection.prototype.distinct = function () {\n        var ctx = this._ctx, idx = ctx.index && ctx.table.schema.idxByName[ctx.index];\n        if (!idx || !idx.multi)\n            return this;\n        var set = {};\n        addFilter(this._ctx, function (cursor) {\n            var strKey = cursor.primaryKey.toString();\n            var found = hasOwn(set, strKey);\n            set[strKey] = true;\n            return !found;\n        });\n        return this;\n    };\n    Collection.prototype.modify = function (changes) {\n        var _this = this;\n        var ctx = this._ctx;\n        return this._write(function (trans) {\n            var modifyer;\n            if (typeof changes === 'function') {\n                modifyer = changes;\n            }\n            else {\n                var keyPaths = keys(changes);\n                var numKeys = keyPaths.length;\n                modifyer = function (item) {\n                    var anythingModified = false;\n                    for (var i = 0; i < numKeys; ++i) {\n                        var keyPath = keyPaths[i], val = changes[keyPath];\n                        if (getByKeyPath(item, keyPath) !== val) {\n                            setByKeyPath(item, keyPath, val);\n                            anythingModified = true;\n                        }\n                    }\n                    return anythingModified;\n                };\n            }\n            var coreTable = ctx.table.core;\n            var _a = coreTable.schema.primaryKey, outbound = _a.outbound, extractKey = _a.extractKey;\n            var limit = _this.db._options.modifyChunkSize || 200;\n            var totalFailures = [];\n            var successCount = 0;\n            var failedKeys = [];\n            var applyMutateResult = function (expectedCount, res) {\n                var failures = res.failures, numFailures = res.numFailures;\n                successCount += expectedCount - numFailures;\n                for (var _i = 0, _a = keys(failures); _i < _a.length; _i++) {\n                    var pos = _a[_i];\n                    totalFailures.push(failures[pos]);\n                }\n            };\n            return _this.clone().primaryKeys().then(function (keys) {\n                var nextChunk = function (offset) {\n                    var count = Math.min(limit, keys.length - offset);\n                    return coreTable.getMany({\n                        trans: trans,\n                        keys: keys.slice(offset, offset + count),\n                        cache: \"immutable\"\n                    }).then(function (values) {\n                        var addValues = [];\n                        var putValues = [];\n                        var putKeys = outbound ? [] : null;\n                        var deleteKeys = [];\n                        for (var i = 0; i < count; ++i) {\n                            var origValue = values[i];\n                            var ctx_1 = {\n                                value: deepClone(origValue),\n                                primKey: keys[offset + i]\n                            };\n                            if (modifyer.call(ctx_1, ctx_1.value, ctx_1) !== false) {\n                                if (ctx_1.value == null) {\n                                    deleteKeys.push(keys[offset + i]);\n                                }\n                                else if (!outbound && cmp(extractKey(origValue), extractKey(ctx_1.value)) !== 0) {\n                                    deleteKeys.push(keys[offset + i]);\n                                    addValues.push(ctx_1.value);\n                                }\n                                else {\n                                    putValues.push(ctx_1.value);\n                                    if (outbound)\n                                        putKeys.push(keys[offset + i]);\n                                }\n                            }\n                        }\n                        var criteria = isPlainKeyRange(ctx) &&\n                            ctx.limit === Infinity &&\n                            (typeof changes !== 'function' || changes === deleteCallback) && {\n                            index: ctx.index,\n                            range: ctx.range\n                        };\n                        return Promise.resolve(addValues.length > 0 &&\n                            coreTable.mutate({ trans: trans, type: 'add', values: addValues })\n                                .then(function (res) {\n                                for (var pos in res.failures) {\n                                    deleteKeys.splice(parseInt(pos), 1);\n                                }\n                                applyMutateResult(addValues.length, res);\n                            })).then(function () { return (putValues.length > 0 || (criteria && typeof changes === 'object')) &&\n                            coreTable.mutate({\n                                trans: trans,\n                                type: 'put',\n                                keys: putKeys,\n                                values: putValues,\n                                criteria: criteria,\n                                changeSpec: typeof changes !== 'function'\n                                    && changes\n                            }).then(function (res) { return applyMutateResult(putValues.length, res); }); }).then(function () { return (deleteKeys.length > 0 || (criteria && changes === deleteCallback)) &&\n                            coreTable.mutate({\n                                trans: trans,\n                                type: 'delete',\n                                keys: deleteKeys,\n                                criteria: criteria\n                            }).then(function (res) { return applyMutateResult(deleteKeys.length, res); }); }).then(function () {\n                            return keys.length > offset + count && nextChunk(offset + limit);\n                        });\n                    });\n                };\n                return nextChunk(0).then(function () {\n                    if (totalFailures.length > 0)\n                        throw new ModifyError(\"Error modifying one or more objects\", totalFailures, successCount, failedKeys);\n                    return keys.length;\n                });\n            });\n        });\n    };\n    Collection.prototype.delete = function () {\n        var ctx = this._ctx, range = ctx.range;\n        if (isPlainKeyRange(ctx) &&\n            ((ctx.isPrimKey && !hangsOnDeleteLargeKeyRange) || range.type === 3 ))\n         {\n            return this._write(function (trans) {\n                var primaryKey = ctx.table.core.schema.primaryKey;\n                var coreRange = range;\n                return ctx.table.core.count({ trans: trans, query: { index: primaryKey, range: coreRange } }).then(function (count) {\n                    return ctx.table.core.mutate({ trans: trans, type: 'deleteRange', range: coreRange })\n                        .then(function (_a) {\n                        var failures = _a.failures; _a.lastResult; _a.results; var numFailures = _a.numFailures;\n                        if (numFailures)\n                            throw new ModifyError(\"Could not delete some values\", Object.keys(failures).map(function (pos) { return failures[pos]; }), count - numFailures);\n                        return count - numFailures;\n                    });\n                });\n            });\n        }\n        return this.modify(deleteCallback);\n    };\n    return Collection;\n}());\nvar deleteCallback = function (value, ctx) { return ctx.value = null; };\n\nfunction createCollectionConstructor(db) {\n    return makeClassConstructor(Collection.prototype, function Collection(whereClause, keyRangeGenerator) {\n        this.db = db;\n        var keyRange = AnyRange, error = null;\n        if (keyRangeGenerator)\n            try {\n                keyRange = keyRangeGenerator();\n            }\n            catch (ex) {\n                error = ex;\n            }\n        var whereCtx = whereClause._ctx;\n        var table = whereCtx.table;\n        var readingHook = table.hook.reading.fire;\n        this._ctx = {\n            table: table,\n            index: whereCtx.index,\n            isPrimKey: (!whereCtx.index || (table.schema.primKey.keyPath && whereCtx.index === table.schema.primKey.name)),\n            range: keyRange,\n            keysOnly: false,\n            dir: \"next\",\n            unique: \"\",\n            algorithm: null,\n            filter: null,\n            replayFilter: null,\n            justLimit: true,\n            isMatch: null,\n            offset: 0,\n            limit: Infinity,\n            error: error,\n            or: whereCtx.or,\n            valueMapper: readingHook !== mirror ? readingHook : null\n        };\n    });\n}\n\nfunction simpleCompare(a, b) {\n    return a < b ? -1 : a === b ? 0 : 1;\n}\nfunction simpleCompareReverse(a, b) {\n    return a > b ? -1 : a === b ? 0 : 1;\n}\n\nfunction fail(collectionOrWhereClause, err, T) {\n    var collection = collectionOrWhereClause instanceof WhereClause ?\n        new collectionOrWhereClause.Collection(collectionOrWhereClause) :\n        collectionOrWhereClause;\n    collection._ctx.error = T ? new T(err) : new TypeError(err);\n    return collection;\n}\nfunction emptyCollection(whereClause) {\n    return new whereClause.Collection(whereClause, function () { return rangeEqual(\"\"); }).limit(0);\n}\nfunction upperFactory(dir) {\n    return dir === \"next\" ?\n        function (s) { return s.toUpperCase(); } :\n        function (s) { return s.toLowerCase(); };\n}\nfunction lowerFactory(dir) {\n    return dir === \"next\" ?\n        function (s) { return s.toLowerCase(); } :\n        function (s) { return s.toUpperCase(); };\n}\nfunction nextCasing(key, lowerKey, upperNeedle, lowerNeedle, cmp, dir) {\n    var length = Math.min(key.length, lowerNeedle.length);\n    var llp = -1;\n    for (var i = 0; i < length; ++i) {\n        var lwrKeyChar = lowerKey[i];\n        if (lwrKeyChar !== lowerNeedle[i]) {\n            if (cmp(key[i], upperNeedle[i]) < 0)\n                return key.substr(0, i) + upperNeedle[i] + upperNeedle.substr(i + 1);\n            if (cmp(key[i], lowerNeedle[i]) < 0)\n                return key.substr(0, i) + lowerNeedle[i] + upperNeedle.substr(i + 1);\n            if (llp >= 0)\n                return key.substr(0, llp) + lowerKey[llp] + upperNeedle.substr(llp + 1);\n            return null;\n        }\n        if (cmp(key[i], lwrKeyChar) < 0)\n            llp = i;\n    }\n    if (length < lowerNeedle.length && dir === \"next\")\n        return key + upperNeedle.substr(key.length);\n    if (length < key.length && dir === \"prev\")\n        return key.substr(0, upperNeedle.length);\n    return (llp < 0 ? null : key.substr(0, llp) + lowerNeedle[llp] + upperNeedle.substr(llp + 1));\n}\nfunction addIgnoreCaseAlgorithm(whereClause, match, needles, suffix) {\n    var upper, lower, compare, upperNeedles, lowerNeedles, direction, nextKeySuffix, needlesLen = needles.length;\n    if (!needles.every(function (s) { return typeof s === 'string'; })) {\n        return fail(whereClause, STRING_EXPECTED);\n    }\n    function initDirection(dir) {\n        upper = upperFactory(dir);\n        lower = lowerFactory(dir);\n        compare = (dir === \"next\" ? simpleCompare : simpleCompareReverse);\n        var needleBounds = needles.map(function (needle) {\n            return { lower: lower(needle), upper: upper(needle) };\n        }).sort(function (a, b) {\n            return compare(a.lower, b.lower);\n        });\n        upperNeedles = needleBounds.map(function (nb) { return nb.upper; });\n        lowerNeedles = needleBounds.map(function (nb) { return nb.lower; });\n        direction = dir;\n        nextKeySuffix = (dir === \"next\" ? \"\" : suffix);\n    }\n    initDirection(\"next\");\n    var c = new whereClause.Collection(whereClause, function () { return createRange(upperNeedles[0], lowerNeedles[needlesLen - 1] + suffix); });\n    c._ondirectionchange = function (direction) {\n        initDirection(direction);\n    };\n    var firstPossibleNeedle = 0;\n    c._addAlgorithm(function (cursor, advance, resolve) {\n        var key = cursor.key;\n        if (typeof key !== 'string')\n            return false;\n        var lowerKey = lower(key);\n        if (match(lowerKey, lowerNeedles, firstPossibleNeedle)) {\n            return true;\n        }\n        else {\n            var lowestPossibleCasing = null;\n            for (var i = firstPossibleNeedle; i < needlesLen; ++i) {\n                var casing = nextCasing(key, lowerKey, upperNeedles[i], lowerNeedles[i], compare, direction);\n                if (casing === null && lowestPossibleCasing === null)\n                    firstPossibleNeedle = i + 1;\n                else if (lowestPossibleCasing === null || compare(lowestPossibleCasing, casing) > 0) {\n                    lowestPossibleCasing = casing;\n                }\n            }\n            if (lowestPossibleCasing !== null) {\n                advance(function () { cursor.continue(lowestPossibleCasing + nextKeySuffix); });\n            }\n            else {\n                advance(resolve);\n            }\n            return false;\n        }\n    });\n    return c;\n}\nfunction createRange(lower, upper, lowerOpen, upperOpen) {\n    return {\n        type: 2 ,\n        lower: lower,\n        upper: upper,\n        lowerOpen: lowerOpen,\n        upperOpen: upperOpen\n    };\n}\nfunction rangeEqual(value) {\n    return {\n        type: 1 ,\n        lower: value,\n        upper: value\n    };\n}\n\nvar WhereClause =  (function () {\n    function WhereClause() {\n    }\n    Object.defineProperty(WhereClause.prototype, \"Collection\", {\n        get: function () {\n            return this._ctx.table.db.Collection;\n        },\n        enumerable: false,\n        configurable: true\n    });\n    WhereClause.prototype.between = function (lower, upper, includeLower, includeUpper) {\n        includeLower = includeLower !== false;\n        includeUpper = includeUpper === true;\n        try {\n            if ((this._cmp(lower, upper) > 0) ||\n                (this._cmp(lower, upper) === 0 && (includeLower || includeUpper) && !(includeLower && includeUpper)))\n                return emptyCollection(this);\n            return new this.Collection(this, function () { return createRange(lower, upper, !includeLower, !includeUpper); });\n        }\n        catch (e) {\n            return fail(this, INVALID_KEY_ARGUMENT);\n        }\n    };\n    WhereClause.prototype.equals = function (value) {\n        if (value == null)\n            return fail(this, INVALID_KEY_ARGUMENT);\n        return new this.Collection(this, function () { return rangeEqual(value); });\n    };\n    WhereClause.prototype.above = function (value) {\n        if (value == null)\n            return fail(this, INVALID_KEY_ARGUMENT);\n        return new this.Collection(this, function () { return createRange(value, undefined, true); });\n    };\n    WhereClause.prototype.aboveOrEqual = function (value) {\n        if (value == null)\n            return fail(this, INVALID_KEY_ARGUMENT);\n        return new this.Collection(this, function () { return createRange(value, undefined, false); });\n    };\n    WhereClause.prototype.below = function (value) {\n        if (value == null)\n            return fail(this, INVALID_KEY_ARGUMENT);\n        return new this.Collection(this, function () { return createRange(undefined, value, false, true); });\n    };\n    WhereClause.prototype.belowOrEqual = function (value) {\n        if (value == null)\n            return fail(this, INVALID_KEY_ARGUMENT);\n        return new this.Collection(this, function () { return createRange(undefined, value); });\n    };\n    WhereClause.prototype.startsWith = function (str) {\n        if (typeof str !== 'string')\n            return fail(this, STRING_EXPECTED);\n        return this.between(str, str + maxString, true, true);\n    };\n    WhereClause.prototype.startsWithIgnoreCase = function (str) {\n        if (str === \"\")\n            return this.startsWith(str);\n        return addIgnoreCaseAlgorithm(this, function (x, a) { return x.indexOf(a[0]) === 0; }, [str], maxString);\n    };\n    WhereClause.prototype.equalsIgnoreCase = function (str) {\n        return addIgnoreCaseAlgorithm(this, function (x, a) { return x === a[0]; }, [str], \"\");\n    };\n    WhereClause.prototype.anyOfIgnoreCase = function () {\n        var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);\n        if (set.length === 0)\n            return emptyCollection(this);\n        return addIgnoreCaseAlgorithm(this, function (x, a) { return a.indexOf(x) !== -1; }, set, \"\");\n    };\n    WhereClause.prototype.startsWithAnyOfIgnoreCase = function () {\n        var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);\n        if (set.length === 0)\n            return emptyCollection(this);\n        return addIgnoreCaseAlgorithm(this, function (x, a) { return a.some(function (n) { return x.indexOf(n) === 0; }); }, set, maxString);\n    };\n    WhereClause.prototype.anyOf = function () {\n        var _this = this;\n        var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);\n        var compare = this._cmp;\n        try {\n            set.sort(compare);\n        }\n        catch (e) {\n            return fail(this, INVALID_KEY_ARGUMENT);\n        }\n        if (set.length === 0)\n            return emptyCollection(this);\n        var c = new this.Collection(this, function () { return createRange(set[0], set[set.length - 1]); });\n        c._ondirectionchange = function (direction) {\n            compare = (direction === \"next\" ?\n                _this._ascending :\n                _this._descending);\n            set.sort(compare);\n        };\n        var i = 0;\n        c._addAlgorithm(function (cursor, advance, resolve) {\n            var key = cursor.key;\n            while (compare(key, set[i]) > 0) {\n                ++i;\n                if (i === set.length) {\n                    advance(resolve);\n                    return false;\n                }\n            }\n            if (compare(key, set[i]) === 0) {\n                return true;\n            }\n            else {\n                advance(function () { cursor.continue(set[i]); });\n                return false;\n            }\n        });\n        return c;\n    };\n    WhereClause.prototype.notEqual = function (value) {\n        return this.inAnyRange([[minKey, value], [value, this.db._maxKey]], { includeLowers: false, includeUppers: false });\n    };\n    WhereClause.prototype.noneOf = function () {\n        var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);\n        if (set.length === 0)\n            return new this.Collection(this);\n        try {\n            set.sort(this._ascending);\n        }\n        catch (e) {\n            return fail(this, INVALID_KEY_ARGUMENT);\n        }\n        var ranges = set.reduce(function (res, val) { return res ?\n            res.concat([[res[res.length - 1][1], val]]) :\n            [[minKey, val]]; }, null);\n        ranges.push([set[set.length - 1], this.db._maxKey]);\n        return this.inAnyRange(ranges, { includeLowers: false, includeUppers: false });\n    };\n    WhereClause.prototype.inAnyRange = function (ranges, options) {\n        var _this = this;\n        var cmp = this._cmp, ascending = this._ascending, descending = this._descending, min = this._min, max = this._max;\n        if (ranges.length === 0)\n            return emptyCollection(this);\n        if (!ranges.every(function (range) {\n            return range[0] !== undefined &&\n                range[1] !== undefined &&\n                ascending(range[0], range[1]) <= 0;\n        })) {\n            return fail(this, \"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower\", exceptions.InvalidArgument);\n        }\n        var includeLowers = !options || options.includeLowers !== false;\n        var includeUppers = options && options.includeUppers === true;\n        function addRange(ranges, newRange) {\n            var i = 0, l = ranges.length;\n            for (; i < l; ++i) {\n                var range = ranges[i];\n                if (cmp(newRange[0], range[1]) < 0 && cmp(newRange[1], range[0]) > 0) {\n                    range[0] = min(range[0], newRange[0]);\n                    range[1] = max(range[1], newRange[1]);\n                    break;\n                }\n            }\n            if (i === l)\n                ranges.push(newRange);\n            return ranges;\n        }\n        var sortDirection = ascending;\n        function rangeSorter(a, b) { return sortDirection(a[0], b[0]); }\n        var set;\n        try {\n            set = ranges.reduce(addRange, []);\n            set.sort(rangeSorter);\n        }\n        catch (ex) {\n            return fail(this, INVALID_KEY_ARGUMENT);\n        }\n        var rangePos = 0;\n        var keyIsBeyondCurrentEntry = includeUppers ?\n            function (key) { return ascending(key, set[rangePos][1]) > 0; } :\n            function (key) { return ascending(key, set[rangePos][1]) >= 0; };\n        var keyIsBeforeCurrentEntry = includeLowers ?\n            function (key) { return descending(key, set[rangePos][0]) > 0; } :\n            function (key) { return descending(key, set[rangePos][0]) >= 0; };\n        function keyWithinCurrentRange(key) {\n            return !keyIsBeyondCurrentEntry(key) && !keyIsBeforeCurrentEntry(key);\n        }\n        var checkKey = keyIsBeyondCurrentEntry;\n        var c = new this.Collection(this, function () { return createRange(set[0][0], set[set.length - 1][1], !includeLowers, !includeUppers); });\n        c._ondirectionchange = function (direction) {\n            if (direction === \"next\") {\n                checkKey = keyIsBeyondCurrentEntry;\n                sortDirection = ascending;\n            }\n            else {\n                checkKey = keyIsBeforeCurrentEntry;\n                sortDirection = descending;\n            }\n            set.sort(rangeSorter);\n        };\n        c._addAlgorithm(function (cursor, advance, resolve) {\n            var key = cursor.key;\n            while (checkKey(key)) {\n                ++rangePos;\n                if (rangePos === set.length) {\n                    advance(resolve);\n                    return false;\n                }\n            }\n            if (keyWithinCurrentRange(key)) {\n                return true;\n            }\n            else if (_this._cmp(key, set[rangePos][1]) === 0 || _this._cmp(key, set[rangePos][0]) === 0) {\n                return false;\n            }\n            else {\n                advance(function () {\n                    if (sortDirection === ascending)\n                        cursor.continue(set[rangePos][0]);\n                    else\n                        cursor.continue(set[rangePos][1]);\n                });\n                return false;\n            }\n        });\n        return c;\n    };\n    WhereClause.prototype.startsWithAnyOf = function () {\n        var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);\n        if (!set.every(function (s) { return typeof s === 'string'; })) {\n            return fail(this, \"startsWithAnyOf() only works with strings\");\n        }\n        if (set.length === 0)\n            return emptyCollection(this);\n        return this.inAnyRange(set.map(function (str) { return [str, str + maxString]; }));\n    };\n    return WhereClause;\n}());\n\nfunction createWhereClauseConstructor(db) {\n    return makeClassConstructor(WhereClause.prototype, function WhereClause(table, index, orCollection) {\n        this.db = db;\n        this._ctx = {\n            table: table,\n            index: index === \":id\" ? null : index,\n            or: orCollection\n        };\n        var indexedDB = db._deps.indexedDB;\n        if (!indexedDB)\n            throw new exceptions.MissingAPI();\n        this._cmp = this._ascending = indexedDB.cmp.bind(indexedDB);\n        this._descending = function (a, b) { return indexedDB.cmp(b, a); };\n        this._max = function (a, b) { return indexedDB.cmp(a, b) > 0 ? a : b; };\n        this._min = function (a, b) { return indexedDB.cmp(a, b) < 0 ? a : b; };\n        this._IDBKeyRange = db._deps.IDBKeyRange;\n    });\n}\n\nfunction eventRejectHandler(reject) {\n    return wrap(function (event) {\n        preventDefault(event);\n        reject(event.target.error);\n        return false;\n    });\n}\nfunction preventDefault(event) {\n    if (event.stopPropagation)\n        event.stopPropagation();\n    if (event.preventDefault)\n        event.preventDefault();\n}\n\nvar DEXIE_STORAGE_MUTATED_EVENT_NAME = 'storagemutated';\nvar STORAGE_MUTATED_DOM_EVENT_NAME = 'x-storagemutated-1';\nvar globalEvents = Events(null, DEXIE_STORAGE_MUTATED_EVENT_NAME);\n\nvar Transaction =  (function () {\n    function Transaction() {\n    }\n    Transaction.prototype._lock = function () {\n        assert(!PSD.global);\n        ++this._reculock;\n        if (this._reculock === 1 && !PSD.global)\n            PSD.lockOwnerFor = this;\n        return this;\n    };\n    Transaction.prototype._unlock = function () {\n        assert(!PSD.global);\n        if (--this._reculock === 0) {\n            if (!PSD.global)\n                PSD.lockOwnerFor = null;\n            while (this._blockedFuncs.length > 0 && !this._locked()) {\n                var fnAndPSD = this._blockedFuncs.shift();\n                try {\n                    usePSD(fnAndPSD[1], fnAndPSD[0]);\n                }\n                catch (e) { }\n            }\n        }\n        return this;\n    };\n    Transaction.prototype._locked = function () {\n        return this._reculock && PSD.lockOwnerFor !== this;\n    };\n    Transaction.prototype.create = function (idbtrans) {\n        var _this = this;\n        if (!this.mode)\n            return this;\n        var idbdb = this.db.idbdb;\n        var dbOpenError = this.db._state.dbOpenError;\n        assert(!this.idbtrans);\n        if (!idbtrans && !idbdb) {\n            switch (dbOpenError && dbOpenError.name) {\n                case \"DatabaseClosedError\":\n                    throw new exceptions.DatabaseClosed(dbOpenError);\n                case \"MissingAPIError\":\n                    throw new exceptions.MissingAPI(dbOpenError.message, dbOpenError);\n                default:\n                    throw new exceptions.OpenFailed(dbOpenError);\n            }\n        }\n        if (!this.active)\n            throw new exceptions.TransactionInactive();\n        assert(this._completion._state === null);\n        idbtrans = this.idbtrans = idbtrans ||\n            (this.db.core\n                ? this.db.core.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability })\n                : idbdb.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }));\n        idbtrans.onerror = wrap(function (ev) {\n            preventDefault(ev);\n            _this._reject(idbtrans.error);\n        });\n        idbtrans.onabort = wrap(function (ev) {\n            preventDefault(ev);\n            _this.active && _this._reject(new exceptions.Abort(idbtrans.error));\n            _this.active = false;\n            _this.on(\"abort\").fire(ev);\n        });\n        idbtrans.oncomplete = wrap(function () {\n            _this.active = false;\n            _this._resolve();\n            if ('mutatedParts' in idbtrans) {\n                globalEvents.storagemutated.fire(idbtrans[\"mutatedParts\"]);\n            }\n        });\n        return this;\n    };\n    Transaction.prototype._promise = function (mode, fn, bWriteLock) {\n        var _this = this;\n        if (mode === 'readwrite' && this.mode !== 'readwrite')\n            return rejection(new exceptions.ReadOnly(\"Transaction is readonly\"));\n        if (!this.active)\n            return rejection(new exceptions.TransactionInactive());\n        if (this._locked()) {\n            return new DexiePromise(function (resolve, reject) {\n                _this._blockedFuncs.push([function () {\n                        _this._promise(mode, fn, bWriteLock).then(resolve, reject);\n                    }, PSD]);\n            });\n        }\n        else if (bWriteLock) {\n            return newScope(function () {\n                var p = new DexiePromise(function (resolve, reject) {\n                    _this._lock();\n                    var rv = fn(resolve, reject, _this);\n                    if (rv && rv.then)\n                        rv.then(resolve, reject);\n                });\n                p.finally(function () { return _this._unlock(); });\n                p._lib = true;\n                return p;\n            });\n        }\n        else {\n            var p = new DexiePromise(function (resolve, reject) {\n                var rv = fn(resolve, reject, _this);\n                if (rv && rv.then)\n                    rv.then(resolve, reject);\n            });\n            p._lib = true;\n            return p;\n        }\n    };\n    Transaction.prototype._root = function () {\n        return this.parent ? this.parent._root() : this;\n    };\n    Transaction.prototype.waitFor = function (promiseLike) {\n        var root = this._root();\n        var promise = DexiePromise.resolve(promiseLike);\n        if (root._waitingFor) {\n            root._waitingFor = root._waitingFor.then(function () { return promise; });\n        }\n        else {\n            root._waitingFor = promise;\n            root._waitingQueue = [];\n            var store = root.idbtrans.objectStore(root.storeNames[0]);\n            (function spin() {\n                ++root._spinCount;\n                while (root._waitingQueue.length)\n                    (root._waitingQueue.shift())();\n                if (root._waitingFor)\n                    store.get(-Infinity).onsuccess = spin;\n            }());\n        }\n        var currentWaitPromise = root._waitingFor;\n        return new DexiePromise(function (resolve, reject) {\n            promise.then(function (res) { return root._waitingQueue.push(wrap(resolve.bind(null, res))); }, function (err) { return root._waitingQueue.push(wrap(reject.bind(null, err))); }).finally(function () {\n                if (root._waitingFor === currentWaitPromise) {\n                    root._waitingFor = null;\n                }\n            });\n        });\n    };\n    Transaction.prototype.abort = function () {\n        if (this.active) {\n            this.active = false;\n            if (this.idbtrans)\n                this.idbtrans.abort();\n            this._reject(new exceptions.Abort());\n        }\n    };\n    Transaction.prototype.table = function (tableName) {\n        var memoizedTables = (this._memoizedTables || (this._memoizedTables = {}));\n        if (hasOwn(memoizedTables, tableName))\n            return memoizedTables[tableName];\n        var tableSchema = this.schema[tableName];\n        if (!tableSchema) {\n            throw new exceptions.NotFound(\"Table \" + tableName + \" not part of transaction\");\n        }\n        var transactionBoundTable = new this.db.Table(tableName, tableSchema, this);\n        transactionBoundTable.core = this.db.core.table(tableName);\n        memoizedTables[tableName] = transactionBoundTable;\n        return transactionBoundTable;\n    };\n    return Transaction;\n}());\n\nfunction createTransactionConstructor(db) {\n    return makeClassConstructor(Transaction.prototype, function Transaction(mode, storeNames, dbschema, chromeTransactionDurability, parent) {\n        var _this = this;\n        this.db = db;\n        this.mode = mode;\n        this.storeNames = storeNames;\n        this.schema = dbschema;\n        this.chromeTransactionDurability = chromeTransactionDurability;\n        this.idbtrans = null;\n        this.on = Events(this, \"complete\", \"error\", \"abort\");\n        this.parent = parent || null;\n        this.active = true;\n        this._reculock = 0;\n        this._blockedFuncs = [];\n        this._resolve = null;\n        this._reject = null;\n        this._waitingFor = null;\n        this._waitingQueue = null;\n        this._spinCount = 0;\n        this._completion = new DexiePromise(function (resolve, reject) {\n            _this._resolve = resolve;\n            _this._reject = reject;\n        });\n        this._completion.then(function () {\n            _this.active = false;\n            _this.on.complete.fire();\n        }, function (e) {\n            var wasActive = _this.active;\n            _this.active = false;\n            _this.on.error.fire(e);\n            _this.parent ?\n                _this.parent._reject(e) :\n                wasActive && _this.idbtrans && _this.idbtrans.abort();\n            return rejection(e);\n        });\n    });\n}\n\nfunction createIndexSpec(name, keyPath, unique, multi, auto, compound, isPrimKey) {\n    return {\n        name: name,\n        keyPath: keyPath,\n        unique: unique,\n        multi: multi,\n        auto: auto,\n        compound: compound,\n        src: (unique && !isPrimKey ? '&' : '') + (multi ? '*' : '') + (auto ? \"++\" : \"\") + nameFromKeyPath(keyPath)\n    };\n}\nfunction nameFromKeyPath(keyPath) {\n    return typeof keyPath === 'string' ?\n        keyPath :\n        keyPath ? ('[' + [].join.call(keyPath, '+') + ']') : \"\";\n}\n\nfunction createTableSchema(name, primKey, indexes) {\n    return {\n        name: name,\n        primKey: primKey,\n        indexes: indexes,\n        mappedClass: null,\n        idxByName: arrayToObject(indexes, function (index) { return [index.name, index]; })\n    };\n}\n\nfunction safariMultiStoreFix(storeNames) {\n    return storeNames.length === 1 ? storeNames[0] : storeNames;\n}\nvar getMaxKey = function (IdbKeyRange) {\n    try {\n        IdbKeyRange.only([[]]);\n        getMaxKey = function () { return [[]]; };\n        return [[]];\n    }\n    catch (e) {\n        getMaxKey = function () { return maxString; };\n        return maxString;\n    }\n};\n\nfunction getKeyExtractor(keyPath) {\n    if (keyPath == null) {\n        return function () { return undefined; };\n    }\n    else if (typeof keyPath === 'string') {\n        return getSinglePathKeyExtractor(keyPath);\n    }\n    else {\n        return function (obj) { return getByKeyPath(obj, keyPath); };\n    }\n}\nfunction getSinglePathKeyExtractor(keyPath) {\n    var split = keyPath.split('.');\n    if (split.length === 1) {\n        return function (obj) { return obj[keyPath]; };\n    }\n    else {\n        return function (obj) { return getByKeyPath(obj, keyPath); };\n    }\n}\n\nfunction arrayify(arrayLike) {\n    return [].slice.call(arrayLike);\n}\nvar _id_counter = 0;\nfunction getKeyPathAlias(keyPath) {\n    return keyPath == null ?\n        \":id\" :\n        typeof keyPath === 'string' ?\n            keyPath :\n            \"[\" + keyPath.join('+') + \"]\";\n}\nfunction createDBCore(db, IdbKeyRange, tmpTrans) {\n    function extractSchema(db, trans) {\n        var tables = arrayify(db.objectStoreNames);\n        return {\n            schema: {\n                name: db.name,\n                tables: tables.map(function (table) { return trans.objectStore(table); }).map(function (store) {\n                    var keyPath = store.keyPath, autoIncrement = store.autoIncrement;\n                    var compound = isArray(keyPath);\n                    var outbound = keyPath == null;\n                    var indexByKeyPath = {};\n                    var result = {\n                        name: store.name,\n                        primaryKey: {\n                            name: null,\n                            isPrimaryKey: true,\n                            outbound: outbound,\n                            compound: compound,\n                            keyPath: keyPath,\n                            autoIncrement: autoIncrement,\n                            unique: true,\n                            extractKey: getKeyExtractor(keyPath)\n                        },\n                        indexes: arrayify(store.indexNames).map(function (indexName) { return store.index(indexName); })\n                            .map(function (index) {\n                            var name = index.name, unique = index.unique, multiEntry = index.multiEntry, keyPath = index.keyPath;\n                            var compound = isArray(keyPath);\n                            var result = {\n                                name: name,\n                                compound: compound,\n                                keyPath: keyPath,\n                                unique: unique,\n                                multiEntry: multiEntry,\n                                extractKey: getKeyExtractor(keyPath)\n                            };\n                            indexByKeyPath[getKeyPathAlias(keyPath)] = result;\n                            return result;\n                        }),\n                        getIndexByKeyPath: function (keyPath) { return indexByKeyPath[getKeyPathAlias(keyPath)]; }\n                    };\n                    indexByKeyPath[\":id\"] = result.primaryKey;\n                    if (keyPath != null) {\n                        indexByKeyPath[getKeyPathAlias(keyPath)] = result.primaryKey;\n                    }\n                    return result;\n                })\n            },\n            hasGetAll: tables.length > 0 && ('getAll' in trans.objectStore(tables[0])) &&\n                !(typeof navigator !== 'undefined' && /Safari/.test(navigator.userAgent) &&\n                    !/(Chrome\\/|Edge\\/)/.test(navigator.userAgent) &&\n                    [].concat(navigator.userAgent.match(/Safari\\/(\\d*)/))[1] < 604)\n        };\n    }\n    function makeIDBKeyRange(range) {\n        if (range.type === 3 )\n            return null;\n        if (range.type === 4 )\n            throw new Error(\"Cannot convert never type to IDBKeyRange\");\n        var lower = range.lower, upper = range.upper, lowerOpen = range.lowerOpen, upperOpen = range.upperOpen;\n        var idbRange = lower === undefined ?\n            upper === undefined ?\n                null :\n                IdbKeyRange.upperBound(upper, !!upperOpen) :\n            upper === undefined ?\n                IdbKeyRange.lowerBound(lower, !!lowerOpen) :\n                IdbKeyRange.bound(lower, upper, !!lowerOpen, !!upperOpen);\n        return idbRange;\n    }\n    function createDbCoreTable(tableSchema) {\n        var tableName = tableSchema.name;\n        function mutate(_a) {\n            var trans = _a.trans, type = _a.type, keys = _a.keys, values = _a.values, range = _a.range;\n            return new Promise(function (resolve, reject) {\n                resolve = wrap(resolve);\n                var store = trans.objectStore(tableName);\n                var outbound = store.keyPath == null;\n                var isAddOrPut = type === \"put\" || type === \"add\";\n                if (!isAddOrPut && type !== 'delete' && type !== 'deleteRange')\n                    throw new Error(\"Invalid operation type: \" + type);\n                var length = (keys || values || { length: 1 }).length;\n                if (keys && values && keys.length !== values.length) {\n                    throw new Error(\"Given keys array must have same length as given values array.\");\n                }\n                if (length === 0)\n                    return resolve({ numFailures: 0, failures: {}, results: [], lastResult: undefined });\n                var req;\n                var reqs = [];\n                var failures = [];\n                var numFailures = 0;\n                var errorHandler = function (event) {\n                    ++numFailures;\n                    preventDefault(event);\n                };\n                if (type === 'deleteRange') {\n                    if (range.type === 4 )\n                        return resolve({ numFailures: numFailures, failures: failures, results: [], lastResult: undefined });\n                    if (range.type === 3 )\n                        reqs.push(req = store.clear());\n                    else\n                        reqs.push(req = store.delete(makeIDBKeyRange(range)));\n                }\n                else {\n                    var _a = isAddOrPut ?\n                        outbound ?\n                            [values, keys] :\n                            [values, null] :\n                        [keys, null], args1 = _a[0], args2 = _a[1];\n                    if (isAddOrPut) {\n                        for (var i = 0; i < length; ++i) {\n                            reqs.push(req = (args2 && args2[i] !== undefined ?\n                                store[type](args1[i], args2[i]) :\n                                store[type](args1[i])));\n                            req.onerror = errorHandler;\n                        }\n                    }\n                    else {\n                        for (var i = 0; i < length; ++i) {\n                            reqs.push(req = store[type](args1[i]));\n                            req.onerror = errorHandler;\n                        }\n                    }\n                }\n                var done = function (event) {\n                    var lastResult = event.target.result;\n                    reqs.forEach(function (req, i) { return req.error != null && (failures[i] = req.error); });\n                    resolve({\n                        numFailures: numFailures,\n                        failures: failures,\n                        results: type === \"delete\" ? keys : reqs.map(function (req) { return req.result; }),\n                        lastResult: lastResult\n                    });\n                };\n                req.onerror = function (event) {\n                    errorHandler(event);\n                    done(event);\n                };\n                req.onsuccess = done;\n            });\n        }\n        function openCursor(_a) {\n            var trans = _a.trans, values = _a.values, query = _a.query, reverse = _a.reverse, unique = _a.unique;\n            return new Promise(function (resolve, reject) {\n                resolve = wrap(resolve);\n                var index = query.index, range = query.range;\n                var store = trans.objectStore(tableName);\n                var source = index.isPrimaryKey ?\n                    store :\n                    store.index(index.name);\n                var direction = reverse ?\n                    unique ?\n                        \"prevunique\" :\n                        \"prev\" :\n                    unique ?\n                        \"nextunique\" :\n                        \"next\";\n                var req = values || !('openKeyCursor' in source) ?\n                    source.openCursor(makeIDBKeyRange(range), direction) :\n                    source.openKeyCursor(makeIDBKeyRange(range), direction);\n                req.onerror = eventRejectHandler(reject);\n                req.onsuccess = wrap(function (ev) {\n                    var cursor = req.result;\n                    if (!cursor) {\n                        resolve(null);\n                        return;\n                    }\n                    cursor.___id = ++_id_counter;\n                    cursor.done = false;\n                    var _cursorContinue = cursor.continue.bind(cursor);\n                    var _cursorContinuePrimaryKey = cursor.continuePrimaryKey;\n                    if (_cursorContinuePrimaryKey)\n                        _cursorContinuePrimaryKey = _cursorContinuePrimaryKey.bind(cursor);\n                    var _cursorAdvance = cursor.advance.bind(cursor);\n                    var doThrowCursorIsNotStarted = function () { throw new Error(\"Cursor not started\"); };\n                    var doThrowCursorIsStopped = function () { throw new Error(\"Cursor not stopped\"); };\n                    cursor.trans = trans;\n                    cursor.stop = cursor.continue = cursor.continuePrimaryKey = cursor.advance = doThrowCursorIsNotStarted;\n                    cursor.fail = wrap(reject);\n                    cursor.next = function () {\n                        var _this = this;\n                        var gotOne = 1;\n                        return this.start(function () { return gotOne-- ? _this.continue() : _this.stop(); }).then(function () { return _this; });\n                    };\n                    cursor.start = function (callback) {\n                        var iterationPromise = new Promise(function (resolveIteration, rejectIteration) {\n                            resolveIteration = wrap(resolveIteration);\n                            req.onerror = eventRejectHandler(rejectIteration);\n                            cursor.fail = rejectIteration;\n                            cursor.stop = function (value) {\n                                cursor.stop = cursor.continue = cursor.continuePrimaryKey = cursor.advance = doThrowCursorIsStopped;\n                                resolveIteration(value);\n                            };\n                        });\n                        var guardedCallback = function () {\n                            if (req.result) {\n                                try {\n                                    callback();\n                                }\n                                catch (err) {\n                                    cursor.fail(err);\n                                }\n                            }\n                            else {\n                                cursor.done = true;\n                                cursor.start = function () { throw new Error(\"Cursor behind last entry\"); };\n                                cursor.stop();\n                            }\n                        };\n                        req.onsuccess = wrap(function (ev) {\n                            req.onsuccess = guardedCallback;\n                            guardedCallback();\n                        });\n                        cursor.continue = _cursorContinue;\n                        cursor.continuePrimaryKey = _cursorContinuePrimaryKey;\n                        cursor.advance = _cursorAdvance;\n                        guardedCallback();\n                        return iterationPromise;\n                    };\n                    resolve(cursor);\n                }, reject);\n            });\n        }\n        function query(hasGetAll) {\n            return function (request) {\n                return new Promise(function (resolve, reject) {\n                    resolve = wrap(resolve);\n                    var trans = request.trans, values = request.values, limit = request.limit, query = request.query;\n                    var nonInfinitLimit = limit === Infinity ? undefined : limit;\n                    var index = query.index, range = query.range;\n                    var store = trans.objectStore(tableName);\n                    var source = index.isPrimaryKey ? store : store.index(index.name);\n                    var idbKeyRange = makeIDBKeyRange(range);\n                    if (limit === 0)\n                        return resolve({ result: [] });\n                    if (hasGetAll) {\n                        var req = values ?\n                            source.getAll(idbKeyRange, nonInfinitLimit) :\n                            source.getAllKeys(idbKeyRange, nonInfinitLimit);\n                        req.onsuccess = function (event) { return resolve({ result: event.target.result }); };\n                        req.onerror = eventRejectHandler(reject);\n                    }\n                    else {\n                        var count_1 = 0;\n                        var req_1 = values || !('openKeyCursor' in source) ?\n                            source.openCursor(idbKeyRange) :\n                            source.openKeyCursor(idbKeyRange);\n                        var result_1 = [];\n                        req_1.onsuccess = function (event) {\n                            var cursor = req_1.result;\n                            if (!cursor)\n                                return resolve({ result: result_1 });\n                            result_1.push(values ? cursor.value : cursor.primaryKey);\n                            if (++count_1 === limit)\n                                return resolve({ result: result_1 });\n                            cursor.continue();\n                        };\n                        req_1.onerror = eventRejectHandler(reject);\n                    }\n                });\n            };\n        }\n        return {\n            name: tableName,\n            schema: tableSchema,\n            mutate: mutate,\n            getMany: function (_a) {\n                var trans = _a.trans, keys = _a.keys;\n                return new Promise(function (resolve, reject) {\n                    resolve = wrap(resolve);\n                    var store = trans.objectStore(tableName);\n                    var length = keys.length;\n                    var result = new Array(length);\n                    var keyCount = 0;\n                    var callbackCount = 0;\n                    var req;\n                    var successHandler = function (event) {\n                        var req = event.target;\n                        if ((result[req._pos] = req.result) != null)\n                            ;\n                        if (++callbackCount === keyCount)\n                            resolve(result);\n                    };\n                    var errorHandler = eventRejectHandler(reject);\n                    for (var i = 0; i < length; ++i) {\n                        var key = keys[i];\n                        if (key != null) {\n                            req = store.get(keys[i]);\n                            req._pos = i;\n                            req.onsuccess = successHandler;\n                            req.onerror = errorHandler;\n                            ++keyCount;\n                        }\n                    }\n                    if (keyCount === 0)\n                        resolve(result);\n                });\n            },\n            get: function (_a) {\n                var trans = _a.trans, key = _a.key;\n                return new Promise(function (resolve, reject) {\n                    resolve = wrap(resolve);\n                    var store = trans.objectStore(tableName);\n                    var req = store.get(key);\n                    req.onsuccess = function (event) { return resolve(event.target.result); };\n                    req.onerror = eventRejectHandler(reject);\n                });\n            },\n            query: query(hasGetAll),\n            openCursor: openCursor,\n            count: function (_a) {\n                var query = _a.query, trans = _a.trans;\n                var index = query.index, range = query.range;\n                return new Promise(function (resolve, reject) {\n                    var store = trans.objectStore(tableName);\n                    var source = index.isPrimaryKey ? store : store.index(index.name);\n                    var idbKeyRange = makeIDBKeyRange(range);\n                    var req = idbKeyRange ? source.count(idbKeyRange) : source.count();\n                    req.onsuccess = wrap(function (ev) { return resolve(ev.target.result); });\n                    req.onerror = eventRejectHandler(reject);\n                });\n            }\n        };\n    }\n    var _a = extractSchema(db, tmpTrans), schema = _a.schema, hasGetAll = _a.hasGetAll;\n    var tables = schema.tables.map(function (tableSchema) { return createDbCoreTable(tableSchema); });\n    var tableMap = {};\n    tables.forEach(function (table) { return tableMap[table.name] = table; });\n    return {\n        stack: \"dbcore\",\n        transaction: db.transaction.bind(db),\n        table: function (name) {\n            var result = tableMap[name];\n            if (!result)\n                throw new Error(\"Table '\" + name + \"' not found\");\n            return tableMap[name];\n        },\n        MIN_KEY: -Infinity,\n        MAX_KEY: getMaxKey(IdbKeyRange),\n        schema: schema\n    };\n}\n\nfunction createMiddlewareStack(stackImpl, middlewares) {\n    return middlewares.reduce(function (down, _a) {\n        var create = _a.create;\n        return (__assign(__assign({}, down), create(down)));\n    }, stackImpl);\n}\nfunction createMiddlewareStacks(middlewares, idbdb, _a, tmpTrans) {\n    var IDBKeyRange = _a.IDBKeyRange; _a.indexedDB;\n    var dbcore = createMiddlewareStack(createDBCore(idbdb, IDBKeyRange, tmpTrans), middlewares.dbcore);\n    return {\n        dbcore: dbcore\n    };\n}\nfunction generateMiddlewareStacks(_a, tmpTrans) {\n    var db = _a._novip;\n    var idbdb = tmpTrans.db;\n    var stacks = createMiddlewareStacks(db._middlewares, idbdb, db._deps, tmpTrans);\n    db.core = stacks.dbcore;\n    db.tables.forEach(function (table) {\n        var tableName = table.name;\n        if (db.core.schema.tables.some(function (tbl) { return tbl.name === tableName; })) {\n            table.core = db.core.table(tableName);\n            if (db[tableName] instanceof db.Table) {\n                db[tableName].core = table.core;\n            }\n        }\n    });\n}\n\nfunction setApiOnPlace(_a, objs, tableNames, dbschema) {\n    var db = _a._novip;\n    tableNames.forEach(function (tableName) {\n        var schema = dbschema[tableName];\n        objs.forEach(function (obj) {\n            var propDesc = getPropertyDescriptor(obj, tableName);\n            if (!propDesc || (\"value\" in propDesc && propDesc.value === undefined)) {\n                if (obj === db.Transaction.prototype || obj instanceof db.Transaction) {\n                    setProp(obj, tableName, {\n                        get: function () { return this.table(tableName); },\n                        set: function (value) {\n                            defineProperty(this, tableName, { value: value, writable: true, configurable: true, enumerable: true });\n                        }\n                    });\n                }\n                else {\n                    obj[tableName] = new db.Table(tableName, schema);\n                }\n            }\n        });\n    });\n}\nfunction removeTablesApi(_a, objs) {\n    var db = _a._novip;\n    objs.forEach(function (obj) {\n        for (var key in obj) {\n            if (obj[key] instanceof db.Table)\n                delete obj[key];\n        }\n    });\n}\nfunction lowerVersionFirst(a, b) {\n    return a._cfg.version - b._cfg.version;\n}\nfunction runUpgraders(db, oldVersion, idbUpgradeTrans, reject) {\n    var globalSchema = db._dbSchema;\n    var trans = db._createTransaction('readwrite', db._storeNames, globalSchema);\n    trans.create(idbUpgradeTrans);\n    trans._completion.catch(reject);\n    var rejectTransaction = trans._reject.bind(trans);\n    var transless = PSD.transless || PSD;\n    newScope(function () {\n        PSD.trans = trans;\n        PSD.transless = transless;\n        if (oldVersion === 0) {\n            keys(globalSchema).forEach(function (tableName) {\n                createTable(idbUpgradeTrans, tableName, globalSchema[tableName].primKey, globalSchema[tableName].indexes);\n            });\n            generateMiddlewareStacks(db, idbUpgradeTrans);\n            DexiePromise.follow(function () { return db.on.populate.fire(trans); }).catch(rejectTransaction);\n        }\n        else\n            updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans).catch(rejectTransaction);\n    });\n}\nfunction updateTablesAndIndexes(_a, oldVersion, trans, idbUpgradeTrans) {\n    var db = _a._novip;\n    var queue = [];\n    var versions = db._versions;\n    var globalSchema = db._dbSchema = buildGlobalSchema(db, db.idbdb, idbUpgradeTrans);\n    var anyContentUpgraderHasRun = false;\n    var versToRun = versions.filter(function (v) { return v._cfg.version >= oldVersion; });\n    versToRun.forEach(function (version) {\n        queue.push(function () {\n            var oldSchema = globalSchema;\n            var newSchema = version._cfg.dbschema;\n            adjustToExistingIndexNames(db, oldSchema, idbUpgradeTrans);\n            adjustToExistingIndexNames(db, newSchema, idbUpgradeTrans);\n            globalSchema = db._dbSchema = newSchema;\n            var diff = getSchemaDiff(oldSchema, newSchema);\n            diff.add.forEach(function (tuple) {\n                createTable(idbUpgradeTrans, tuple[0], tuple[1].primKey, tuple[1].indexes);\n            });\n            diff.change.forEach(function (change) {\n                if (change.recreate) {\n                    throw new exceptions.Upgrade(\"Not yet support for changing primary key\");\n                }\n                else {\n                    var store_1 = idbUpgradeTrans.objectStore(change.name);\n                    change.add.forEach(function (idx) { return addIndex(store_1, idx); });\n                    change.change.forEach(function (idx) {\n                        store_1.deleteIndex(idx.name);\n                        addIndex(store_1, idx);\n                    });\n                    change.del.forEach(function (idxName) { return store_1.deleteIndex(idxName); });\n                }\n            });\n            var contentUpgrade = version._cfg.contentUpgrade;\n            if (contentUpgrade && version._cfg.version > oldVersion) {\n                generateMiddlewareStacks(db, idbUpgradeTrans);\n                trans._memoizedTables = {};\n                anyContentUpgraderHasRun = true;\n                var upgradeSchema_1 = shallowClone(newSchema);\n                diff.del.forEach(function (table) {\n                    upgradeSchema_1[table] = oldSchema[table];\n                });\n                removeTablesApi(db, [db.Transaction.prototype]);\n                setApiOnPlace(db, [db.Transaction.prototype], keys(upgradeSchema_1), upgradeSchema_1);\n                trans.schema = upgradeSchema_1;\n                var contentUpgradeIsAsync_1 = isAsyncFunction(contentUpgrade);\n                if (contentUpgradeIsAsync_1) {\n                    incrementExpectedAwaits();\n                }\n                var returnValue_1;\n                var promiseFollowed = DexiePromise.follow(function () {\n                    returnValue_1 = contentUpgrade(trans);\n                    if (returnValue_1) {\n                        if (contentUpgradeIsAsync_1) {\n                            var decrementor = decrementExpectedAwaits.bind(null, null);\n                            returnValue_1.then(decrementor, decrementor);\n                        }\n                    }\n                });\n                return (returnValue_1 && typeof returnValue_1.then === 'function' ?\n                    DexiePromise.resolve(returnValue_1) : promiseFollowed.then(function () { return returnValue_1; }));\n            }\n        });\n        queue.push(function (idbtrans) {\n            if (!anyContentUpgraderHasRun || !hasIEDeleteObjectStoreBug) {\n                var newSchema = version._cfg.dbschema;\n                deleteRemovedTables(newSchema, idbtrans);\n            }\n            removeTablesApi(db, [db.Transaction.prototype]);\n            setApiOnPlace(db, [db.Transaction.prototype], db._storeNames, db._dbSchema);\n            trans.schema = db._dbSchema;\n        });\n    });\n    function runQueue() {\n        return queue.length ? DexiePromise.resolve(queue.shift()(trans.idbtrans)).then(runQueue) :\n            DexiePromise.resolve();\n    }\n    return runQueue().then(function () {\n        createMissingTables(globalSchema, idbUpgradeTrans);\n    });\n}\nfunction getSchemaDiff(oldSchema, newSchema) {\n    var diff = {\n        del: [],\n        add: [],\n        change: []\n    };\n    var table;\n    for (table in oldSchema) {\n        if (!newSchema[table])\n            diff.del.push(table);\n    }\n    for (table in newSchema) {\n        var oldDef = oldSchema[table], newDef = newSchema[table];\n        if (!oldDef) {\n            diff.add.push([table, newDef]);\n        }\n        else {\n            var change = {\n                name: table,\n                def: newDef,\n                recreate: false,\n                del: [],\n                add: [],\n                change: []\n            };\n            if ((\n            '' + (oldDef.primKey.keyPath || '')) !== ('' + (newDef.primKey.keyPath || '')) ||\n                (oldDef.primKey.auto !== newDef.primKey.auto && !isIEOrEdge))\n             {\n                change.recreate = true;\n                diff.change.push(change);\n            }\n            else {\n                var oldIndexes = oldDef.idxByName;\n                var newIndexes = newDef.idxByName;\n                var idxName = void 0;\n                for (idxName in oldIndexes) {\n                    if (!newIndexes[idxName])\n                        change.del.push(idxName);\n                }\n                for (idxName in newIndexes) {\n                    var oldIdx = oldIndexes[idxName], newIdx = newIndexes[idxName];\n                    if (!oldIdx)\n                        change.add.push(newIdx);\n                    else if (oldIdx.src !== newIdx.src)\n                        change.change.push(newIdx);\n                }\n                if (change.del.length > 0 || change.add.length > 0 || change.change.length > 0) {\n                    diff.change.push(change);\n                }\n            }\n        }\n    }\n    return diff;\n}\nfunction createTable(idbtrans, tableName, primKey, indexes) {\n    var store = idbtrans.db.createObjectStore(tableName, primKey.keyPath ?\n        { keyPath: primKey.keyPath, autoIncrement: primKey.auto } :\n        { autoIncrement: primKey.auto });\n    indexes.forEach(function (idx) { return addIndex(store, idx); });\n    return store;\n}\nfunction createMissingTables(newSchema, idbtrans) {\n    keys(newSchema).forEach(function (tableName) {\n        if (!idbtrans.db.objectStoreNames.contains(tableName)) {\n            createTable(idbtrans, tableName, newSchema[tableName].primKey, newSchema[tableName].indexes);\n        }\n    });\n}\nfunction deleteRemovedTables(newSchema, idbtrans) {\n    [].slice.call(idbtrans.db.objectStoreNames).forEach(function (storeName) {\n        return newSchema[storeName] == null && idbtrans.db.deleteObjectStore(storeName);\n    });\n}\nfunction addIndex(store, idx) {\n    store.createIndex(idx.name, idx.keyPath, { unique: idx.unique, multiEntry: idx.multi });\n}\nfunction buildGlobalSchema(db, idbdb, tmpTrans) {\n    var globalSchema = {};\n    var dbStoreNames = slice(idbdb.objectStoreNames, 0);\n    dbStoreNames.forEach(function (storeName) {\n        var store = tmpTrans.objectStore(storeName);\n        var keyPath = store.keyPath;\n        var primKey = createIndexSpec(nameFromKeyPath(keyPath), keyPath || \"\", false, false, !!store.autoIncrement, keyPath && typeof keyPath !== \"string\", true);\n        var indexes = [];\n        for (var j = 0; j < store.indexNames.length; ++j) {\n            var idbindex = store.index(store.indexNames[j]);\n            keyPath = idbindex.keyPath;\n            var index = createIndexSpec(idbindex.name, keyPath, !!idbindex.unique, !!idbindex.multiEntry, false, keyPath && typeof keyPath !== \"string\", false);\n            indexes.push(index);\n        }\n        globalSchema[storeName] = createTableSchema(storeName, primKey, indexes);\n    });\n    return globalSchema;\n}\nfunction readGlobalSchema(_a, idbdb, tmpTrans) {\n    var db = _a._novip;\n    db.verno = idbdb.version / 10;\n    var globalSchema = db._dbSchema = buildGlobalSchema(db, idbdb, tmpTrans);\n    db._storeNames = slice(idbdb.objectStoreNames, 0);\n    setApiOnPlace(db, [db._allTables], keys(globalSchema), globalSchema);\n}\nfunction verifyInstalledSchema(db, tmpTrans) {\n    var installedSchema = buildGlobalSchema(db, db.idbdb, tmpTrans);\n    var diff = getSchemaDiff(installedSchema, db._dbSchema);\n    return !(diff.add.length || diff.change.some(function (ch) { return ch.add.length || ch.change.length; }));\n}\nfunction adjustToExistingIndexNames(_a, schema, idbtrans) {\n    var db = _a._novip;\n    var storeNames = idbtrans.db.objectStoreNames;\n    for (var i = 0; i < storeNames.length; ++i) {\n        var storeName = storeNames[i];\n        var store = idbtrans.objectStore(storeName);\n        db._hasGetAll = 'getAll' in store;\n        for (var j = 0; j < store.indexNames.length; ++j) {\n            var indexName = store.indexNames[j];\n            var keyPath = store.index(indexName).keyPath;\n            var dexieName = typeof keyPath === 'string' ? keyPath : \"[\" + slice(keyPath).join('+') + \"]\";\n            if (schema[storeName]) {\n                var indexSpec = schema[storeName].idxByName[dexieName];\n                if (indexSpec) {\n                    indexSpec.name = indexName;\n                    delete schema[storeName].idxByName[dexieName];\n                    schema[storeName].idxByName[indexName] = indexSpec;\n                }\n            }\n        }\n    }\n    if (typeof navigator !== 'undefined' && /Safari/.test(navigator.userAgent) &&\n        !/(Chrome\\/|Edge\\/)/.test(navigator.userAgent) &&\n        _global.WorkerGlobalScope && _global instanceof _global.WorkerGlobalScope &&\n        [].concat(navigator.userAgent.match(/Safari\\/(\\d*)/))[1] < 604) {\n        db._hasGetAll = false;\n    }\n}\nfunction parseIndexSyntax(primKeyAndIndexes) {\n    return primKeyAndIndexes.split(',').map(function (index, indexNum) {\n        index = index.trim();\n        var name = index.replace(/([&*]|\\+\\+)/g, \"\");\n        var keyPath = /^\\[/.test(name) ? name.match(/^\\[(.*)\\]$/)[1].split('+') : name;\n        return createIndexSpec(name, keyPath || null, /\\&/.test(index), /\\*/.test(index), /\\+\\+/.test(index), isArray(keyPath), indexNum === 0);\n    });\n}\n\nvar Version =  (function () {\n    function Version() {\n    }\n    Version.prototype._parseStoresSpec = function (stores, outSchema) {\n        keys(stores).forEach(function (tableName) {\n            if (stores[tableName] !== null) {\n                var indexes = parseIndexSyntax(stores[tableName]);\n                var primKey = indexes.shift();\n                if (primKey.multi)\n                    throw new exceptions.Schema(\"Primary key cannot be multi-valued\");\n                indexes.forEach(function (idx) {\n                    if (idx.auto)\n                        throw new exceptions.Schema(\"Only primary key can be marked as autoIncrement (++)\");\n                    if (!idx.keyPath)\n                        throw new exceptions.Schema(\"Index must have a name and cannot be an empty string\");\n                });\n                outSchema[tableName] = createTableSchema(tableName, primKey, indexes);\n            }\n        });\n    };\n    Version.prototype.stores = function (stores) {\n        var db = this.db;\n        this._cfg.storesSource = this._cfg.storesSource ?\n            extend(this._cfg.storesSource, stores) :\n            stores;\n        var versions = db._versions;\n        var storesSpec = {};\n        var dbschema = {};\n        versions.forEach(function (version) {\n            extend(storesSpec, version._cfg.storesSource);\n            dbschema = (version._cfg.dbschema = {});\n            version._parseStoresSpec(storesSpec, dbschema);\n        });\n        db._dbSchema = dbschema;\n        removeTablesApi(db, [db._allTables, db, db.Transaction.prototype]);\n        setApiOnPlace(db, [db._allTables, db, db.Transaction.prototype, this._cfg.tables], keys(dbschema), dbschema);\n        db._storeNames = keys(dbschema);\n        return this;\n    };\n    Version.prototype.upgrade = function (upgradeFunction) {\n        this._cfg.contentUpgrade = promisableChain(this._cfg.contentUpgrade || nop, upgradeFunction);\n        return this;\n    };\n    return Version;\n}());\n\nfunction createVersionConstructor(db) {\n    return makeClassConstructor(Version.prototype, function Version(versionNumber) {\n        this.db = db;\n        this._cfg = {\n            version: versionNumber,\n            storesSource: null,\n            dbschema: {},\n            tables: {},\n            contentUpgrade: null\n        };\n    });\n}\n\nfunction getDbNamesTable(indexedDB, IDBKeyRange) {\n    var dbNamesDB = indexedDB[\"_dbNamesDB\"];\n    if (!dbNamesDB) {\n        dbNamesDB = indexedDB[\"_dbNamesDB\"] = new Dexie$1(DBNAMES_DB, {\n            addons: [],\n            indexedDB: indexedDB,\n            IDBKeyRange: IDBKeyRange,\n        });\n        dbNamesDB.version(1).stores({ dbnames: \"name\" });\n    }\n    return dbNamesDB.table(\"dbnames\");\n}\nfunction hasDatabasesNative(indexedDB) {\n    return indexedDB && typeof indexedDB.databases === \"function\";\n}\nfunction getDatabaseNames(_a) {\n    var indexedDB = _a.indexedDB, IDBKeyRange = _a.IDBKeyRange;\n    return hasDatabasesNative(indexedDB)\n        ? Promise.resolve(indexedDB.databases()).then(function (infos) {\n            return infos\n                .map(function (info) { return info.name; })\n                .filter(function (name) { return name !== DBNAMES_DB; });\n        })\n        : getDbNamesTable(indexedDB, IDBKeyRange).toCollection().primaryKeys();\n}\nfunction _onDatabaseCreated(_a, name) {\n    var indexedDB = _a.indexedDB, IDBKeyRange = _a.IDBKeyRange;\n    !hasDatabasesNative(indexedDB) &&\n        name !== DBNAMES_DB &&\n        getDbNamesTable(indexedDB, IDBKeyRange).put({ name: name }).catch(nop);\n}\nfunction _onDatabaseDeleted(_a, name) {\n    var indexedDB = _a.indexedDB, IDBKeyRange = _a.IDBKeyRange;\n    !hasDatabasesNative(indexedDB) &&\n        name !== DBNAMES_DB &&\n        getDbNamesTable(indexedDB, IDBKeyRange).delete(name).catch(nop);\n}\n\nfunction vip(fn) {\n    return newScope(function () {\n        PSD.letThrough = true;\n        return fn();\n    });\n}\n\nfunction idbReady() {\n    var isSafari = !navigator.userAgentData &&\n        /Safari\\//.test(navigator.userAgent) &&\n        !/Chrom(e|ium)\\//.test(navigator.userAgent);\n    if (!isSafari || !indexedDB.databases)\n        return Promise.resolve();\n    var intervalId;\n    return new Promise(function (resolve) {\n        var tryIdb = function () { return indexedDB.databases().finally(resolve); };\n        intervalId = setInterval(tryIdb, 100);\n        tryIdb();\n    }).finally(function () { return clearInterval(intervalId); });\n}\n\nfunction dexieOpen(db) {\n    var state = db._state;\n    var indexedDB = db._deps.indexedDB;\n    if (state.isBeingOpened || db.idbdb)\n        return state.dbReadyPromise.then(function () { return state.dbOpenError ?\n            rejection(state.dbOpenError) :\n            db; });\n    debug && (state.openCanceller._stackHolder = getErrorWithStack());\n    state.isBeingOpened = true;\n    state.dbOpenError = null;\n    state.openComplete = false;\n    var openCanceller = state.openCanceller;\n    function throwIfCancelled() {\n        if (state.openCanceller !== openCanceller)\n            throw new exceptions.DatabaseClosed('db.open() was cancelled');\n    }\n    var resolveDbReady = state.dbReadyResolve,\n    upgradeTransaction = null, wasCreated = false;\n    return DexiePromise.race([openCanceller, (typeof navigator === 'undefined' ? DexiePromise.resolve() : idbReady()).then(function () { return new DexiePromise(function (resolve, reject) {\n            throwIfCancelled();\n            if (!indexedDB)\n                throw new exceptions.MissingAPI();\n            var dbName = db.name;\n            var req = state.autoSchema ?\n                indexedDB.open(dbName) :\n                indexedDB.open(dbName, Math.round(db.verno * 10));\n            if (!req)\n                throw new exceptions.MissingAPI();\n            req.onerror = eventRejectHandler(reject);\n            req.onblocked = wrap(db._fireOnBlocked);\n            req.onupgradeneeded = wrap(function (e) {\n                upgradeTransaction = req.transaction;\n                if (state.autoSchema && !db._options.allowEmptyDB) {\n                    req.onerror = preventDefault;\n                    upgradeTransaction.abort();\n                    req.result.close();\n                    var delreq = indexedDB.deleteDatabase(dbName);\n                    delreq.onsuccess = delreq.onerror = wrap(function () {\n                        reject(new exceptions.NoSuchDatabase(\"Database \" + dbName + \" doesnt exist\"));\n                    });\n                }\n                else {\n                    upgradeTransaction.onerror = eventRejectHandler(reject);\n                    var oldVer = e.oldVersion > Math.pow(2, 62) ? 0 : e.oldVersion;\n                    wasCreated = oldVer < 1;\n                    db._novip.idbdb = req.result;\n                    runUpgraders(db, oldVer / 10, upgradeTransaction, reject);\n                }\n            }, reject);\n            req.onsuccess = wrap(function () {\n                upgradeTransaction = null;\n                var idbdb = db._novip.idbdb = req.result;\n                var objectStoreNames = slice(idbdb.objectStoreNames);\n                if (objectStoreNames.length > 0)\n                    try {\n                        var tmpTrans = idbdb.transaction(safariMultiStoreFix(objectStoreNames), 'readonly');\n                        if (state.autoSchema)\n                            readGlobalSchema(db, idbdb, tmpTrans);\n                        else {\n                            adjustToExistingIndexNames(db, db._dbSchema, tmpTrans);\n                            if (!verifyInstalledSchema(db, tmpTrans)) {\n                                console.warn(\"Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.\");\n                            }\n                        }\n                        generateMiddlewareStacks(db, tmpTrans);\n                    }\n                    catch (e) {\n                    }\n                connections.push(db);\n                idbdb.onversionchange = wrap(function (ev) {\n                    state.vcFired = true;\n                    db.on(\"versionchange\").fire(ev);\n                });\n                idbdb.onclose = wrap(function (ev) {\n                    db.on(\"close\").fire(ev);\n                });\n                if (wasCreated)\n                    _onDatabaseCreated(db._deps, dbName);\n                resolve();\n            }, reject);\n        }); })]).then(function () {\n        throwIfCancelled();\n        state.onReadyBeingFired = [];\n        return DexiePromise.resolve(vip(function () { return db.on.ready.fire(db.vip); })).then(function fireRemainders() {\n            if (state.onReadyBeingFired.length > 0) {\n                var remainders_1 = state.onReadyBeingFired.reduce(promisableChain, nop);\n                state.onReadyBeingFired = [];\n                return DexiePromise.resolve(vip(function () { return remainders_1(db.vip); })).then(fireRemainders);\n            }\n        });\n    }).finally(function () {\n        state.onReadyBeingFired = null;\n        state.isBeingOpened = false;\n    }).then(function () {\n        return db;\n    }).catch(function (err) {\n        state.dbOpenError = err;\n        try {\n            upgradeTransaction && upgradeTransaction.abort();\n        }\n        catch (_a) { }\n        if (openCanceller === state.openCanceller) {\n            db._close();\n        }\n        return rejection(err);\n    }).finally(function () {\n        state.openComplete = true;\n        resolveDbReady();\n    });\n}\n\nfunction awaitIterator(iterator) {\n    var callNext = function (result) { return iterator.next(result); }, doThrow = function (error) { return iterator.throw(error); }, onSuccess = step(callNext), onError = step(doThrow);\n    function step(getNext) {\n        return function (val) {\n            var next = getNext(val), value = next.value;\n            return next.done ? value :\n                (!value || typeof value.then !== 'function' ?\n                    isArray(value) ? Promise.all(value).then(onSuccess, onError) : onSuccess(value) :\n                    value.then(onSuccess, onError));\n        };\n    }\n    return step(callNext)();\n}\n\nfunction extractTransactionArgs(mode, _tableArgs_, scopeFunc) {\n    var i = arguments.length;\n    if (i < 2)\n        throw new exceptions.InvalidArgument(\"Too few arguments\");\n    var args = new Array(i - 1);\n    while (--i)\n        args[i - 1] = arguments[i];\n    scopeFunc = args.pop();\n    var tables = flatten(args);\n    return [mode, tables, scopeFunc];\n}\nfunction enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFunc) {\n    return DexiePromise.resolve().then(function () {\n        var transless = PSD.transless || PSD;\n        var trans = db._createTransaction(mode, storeNames, db._dbSchema, parentTransaction);\n        var zoneProps = {\n            trans: trans,\n            transless: transless\n        };\n        if (parentTransaction) {\n            trans.idbtrans = parentTransaction.idbtrans;\n        }\n        else {\n            try {\n                trans.create();\n                db._state.PR1398_maxLoop = 3;\n            }\n            catch (ex) {\n                if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {\n                    console.warn('Dexie: Need to reopen db');\n                    db._close();\n                    return db.open().then(function () { return enterTransactionScope(db, mode, storeNames, null, scopeFunc); });\n                }\n                return rejection(ex);\n            }\n        }\n        var scopeFuncIsAsync = isAsyncFunction(scopeFunc);\n        if (scopeFuncIsAsync) {\n            incrementExpectedAwaits();\n        }\n        var returnValue;\n        var promiseFollowed = DexiePromise.follow(function () {\n            returnValue = scopeFunc.call(trans, trans);\n            if (returnValue) {\n                if (scopeFuncIsAsync) {\n                    var decrementor = decrementExpectedAwaits.bind(null, null);\n                    returnValue.then(decrementor, decrementor);\n                }\n                else if (typeof returnValue.next === 'function' && typeof returnValue.throw === 'function') {\n                    returnValue = awaitIterator(returnValue);\n                }\n            }\n        }, zoneProps);\n        return (returnValue && typeof returnValue.then === 'function' ?\n            DexiePromise.resolve(returnValue).then(function (x) { return trans.active ?\n                x\n                : rejection(new exceptions.PrematureCommit(\"Transaction committed too early. See http://bit.ly/2kdckMn\")); })\n            : promiseFollowed.then(function () { return returnValue; })).then(function (x) {\n            if (parentTransaction)\n                trans._resolve();\n            return trans._completion.then(function () { return x; });\n        }).catch(function (e) {\n            trans._reject(e);\n            return rejection(e);\n        });\n    });\n}\n\nfunction pad(a, value, count) {\n    var result = isArray(a) ? a.slice() : [a];\n    for (var i = 0; i < count; ++i)\n        result.push(value);\n    return result;\n}\nfunction createVirtualIndexMiddleware(down) {\n    return __assign(__assign({}, down), { table: function (tableName) {\n            var table = down.table(tableName);\n            var schema = table.schema;\n            var indexLookup = {};\n            var allVirtualIndexes = [];\n            function addVirtualIndexes(keyPath, keyTail, lowLevelIndex) {\n                var keyPathAlias = getKeyPathAlias(keyPath);\n                var indexList = (indexLookup[keyPathAlias] = indexLookup[keyPathAlias] || []);\n                var keyLength = keyPath == null ? 0 : typeof keyPath === 'string' ? 1 : keyPath.length;\n                var isVirtual = keyTail > 0;\n                var virtualIndex = __assign(__assign({}, lowLevelIndex), { isVirtual: isVirtual, keyTail: keyTail, keyLength: keyLength, extractKey: getKeyExtractor(keyPath), unique: !isVirtual && lowLevelIndex.unique });\n                indexList.push(virtualIndex);\n                if (!virtualIndex.isPrimaryKey) {\n                    allVirtualIndexes.push(virtualIndex);\n                }\n                if (keyLength > 1) {\n                    var virtualKeyPath = keyLength === 2 ?\n                        keyPath[0] :\n                        keyPath.slice(0, keyLength - 1);\n                    addVirtualIndexes(virtualKeyPath, keyTail + 1, lowLevelIndex);\n                }\n                indexList.sort(function (a, b) { return a.keyTail - b.keyTail; });\n                return virtualIndex;\n            }\n            var primaryKey = addVirtualIndexes(schema.primaryKey.keyPath, 0, schema.primaryKey);\n            indexLookup[\":id\"] = [primaryKey];\n            for (var _i = 0, _a = schema.indexes; _i < _a.length; _i++) {\n                var index = _a[_i];\n                addVirtualIndexes(index.keyPath, 0, index);\n            }\n            function findBestIndex(keyPath) {\n                var result = indexLookup[getKeyPathAlias(keyPath)];\n                return result && result[0];\n            }\n            function translateRange(range, keyTail) {\n                return {\n                    type: range.type === 1  ?\n                        2  :\n                        range.type,\n                    lower: pad(range.lower, range.lowerOpen ? down.MAX_KEY : down.MIN_KEY, keyTail),\n                    lowerOpen: true,\n                    upper: pad(range.upper, range.upperOpen ? down.MIN_KEY : down.MAX_KEY, keyTail),\n                    upperOpen: true\n                };\n            }\n            function translateRequest(req) {\n                var index = req.query.index;\n                return index.isVirtual ? __assign(__assign({}, req), { query: {\n                        index: index,\n                        range: translateRange(req.query.range, index.keyTail)\n                    } }) : req;\n            }\n            var result = __assign(__assign({}, table), { schema: __assign(__assign({}, schema), { primaryKey: primaryKey, indexes: allVirtualIndexes, getIndexByKeyPath: findBestIndex }), count: function (req) {\n                    return table.count(translateRequest(req));\n                }, query: function (req) {\n                    return table.query(translateRequest(req));\n                }, openCursor: function (req) {\n                    var _a = req.query.index, keyTail = _a.keyTail, isVirtual = _a.isVirtual, keyLength = _a.keyLength;\n                    if (!isVirtual)\n                        return table.openCursor(req);\n                    function createVirtualCursor(cursor) {\n                        function _continue(key) {\n                            key != null ?\n                                cursor.continue(pad(key, req.reverse ? down.MAX_KEY : down.MIN_KEY, keyTail)) :\n                                req.unique ?\n                                    cursor.continue(cursor.key.slice(0, keyLength)\n                                        .concat(req.reverse\n                                        ? down.MIN_KEY\n                                        : down.MAX_KEY, keyTail)) :\n                                    cursor.continue();\n                        }\n                        var virtualCursor = Object.create(cursor, {\n                            continue: { value: _continue },\n                            continuePrimaryKey: {\n                                value: function (key, primaryKey) {\n                                    cursor.continuePrimaryKey(pad(key, down.MAX_KEY, keyTail), primaryKey);\n                                }\n                            },\n                            primaryKey: {\n                                get: function () {\n                                    return cursor.primaryKey;\n                                }\n                            },\n                            key: {\n                                get: function () {\n                                    var key = cursor.key;\n                                    return keyLength === 1 ?\n                                        key[0] :\n                                        key.slice(0, keyLength);\n                                }\n                            },\n                            value: {\n                                get: function () {\n                                    return cursor.value;\n                                }\n                            }\n                        });\n                        return virtualCursor;\n                    }\n                    return table.openCursor(translateRequest(req))\n                        .then(function (cursor) { return cursor && createVirtualCursor(cursor); });\n                } });\n            return result;\n        } });\n}\nvar virtualIndexMiddleware = {\n    stack: \"dbcore\",\n    name: \"VirtualIndexMiddleware\",\n    level: 1,\n    create: createVirtualIndexMiddleware\n};\n\nfunction getObjectDiff(a, b, rv, prfx) {\n    rv = rv || {};\n    prfx = prfx || '';\n    keys(a).forEach(function (prop) {\n        if (!hasOwn(b, prop)) {\n            rv[prfx + prop] = undefined;\n        }\n        else {\n            var ap = a[prop], bp = b[prop];\n            if (typeof ap === 'object' && typeof bp === 'object' && ap && bp) {\n                var apTypeName = toStringTag(ap);\n                var bpTypeName = toStringTag(bp);\n                if (apTypeName !== bpTypeName) {\n                    rv[prfx + prop] = b[prop];\n                }\n                else if (apTypeName === 'Object') {\n                    getObjectDiff(ap, bp, rv, prfx + prop + '.');\n                }\n                else if (ap !== bp) {\n                    rv[prfx + prop] = b[prop];\n                }\n            }\n            else if (ap !== bp)\n                rv[prfx + prop] = b[prop];\n        }\n    });\n    keys(b).forEach(function (prop) {\n        if (!hasOwn(a, prop)) {\n            rv[prfx + prop] = b[prop];\n        }\n    });\n    return rv;\n}\n\nfunction getEffectiveKeys(primaryKey, req) {\n    if (req.type === 'delete')\n        return req.keys;\n    return req.keys || req.values.map(primaryKey.extractKey);\n}\n\nvar hooksMiddleware = {\n    stack: \"dbcore\",\n    name: \"HooksMiddleware\",\n    level: 2,\n    create: function (downCore) { return (__assign(__assign({}, downCore), { table: function (tableName) {\n            var downTable = downCore.table(tableName);\n            var primaryKey = downTable.schema.primaryKey;\n            var tableMiddleware = __assign(__assign({}, downTable), { mutate: function (req) {\n                    var dxTrans = PSD.trans;\n                    var _a = dxTrans.table(tableName).hook, deleting = _a.deleting, creating = _a.creating, updating = _a.updating;\n                    switch (req.type) {\n                        case 'add':\n                            if (creating.fire === nop)\n                                break;\n                            return dxTrans._promise('readwrite', function () { return addPutOrDelete(req); }, true);\n                        case 'put':\n                            if (creating.fire === nop && updating.fire === nop)\n                                break;\n                            return dxTrans._promise('readwrite', function () { return addPutOrDelete(req); }, true);\n                        case 'delete':\n                            if (deleting.fire === nop)\n                                break;\n                            return dxTrans._promise('readwrite', function () { return addPutOrDelete(req); }, true);\n                        case 'deleteRange':\n                            if (deleting.fire === nop)\n                                break;\n                            return dxTrans._promise('readwrite', function () { return deleteRange(req); }, true);\n                    }\n                    return downTable.mutate(req);\n                    function addPutOrDelete(req) {\n                        var dxTrans = PSD.trans;\n                        var keys = req.keys || getEffectiveKeys(primaryKey, req);\n                        if (!keys)\n                            throw new Error(\"Keys missing\");\n                        req = req.type === 'add' || req.type === 'put' ? __assign(__assign({}, req), { keys: keys }) : __assign({}, req);\n                        if (req.type !== 'delete')\n                            req.values = __spreadArray([], req.values, true);\n                        if (req.keys)\n                            req.keys = __spreadArray([], req.keys, true);\n                        return getExistingValues(downTable, req, keys).then(function (existingValues) {\n                            var contexts = keys.map(function (key, i) {\n                                var existingValue = existingValues[i];\n                                var ctx = { onerror: null, onsuccess: null };\n                                if (req.type === 'delete') {\n                                    deleting.fire.call(ctx, key, existingValue, dxTrans);\n                                }\n                                else if (req.type === 'add' || existingValue === undefined) {\n                                    var generatedPrimaryKey = creating.fire.call(ctx, key, req.values[i], dxTrans);\n                                    if (key == null && generatedPrimaryKey != null) {\n                                        key = generatedPrimaryKey;\n                                        req.keys[i] = key;\n                                        if (!primaryKey.outbound) {\n                                            setByKeyPath(req.values[i], primaryKey.keyPath, key);\n                                        }\n                                    }\n                                }\n                                else {\n                                    var objectDiff = getObjectDiff(existingValue, req.values[i]);\n                                    var additionalChanges_1 = updating.fire.call(ctx, objectDiff, key, existingValue, dxTrans);\n                                    if (additionalChanges_1) {\n                                        var requestedValue_1 = req.values[i];\n                                        Object.keys(additionalChanges_1).forEach(function (keyPath) {\n                                            if (hasOwn(requestedValue_1, keyPath)) {\n                                                requestedValue_1[keyPath] = additionalChanges_1[keyPath];\n                                            }\n                                            else {\n                                                setByKeyPath(requestedValue_1, keyPath, additionalChanges_1[keyPath]);\n                                            }\n                                        });\n                                    }\n                                }\n                                return ctx;\n                            });\n                            return downTable.mutate(req).then(function (_a) {\n                                var failures = _a.failures, results = _a.results, numFailures = _a.numFailures, lastResult = _a.lastResult;\n                                for (var i = 0; i < keys.length; ++i) {\n                                    var primKey = results ? results[i] : keys[i];\n                                    var ctx = contexts[i];\n                                    if (primKey == null) {\n                                        ctx.onerror && ctx.onerror(failures[i]);\n                                    }\n                                    else {\n                                        ctx.onsuccess && ctx.onsuccess(req.type === 'put' && existingValues[i] ?\n                                            req.values[i] :\n                                            primKey\n                                        );\n                                    }\n                                }\n                                return { failures: failures, results: results, numFailures: numFailures, lastResult: lastResult };\n                            }).catch(function (error) {\n                                contexts.forEach(function (ctx) { return ctx.onerror && ctx.onerror(error); });\n                                return Promise.reject(error);\n                            });\n                        });\n                    }\n                    function deleteRange(req) {\n                        return deleteNextChunk(req.trans, req.range, 10000);\n                    }\n                    function deleteNextChunk(trans, range, limit) {\n                        return downTable.query({ trans: trans, values: false, query: { index: primaryKey, range: range }, limit: limit })\n                            .then(function (_a) {\n                            var result = _a.result;\n                            return addPutOrDelete({ type: 'delete', keys: result, trans: trans }).then(function (res) {\n                                if (res.numFailures > 0)\n                                    return Promise.reject(res.failures[0]);\n                                if (result.length < limit) {\n                                    return { failures: [], numFailures: 0, lastResult: undefined };\n                                }\n                                else {\n                                    return deleteNextChunk(trans, __assign(__assign({}, range), { lower: result[result.length - 1], lowerOpen: true }), limit);\n                                }\n                            });\n                        });\n                    }\n                } });\n            return tableMiddleware;\n        } })); }\n};\nfunction getExistingValues(table, req, effectiveKeys) {\n    return req.type === \"add\"\n        ? Promise.resolve([])\n        : table.getMany({ trans: req.trans, keys: effectiveKeys, cache: \"immutable\" });\n}\n\nfunction getFromTransactionCache(keys, cache, clone) {\n    try {\n        if (!cache)\n            return null;\n        if (cache.keys.length < keys.length)\n            return null;\n        var result = [];\n        for (var i = 0, j = 0; i < cache.keys.length && j < keys.length; ++i) {\n            if (cmp(cache.keys[i], keys[j]) !== 0)\n                continue;\n            result.push(clone ? deepClone(cache.values[i]) : cache.values[i]);\n            ++j;\n        }\n        return result.length === keys.length ? result : null;\n    }\n    catch (_a) {\n        return null;\n    }\n}\nvar cacheExistingValuesMiddleware = {\n    stack: \"dbcore\",\n    level: -1,\n    create: function (core) {\n        return {\n            table: function (tableName) {\n                var table = core.table(tableName);\n                return __assign(__assign({}, table), { getMany: function (req) {\n                        if (!req.cache) {\n                            return table.getMany(req);\n                        }\n                        var cachedResult = getFromTransactionCache(req.keys, req.trans[\"_cache\"], req.cache === \"clone\");\n                        if (cachedResult) {\n                            return DexiePromise.resolve(cachedResult);\n                        }\n                        return table.getMany(req).then(function (res) {\n                            req.trans[\"_cache\"] = {\n                                keys: req.keys,\n                                values: req.cache === \"clone\" ? deepClone(res) : res,\n                            };\n                            return res;\n                        });\n                    }, mutate: function (req) {\n                        if (req.type !== \"add\")\n                            req.trans[\"_cache\"] = null;\n                        return table.mutate(req);\n                    } });\n            },\n        };\n    },\n};\n\nvar _a;\nfunction isEmptyRange(node) {\n    return !(\"from\" in node);\n}\nvar RangeSet = function (fromOrTree, to) {\n    if (this) {\n        extend(this, arguments.length ? { d: 1, from: fromOrTree, to: arguments.length > 1 ? to : fromOrTree } : { d: 0 });\n    }\n    else {\n        var rv = new RangeSet();\n        if (fromOrTree && (\"d\" in fromOrTree)) {\n            extend(rv, fromOrTree);\n        }\n        return rv;\n    }\n};\nprops(RangeSet.prototype, (_a = {\n        add: function (rangeSet) {\n            mergeRanges(this, rangeSet);\n            return this;\n        },\n        addKey: function (key) {\n            addRange(this, key, key);\n            return this;\n        },\n        addKeys: function (keys) {\n            var _this = this;\n            keys.forEach(function (key) { return addRange(_this, key, key); });\n            return this;\n        }\n    },\n    _a[iteratorSymbol] = function () {\n        return getRangeSetIterator(this);\n    },\n    _a));\nfunction addRange(target, from, to) {\n    var diff = cmp(from, to);\n    if (isNaN(diff))\n        return;\n    if (diff > 0)\n        throw RangeError();\n    if (isEmptyRange(target))\n        return extend(target, { from: from, to: to, d: 1 });\n    var left = target.l;\n    var right = target.r;\n    if (cmp(to, target.from) < 0) {\n        left\n            ? addRange(left, from, to)\n            : (target.l = { from: from, to: to, d: 1, l: null, r: null });\n        return rebalance(target);\n    }\n    if (cmp(from, target.to) > 0) {\n        right\n            ? addRange(right, from, to)\n            : (target.r = { from: from, to: to, d: 1, l: null, r: null });\n        return rebalance(target);\n    }\n    if (cmp(from, target.from) < 0) {\n        target.from = from;\n        target.l = null;\n        target.d = right ? right.d + 1 : 1;\n    }\n    if (cmp(to, target.to) > 0) {\n        target.to = to;\n        target.r = null;\n        target.d = target.l ? target.l.d + 1 : 1;\n    }\n    var rightWasCutOff = !target.r;\n    if (left && !target.l) {\n        mergeRanges(target, left);\n    }\n    if (right && rightWasCutOff) {\n        mergeRanges(target, right);\n    }\n}\nfunction mergeRanges(target, newSet) {\n    function _addRangeSet(target, _a) {\n        var from = _a.from, to = _a.to, l = _a.l, r = _a.r;\n        addRange(target, from, to);\n        if (l)\n            _addRangeSet(target, l);\n        if (r)\n            _addRangeSet(target, r);\n    }\n    if (!isEmptyRange(newSet))\n        _addRangeSet(target, newSet);\n}\nfunction rangesOverlap(rangeSet1, rangeSet2) {\n    var i1 = getRangeSetIterator(rangeSet2);\n    var nextResult1 = i1.next();\n    if (nextResult1.done)\n        return false;\n    var a = nextResult1.value;\n    var i2 = getRangeSetIterator(rangeSet1);\n    var nextResult2 = i2.next(a.from);\n    var b = nextResult2.value;\n    while (!nextResult1.done && !nextResult2.done) {\n        if (cmp(b.from, a.to) <= 0 && cmp(b.to, a.from) >= 0)\n            return true;\n        cmp(a.from, b.from) < 0\n            ? (a = (nextResult1 = i1.next(b.from)).value)\n            : (b = (nextResult2 = i2.next(a.from)).value);\n    }\n    return false;\n}\nfunction getRangeSetIterator(node) {\n    var state = isEmptyRange(node) ? null : { s: 0, n: node };\n    return {\n        next: function (key) {\n            var keyProvided = arguments.length > 0;\n            while (state) {\n                switch (state.s) {\n                    case 0:\n                        state.s = 1;\n                        if (keyProvided) {\n                            while (state.n.l && cmp(key, state.n.from) < 0)\n                                state = { up: state, n: state.n.l, s: 1 };\n                        }\n                        else {\n                            while (state.n.l)\n                                state = { up: state, n: state.n.l, s: 1 };\n                        }\n                    case 1:\n                        state.s = 2;\n                        if (!keyProvided || cmp(key, state.n.to) <= 0)\n                            return { value: state.n, done: false };\n                    case 2:\n                        if (state.n.r) {\n                            state.s = 3;\n                            state = { up: state, n: state.n.r, s: 0 };\n                            continue;\n                        }\n                    case 3:\n                        state = state.up;\n                }\n            }\n            return { done: true };\n        },\n    };\n}\nfunction rebalance(target) {\n    var _a, _b;\n    var diff = (((_a = target.r) === null || _a === void 0 ? void 0 : _a.d) || 0) - (((_b = target.l) === null || _b === void 0 ? void 0 : _b.d) || 0);\n    var r = diff > 1 ? \"r\" : diff < -1 ? \"l\" : \"\";\n    if (r) {\n        var l = r === \"r\" ? \"l\" : \"r\";\n        var rootClone = __assign({}, target);\n        var oldRootRight = target[r];\n        target.from = oldRootRight.from;\n        target.to = oldRootRight.to;\n        target[r] = oldRootRight[r];\n        rootClone[r] = oldRootRight[l];\n        target[l] = rootClone;\n        rootClone.d = computeDepth(rootClone);\n    }\n    target.d = computeDepth(target);\n}\nfunction computeDepth(_a) {\n    var r = _a.r, l = _a.l;\n    return (r ? (l ? Math.max(r.d, l.d) : r.d) : l ? l.d : 0) + 1;\n}\n\nvar observabilityMiddleware = {\n    stack: \"dbcore\",\n    level: 0,\n    create: function (core) {\n        var dbName = core.schema.name;\n        var FULL_RANGE = new RangeSet(core.MIN_KEY, core.MAX_KEY);\n        return __assign(__assign({}, core), { table: function (tableName) {\n                var table = core.table(tableName);\n                var schema = table.schema;\n                var primaryKey = schema.primaryKey;\n                var extractKey = primaryKey.extractKey, outbound = primaryKey.outbound;\n                var tableClone = __assign(__assign({}, table), { mutate: function (req) {\n                        var trans = req.trans;\n                        var mutatedParts = trans.mutatedParts || (trans.mutatedParts = {});\n                        var getRangeSet = function (indexName) {\n                            var part = \"idb://\" + dbName + \"/\" + tableName + \"/\" + indexName;\n                            return (mutatedParts[part] ||\n                                (mutatedParts[part] = new RangeSet()));\n                        };\n                        var pkRangeSet = getRangeSet(\"\");\n                        var delsRangeSet = getRangeSet(\":dels\");\n                        var type = req.type;\n                        var _a = req.type === \"deleteRange\"\n                            ? [req.range]\n                            : req.type === \"delete\"\n                                ? [req.keys]\n                                : req.values.length < 50\n                                    ? [[], req.values]\n                                    : [], keys = _a[0], newObjs = _a[1];\n                        var oldCache = req.trans[\"_cache\"];\n                        return table.mutate(req).then(function (res) {\n                            if (isArray(keys)) {\n                                if (type !== \"delete\")\n                                    keys = res.results;\n                                pkRangeSet.addKeys(keys);\n                                var oldObjs = getFromTransactionCache(keys, oldCache);\n                                if (!oldObjs && type !== \"add\") {\n                                    delsRangeSet.addKeys(keys);\n                                }\n                                if (oldObjs || newObjs) {\n                                    trackAffectedIndexes(getRangeSet, schema, oldObjs, newObjs);\n                                }\n                            }\n                            else if (keys) {\n                                var range = { from: keys.lower, to: keys.upper };\n                                delsRangeSet.add(range);\n                                pkRangeSet.add(range);\n                            }\n                            else {\n                                pkRangeSet.add(FULL_RANGE);\n                                delsRangeSet.add(FULL_RANGE);\n                                schema.indexes.forEach(function (idx) { return getRangeSet(idx.name).add(FULL_RANGE); });\n                            }\n                            return res;\n                        });\n                    } });\n                var getRange = function (_a) {\n                    var _b, _c;\n                    var _d = _a.query, index = _d.index, range = _d.range;\n                    return [\n                        index,\n                        new RangeSet((_b = range.lower) !== null && _b !== void 0 ? _b : core.MIN_KEY, (_c = range.upper) !== null && _c !== void 0 ? _c : core.MAX_KEY),\n                    ];\n                };\n                var readSubscribers = {\n                    get: function (req) { return [primaryKey, new RangeSet(req.key)]; },\n                    getMany: function (req) { return [primaryKey, new RangeSet().addKeys(req.keys)]; },\n                    count: getRange,\n                    query: getRange,\n                    openCursor: getRange,\n                };\n                keys(readSubscribers).forEach(function (method) {\n                    tableClone[method] = function (req) {\n                        var subscr = PSD.subscr;\n                        if (subscr) {\n                            var getRangeSet = function (indexName) {\n                                var part = \"idb://\" + dbName + \"/\" + tableName + \"/\" + indexName;\n                                return (subscr[part] ||\n                                    (subscr[part] = new RangeSet()));\n                            };\n                            var pkRangeSet_1 = getRangeSet(\"\");\n                            var delsRangeSet_1 = getRangeSet(\":dels\");\n                            var _a = readSubscribers[method](req), queriedIndex = _a[0], queriedRanges = _a[1];\n                            getRangeSet(queriedIndex.name || \"\").add(queriedRanges);\n                            if (!queriedIndex.isPrimaryKey) {\n                                if (method === \"count\") {\n                                    delsRangeSet_1.add(FULL_RANGE);\n                                }\n                                else {\n                                    var keysPromise_1 = method === \"query\" &&\n                                        outbound &&\n                                        req.values &&\n                                        table.query(__assign(__assign({}, req), { values: false }));\n                                    return table[method].apply(this, arguments).then(function (res) {\n                                        if (method === \"query\") {\n                                            if (outbound && req.values) {\n                                                return keysPromise_1.then(function (_a) {\n                                                    var resultingKeys = _a.result;\n                                                    pkRangeSet_1.addKeys(resultingKeys);\n                                                    return res;\n                                                });\n                                            }\n                                            var pKeys = req.values\n                                                ? res.result.map(extractKey)\n                                                : res.result;\n                                            if (req.values) {\n                                                pkRangeSet_1.addKeys(pKeys);\n                                            }\n                                            else {\n                                                delsRangeSet_1.addKeys(pKeys);\n                                            }\n                                        }\n                                        else if (method === \"openCursor\") {\n                                            var cursor_1 = res;\n                                            var wantValues_1 = req.values;\n                                            return (cursor_1 &&\n                                                Object.create(cursor_1, {\n                                                    key: {\n                                                        get: function () {\n                                                            delsRangeSet_1.addKey(cursor_1.primaryKey);\n                                                            return cursor_1.key;\n                                                        },\n                                                    },\n                                                    primaryKey: {\n                                                        get: function () {\n                                                            var pkey = cursor_1.primaryKey;\n                                                            delsRangeSet_1.addKey(pkey);\n                                                            return pkey;\n                                                        },\n                                                    },\n                                                    value: {\n                                                        get: function () {\n                                                            wantValues_1 && pkRangeSet_1.addKey(cursor_1.primaryKey);\n                                                            return cursor_1.value;\n                                                        },\n                                                    },\n                                                }));\n                                        }\n                                        return res;\n                                    });\n                                }\n                            }\n                        }\n                        return table[method].apply(this, arguments);\n                    };\n                });\n                return tableClone;\n            } });\n    },\n};\nfunction trackAffectedIndexes(getRangeSet, schema, oldObjs, newObjs) {\n    function addAffectedIndex(ix) {\n        var rangeSet = getRangeSet(ix.name || \"\");\n        function extractKey(obj) {\n            return obj != null ? ix.extractKey(obj) : null;\n        }\n        var addKeyOrKeys = function (key) { return ix.multiEntry && isArray(key)\n            ? key.forEach(function (key) { return rangeSet.addKey(key); })\n            : rangeSet.addKey(key); };\n        (oldObjs || newObjs).forEach(function (_, i) {\n            var oldKey = oldObjs && extractKey(oldObjs[i]);\n            var newKey = newObjs && extractKey(newObjs[i]);\n            if (cmp(oldKey, newKey) !== 0) {\n                if (oldKey != null)\n                    addKeyOrKeys(oldKey);\n                if (newKey != null)\n                    addKeyOrKeys(newKey);\n            }\n        });\n    }\n    schema.indexes.forEach(addAffectedIndex);\n}\n\nvar Dexie$1 =  (function () {\n    function Dexie(name, options) {\n        var _this = this;\n        this._middlewares = {};\n        this.verno = 0;\n        var deps = Dexie.dependencies;\n        this._options = options = __assign({\n            addons: Dexie.addons, autoOpen: true,\n            indexedDB: deps.indexedDB, IDBKeyRange: deps.IDBKeyRange }, options);\n        this._deps = {\n            indexedDB: options.indexedDB,\n            IDBKeyRange: options.IDBKeyRange\n        };\n        var addons = options.addons;\n        this._dbSchema = {};\n        this._versions = [];\n        this._storeNames = [];\n        this._allTables = {};\n        this.idbdb = null;\n        this._novip = this;\n        var state = {\n            dbOpenError: null,\n            isBeingOpened: false,\n            onReadyBeingFired: null,\n            openComplete: false,\n            dbReadyResolve: nop,\n            dbReadyPromise: null,\n            cancelOpen: nop,\n            openCanceller: null,\n            autoSchema: true,\n            PR1398_maxLoop: 3\n        };\n        state.dbReadyPromise = new DexiePromise(function (resolve) {\n            state.dbReadyResolve = resolve;\n        });\n        state.openCanceller = new DexiePromise(function (_, reject) {\n            state.cancelOpen = reject;\n        });\n        this._state = state;\n        this.name = name;\n        this.on = Events(this, \"populate\", \"blocked\", \"versionchange\", \"close\", { ready: [promisableChain, nop] });\n        this.on.ready.subscribe = override(this.on.ready.subscribe, function (subscribe) {\n            return function (subscriber, bSticky) {\n                Dexie.vip(function () {\n                    var state = _this._state;\n                    if (state.openComplete) {\n                        if (!state.dbOpenError)\n                            DexiePromise.resolve().then(subscriber);\n                        if (bSticky)\n                            subscribe(subscriber);\n                    }\n                    else if (state.onReadyBeingFired) {\n                        state.onReadyBeingFired.push(subscriber);\n                        if (bSticky)\n                            subscribe(subscriber);\n                    }\n                    else {\n                        subscribe(subscriber);\n                        var db_1 = _this;\n                        if (!bSticky)\n                            subscribe(function unsubscribe() {\n                                db_1.on.ready.unsubscribe(subscriber);\n                                db_1.on.ready.unsubscribe(unsubscribe);\n                            });\n                    }\n                });\n            };\n        });\n        this.Collection = createCollectionConstructor(this);\n        this.Table = createTableConstructor(this);\n        this.Transaction = createTransactionConstructor(this);\n        this.Version = createVersionConstructor(this);\n        this.WhereClause = createWhereClauseConstructor(this);\n        this.on(\"versionchange\", function (ev) {\n            if (ev.newVersion > 0)\n                console.warn(\"Another connection wants to upgrade database '\" + _this.name + \"'. Closing db now to resume the upgrade.\");\n            else\n                console.warn(\"Another connection wants to delete database '\" + _this.name + \"'. Closing db now to resume the delete request.\");\n            _this.close();\n        });\n        this.on(\"blocked\", function (ev) {\n            if (!ev.newVersion || ev.newVersion < ev.oldVersion)\n                console.warn(\"Dexie.delete('\" + _this.name + \"') was blocked\");\n            else\n                console.warn(\"Upgrade '\" + _this.name + \"' blocked by other connection holding version \" + ev.oldVersion / 10);\n        });\n        this._maxKey = getMaxKey(options.IDBKeyRange);\n        this._createTransaction = function (mode, storeNames, dbschema, parentTransaction) { return new _this.Transaction(mode, storeNames, dbschema, _this._options.chromeTransactionDurability, parentTransaction); };\n        this._fireOnBlocked = function (ev) {\n            _this.on(\"blocked\").fire(ev);\n            connections\n                .filter(function (c) { return c.name === _this.name && c !== _this && !c._state.vcFired; })\n                .map(function (c) { return c.on(\"versionchange\").fire(ev); });\n        };\n        this.use(virtualIndexMiddleware);\n        this.use(hooksMiddleware);\n        this.use(observabilityMiddleware);\n        this.use(cacheExistingValuesMiddleware);\n        this.vip = Object.create(this, { _vip: { value: true } });\n        addons.forEach(function (addon) { return addon(_this); });\n    }\n    Dexie.prototype.version = function (versionNumber) {\n        if (isNaN(versionNumber) || versionNumber < 0.1)\n            throw new exceptions.Type(\"Given version is not a positive number\");\n        versionNumber = Math.round(versionNumber * 10) / 10;\n        if (this.idbdb || this._state.isBeingOpened)\n            throw new exceptions.Schema(\"Cannot add version when database is open\");\n        this.verno = Math.max(this.verno, versionNumber);\n        var versions = this._versions;\n        var versionInstance = versions.filter(function (v) { return v._cfg.version === versionNumber; })[0];\n        if (versionInstance)\n            return versionInstance;\n        versionInstance = new this.Version(versionNumber);\n        versions.push(versionInstance);\n        versions.sort(lowerVersionFirst);\n        versionInstance.stores({});\n        this._state.autoSchema = false;\n        return versionInstance;\n    };\n    Dexie.prototype._whenReady = function (fn) {\n        var _this = this;\n        return (this.idbdb && (this._state.openComplete || PSD.letThrough || this._vip)) ? fn() : new DexiePromise(function (resolve, reject) {\n            if (_this._state.openComplete) {\n                return reject(new exceptions.DatabaseClosed(_this._state.dbOpenError));\n            }\n            if (!_this._state.isBeingOpened) {\n                if (!_this._options.autoOpen) {\n                    reject(new exceptions.DatabaseClosed());\n                    return;\n                }\n                _this.open().catch(nop);\n            }\n            _this._state.dbReadyPromise.then(resolve, reject);\n        }).then(fn);\n    };\n    Dexie.prototype.use = function (_a) {\n        var stack = _a.stack, create = _a.create, level = _a.level, name = _a.name;\n        if (name)\n            this.unuse({ stack: stack, name: name });\n        var middlewares = this._middlewares[stack] || (this._middlewares[stack] = []);\n        middlewares.push({ stack: stack, create: create, level: level == null ? 10 : level, name: name });\n        middlewares.sort(function (a, b) { return a.level - b.level; });\n        return this;\n    };\n    Dexie.prototype.unuse = function (_a) {\n        var stack = _a.stack, name = _a.name, create = _a.create;\n        if (stack && this._middlewares[stack]) {\n            this._middlewares[stack] = this._middlewares[stack].filter(function (mw) {\n                return create ? mw.create !== create :\n                    name ? mw.name !== name :\n                        false;\n            });\n        }\n        return this;\n    };\n    Dexie.prototype.open = function () {\n        return dexieOpen(this);\n    };\n    Dexie.prototype._close = function () {\n        var state = this._state;\n        var idx = connections.indexOf(this);\n        if (idx >= 0)\n            connections.splice(idx, 1);\n        if (this.idbdb) {\n            try {\n                this.idbdb.close();\n            }\n            catch (e) { }\n            this._novip.idbdb = null;\n        }\n        state.dbReadyPromise = new DexiePromise(function (resolve) {\n            state.dbReadyResolve = resolve;\n        });\n        state.openCanceller = new DexiePromise(function (_, reject) {\n            state.cancelOpen = reject;\n        });\n    };\n    Dexie.prototype.close = function () {\n        this._close();\n        var state = this._state;\n        this._options.autoOpen = false;\n        state.dbOpenError = new exceptions.DatabaseClosed();\n        if (state.isBeingOpened)\n            state.cancelOpen(state.dbOpenError);\n    };\n    Dexie.prototype.delete = function () {\n        var _this = this;\n        var hasArguments = arguments.length > 0;\n        var state = this._state;\n        return new DexiePromise(function (resolve, reject) {\n            var doDelete = function () {\n                _this.close();\n                var req = _this._deps.indexedDB.deleteDatabase(_this.name);\n                req.onsuccess = wrap(function () {\n                    _onDatabaseDeleted(_this._deps, _this.name);\n                    resolve();\n                });\n                req.onerror = eventRejectHandler(reject);\n                req.onblocked = _this._fireOnBlocked;\n            };\n            if (hasArguments)\n                throw new exceptions.InvalidArgument(\"Arguments not allowed in db.delete()\");\n            if (state.isBeingOpened) {\n                state.dbReadyPromise.then(doDelete);\n            }\n            else {\n                doDelete();\n            }\n        });\n    };\n    Dexie.prototype.backendDB = function () {\n        return this.idbdb;\n    };\n    Dexie.prototype.isOpen = function () {\n        return this.idbdb !== null;\n    };\n    Dexie.prototype.hasBeenClosed = function () {\n        var dbOpenError = this._state.dbOpenError;\n        return dbOpenError && (dbOpenError.name === 'DatabaseClosed');\n    };\n    Dexie.prototype.hasFailed = function () {\n        return this._state.dbOpenError !== null;\n    };\n    Dexie.prototype.dynamicallyOpened = function () {\n        return this._state.autoSchema;\n    };\n    Object.defineProperty(Dexie.prototype, \"tables\", {\n        get: function () {\n            var _this = this;\n            return keys(this._allTables).map(function (name) { return _this._allTables[name]; });\n        },\n        enumerable: false,\n        configurable: true\n    });\n    Dexie.prototype.transaction = function () {\n        var args = extractTransactionArgs.apply(this, arguments);\n        return this._transaction.apply(this, args);\n    };\n    Dexie.prototype._transaction = function (mode, tables, scopeFunc) {\n        var _this = this;\n        var parentTransaction = PSD.trans;\n        if (!parentTransaction || parentTransaction.db !== this || mode.indexOf('!') !== -1)\n            parentTransaction = null;\n        var onlyIfCompatible = mode.indexOf('?') !== -1;\n        mode = mode.replace('!', '').replace('?', '');\n        var idbMode, storeNames;\n        try {\n            storeNames = tables.map(function (table) {\n                var storeName = table instanceof _this.Table ? table.name : table;\n                if (typeof storeName !== 'string')\n                    throw new TypeError(\"Invalid table argument to Dexie.transaction(). Only Table or String are allowed\");\n                return storeName;\n            });\n            if (mode == \"r\" || mode === READONLY)\n                idbMode = READONLY;\n            else if (mode == \"rw\" || mode == READWRITE)\n                idbMode = READWRITE;\n            else\n                throw new exceptions.InvalidArgument(\"Invalid transaction mode: \" + mode);\n            if (parentTransaction) {\n                if (parentTransaction.mode === READONLY && idbMode === READWRITE) {\n                    if (onlyIfCompatible) {\n                        parentTransaction = null;\n                    }\n                    else\n                        throw new exceptions.SubTransaction(\"Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY\");\n                }\n                if (parentTransaction) {\n                    storeNames.forEach(function (storeName) {\n                        if (parentTransaction && parentTransaction.storeNames.indexOf(storeName) === -1) {\n                            if (onlyIfCompatible) {\n                                parentTransaction = null;\n                            }\n                            else\n                                throw new exceptions.SubTransaction(\"Table \" + storeName +\n                                    \" not included in parent transaction.\");\n                        }\n                    });\n                }\n                if (onlyIfCompatible && parentTransaction && !parentTransaction.active) {\n                    parentTransaction = null;\n                }\n            }\n        }\n        catch (e) {\n            return parentTransaction ?\n                parentTransaction._promise(null, function (_, reject) { reject(e); }) :\n                rejection(e);\n        }\n        var enterTransaction = enterTransactionScope.bind(null, this, idbMode, storeNames, parentTransaction, scopeFunc);\n        return (parentTransaction ?\n            parentTransaction._promise(idbMode, enterTransaction, \"lock\") :\n            PSD.trans ?\n                usePSD(PSD.transless, function () { return _this._whenReady(enterTransaction); }) :\n                this._whenReady(enterTransaction));\n    };\n    Dexie.prototype.table = function (tableName) {\n        if (!hasOwn(this._allTables, tableName)) {\n            throw new exceptions.InvalidTable(\"Table \" + tableName + \" does not exist\");\n        }\n        return this._allTables[tableName];\n    };\n    return Dexie;\n}());\n\nvar symbolObservable = typeof Symbol !== \"undefined\" && \"observable\" in Symbol\n    ? Symbol.observable\n    : \"@@observable\";\nvar Observable =  (function () {\n    function Observable(subscribe) {\n        this._subscribe = subscribe;\n    }\n    Observable.prototype.subscribe = function (x, error, complete) {\n        return this._subscribe(!x || typeof x === \"function\" ? { next: x, error: error, complete: complete } : x);\n    };\n    Observable.prototype[symbolObservable] = function () {\n        return this;\n    };\n    return Observable;\n}());\n\nfunction extendObservabilitySet(target, newSet) {\n    keys(newSet).forEach(function (part) {\n        var rangeSet = target[part] || (target[part] = new RangeSet());\n        mergeRanges(rangeSet, newSet[part]);\n    });\n    return target;\n}\n\nfunction liveQuery(querier) {\n    return new Observable(function (observer) {\n        var scopeFuncIsAsync = isAsyncFunction(querier);\n        function execute(subscr) {\n            if (scopeFuncIsAsync) {\n                incrementExpectedAwaits();\n            }\n            var exec = function () { return newScope(querier, { subscr: subscr, trans: null }); };\n            var rv = PSD.trans\n                ?\n                    usePSD(PSD.transless, exec)\n                : exec();\n            if (scopeFuncIsAsync) {\n                rv.then(decrementExpectedAwaits, decrementExpectedAwaits);\n            }\n            return rv;\n        }\n        var closed = false;\n        var accumMuts = {};\n        var currentObs = {};\n        var subscription = {\n            get closed() {\n                return closed;\n            },\n            unsubscribe: function () {\n                closed = true;\n                globalEvents.storagemutated.unsubscribe(mutationListener);\n            },\n        };\n        observer.start && observer.start(subscription);\n        var querying = false, startedListening = false;\n        function shouldNotify() {\n            return keys(currentObs).some(function (key) {\n                return accumMuts[key] && rangesOverlap(accumMuts[key], currentObs[key]);\n            });\n        }\n        var mutationListener = function (parts) {\n            extendObservabilitySet(accumMuts, parts);\n            if (shouldNotify()) {\n                doQuery();\n            }\n        };\n        var doQuery = function () {\n            if (querying || closed)\n                return;\n            accumMuts = {};\n            var subscr = {};\n            var ret = execute(subscr);\n            if (!startedListening) {\n                globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, mutationListener);\n                startedListening = true;\n            }\n            querying = true;\n            Promise.resolve(ret).then(function (result) {\n                querying = false;\n                if (closed)\n                    return;\n                if (shouldNotify()) {\n                    doQuery();\n                }\n                else {\n                    accumMuts = {};\n                    currentObs = subscr;\n                    observer.next && observer.next(result);\n                }\n            }, function (err) {\n                querying = false;\n                observer.error && observer.error(err);\n                subscription.unsubscribe();\n            });\n        };\n        doQuery();\n        return subscription;\n    });\n}\n\nvar domDeps;\ntry {\n    domDeps = {\n        indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,\n        IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange\n    };\n}\ncatch (e) {\n    domDeps = { indexedDB: null, IDBKeyRange: null };\n}\n\nvar Dexie = Dexie$1;\nprops(Dexie, __assign(__assign({}, fullNameExceptions), {\n    delete: function (databaseName) {\n        var db = new Dexie(databaseName, { addons: [] });\n        return db.delete();\n    },\n    exists: function (name) {\n        return new Dexie(name, { addons: [] }).open().then(function (db) {\n            db.close();\n            return true;\n        }).catch('NoSuchDatabaseError', function () { return false; });\n    },\n    getDatabaseNames: function (cb) {\n        try {\n            return getDatabaseNames(Dexie.dependencies).then(cb);\n        }\n        catch (_a) {\n            return rejection(new exceptions.MissingAPI());\n        }\n    },\n    defineClass: function () {\n        function Class(content) {\n            extend(this, content);\n        }\n        return Class;\n    }, ignoreTransaction: function (scopeFunc) {\n        return PSD.trans ?\n            usePSD(PSD.transless, scopeFunc) :\n            scopeFunc();\n    }, vip: vip, async: function (generatorFn) {\n        return function () {\n            try {\n                var rv = awaitIterator(generatorFn.apply(this, arguments));\n                if (!rv || typeof rv.then !== 'function')\n                    return DexiePromise.resolve(rv);\n                return rv;\n            }\n            catch (e) {\n                return rejection(e);\n            }\n        };\n    }, spawn: function (generatorFn, args, thiz) {\n        try {\n            var rv = awaitIterator(generatorFn.apply(thiz, args || []));\n            if (!rv || typeof rv.then !== 'function')\n                return DexiePromise.resolve(rv);\n            return rv;\n        }\n        catch (e) {\n            return rejection(e);\n        }\n    },\n    currentTransaction: {\n        get: function () { return PSD.trans || null; }\n    }, waitFor: function (promiseOrFunction, optionalTimeout) {\n        var promise = DexiePromise.resolve(typeof promiseOrFunction === 'function' ?\n            Dexie.ignoreTransaction(promiseOrFunction) :\n            promiseOrFunction)\n            .timeout(optionalTimeout || 60000);\n        return PSD.trans ?\n            PSD.trans.waitFor(promise) :\n            promise;\n    },\n    Promise: DexiePromise,\n    debug: {\n        get: function () { return debug; },\n        set: function (value) {\n            setDebug(value, value === 'dexie' ? function () { return true; } : dexieStackFrameFilter);\n        }\n    },\n    derive: derive, extend: extend, props: props, override: override,\n    Events: Events, on: globalEvents, liveQuery: liveQuery, extendObservabilitySet: extendObservabilitySet,\n    getByKeyPath: getByKeyPath, setByKeyPath: setByKeyPath, delByKeyPath: delByKeyPath, shallowClone: shallowClone, deepClone: deepClone, getObjectDiff: getObjectDiff, cmp: cmp, asap: asap$1,\n    minKey: minKey,\n    addons: [],\n    connections: connections,\n    errnames: errnames,\n    dependencies: domDeps,\n    semVer: DEXIE_VERSION, version: DEXIE_VERSION.split('.')\n        .map(function (n) { return parseInt(n); })\n        .reduce(function (p, c, i) { return p + (c / Math.pow(10, i * 2)); }) }));\nDexie.maxKey = getMaxKey(Dexie.dependencies.IDBKeyRange);\n\nif (typeof dispatchEvent !== 'undefined' && typeof addEventListener !== 'undefined') {\n    globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, function (updatedParts) {\n        if (!propagatingLocally) {\n            var event_1;\n            if (isIEOrEdge) {\n                event_1 = document.createEvent('CustomEvent');\n                event_1.initCustomEvent(STORAGE_MUTATED_DOM_EVENT_NAME, true, true, updatedParts);\n            }\n            else {\n                event_1 = new CustomEvent(STORAGE_MUTATED_DOM_EVENT_NAME, {\n                    detail: updatedParts\n                });\n            }\n            propagatingLocally = true;\n            dispatchEvent(event_1);\n            propagatingLocally = false;\n        }\n    });\n    addEventListener(STORAGE_MUTATED_DOM_EVENT_NAME, function (_a) {\n        var detail = _a.detail;\n        if (!propagatingLocally) {\n            propagateLocally(detail);\n        }\n    });\n}\nfunction propagateLocally(updateParts) {\n    var wasMe = propagatingLocally;\n    try {\n        propagatingLocally = true;\n        globalEvents.storagemutated.fire(updateParts);\n    }\n    finally {\n        propagatingLocally = wasMe;\n    }\n}\nvar propagatingLocally = false;\n\nif (typeof BroadcastChannel !== 'undefined') {\n    var bc_1 = new BroadcastChannel(STORAGE_MUTATED_DOM_EVENT_NAME);\n    if (typeof bc_1.unref === 'function') {\n        bc_1.unref();\n    }\n    globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, function (changedParts) {\n        if (!propagatingLocally) {\n            bc_1.postMessage(changedParts);\n        }\n    });\n    bc_1.onmessage = function (ev) {\n        if (ev.data)\n            propagateLocally(ev.data);\n    };\n}\nelse if (typeof self !== 'undefined' && typeof navigator !== 'undefined') {\n    globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, function (changedParts) {\n        try {\n            if (!propagatingLocally) {\n                if (typeof localStorage !== 'undefined') {\n                    localStorage.setItem(STORAGE_MUTATED_DOM_EVENT_NAME, JSON.stringify({\n                        trig: Math.random(),\n                        changedParts: changedParts,\n                    }));\n                }\n                if (typeof self['clients'] === 'object') {\n                    __spreadArray([], self['clients'].matchAll({ includeUncontrolled: true }), true).forEach(function (client) {\n                        return client.postMessage({\n                            type: STORAGE_MUTATED_DOM_EVENT_NAME,\n                            changedParts: changedParts,\n                        });\n                    });\n                }\n            }\n        }\n        catch (_a) { }\n    });\n    if (typeof addEventListener !== 'undefined') {\n        addEventListener('storage', function (ev) {\n            if (ev.key === STORAGE_MUTATED_DOM_EVENT_NAME) {\n                var data = JSON.parse(ev.newValue);\n                if (data)\n                    propagateLocally(data.changedParts);\n            }\n        });\n    }\n    var swContainer = self.document && navigator.serviceWorker;\n    if (swContainer) {\n        swContainer.addEventListener('message', propagateMessageLocally);\n    }\n}\nfunction propagateMessageLocally(_a) {\n    var data = _a.data;\n    if (data && data.type === STORAGE_MUTATED_DOM_EVENT_NAME) {\n        propagateLocally(data.changedParts);\n    }\n}\n\nDexiePromise.rejectionMapper = mapError;\nsetDebug(debug, dexieStackFrameFilter);\n\nexport { Dexie$1 as Dexie, RangeSet, Dexie$1 as default, liveQuery, mergeRanges, rangesOverlap };\n//# sourceMappingURL=dexie.mjs.map\n","import Dexie from 'dexie'\n\nexport const db = new Dexie('pushDatabase')\nexport const bm = new Dexie('bookmarksDatabase')\n\ndb.version(1).stores({\n  messages: '++id, uuid'\n})\n\nbm.version(1).stores({\n  messages: '++id, uuid, article'\n})\n","\nimport React, { useState, useEffect, Fragment } from 'react'\nimport { connect } from 'react-redux'\nimport { bindActionCreators } from 'redux'\nimport axios from 'axios'\nimport { Link } from 'react-router-dom'\nimport { urlB64ToUint8Array } from '../components/ServiceWorker'\nimport qs from 'qs'\n\nimport { fetchArticleAPI } from '../../store/article'\nimport { getImageSize, getImage, getCanonical } from '../components/ui/articleutils'\nimport { isBrowser, setCookie } from '../components/ui/utils'\nimport { formatAgo } from '../components/ui/dateutils'\nimport { ImageOrNoImage } from 'ion-image'\nimport Popup from 'ion-popup'\nimport popupLogo from '../static/general/hag-popup.svg'\nimport NoImage from '../static/no-image.png'\nimport NotificationImg from '../static/general/hag-static-page.jpg'\nimport StyledLink from '../components/StyledLink'\nimport { db } from '../db'\n\nconst NotifiedArticles = ({ uuids }) => {\n  const [articles, setArticles] = useState([])\n  useEffect(() => {\n    const fetchArticles = async () => {\n      const articles = await Promise.all(uuids.map(uuid => fetchArticleAPI(uuid)))\n      setArticles(articles)\n    }\n    fetchArticles()\n  }, [uuids])\n  return (\n    <div>\n      <div className='notifications-articles'>\n        {articles.map((article, index) => (\n          <Fragment key={index}>\n            <article key={article.uuid}>\n              <StyledLink keyProp={article.uuid} to={'/' + getCanonical(article)} display='grid' gap={20} gridTemplateColumns='auto 80px'>\n                <div>\n                  <h6>{article.headline}</h6>\n                  <p>By {article.author} | Published {formatAgo(article.published, true)}</p>\n                </div>\n                <div>\n                  <ImageOrNoImage image={getImage(article)} width={getImageSize('push')} alt={article.headline} shape='square' noImage={NoImage} />\n                </div>\n              </StyledLink>\n            </article>\n          </Fragment>\n        ))}\n      </div>\n    </div>\n  )\n}\n\nfunction subscribeConcept (registration, setSubscription, setHelpPopupVisible) {\n  if (registration) {\n    registration.pushManager.subscribe({\n      userVisibleOnly: true,\n      applicationServerKey: urlB64ToUint8Array(process.env.RAZZLE_SERVERKEY)\n    })\n      .then(function (subscription) {\n        console.log('User IS now subscribed.')\n        setSubscription(subscription)\n      })\n      .catch(function (err) {\n        console.log('Failed to subscribe the user: ', err)\n        setHelpPopupVisible(true)\n        setSubscription(false)\n      })\n  }\n}\n\nconst TopicItem = ({ topic, subscription, subscribed, toggleSubscribed, registration, setSubscription, setHelpPopupVisible }) => {\n  const handleOnChange = () => {\n    if (navigator) {\n      navigator.permissions.query({\n        name: 'notifications'\n      }).then((result) => {\n        if (result.state === 'denied' || result.state === 'prompt') {\n          setHelpPopupVisible(true)\n        } else {\n          if (!subscription) {\n            subscribeConcept(registration, setSubscription, setHelpPopupVisible)\n          } else {\n            const data = {\n              topic: topic.topic,\n              titleKey: process.env.RAZZLE_TITLE_KEY,\n              subscription: JSON.stringify(subscription)\n            }\n            axios.post(process.env.RAZZLE_PUSH_SERVICE + (subscribed ? '/unsubscribe' : '/subscribe'), qs.stringify(data), {\n              headers: {\n                'Content-Type': 'application/x-www-form-urlencoded'\n              }\n            })\n              .then(res => toggleSubscribed(topic))\n              .catch(error => {\n                console.log(subscribed ? 'Unsubscribe' : 'Subscribe', 'Error:', error.message)\n                return false\n              })\n          }\n        }\n      })\n    }\n  }\n  return (\n    <div>\n      <label htmlFor={topic.name} position='relative'>\n        {topic.name === 'General' ? 'Recent Stories' : topic.name}\n        <div className='switch'>\n          <input id={topic.name} type='checkbox' onChange={handleOnChange} checked={subscribed} />\n          <span className='slider' />\n        </div>\n      </label>\n    </div>\n  )\n}\n\nconst PrivatePushNotificationsManagementPage = props => {\n  const [topicsDict, setTopicsDict] = useState([])\n  const [subscribed, setSubscribed] = useState(new Map())\n  const [pushedArticles, setPushedArticles] = useState([])\n  const [subscription, setSubscription] = useState(false)\n  const [registration, setRegistration] = useState(false)\n  const [helpPopupVisible, setHelpPopupVisible] = useState(false)\n  const generalTopic = { topic: 'General', type: 'Notification', name: 'General' }\n\n  useEffect(() => {\n    if (navigator.serviceWorker) {\n      navigator.serviceWorker.getRegistration()\n        .then(reg => {\n          setRegistration(reg)\n        })\n    }\n  }, [])\n\n  useEffect(() => {\n    if (registration && registration.pushManager) {\n      registration.pushManager.getSubscription()\n        .then(sub => {\n          setSubscription(sub)\n        })\n    }\n  }, [registration])\n\n  useEffect(() => {\n    db.messages.reverse().toArray().then(articles => setPushedArticles(articles.map(article => article.uuid)))\n    setCookie('NotificationsLastViewed', new Date().toISOString(), { days: 30 })\n  }, [])\n\n  useEffect(() => {\n    const data = qs.stringify({\n      titleKey: process.env.RAZZLE_TITLE_KEY,\n      endpoint: (subscription && subscription.endpoint) || ''\n    })\n    axios.post(process.env.RAZZLE_PUSH_SERVICE + '/topics', data, {\n      headers: {\n        'Content-Type': 'application/x-www-form-urlencoded'\n      }\n    })\n      .then(res => {\n        const toggleSliders = new Map()\n        res.data.map(topic => {\n          toggleSliders.set(topic.topic, true)\n          return topic\n        })\n        setSubscribed(toggleSliders)\n        const dict = res.data.reduce((previousTopic, currentTopic, index) => {\n          const firstType = currentTopic.type\n          if (previousTopic[firstType]) {\n            previousTopic[firstType].push(currentTopic)\n          } else {\n            previousTopic[firstType] = [currentTopic]\n          }\n          return previousTopic\n        }, {})\n        return setTopicsDict(dict)\n      })\n  }, [subscription])\n\n  const handleUnfollowAll = async (topics, subscription) => {\n    const newSubscribed = new Map(subscribed)\n    await Promise.all(topics.map(async (topic) => {\n      const data = {\n        topic: topic.topic,\n        titleKey: process.env.RAZZLE_TITLE_KEY,\n        subscription: JSON.stringify(subscription)\n      }\n      await axios.post(process.env.RAZZLE_PUSH_SERVICE + '/unsubscribe', qs.stringify(data), {\n        headers: {\n          'Content-Type': 'application/x-www-form-urlencoded'\n        }\n      })\n        .then(res => {\n          return newSubscribed.set(topic.topic, false)\n        })\n        .catch(error => {\n          console.log('Unsubscribe Error:', error.message)\n          return false\n        })\n    }))\n    return setSubscribed(newSubscribed)\n  }\n\n  function toggleSubscribed (topic) {\n    const newSubscribed = new Map(subscribed)\n    newSubscribed.set(topic.topic, !(newSubscribed.get(topic.topic)))\n    setSubscribed(newSubscribed)\n  }\n\n  return (\n    <>\n      {helpPopupVisible &&\n        <Popup visible>\n          <div className='push-notification'>\n            <div>\n              <img src={popupLogo} alt={process.env.RAZZLE_SITE_NAME} />\n            </div>\n            <div color='grey'>\n              <p>Small problem..</p>\n              <p>You have chosen to block notifications.</p>\n              <p>To follow stories requires you to enable notifications in your browser settings.</p>\n              <div display='flex' justifycontent='flex-end'>\n                <Link onClick={() => setHelpPopupVisible(false)} to='/help'>Help</Link>\n                <button onClick={() => setHelpPopupVisible(false)}>OK</button>\n              </div>\n            </div>\n          </div>\n        </Popup>}\n      <div className='wrapper'>\n        <h1>My Notifications</h1>\n        <img src={NotificationImg} alt='' />\n        <NotifiedArticles uuids={pushedArticles} />\n        <div>\n          <div className='notifications-section-h2'>\n            <h2>Notification Followed</h2>\n          </div>\n          <div className='notifications-list'>\n            <TopicItem key={generalTopic.topic} topic={generalTopic} registration={registration} subscription={subscription} setSubscription={setSubscription} subscribed={subscribed && !!subscribed.get(generalTopic.topic)} setHelpPopupVisible={setHelpPopupVisible} toggleSubscribed={() => toggleSubscribed(generalTopic)} />\n          </div>\n        </div>\n        {topicsDict && Object.keys(topicsDict).sort().map((topicType, index) => {\n          return (\n            <Fragment key={topicType}>\n              {topicType !== 'Notification' &&\n                <div>\n                  <div className='notifications-section-h2'>\n                    <h2>{topicType.replace(/y$/, 'ie')}s Followed</h2>\n                    <button className='follow-me-btn' onClick={() => { handleUnfollowAll(topicsDict[topicType], subscription) }}>Unfollow All {topicType.replace(/y$/, 'ie')}s</button>\n                  </div>\n                  <div className='notifications-list'>\n                    {topicsDict[topicType].map((topic) =>\n                      <TopicItem key={topic.topic} topic={topic} registration={registration} subscription={subscription} setSubscription={setSubscription} subscribed={subscribed && !!subscribed.get(topic.topic)} setHelpPopupVisible={setHelpPopupVisible} toggleSubscribed={() => toggleSubscribed(topic)} />\n                    )}\n                  </div>\n                </div>}\n            </Fragment>\n          )\n        })}\n        {/* If no subscriptions or you are only subscribed to General */}\n        {topicsDict && (Object.keys(topicsDict).filter(item => item !== 'Notification').length < 1) &&\n          <div className='static-page'>\n            <div>\n              <h2>You are not following any authors or topics.</h2>\n              <p>If you would like to be notified when a new article is published by your preferred author, or on your topic of interest, then you can do this by following that author or topic.</p>\n              <p>On an article, click on the author's link, or on the topic at the bottom of the article, and from there, click to follow.</p>\n            </div>\n          </div>}\n      </div>\n    </>\n  )\n}\n\nconst PushNotificationsManagementPage = (props) => {\n  if (isBrowser) {\n    return <PrivatePushNotificationsManagementPage {...props} />\n  } else {\n    return null\n  }\n}\n\nconst mapStateToProps = (state) => ({})\nconst mapDispatchToProps = (dispatch) => bindActionCreators({ fetchArticleAPI }, dispatch)\n\nexport default connect(mapStateToProps, mapDispatchToProps)(PushNotificationsManagementPage)\n","module.exports = __webpack_public_path__ + \"static/media/hag-static-page.cb6817ac.jpg\";","import React, { useState, useEffect, Fragment } from 'react'\nimport { connect } from 'react-redux'\nimport { bindActionCreators } from 'redux'\nimport { withRouter } from 'react-router'\n\nimport { sectionPageView } from '../../store/app'\nimport { getCanonical, getImageSize, getImage } from '../components/ui/articleutils'\nimport { formatAgo } from '../components/ui/dateutils'\nimport { ImageOrNoImage } from 'ion-image'\nimport NoImage from '../static/no-image.png'\nimport BookmarkImg from '../static/general/hag-static-page.jpg'\nimport StyledLink from '../components/StyledLink'\nimport { bm } from '../db'\n\nconst BookmarkedArticles = ({ articles }) => {\n  return (\n    <div>\n      <div className='notifications-articles'>\n        {articles.map((article, index) => (\n          <Fragment key={index}>\n            <article key={article.uuid}>\n              <StyledLink to={'/' + getCanonical(article)} display='flex'>\n                <div>\n                  <h6>{article.headline}</h6>\n                  <p>By {article.author} | Published {formatAgo(article.published, true)}</p>\n                </div>\n                <div>\n                  <ImageOrNoImage image={getImage(article)} width={getImageSize('push')} alt={article.headline} shape='square' noImage={NoImage} />\n                </div>\n              </StyledLink>\n            </article>\n          </Fragment>\n        ))}\n      </div>\n    </div>\n  )\n}\n\nconst BookmarksPage = props => {\n  const [bookmarkedArticles, setBookmarkedArticles] = useState([])\n  useEffect(() => {\n    bm.messages.reverse().toArray().then(entries => setBookmarkedArticles(entries.map(entry => entry.article)))\n  }, [])\n  useEffect(() => {\n    if (('/' + props.section) === props.location.pathname) {\n      props.sectionPageView(props.location.pathname)\n    }\n  }, [props.section])\n  return (\n    <div className='wrapper'>\n      <img src={BookmarkImg} alt='' />\n      <h1>My Bookmarked Articles</h1>\n      {bookmarkedArticles && bookmarkedArticles.length > 0 &&\n        <BookmarkedArticles articles={bookmarkedArticles} />}\n      {bookmarkedArticles && bookmarkedArticles.length < 1 &&\n        <div className='static-page'>\n          <p>You are able to bookmark articles for offline or later reading.</p>\n          <p>The site header has a bookmark icon available when you are on an article. Clicking on that icon adds the article to your store.</p>\n        </div>}\n    </div>\n  )\n}\n\nconst mapDispatchToProps = (dispatch) => bindActionCreators({ sectionPageView }, dispatch)\n\nexport default withRouter(connect(mapDispatchToProps)(BookmarksPage))\n","import Urlify from 'urlify'\n\nconst urlify = Urlify.create({\n  addEToUmlauts: true,\n  szToSs: true,\n  spaces: '-',\n  nonPrintable: '',\n  toLower: true,\n  trim: false\n})\n\nconst ImageSizes = {\n  hero: 560,\n  featured: 800,\n  primary: 240,\n  slider: 275,\n  normal: 100,\n  push: 80\n}\n\nexport function getCanonical (article) {\n  if (!article.headline) {\n    return article.contentKey\n  }\n  return article.section + '/' + urlify(article.headline.replace(/&/g, '-and-')).replace(/-+/g, '-') + '-' + article.contentKey\n}\n\nexport function getImageSize (size) {\n  const ImageSize = ImageSizes[size] || size\n  return ImageSize\n}\n\nexport function getImage (article) {\n  const Image = article.image || (article.images && article.images[0]) || (article.videos && { url: article.videos[0].thumbnailURL })\n  return Image\n}\n/**\n * Returns the teaser headline to be used in article cards, social shares etc.\n *\n * @param {*} article An article to retrieve the headline from\n * @returns The headline to use\n */\nexport function getTeaser (article) {\n  return article.teaserHeadline\n}\n","// import styled, { system } from '@xstyled/styled-components'\nimport { Link } from 'react-router-dom'\n\nconst StyledLink = ({ className, to, keyProp, replace, onClick, children }) => <Link key={keyProp} to={to} replace={replace} onClick={onClick} className={className}>{children}</Link>\n\n// const StyledLink = styled(MyLink)`\n//   ${system}\n// `\n\nexport default StyledLink\n"],"sourceRoot":""}