/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var KJ=Object.create;var xQ=Object.defineProperty,gJ=Object.defineProperties,PJ=Object.getOwnPropertyDescriptor,qJ=Object.getOwnPropertyDescriptors,_J=Object.getOwnPropertyNames,zB=Object.getOwnPropertySymbols,AJ=Object.getPrototypeOf,FV=Object.prototype.hasOwnProperty,hd=Object.prototype.propertyIsEnumerable;var cd=(F,U,Q)=>U in F?xQ(F,U,{enumerable:!0,configurable:!0,writable:!0,value:Q}):F[U]=Q,z=(F,U)=>{for(var Q in U||(U={}))FV.call(U,Q)&&cd(F,Q,U[Q]);if(zB)for(var Q of zB(U))hd.call(U,Q)&&cd(F,Q,U[Q]);return F},q=(F,U)=>gJ(F,qJ(U)),rd=F=>xQ(F,"__esModule",{value:!0});var Cd=(F,U)=>{var Q={};for(var B in F)FV.call(F,B)&&U.indexOf(B)<0&&(Q[B]=F[B]);if(F!=null&&zB)for(var B of zB(F))U.indexOf(B)<0&&hd.call(F,B)&&(Q[B]=F[B]);return Q};var $J=(F,U)=>()=>(U||F((U={exports:{}}).exports,U),U.exports),UW=(F,U)=>{rd(F);for(var Q in U)xQ(F,Q,{get:U[Q],enumerable:!0})},FW=(F,U,Q)=>{if(U&&typeof U=="object"||typeof U=="function")for(let B of _J(U))!FV.call(F,B)&&B!=="default"&&xQ(F,B,{get:()=>U[B],enumerable:!(Q=PJ(U,B))||Q.enumerable});return F},XU=F=>FW(rd(xQ(F!=null?KJ(AJ(F)):{},"default",F&&F.__esModule&&"default"in F?{get:()=>F.default,enumerable:!0}:{value:F,enumerable:!0})),F);var Gl=$J((eB,V0)=>{(function(F,U){if(typeof eB=="object"&&typeof V0=="object")V0.exports=U();else if(typeof define=="function"&&define.amd)define([],U);else{var Q=U();for(var B in Q)(typeof eB=="object"?eB:F)[B]=Q[B]}})(typeof self!="undefined"?self:eB,function(){return function(F){var U={};function Q(B){if(U[B])return U[B].exports;var R=U[B]={i:B,l:!1,exports:{}};return F[B].call(R.exports,R,R.exports,Q),R.l=!0,R.exports}return Q.m=F,Q.c=U,Q.d=function(B,R,V){Q.o(B,R)||Object.defineProperty(B,R,{enumerable:!0,get:V})},Q.r=function(B){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(B,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(B,"__esModule",{value:!0})},Q.t=function(B,R){if(1&R&&(B=Q(B)),8&R||4&R&&typeof B=="object"&&B&&B.__esModule)return B;var V=Object.create(null);if(Q.r(V),Object.defineProperty(V,"default",{enumerable:!0,value:B}),2&R&&typeof B!="string")for(var d in B)Q.d(V,d,function(l){return B[l]}.bind(null,d));return V},Q.n=function(B){var R=B&&B.__esModule?function(){return B.default}:function(){return B};return Q.d(R,"a",R),R},Q.o=function(B,R){return Object.prototype.hasOwnProperty.call(B,R)},Q.p="",Q(Q.s=0)}([function(F,U,Q){"use strict";Q.r(U),Q.d(U,"md5",function(){return c});var B="0123456789abcdef".split(""),R=function(h){for(var N="",k=0;k<4;k++)N+=B[h>>8*k+4&15]+B[h>>8*k&15];return N},V=function(h){for(var N=h.length,k=0;k>>32-D,p)}(N=function(C,D,p,o){return D=d(d(D,C),d(p,o))}(h,N,t,a),S,k)},n=function(h,N,k,t,S,a,T,C){return l(k&t|~k&S,N,k,a,T,C,h)},J=function(h,N,k,t,S,a,T,C){return l(k&S|t&~S,N,k,a,T,C,h)},W=function(h,N,k,t,S,a,T,C){return l(k^t^S,N,k,a,T,C,h)},E=function(h,N,k,t,S,a,T,C){return l(t^(k|~S),N,k,a,T,C,h)},Z=function(h,N,k){k===void 0&&(k=d);var t=h[0],S=h[1],a=h[2],T=h[3],C=n.bind(null,k);t=C(t,S,a,T,N[0],7,-680876936),T=C(T,t,S,a,N[1],12,-389564586),a=C(a,T,t,S,N[2],17,606105819),S=C(S,a,T,t,N[3],22,-1044525330),t=C(t,S,a,T,N[4],7,-176418897),T=C(T,t,S,a,N[5],12,1200080426),a=C(a,T,t,S,N[6],17,-1473231341),S=C(S,a,T,t,N[7],22,-45705983),t=C(t,S,a,T,N[8],7,1770035416),T=C(T,t,S,a,N[9],12,-1958414417),a=C(a,T,t,S,N[10],17,-42063),S=C(S,a,T,t,N[11],22,-1990404162),t=C(t,S,a,T,N[12],7,1804603682),T=C(T,t,S,a,N[13],12,-40341101),a=C(a,T,t,S,N[14],17,-1502002290),S=C(S,a,T,t,N[15],22,1236535329);var D=J.bind(null,k);t=D(t,S,a,T,N[1],5,-165796510),T=D(T,t,S,a,N[6],9,-1069501632),a=D(a,T,t,S,N[11],14,643717713),S=D(S,a,T,t,N[0],20,-373897302),t=D(t,S,a,T,N[5],5,-701558691),T=D(T,t,S,a,N[10],9,38016083),a=D(a,T,t,S,N[15],14,-660478335),S=D(S,a,T,t,N[4],20,-405537848),t=D(t,S,a,T,N[9],5,568446438),T=D(T,t,S,a,N[14],9,-1019803690),a=D(a,T,t,S,N[3],14,-187363961),S=D(S,a,T,t,N[8],20,1163531501),t=D(t,S,a,T,N[13],5,-1444681467),T=D(T,t,S,a,N[2],9,-51403784),a=D(a,T,t,S,N[7],14,1735328473),S=D(S,a,T,t,N[12],20,-1926607734);var p=W.bind(null,k);t=p(t,S,a,T,N[5],4,-378558),T=p(T,t,S,a,N[8],11,-2022574463),a=p(a,T,t,S,N[11],16,1839030562),S=p(S,a,T,t,N[14],23,-35309556),t=p(t,S,a,T,N[1],4,-1530992060),T=p(T,t,S,a,N[4],11,1272893353),a=p(a,T,t,S,N[7],16,-155497632),S=p(S,a,T,t,N[10],23,-1094730640),t=p(t,S,a,T,N[13],4,681279174),T=p(T,t,S,a,N[0],11,-358537222),a=p(a,T,t,S,N[3],16,-722521979),S=p(S,a,T,t,N[6],23,76029189),t=p(t,S,a,T,N[9],4,-640364487),T=p(T,t,S,a,N[12],11,-421815835),a=p(a,T,t,S,N[15],16,530742520),S=p(S,a,T,t,N[2],23,-995338651);var o=E.bind(null,k);t=o(t,S,a,T,N[0],6,-198630844),T=o(T,t,S,a,N[7],10,1126891415),a=o(a,T,t,S,N[14],15,-1416354905),S=o(S,a,T,t,N[5],21,-57434055),t=o(t,S,a,T,N[12],6,1700485571),T=o(T,t,S,a,N[3],10,-1894986606),a=o(a,T,t,S,N[10],15,-1051523),S=o(S,a,T,t,N[1],21,-2054922799),t=o(t,S,a,T,N[8],6,1873313359),T=o(T,t,S,a,N[15],10,-30611744),a=o(a,T,t,S,N[6],15,-1560198380),S=o(S,a,T,t,N[13],21,1309151649),t=o(t,S,a,T,N[4],6,-145523070),T=o(T,t,S,a,N[11],10,-1120210379),a=o(a,T,t,S,N[2],15,718787259),S=o(S,a,T,t,N[9],21,-343485551),h[0]=k(t,h[0]),h[1]=k(S,h[1]),h[2]=k(a,h[2]),h[3]=k(T,h[3])},e=function(h){for(var N=[],k=0;k<64;k+=4)N[k>>2]=h.charCodeAt(k)+(h.charCodeAt(k+1)<<8)+(h.charCodeAt(k+2)<<16)+(h.charCodeAt(k+3)<<24);return N},r=function(h,N){var k,t=h.length,S=[1732584193,-271733879,-1732584194,271733878];for(k=64;k<=t;k+=64)Z(S,e(h.substring(k-64,k)),N);var a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],T=(h=h.substring(k-64)).length;for(k=0;k>2]|=h.charCodeAt(k)<<(k%4<<3);if(a[k>>2]|=128<<(k%4<<3),k>55)for(Z(S,a,N),k=16;k--;)a[k]=0;return a[14]=8*t,Z(S,a,N),S};function c(h){var N;return V(r("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(N=function(k,t){var S=(65535&k)+(65535&t);return(k>>16)+(t>>16)+(S>>16)<<16|65535&S}),V(r(h,N))}}])})});UW(exports,{default:()=>Td});var uF=XU(require("obsidian"));var fJ=XU(require("obsidian"));function tU(){}function QW(F,U){for(let Q in U)F[Q]=U[Q];return F}function QV(F){return F()}function Dd(){return Object.create(null)}function gU(F){F.forEach(QV)}function wQ(F){return typeof F=="function"}function rU(F,U){return F!=F?U==U:F!==U||F&&typeof F=="object"||typeof F=="function"}var uB;function BV(F,U){return uB||(uB=document.createElement("a")),uB.href=U,F===uB.href}function pd(F){return Object.keys(F).length===0}function md(F,...U){if(F==null)return tU;let Q=F.subscribe(...U);return Q.unsubscribe?()=>Q.unsubscribe():Q}function xB(F,U,Q){F.$$.on_destroy.push(md(U,Q))}function NQ(F,U,Q,B){if(F){let R=Md(F,U,Q,B);return F[0](R)}}function Md(F,U,Q,B){return F[1]&&B?QW(Q.ctx.slice(),F[1](B(U))):Q.ctx}function EQ(F,U,Q,B){if(F[2]&&B){let R=F[2](B(Q));if(U.dirty===void 0)return R;if(typeof R=="object"){let V=[],d=Math.max(U.dirty.length,R.length);for(let l=0;l32){let U=[],Q=F.ctx.length/32;for(let B=0;BF.removeEventListener(U,Q,B)}function P(F,U,Q){Q==null?F.removeAttribute(U):F.getAttribute(U)!==Q&&F.setAttribute(U,Q)}function VW(F){return Array.from(F.childNodes)}function jQ(F,U){U=""+U,F.wholeText!==U&&(F.data=U)}function RV(F,U){F.value=U??""}function UF(F,U,Q,B){Q===null?F.style.removeProperty(U):F.style.setProperty(U,Q,B?"important":"")}function VV(F,U,Q){F.classList[Q?"add":"remove"](U)}function dW(F,U,{bubbles:Q=!1,cancelable:B=!1}={}){let R=document.createEvent("CustomEvent");return R.initCustomEvent(F,Q,B,U),R}var IQ;function fQ(F){IQ=F}function dV(){if(!IQ)throw new Error("Function called outside component initialization");return IQ}function KQ(F){dV().$$.on_mount.push(F)}function gQ(F){dV().$$.on_destroy.push(F)}function lV(){let F=dV();return(U,Q,{cancelable:B=!1}={})=>{let R=F.$$.callbacks[U];if(R){let V=dW(U,Q,{cancelable:B});return R.slice().forEach(d=>{d.call(F,V)}),!V.defaultPrevented}return!0}}function FF(F,U){let Q=F.$$.callbacks[U.type];Q&&Q.slice().forEach(B=>B.call(this,U))}var PQ=[];var LB=[],jB=[],id=[],sd=Promise.resolve(),nV=!1;function Yd(){nV||(nV=!0,sd.then(yd))}function lF(){return Yd(),sd}function JV(F){jB.push(F)}var WV=new Set,IB=0;function yd(){let F=IQ;do{for(;IB{fB.delete(F),B&&(Q&&F.d(1),B())}),F.o(U)}else B&&B()}var PE=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;function OU(F){F&&F.c()}function YU(F,U,Q,B){let{fragment:R,after_update:V}=F.$$;R&&R.m(U,Q),B||JV(()=>{let d=F.$$.on_mount.map(QV).filter(wQ);F.$$.on_destroy?F.$$.on_destroy.push(...d):gU(d),F.$$.on_mount=[]}),V.forEach(JV)}function pU(F,U){let Q=F.$$;Q.fragment!==null&&(gU(Q.on_destroy),Q.fragment&&Q.fragment.d(U),Q.on_destroy=Q.fragment=null,Q.ctx=[])}function nW(F,U){F.$$.dirty[0]===-1&&(PQ.push(F),Yd(),F.$$.dirty.fill(0)),F.$$.dirty[U/31|0]|=1<{let r=e.length?e[0]:Z;return J.ctx&&R(J.ctx[E],J.ctx[E]=r)&&(!J.skip_bound&&J.bound[E]&&J.bound[E](r),W&&nW(F,E)),Z}):[],J.update(),W=!0,gU(J.before_update),J.fragment=B?B(J.ctx):!1,U.target){if(U.hydrate){BW();let E=VW(U.target);J.fragment&&J.fragment.l(E),E.forEach(A)}else J.fragment&&J.fragment.c();U.intro&&BU(F.$$.fragment),YU(F,U.target,U.anchor,U.customElement),RW(),yd()}fQ(n)}var JW;typeof HTMLElement=="function"&&(JW=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:F}=this.$$;this.$$.on_disconnect=F.map(QV).filter(wQ);for(let U in this.$$.slotted)this.appendChild(this.$$.slotted[U])}attributeChangedCallback(F,U,Q){this[F]=Q}disconnectedCallback(){gU(this.$$.on_disconnect)}$destroy(){pU(this,1),this.$destroy=tU}$on(F,U){if(!wQ(U))return tU;let Q=this.$$.callbacks[F]||(this.$$.callbacks[F]=[]);return Q.push(U),()=>{let B=Q.indexOf(U);B!==-1&&Q.splice(B,1)}}$set(F){this.$$set&&!pd(F)&&(this.$$.skip_bound=!0,this.$$set(F),this.$$.skip_bound=!1)}});var CU=class{$destroy(){pU(this,1),this.$destroy=tU}$on(U,Q){if(!wQ(Q))return tU;let B=this.$$.callbacks[U]||(this.$$.callbacks[U]=[]);return B.push(Q),()=>{let R=B.indexOf(Q);R!==-1&&B.splice(R,1)}}$set(U){this.$$set&&!pd(U)&&(this.$$.skip_bound=!0,this.$$set(U),this.$$.skip_bound=!1)}};var zF=XU(require("obsidian"));var nJ=XU(require("obsidian"));var ZV=class{constructor(){this.handlers=new Map;this.disabled=[]}on(U,Q,B){if(U.includes("@")||Q.includes("@"))throw new Error("Invalid context/event name - Cannot contain @");this.handlers.set(`${U}@${Q}`,B)}off(U,Q){if(Q)this.handlers.delete(`${U}@${Q}`);else for(let[B]of this.handlers.entries())B.startsWith(`${U}@`)&&this.handlers.delete(B)}disable(U){this.enable(U),this.disabled.push(U)}enable(U){this.disabled=this.disabled.filter(Q=>Q!==U)}emit(U,...Q){let B=[...this.handlers.entries()].filter(([R,V])=>!this.disabled.includes(R.split("@")[0]));for(let[R,V]of B)R.endsWith(`@${U}`)&&V(...Q)}};var eQ=[];function KB(F,U=tU){let Q,B=new Set;function R(l){if(rU(F,l)&&(F=l,Q)){let n=!eQ.length;for(let J of B)J[1](),eQ.push(J,F);if(n){for(let J=0;J{B.delete(J),B.size===0&&(Q(),Q=null)}}return{set:R,update:V,subscribe:d}}var QU=XU(require("obsidian"));var nU=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,SU=Object.keys,MU=Array.isArray;typeof Promise!="undefined"&&!nU.Promise&&(nU.Promise=Promise);function yU(F,U){return typeof U!="object"||SU(U).forEach(function(Q){F[Q]=U[Q]}),F}var qQ=Object.getPrototypeOf,WW={}.hasOwnProperty;function wU(F,U){return WW.call(F,U)}function kQ(F,U){typeof U=="function"&&(U=U(qQ(F))),(typeof Reflect=="undefined"?SU:Reflect.ownKeys)(U).forEach(Q=>{nF(F,Q,U[Q])})}var vd=Object.defineProperty;function nF(F,U,Q,B){vd(F,U,yU(Q&&wU(Q,"get")&&typeof Q.get=="function"?{get:Q.get,set:Q.set,configurable:!0}:{value:Q,configurable:!0,writable:!0},B))}function aQ(F){return{from:function(U){return F.prototype=Object.create(U.prototype),nF(F.prototype,"constructor",F),{extend:kQ.bind(null,F.prototype)}}}}var ZW=Object.getOwnPropertyDescriptor;function NV(F,U){let Q=ZW(F,U),B;return Q||(B=qQ(F))&&NV(B,U)}var NW=[].slice;function gB(F,U,Q){return NW.call(F,U,Q)}function Gd(F,U){return U(F)}function _Q(F){if(!F)throw new Error("Assertion Failed")}function bd(F){nU.setImmediate?setImmediate(F):setTimeout(F,0)}function Xd(F,U){return F.reduce((Q,B,R)=>{var V=U(B,R);return V&&(Q[V[0]]=V[1]),Q},{})}function EW(F,U,Q){try{F.apply(null,Q)}catch(B){U&&U(B)}}function JF(F,U){if(wU(F,U))return F[U];if(!U)return F;if(typeof U!="string"){for(var Q=[],B=0,R=U.length;B["Int","Uint","Float"].map(U=>U+F+"Array")))).filter(F=>nU[F]),eW=zd.map(F=>nU[F]);Xd(zd,F=>[F,!0]);var DF=null;function AQ(F){DF=typeof WeakMap!="undefined"&&new WeakMap;let U=EV(F);return DF=null,U}function EV(F){if(!F||typeof F!="object")return F;let U=DF&&DF.get(F);if(U)return U;if(MU(F)){U=[],DF&&DF.set(F,U);for(var Q=0,B=F.length;Q=0)U=F;else{let V=qQ(F);U=V===Object.prototype?{}:Object.create(V),DF&&DF.set(F,U);for(var R in F)wU(F,R)&&(U[R]=EV(F[R]))}return U}var{toString:kW}={};function tV(F){return kW.call(F).slice(8,-1)}var SV=typeof Symbol!="undefined"?Symbol.iterator:"@@iterator",aW=typeof SV=="symbol"?function(F){var U;return F!=null&&(U=F[SV])&&U.apply(F)}:function(){return null},TQ={};function WF(F){var U,Q,B,R;if(arguments.length===1){if(MU(F))return F.slice();if(this===TQ&&typeof F=="string")return[F];if(R=aW(F)){for(Q=[];B=R.next(),!B.done;)Q.push(B.value);return Q}if(F==null)return[F];if(U=F.length,typeof U=="number"){for(Q=new Array(U);U--;)Q[U]=F[U];return Q}return[F]}for(U=arguments.length,Q=new Array(U);U--;)Q[U]=arguments[U];return Q}var eV=typeof Symbol!="undefined"?F=>F[Symbol.toStringTag]==="AsyncFunction":()=>!1,QF=typeof location!="undefined"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ud(F,U){QF=F,xd=U}var xd=()=>!0,TW=!new Error("").stack;function IF(){if(TW)try{throw IF.arguments,new Error}catch(F){return F}return new Error}function kV(F,U){var Q=F.stack;return Q?(U=U||0,Q.indexOf(F.name)===0&&(U+=(F.name+F.message).split(` `).length),Q.split(` `).slice(U).filter(xd).map(B=>` `+B).join("")):""}var hW=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],wd=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],aV=hW.concat(wd),cW={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function hQ(F,U){this._e=IF(),this.name=F,this.message=U}aQ(hQ).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+kV(this._e,2))}},toString:function(){return this.name+": "+this.message}});function Ld(F,U){return F+". Errors: "+Object.keys(U).map(Q=>U[Q].toString()).filter((Q,B,R)=>R.indexOf(Q)===B).join(` `)}function PB(F,U,Q,B){this._e=IF(),this.failures=U,this.failedKeys=B,this.successCount=Q,this.message=Ld(F,U)}aQ(PB).from(hQ);function $Q(F,U){this._e=IF(),this.name="BulkError",this.failures=Object.keys(U).map(Q=>U[Q]),this.failuresByPos=U,this.message=Ld(F,U)}aQ($Q).from(hQ);var TV=aV.reduce((F,U)=>(F[U]=U+"Error",F),{}),rW=hQ,f=aV.reduce((F,U)=>{var Q=U+"Error";function B(R,V){this._e=IF(),this.name=Q,R?typeof R=="string"?(this.message=`${R}${V?` `+V:""}`,this.inner=V||null):typeof R=="object"&&(this.message=`${R.name} ${R.message}`,this.inner=R):(this.message=cW[U]||Q,this.inner=null)}return aQ(B).from(rW),F[U]=B,F},{});f.Syntax=SyntaxError;f.Type=TypeError;f.Range=RangeError;var jd=wd.reduce((F,U)=>(F[U+"Error"]=f[U],F),{});function CW(F,U){if(!F||F instanceof hQ||F instanceof TypeError||F instanceof SyntaxError||!F.name||!jd[F.name])return F;var Q=new jd[F.name](U||F.message,F);return"stack"in F&&nF(Q,"stack",{get:function(){return this.inner.stack}}),Q}var qB=aV.reduce((F,U)=>(["Syntax","Type","Range"].indexOf(U)===-1&&(F[U+"Error"]=f[U]),F),{});qB.ModifyError=PB;qB.DexieError=hQ;qB.BulkError=$Q;function VU(){}function UB(F){return F}function DW(F,U){return F==null||F===UB?U:function(Q){return U(F(Q))}}function fF(F,U){return function(){F.apply(this,arguments),U.apply(this,arguments)}}function pW(F,U){return F===VU?U:function(){var Q=F.apply(this,arguments);Q!==void 0&&(arguments[0]=Q);var B=this.onsuccess,R=this.onerror;this.onsuccess=null,this.onerror=null;var V=U.apply(this,arguments);return B&&(this.onsuccess=this.onsuccess?fF(B,this.onsuccess):B),R&&(this.onerror=this.onerror?fF(R,this.onerror):R),V!==void 0?V:Q}}function mW(F,U){return F===VU?U:function(){F.apply(this,arguments);var Q=this.onsuccess,B=this.onerror;this.onsuccess=this.onerror=null,U.apply(this,arguments),Q&&(this.onsuccess=this.onsuccess?fF(Q,this.onsuccess):Q),B&&(this.onerror=this.onerror?fF(B,this.onerror):B)}}function MW(F,U){return F===VU?U:function(Q){var B=F.apply(this,arguments);yU(Q,B);var R=this.onsuccess,V=this.onerror;this.onsuccess=null,this.onerror=null;var d=U.apply(this,arguments);return R&&(this.onsuccess=this.onsuccess?fF(R,this.onsuccess):R),V&&(this.onerror=this.onerror?fF(V,this.onerror):V),B===void 0?d===void 0?void 0:d:yU(B,d)}}function oW(F,U){return F===VU?U:function(){return U.apply(this,arguments)===!1?!1:F.apply(this,arguments)}}function hV(F,U){return F===VU?U:function(){var Q=F.apply(this,arguments);if(Q&&typeof Q.then=="function"){for(var B=this,R=arguments.length,V=new Array(R);R--;)V[R]=arguments[R];return Q.then(function(){return U.apply(B,V)})}return U.apply(this,arguments)}}var FB={},iW=100,sW=20,Id=100,[cV,_B,rV]=typeof Promise=="undefined"?[]:(()=>{let F=Promise.resolve();if(typeof crypto=="undefined"||!crypto.subtle)return[F,qQ(F),F];let U=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[U,qQ(U),F]})(),fd=_B&&_B.then,AB=cV&&cV.constructor,CV=!!rV,DV=!1,YW=rV?()=>{rV.then(QR)}:nU.setImmediate?setImmediate.bind(null,QR):nU.MutationObserver?()=>{var F=document.createElement("div");new MutationObserver(()=>{QR(),F=null}).observe(F,{attributes:!0}),F.setAttribute("i","1")}:()=>{setTimeout(QR,0)},QB=function(F,U){BB.push([F,U]),$B&&(YW(),$B=!1)},pV=!0,$B=!0,KF=[],UR=[],mV=null,MV=UB,cQ={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Ql,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(F=>{try{Ql(F[0],F[1])}catch{}})}},u=cQ,BB=[],gF=0,FR=[];function G(F){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=VU,this._lib=!1;var U=this._PSD=u;if(QF&&(this._stackHolder=IF(),this._prev=null,this._numPrev=0),typeof F!="function"){if(F!==FB)throw new TypeError("Not a function");this._state=arguments[1],this._value=arguments[2],this._state===!1&&iV(this,this._value);return}this._state=null,this._value=null,++U.ref,gd(this,F)}var oV={get:function(){var F=u,U=VR;function Q(B,R){var V=!F.global&&(F!==u||U!==VR);let d=V&&!ZF();var l=new G((n,J)=>{sV(this,new Kd(lR(B,F,V,d),lR(R,F,V,d),n,J,F))});return QF&&_d(l,this),l}return Q.prototype=FB,Q},set:function(F){nF(this,"then",F&&F.prototype===FB?oV:{get:function(){return F},set:oV.set})}};kQ(G.prototype,{then:oV,_then:function(F,U){sV(this,new Kd(null,null,F,U,u))},catch:function(F){if(arguments.length===1)return this.then(null,F);var U=arguments[0],Q=arguments[1];return typeof U=="function"?this.then(null,B=>B instanceof U?Q(B):BR(B)):this.then(null,B=>B&&B.name===U?Q(B):BR(B))},finally:function(F){return this.then(U=>(F(),U),U=>(F(),BR(U)))},stack:{get:function(){if(this._stack)return this._stack;try{DV=!0;var F=qd(this,[],sW),U=F.join(` From previous: `);return this._state!==null&&(this._stack=U),U}finally{DV=!1}}},timeout:function(F,U){return F<1/0?new G((Q,B)=>{var R=setTimeout(()=>B(new f.Timeout(U)),F);this.then(Q,B).finally(clearTimeout.bind(null,R))}):this}});typeof Symbol!="undefined"&&Symbol.toStringTag&&nF(G.prototype,Symbol.toStringTag,"Dexie.Promise");cQ.env=Ad();function Kd(F,U,Q,B,R){this.onFulfilled=typeof F=="function"?F:null,this.onRejected=typeof U=="function"?U:null,this.resolve=Q,this.reject=B,this.psd=R}kQ(G,{all:function(){var F=WF.apply(null,arguments).map(dR);return new G(function(U,Q){F.length===0&&U([]);var B=F.length;F.forEach((R,V)=>G.resolve(R).then(d=>{F[V]=d,--B||U(F)},Q))})},resolve:F=>{if(F instanceof G)return F;if(F&&typeof F.then=="function")return new G((Q,B)=>{F.then(Q,B)});var U=new G(FB,!0,F);return _d(U,mV),U},reject:BR,race:function(){var F=WF.apply(null,arguments).map(dR);return new G((U,Q)=>{F.map(B=>G.resolve(B).then(U,Q))})},PSD:{get:()=>u,set:F=>u=F},totalEchoes:{get:()=>VR},newPSD:pF,usePSD:CQ,scheduler:{get:()=>QB,set:F=>{QB=F}},rejectionMapper:{get:()=>MV,set:F=>{MV=F}},follow:(F,U)=>new G((Q,B)=>pF((R,V)=>{var d=u;d.unhandleds=[],d.onunhandled=V,d.finalize=fF(function(){vW(()=>{this.unhandleds.length===0?R():V(this.unhandleds[0])})},d.finalize),F()},U,Q,B))});AB&&(AB.allSettled&&nF(G,"allSettled",function(){let F=WF.apply(null,arguments).map(dR);return new G(U=>{F.length===0&&U([]);let Q=F.length,B=new Array(Q);F.forEach((R,V)=>G.resolve(R).then(d=>B[V]={status:"fulfilled",value:d},d=>B[V]={status:"rejected",reason:d}).then(()=>--Q||U(B)))})}),AB.any&&typeof AggregateError!="undefined"&&nF(G,"any",function(){let F=WF.apply(null,arguments).map(dR);return new G((U,Q)=>{F.length===0&&Q(new AggregateError([]));let B=F.length,R=new Array(B);F.forEach((V,d)=>G.resolve(V).then(l=>U(l),l=>{R[d]=l,--B||Q(new AggregateError(R))}))})}));function gd(F,U){try{U(Q=>{if(F._state===null){if(Q===F)throw new TypeError("A promise cannot be resolved with itself.");var B=F._lib&&RB();Q&&typeof Q.then=="function"?gd(F,(R,V)=>{Q instanceof G?Q._then(R,V):Q.then(R,V)}):(F._state=!0,F._value=Q,Pd(F)),B&&VB()}},iV.bind(null,F))}catch(Q){iV(F,Q)}}function iV(F,U){if(UR.push(U),F._state===null){var Q=F._lib&&RB();U=MV(U),F._state=!1,F._value=U,QF&&U!==null&&typeof U=="object"&&!U._promise&&EW(()=>{var B=NV(U,"stack");U._promise=F,nF(U,"stack",{get:()=>DV?B&&(B.get?B.get.apply(U):B.value):F.stack})}),GW(F),Pd(F),Q&&VB()}}function Pd(F){var U=F._listeners;F._listeners=[];for(var Q=0,B=U.length;Q{--gF==0&&YV()},[]))}function sV(F,U){if(F._state===null){F._listeners.push(U);return}var Q=F._state?U.onFulfilled:U.onRejected;if(Q===null)return(F._state?U.resolve:U.reject)(F._value);++U.psd.ref,++gF,QB(yW,[Q,F,U])}function yW(F,U,Q){try{mV=U;var B,R=U._value;U._state?B=F(R):(UR.length&&(UR=[]),B=F(R),UR.indexOf(R)===-1&&bW(U)),Q.resolve(B)}catch(V){Q.reject(V)}finally{mV=null,--gF==0&&YV(),--Q.psd.ref||Q.psd.finalize()}}function qd(F,U,Q){if(U.length===Q)return U;var B="";if(F._state===!1){var R=F._value,V,d;R!=null?(V=R.name||"Error",d=R.message||R,B=kV(R,0)):(V=R,d=""),U.push(V+(d?": "+d:"")+B)}return QF&&(B=kV(F._stackHolder,2),B&&U.indexOf(B)===-1&&U.push(B),F._prev&&qd(F._prev,U,Q)),U}function _d(F,U){var Q=U?U._numPrev+1:0;Q0;)for(F=BB,BB=[],Q=F.length,U=0;U0);pV=!0,$B=!0}function YV(){var F=KF;KF=[],F.forEach(B=>{B._PSD.onunhandled.call(null,B._value,B)});for(var U=FR.slice(0),Q=U.length;Q;)U[--Q]()}function vW(F){function U(){F(),FR.splice(FR.indexOf(U),1)}FR.push(U),++gF,QB(()=>{--gF==0&&YV()},[])}function GW(F){KF.some(U=>U._value===F._value)||KF.push(F)}function bW(F){for(var U=KF.length;U;)if(KF[--U]._value===F._value){KF.splice(U,1);return}}function BR(F){return new G(FB,!1,F)}function WU(F,U){var Q=u;return function(){var B=RB(),R=u;try{return mF(Q,!0),F.apply(this,arguments)}catch(V){U&&U(V)}finally{mF(R,!1),B&&VB()}}}var oU={awaits:0,echoes:0,id:0},XW=0,RR=[],yV=0,VR=0,OW=0;function pF(F,U,Q,B){var R=u,V=Object.create(R);V.parent=R,V.ref=0,V.global=!1,V.id=++OW;var d=cQ.env;V.env=CV?{Promise:G,PromiseProp:{value:G,configurable:!0,writable:!0},all:G.all,race:G.race,allSettled:G.allSettled,any:G.any,resolve:G.resolve,reject:G.reject,nthen:Ul(d.nthen,V),gthen:Ul(d.gthen,V)}:{},U&&yU(V,U),++R.ref,V.finalize=function(){--this.parent.ref||this.parent.finalize()};var l=CQ(V,F,Q,B);return V.ref===0&&V.finalize(),l}function rQ(){return oU.id||(oU.id=++XW),++oU.awaits,oU.echoes+=Id,oU.id}function ZF(){return oU.awaits?(--oU.awaits==0&&(oU.id=0),oU.echoes=oU.awaits*Id,!0):!1}(""+fd).indexOf("[native code]")===-1&&(rQ=ZF=VU);function dR(F){return oU.echoes&&F&&F.constructor===AB?(rQ(),F.then(U=>(ZF(),U),U=>(ZF(),aU(U)))):F}function HW(F){++VR,(!oU.echoes||--oU.echoes==0)&&(oU.echoes=oU.id=0),RR.push(u),mF(F,!0)}function zW(){var F=RR[RR.length-1];RR.pop(),mF(F,!1)}function mF(F,U){var Q=u;if((U?oU.echoes&&(!yV++||F!==u):yV&&(!--yV||F!==u))&&$d(U?HW.bind(null,F):zW),F!==u&&(u=F,Q===cQ&&(cQ.env=Ad()),CV)){var B=cQ.env.Promise,R=F.env;_B.then=R.nthen,B.prototype.then=R.gthen,(Q.global||F.global)&&(Object.defineProperty(nU,"Promise",R.PromiseProp),B.all=R.all,B.race=R.race,B.resolve=R.resolve,B.reject=R.reject,R.allSettled&&(B.allSettled=R.allSettled),R.any&&(B.any=R.any))}}function Ad(){var F=nU.Promise;return CV?{Promise:F,PromiseProp:Object.getOwnPropertyDescriptor(nU,"Promise"),all:F.all,race:F.race,allSettled:F.allSettled,any:F.any,resolve:F.resolve,reject:F.reject,nthen:_B.then,gthen:F.prototype.then}:{}}function CQ(F,U,Q,B,R){var V=u;try{return mF(F,!0),U(Q,B,R)}finally{mF(V,!1)}}function $d(F){fd.call(cV,F)}function lR(F,U,Q,B){return typeof F!="function"?F:function(){var R=u;Q&&rQ(),mF(U,!0);try{return F.apply(this,arguments)}finally{mF(R,!1),B&&$d(ZF)}}}function Ul(F,U){return function(Q,B){return F.call(this,lR(Q,U),lR(B,U))}}var Fl="unhandledrejection";function Ql(F,U){var Q;try{Q=U.onuncatched(F)}catch{}if(Q!==!1)try{var B,R={promise:U,reason:F};if(nU.document&&document.createEvent?(B=document.createEvent("Event"),B.initEvent(Fl,!0,!0),yU(B,R)):nU.CustomEvent&&(B=new CustomEvent(Fl,{detail:R}),yU(B,R)),B&&nU.dispatchEvent&&(dispatchEvent(B),!nU.PromiseRejectionEvent&&nU.onunhandledrejection))try{nU.onunhandledrejection(B)}catch{}QF&&B&&!B.defaultPrevented&&console.warn(`Unhandled rejection: ${F.stack||F}`)}catch{}}var aU=G.reject;function vV(F,U,Q,B){if(!F.idbdb||!F._state.openComplete&&!u.letThrough&&!F._vip){if(F._state.openComplete)return aU(new f.DatabaseClosed(F._state.dbOpenError));if(!F._state.isBeingOpened){if(!F._options.autoOpen)return aU(new f.DatabaseClosed);F.open().catch(VU)}return F._state.dbReadyPromise.then(()=>vV(F,U,Q,B))}else{var R=F._createTransaction(U,Q,F._dbSchema);try{R.create(),F._state.PR1398_maxLoop=3}catch(V){return V.name===TV.InvalidState&&F.isOpen()&&--F._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),F._close(),F.open().then(()=>vV(F,U,Q,B))):aU(V)}return R._promise(U,(V,d)=>pF(()=>(u.trans=R,B(V,d,R)))).then(V=>R._completion.then(()=>V))}}var Bl="3.2.2",PF=String.fromCharCode(65535),GV=-1/0,NF="Invalid key provided. Keys must be of type string, number, Date or Array.",Rl="String expected.",dB=[],nR=typeof navigator!="undefined"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),uW=nR,xW=nR,Vl=F=>!/(dexie\.js|dexie\.min\.js)/.test(F),JR="__dbnames",bV="readonly",XV="readwrite";function qF(F,U){return F?U?function(){return F.apply(this,arguments)&&U.apply(this,arguments)}:F:U}var dl={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function WR(F){return typeof F=="string"&&!/\./.test(F)?U=>(U[F]===void 0&&F in U&&(U=AQ(U),delete U[F]),U):U=>U}var ll=class{_trans(U,Q,B){let R=this._tx||u.trans,V=this.name;function d(n,J,W){if(!W.schema[V])throw new f.NotFound("Table "+V+" not part of transaction");return Q(W.idbtrans,W)}let l=RB();try{return R&&R.db===this.db?R===u.trans?R._promise(U,d,B):pF(()=>R._promise(U,d,B),{trans:R,transless:u.transless||u}):vV(this.db,U,[this.name],d)}finally{l&&VB()}}get(U,Q){return U&&U.constructor===Object?this.where(U).first(Q):this._trans("readonly",B=>this.core.get({trans:B,key:U}).then(R=>this.hook.reading.fire(R))).then(Q)}where(U){if(typeof U=="string")return new this.db.WhereClause(this,U);if(MU(U))return new this.db.WhereClause(this,`[${U.join("+")}]`);let Q=SU(U);if(Q.length===1)return this.where(Q[0]).equals(U[Q[0]]);let B=this.schema.indexes.concat(this.schema.primKey).filter(J=>J.compound&&Q.every(W=>J.keyPath.indexOf(W)>=0)&&J.keyPath.every(W=>Q.indexOf(W)>=0))[0];if(B&&this.db._maxKey!==PF)return this.where(B.name).equals(B.keyPath.map(J=>U[J]));!B&&QF&&console.warn(`The query ${JSON.stringify(U)} on ${this.name} would benefit of a compound index [${Q.join("+")}]`);let{idxByName:R}=this.schema,V=this.db._deps.indexedDB;function d(J,W){try{return V.cmp(J,W)===0}catch{return!1}}let[l,n]=Q.reduce(([J,W],E)=>{let Z=R[E],e=U[E];return[J||Z,J||!Z?qF(W,Z&&Z.multi?r=>{let c=JF(r,E);return MU(c)&&c.some(h=>d(e,h))}:r=>d(e,JF(r,E))):W]},[null,null]);return l?this.where(l.name).equals(U[l.keyPath]).filter(n):B?this.filter(n):this.where(Q).equals("")}filter(U){return this.toCollection().and(U)}count(U){return this.toCollection().count(U)}offset(U){return this.toCollection().offset(U)}limit(U){return this.toCollection().limit(U)}each(U){return this.toCollection().each(U)}toArray(U){return this.toCollection().toArray(U)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(U){return new this.db.Collection(new this.db.WhereClause(this,MU(U)?`[${U.join("+")}]`:U))}reverse(){return this.toCollection().reverse()}mapToClass(U){this.schema.mappedClass=U;let Q=B=>{if(!B)return B;let R=Object.create(U.prototype);for(var V in B)if(wU(B,V))try{R[V]=B[V]}catch{}return R};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=Q,this.hook("reading",Q),U}defineClass(){function U(Q){yU(this,Q)}return this.mapToClass(U)}add(U,Q){let{auto:B,keyPath:R}=this.schema.primKey,V=U;return R&&B&&(V=WR(R)(U)),this._trans("readwrite",d=>this.core.mutate({trans:d,type:"add",keys:Q!=null?[Q]:null,values:[V]})).then(d=>d.numFailures?G.reject(d.failures[0]):d.lastResult).then(d=>{if(R)try{qU(U,R,d)}catch{}return d})}update(U,Q){if(typeof U=="object"&&!MU(U)){let B=JF(U,this.schema.primKey.keyPath);if(B===void 0)return aU(new f.InvalidArgument("Given object does not contain its primary key"));try{typeof Q!="function"?SU(Q).forEach(R=>{qU(U,R,Q[R])}):Q(U,{value:U,primKey:B})}catch{}return this.where(":id").equals(B).modify(Q)}else return this.where(":id").equals(U).modify(Q)}put(U,Q){let{auto:B,keyPath:R}=this.schema.primKey,V=U;return R&&B&&(V=WR(R)(U)),this._trans("readwrite",d=>this.core.mutate({trans:d,type:"put",values:[V],keys:Q!=null?[Q]:null})).then(d=>d.numFailures?G.reject(d.failures[0]):d.lastResult).then(d=>{if(R)try{qU(U,R,d)}catch{}return d})}delete(U){return this._trans("readwrite",Q=>this.core.mutate({trans:Q,type:"delete",keys:[U]})).then(Q=>Q.numFailures?G.reject(Q.failures[0]):void 0)}clear(){return this._trans("readwrite",U=>this.core.mutate({trans:U,type:"deleteRange",range:dl})).then(U=>U.numFailures?G.reject(U.failures[0]):void 0)}bulkGet(U){return this._trans("readonly",Q=>this.core.getMany({keys:U,trans:Q}).then(B=>B.map(R=>this.hook.reading.fire(R))))}bulkAdd(U,Q,B){let R=Array.isArray(Q)?Q:void 0;B=B||(R?void 0:Q);let V=B?B.allKeys:void 0;return this._trans("readwrite",d=>{let{auto:l,keyPath:n}=this.schema.primKey;if(n&&R)throw new f.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(R&&R.length!==U.length)throw new f.InvalidArgument("Arguments objects and keys must have the same length");let J=U.length,W=n&&l?U.map(WR(n)):U;return this.core.mutate({trans:d,type:"add",keys:R,values:W,wantResults:V}).then(({numFailures:E,results:Z,lastResult:e,failures:r})=>{let c=V?Z:e;if(E===0)return c;throw new $Q(`${this.name}.bulkAdd(): ${E} of ${J} operations failed`,r)})})}bulkPut(U,Q,B){let R=Array.isArray(Q)?Q:void 0;B=B||(R?void 0:Q);let V=B?B.allKeys:void 0;return this._trans("readwrite",d=>{let{auto:l,keyPath:n}=this.schema.primKey;if(n&&R)throw new f.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(R&&R.length!==U.length)throw new f.InvalidArgument("Arguments objects and keys must have the same length");let J=U.length,W=n&&l?U.map(WR(n)):U;return this.core.mutate({trans:d,type:"put",keys:R,values:W,wantResults:V}).then(({numFailures:E,results:Z,lastResult:e,failures:r})=>{let c=V?Z:e;if(E===0)return c;throw new $Q(`${this.name}.bulkPut(): ${E} of ${J} operations failed`,r)})})}bulkDelete(U){let Q=U.length;return this._trans("readwrite",B=>this.core.mutate({trans:B,type:"delete",keys:U})).then(({numFailures:B,lastResult:R,failures:V})=>{if(B===0)return R;throw new $Q(`${this.name}.bulkDelete(): ${B} of ${Q} operations failed`,V)})}};function lB(F){var U={},Q=function(l,n){if(n){for(var J=arguments.length,W=new Array(J-1);--J;)W[J-1]=arguments[J];return U[l].subscribe.apply(null,W),F}else if(typeof l=="string")return U[l]};Q.addEventType=V;for(var B=1,R=arguments.length;BqF(B(),U()):U,F.justLimit=Q&&!B}function LW(F,U){F.isMatch=qF(F.isMatch,U)}function ZR(F,U){if(F.isPrimKey)return U.primaryKey;let Q=U.getIndexByKeyPath(F.index);if(!Q)throw new f.Schema("KeyPath "+F.index+" on object store "+U.name+" is not indexed");return Q}function nl(F,U,Q){let B=ZR(F,U.schema);return U.openCursor({trans:Q,values:!F.keysOnly,reverse:F.dir==="prev",unique:!!F.unique,query:{index:B,range:F.range}})}function NR(F,U,Q,B){let R=F.replayFilter?qF(F.filter,F.replayFilter()):F.filter;if(F.or){let V={},d=(l,n,J)=>{if(!R||R(n,J,Z=>n.stop(Z),Z=>n.fail(Z))){var W=n.primaryKey,E=""+W;E==="[object ArrayBuffer]"&&(E=""+new Uint8Array(W)),wU(V,E)||(V[E]=!0,U(l,n,J))}};return Promise.all([F.or._iterate(d,Q),Jl(nl(F,B,Q),F.algorithm,d,!F.keysOnly&&F.valueMapper)])}else return Jl(nl(F,B,Q),qF(F.algorithm,R),U,!F.keysOnly&&F.valueMapper)}function Jl(F,U,Q,B){var R=B?(d,l,n)=>Q(B(d),l,n):Q,V=WU(R);return F.then(d=>{if(d)return d.start(()=>{var l=()=>d.continue();(!U||U(d,n=>l=n,n=>{d.stop(n),l=VU},n=>{d.fail(n),l=VU}))&&V(d.value,d,n=>l=n),l()})})}function vU(F,U){try{let Q=Wl(F),B=Wl(U);if(Q!==B)return Q==="Array"?1:B==="Array"?-1:Q==="binary"?1:B==="binary"?-1:Q==="string"?1:B==="string"?-1:Q==="Date"?1:B!=="Date"?NaN:-1;switch(Q){case"number":case"Date":case"string":return F>U?1:FNR(Q,U,B,Q.table.core))}count(U){return this._read(Q=>{let B=this._ctx,R=B.table.core;if(DQ(B,!0))return R.count({trans:Q,query:{index:ZR(B,R.schema),range:B.range}}).then(d=>Math.min(d,B.limit));var V=0;return NR(B,()=>(++V,!1),Q,R).then(()=>V)}).then(U)}sortBy(U,Q){let B=U.split(".").reverse(),R=B[0],V=B.length-1;function d(J,W){return W?d(J[B[W]],W-1):J[R]}var l=this._ctx.dir==="next"?1:-1;function n(J,W){var E=d(J,V),Z=d(W,V);return EZ?l:0}return this.toArray(function(J){return J.sort(n)}).then(Q)}toArray(U){return this._read(Q=>{var B=this._ctx;if(B.dir==="next"&&DQ(B,!0)&&B.limit>0){let{valueMapper:R}=B,V=ZR(B,B.table.core.schema);return B.table.core.query({trans:Q,limit:B.limit,values:!0,query:{index:V,range:B.range}}).then(({result:d})=>R?d.map(R):d)}else{let R=[];return NR(B,V=>R.push(V),Q,B.table.core).then(()=>R)}},U)}offset(U){var Q=this._ctx;return U<=0?this:(Q.offset+=U,DQ(Q)?HV(Q,()=>{var B=U;return(R,V)=>B===0?!0:B===1?(--B,!1):(V(()=>{R.advance(B),B=0}),!1)}):HV(Q,()=>{var B=U;return()=>--B<0}),this)}limit(U){return this._ctx.limit=Math.min(this._ctx.limit,U),HV(this._ctx,()=>{var Q=U;return function(B,R,V){return--Q<=0&&R(V),Q>=0}},!0),this}until(U,Q){return OV(this._ctx,function(B,R,V){return U(B.value)?(R(V),Q):!0}),this}first(U){return this.limit(1).toArray(function(Q){return Q[0]}).then(U)}last(U){return this.reverse().first(U)}filter(U){return OV(this._ctx,function(Q){return U(Q.value)}),LW(this._ctx,U),this}and(U){return this.filter(U)}or(U){return new this.db.WhereClause(this._ctx.table,U,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(U){var Q=this._ctx;return Q.keysOnly=!Q.isMatch,this.each(function(B,R){U(R.key,R)})}eachUniqueKey(U){return this._ctx.unique="unique",this.eachKey(U)}eachPrimaryKey(U){var Q=this._ctx;return Q.keysOnly=!Q.isMatch,this.each(function(B,R){U(R.primaryKey,R)})}keys(U){var Q=this._ctx;Q.keysOnly=!Q.isMatch;var B=[];return this.each(function(R,V){B.push(V.key)}).then(function(){return B}).then(U)}primaryKeys(U){var Q=this._ctx;if(Q.dir==="next"&&DQ(Q,!0)&&Q.limit>0)return this._read(R=>{var V=ZR(Q,Q.table.core.schema);return Q.table.core.query({trans:R,values:!1,limit:Q.limit,query:{index:V,range:Q.range}})}).then(({result:R})=>R).then(U);Q.keysOnly=!Q.isMatch;var B=[];return this.each(function(R,V){B.push(V.primaryKey)}).then(function(){return B}).then(U)}uniqueKeys(U){return this._ctx.unique="unique",this.keys(U)}firstKey(U){return this.limit(1).keys(function(Q){return Q[0]}).then(U)}lastKey(U){return this.reverse().firstKey(U)}distinct(){var U=this._ctx,Q=U.index&&U.table.schema.idxByName[U.index];if(!Q||!Q.multi)return this;var B={};return OV(this._ctx,function(R){var V=R.primaryKey.toString(),d=wU(B,V);return B[V]=!0,!d}),this}modify(U){var Q=this._ctx;return this._write(B=>{var R;if(typeof U=="function")R=U;else{var V=SU(U),d=V.length;R=function(c){for(var h=!1,N=0;N{let{failures:N,numFailures:k}=h;Z+=c-k;for(let t of SU(N))E.push(N[t])};return this.clone().primaryKeys().then(c=>{let h=N=>{let k=Math.min(W,c.length-N);return l.getMany({trans:B,keys:c.slice(N,N+k),cache:"immutable"}).then(t=>{let S=[],a=[],T=n?[]:null,C=[];for(let p=0;p0&&l.mutate({trans:B,type:"add",values:S}).then(p=>{for(let o in p.failures)C.splice(parseInt(o),1);r(S.length,p)})).then(()=>(a.length>0||D&&typeof U=="object")&&l.mutate({trans:B,type:"put",keys:T,values:a,criteria:D,changeSpec:typeof U!="function"&&U}).then(p=>r(a.length,p))).then(()=>(C.length>0||D&&U===zV)&&l.mutate({trans:B,type:"delete",keys:C,criteria:D}).then(p=>r(C.length,p))).then(()=>c.length>N+k&&h(N+W))})};return h(0).then(()=>{if(E.length>0)throw new PB("Error modifying one or more objects",E,Z,e);return c.length})})})}delete(){var U=this._ctx,Q=U.range;return DQ(U)&&(U.isPrimKey&&!xW||Q.type===3)?this._write(B=>{let{primaryKey:R}=U.table.core.schema,V=Q;return U.table.core.count({trans:B,query:{index:R,range:V}}).then(d=>U.table.core.mutate({trans:B,type:"deleteRange",range:V}).then(({failures:l,lastResult:n,results:J,numFailures:W})=>{if(W)throw new PB("Could not delete some values",Object.keys(l).map(E=>l[E]),d-W);return d-W}))}):this.modify(zV)}},zV=(F,U)=>U.value=null;function fW(F){return nB(Nl.prototype,function(Q,B){this.db=F;let R=dl,V=null;if(B)try{R=B()}catch(J){V=J}let d=Q._ctx,l=d.table,n=l.hook.reading.fire;this._ctx={table:l,index:d.index,isPrimKey:!d.index||l.schema.primKey.keyPath&&d.index===l.schema.primKey.name,range:R,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:V,or:d.or,valueMapper:n!==UB?n:null}})}function KW(F,U){return FU?-1:F===U?0:1}function LU(F,U,Q){var B=F instanceof uV?new F.Collection(F):F;return B._ctx.error=Q?new Q(U):new TypeError(U),B}function pQ(F){return new F.Collection(F,()=>El("")).limit(0)}function PW(F){return F==="next"?U=>U.toUpperCase():U=>U.toLowerCase()}function qW(F){return F==="next"?U=>U.toLowerCase():U=>U.toUpperCase()}function _W(F,U,Q,B,R,V){for(var d=Math.min(F.length,B.length),l=-1,n=0;n=0?F.substr(0,l)+U[l]+Q.substr(l+1):null;R(F[n],J)<0&&(l=n)}return dtypeof c=="string"))return LU(F,Rl);function Z(c){R=PW(c),V=qW(c),d=c==="next"?KW:gW;var h=Q.map(function(N){return{lower:V(N),upper:R(N)}}).sort(function(N,k){return d(N.lower,k.lower)});l=h.map(function(N){return N.upper}),n=h.map(function(N){return N.lower}),J=c,W=c==="next"?"":B}Z("next");var e=new F.Collection(F,()=>MF(l[0],n[E-1]+B));e._ondirectionchange=function(c){Z(c)};var r=0;return e._addAlgorithm(function(c,h,N){var k=c.key;if(typeof k!="string")return!1;var t=V(k);if(U(t,n,r))return!0;for(var S=null,a=r;a0)&&(S=T)}return h(S!==null?function(){c.continue(S+W)}:N),!1}),e}function MF(F,U,Q,B){return{type:2,lower:F,upper:U,lowerOpen:Q,upperOpen:B}}function El(F){return{type:1,lower:F,upper:F}}var uV=class{get Collection(){return this._ctx.table.db.Collection}between(U,Q,B,R){B=B!==!1,R=R===!0;try{return this._cmp(U,Q)>0||this._cmp(U,Q)===0&&(B||R)&&!(B&&R)?pQ(this):new this.Collection(this,()=>MF(U,Q,!B,!R))}catch{return LU(this,NF)}}equals(U){return U==null?LU(this,NF):new this.Collection(this,()=>El(U))}above(U){return U==null?LU(this,NF):new this.Collection(this,()=>MF(U,void 0,!0))}aboveOrEqual(U){return U==null?LU(this,NF):new this.Collection(this,()=>MF(U,void 0,!1))}below(U){return U==null?LU(this,NF):new this.Collection(this,()=>MF(void 0,U,!1,!0))}belowOrEqual(U){return U==null?LU(this,NF):new this.Collection(this,()=>MF(void 0,U))}startsWith(U){return typeof U!="string"?LU(this,Rl):this.between(U,U+PF,!0,!0)}startsWithIgnoreCase(U){return U===""?this.startsWith(U):ER(this,(Q,B)=>Q.indexOf(B[0])===0,[U],PF)}equalsIgnoreCase(U){return ER(this,(Q,B)=>Q===B[0],[U],"")}anyOfIgnoreCase(){var U=WF.apply(TQ,arguments);return U.length===0?pQ(this):ER(this,(Q,B)=>B.indexOf(Q)!==-1,U,"")}startsWithAnyOfIgnoreCase(){var U=WF.apply(TQ,arguments);return U.length===0?pQ(this):ER(this,(Q,B)=>B.some(R=>Q.indexOf(R)===0),U,PF)}anyOf(){let U=WF.apply(TQ,arguments),Q=this._cmp;try{U.sort(Q)}catch{return LU(this,NF)}if(U.length===0)return pQ(this);let B=new this.Collection(this,()=>MF(U[0],U[U.length-1]));B._ondirectionchange=V=>{Q=V==="next"?this._ascending:this._descending,U.sort(Q)};let R=0;return B._addAlgorithm((V,d,l)=>{let n=V.key;for(;Q(n,U[R])>0;)if(++R,R===U.length)return d(l),!1;return Q(n,U[R])===0?!0:(d(()=>{V.continue(U[R])}),!1)}),B}notEqual(U){return this.inAnyRange([[GV,U],[U,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let U=WF.apply(TQ,arguments);if(U.length===0)return new this.Collection(this);try{U.sort(this._ascending)}catch{return LU(this,NF)}let Q=U.reduce((B,R)=>B?B.concat([[B[B.length-1][1],R]]):[[GV,R]],null);return Q.push([U[U.length-1],this.db._maxKey]),this.inAnyRange(Q,{includeLowers:!1,includeUppers:!1})}inAnyRange(U,Q){let B=this._cmp,R=this._ascending,V=this._descending,d=this._min,l=this._max;if(U.length===0)return pQ(this);if(!U.every(S=>S[0]!==void 0&&S[1]!==void 0&&R(S[0],S[1])<=0))return LU(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",f.InvalidArgument);let n=!Q||Q.includeLowers!==!1,J=Q&&Q.includeUppers===!0;function W(S,a){let T=0,C=S.length;for(;T0){D[0]=d(D[0],a[0]),D[1]=l(D[1],a[1]);break}}return T===C&&S.push(a),S}let E=R;function Z(S,a){return E(S[0],a[0])}let e;try{e=U.reduce(W,[]),e.sort(Z)}catch{return LU(this,NF)}let r=0,c=J?S=>R(S,e[r][1])>0:S=>R(S,e[r][1])>=0,h=n?S=>V(S,e[r][0])>0:S=>V(S,e[r][0])>=0;function N(S){return!c(S)&&!h(S)}let k=c,t=new this.Collection(this,()=>MF(e[0][0],e[e.length-1][1],!n,!J));return t._ondirectionchange=S=>{S==="next"?(k=c,E=R):(k=h,E=V),e.sort(Z)},t._addAlgorithm((S,a,T)=>{for(var C=S.key;k(C);)if(++r,r===e.length)return a(T),!1;return N(C)?!0:(this._cmp(C,e[r][1])===0||this._cmp(C,e[r][0])===0||a(()=>{E===R?S.continue(e[r][0]):S.continue(e[r][1])}),!1)}),t}startsWithAnyOf(){let U=WF.apply(TQ,arguments);return U.every(Q=>typeof Q=="string")?U.length===0?pQ(this):this.inAnyRange(U.map(Q=>[Q,Q+PF])):LU(this,"startsWithAnyOf() only works with strings")}};function AW(F){return nB(uV.prototype,function(Q,B,R){this.db=F,this._ctx={table:Q,index:B===":id"?null:B,or:R};let V=F._deps.indexedDB;if(!V)throw new f.MissingAPI;this._cmp=this._ascending=V.cmp.bind(V),this._descending=(d,l)=>V.cmp(l,d),this._max=(d,l)=>V.cmp(d,l)>0?d:l,this._min=(d,l)=>V.cmp(d,l)<0?d:l,this._IDBKeyRange=F._deps.IDBKeyRange})}function BF(F){return WU(function(U){return JB(U),F(U.target.error),!1})}function JB(F){F.stopPropagation&&F.stopPropagation(),F.preventDefault&&F.preventDefault()}var WB="storagemutated",oF="x-storagemutated-1",iF=lB(null,WB),tl=class{_lock(){return _Q(!u.global),++this._reculock,this._reculock===1&&!u.global&&(u.lockOwnerFor=this),this}_unlock(){if(_Q(!u.global),--this._reculock==0)for(u.global||(u.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var U=this._blockedFuncs.shift();try{CQ(U[1],U[0])}catch{}}return this}_locked(){return this._reculock&&u.lockOwnerFor!==this}create(U){if(!this.mode)return this;let Q=this.db.idbdb,B=this.db._state.dbOpenError;if(_Q(!this.idbtrans),!U&&!Q)switch(B&&B.name){case"DatabaseClosedError":throw new f.DatabaseClosed(B);case"MissingAPIError":throw new f.MissingAPI(B.message,B);default:throw new f.OpenFailed(B)}if(!this.active)throw new f.TransactionInactive;return _Q(this._completion._state===null),U=this.idbtrans=U||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):Q.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})),U.onerror=WU(R=>{JB(R),this._reject(U.error)}),U.onabort=WU(R=>{JB(R),this.active&&this._reject(new f.Abort(U.error)),this.active=!1,this.on("abort").fire(R)}),U.oncomplete=WU(()=>{this.active=!1,this._resolve(),"mutatedParts"in U&&iF.storagemutated.fire(U.mutatedParts)}),this}_promise(U,Q,B){if(U==="readwrite"&&this.mode!=="readwrite")return aU(new f.ReadOnly("Transaction is readonly"));if(!this.active)return aU(new f.TransactionInactive);if(this._locked())return new G((V,d)=>{this._blockedFuncs.push([()=>{this._promise(U,Q,B).then(V,d)},u])});if(B)return pF(()=>{var V=new G((d,l)=>{this._lock();let n=Q(d,l,this);n&&n.then&&n.then(d,l)});return V.finally(()=>this._unlock()),V._lib=!0,V});var R=new G((V,d)=>{var l=Q(V,d,this);l&&l.then&&l.then(V,d)});return R._lib=!0,R}_root(){return this.parent?this.parent._root():this}waitFor(U){var Q=this._root();let B=G.resolve(U);if(Q._waitingFor)Q._waitingFor=Q._waitingFor.then(()=>B);else{Q._waitingFor=B,Q._waitingQueue=[];var R=Q.idbtrans.objectStore(Q.storeNames[0]);(function d(){for(++Q._spinCount;Q._waitingQueue.length;)Q._waitingQueue.shift()();Q._waitingFor&&(R.get(-1/0).onsuccess=d)})()}var V=Q._waitingFor;return new G((d,l)=>{B.then(n=>Q._waitingQueue.push(WU(d.bind(null,n))),n=>Q._waitingQueue.push(WU(l.bind(null,n)))).finally(()=>{Q._waitingFor===V&&(Q._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new f.Abort))}table(U){let Q=this._memoizedTables||(this._memoizedTables={});if(wU(Q,U))return Q[U];let B=this.schema[U];if(!B)throw new f.NotFound("Table "+U+" not part of transaction");let R=new this.db.Table(U,B,this);return R.core=this.db.core.table(U),Q[U]=R,R}};function $W(F){return nB(tl.prototype,function(Q,B,R,V,d){this.db=F,this.mode=Q,this.storeNames=B,this.schema=R,this.chromeTransactionDurability=V,this.idbtrans=null,this.on=lB(this,"complete","error","abort"),this.parent=d||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new G((l,n)=>{this._resolve=l,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},l=>{var n=this.active;return this.active=!1,this.on.error.fire(l),this.parent?this.parent._reject(l):n&&this.idbtrans&&this.idbtrans.abort(),aU(l)})})}function xV(F,U,Q,B,R,V,d){return{name:F,keyPath:U,unique:Q,multi:B,auto:R,compound:V,src:(Q&&!d?"&":"")+(B?"*":"")+(R?"++":"")+Sl(U)}}function Sl(F){return typeof F=="string"?F:F?"["+[].join.call(F,"+")+"]":""}function el(F,U,Q){return{name:F,primKey:U,indexes:Q,mappedClass:null,idxByName:Xd(Q,B=>[B.name,B])}}function UZ(F){return F.length===1?F[0]:F}var ZB=F=>{try{return F.only([[]]),ZB=()=>[[]],[[]]}catch{return ZB=()=>PF,PF}};function wV(F){return F==null?()=>{}:typeof F=="string"?FZ(F):U=>JF(U,F)}function FZ(F){return F.split(".").length===1?Q=>Q[F]:Q=>JF(Q,F)}function kl(F){return[].slice.call(F)}var QZ=0;function NB(F){return F==null?":id":typeof F=="string"?F:`[${F.join("+")}]`}function BZ(F,U,Q){function B(W,E){let Z=kl(W.objectStoreNames);return{schema:{name:W.name,tables:Z.map(e=>E.objectStore(e)).map(e=>{let{keyPath:r,autoIncrement:c}=e,h=MU(r),N=r==null,k={},t={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:N,compound:h,keyPath:r,autoIncrement:c,unique:!0,extractKey:wV(r)},indexes:kl(e.indexNames).map(S=>e.index(S)).map(S=>{let{name:a,unique:T,multiEntry:C,keyPath:D}=S,p=MU(D),o={name:a,compound:p,keyPath:D,unique:T,multiEntry:C,extractKey:wV(D)};return k[NB(D)]=o,o}),getIndexByKeyPath:S=>k[NB(S)]};return k[":id"]=t.primaryKey,r!=null&&(k[NB(r)]=t.primaryKey),t})},hasGetAll:Z.length>0&&"getAll"in E.objectStore(Z[0])&&!(typeof navigator!="undefined"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}function R(W){if(W.type===3)return null;if(W.type===4)throw new Error("Cannot convert never type to IDBKeyRange");let{lower:E,upper:Z,lowerOpen:e,upperOpen:r}=W;return E===void 0?Z===void 0?null:U.upperBound(Z,!!r):Z===void 0?U.lowerBound(E,!!e):U.bound(E,Z,!!e,!!r)}function V(W){let E=W.name;function Z({trans:c,type:h,keys:N,values:k,range:t}){return new Promise((S,a)=>{S=WU(S);let T=c.objectStore(E),C=T.keyPath==null,D=h==="put"||h==="add";if(!D&&h!=="delete"&&h!=="deleteRange")throw new Error("Invalid operation type: "+h);let{length:p}=N||k||{length:1};if(N&&k&&N.length!==k.length)throw new Error("Given keys array must have same length as given values array.");if(p===0)return S({numFailures:0,failures:{},results:[],lastResult:void 0});let o,s=[],v=[],y=0,i=g=>{++y,JB(g)};if(h==="deleteRange"){if(t.type===4)return S({numFailures:y,failures:v,results:[],lastResult:void 0});t.type===3?s.push(o=T.clear()):s.push(o=T.delete(R(t)))}else{let[g,L]=D?C?[k,N]:[k,null]:[N,null];if(D)for(let M=0;M{let L=g.target.result;s.forEach((M,m)=>M.error!=null&&(v[m]=M.error)),S({numFailures:y,failures:v,results:h==="delete"?N:s.map(M=>M.result),lastResult:L})};o.onerror=g=>{i(g),w(g)},o.onsuccess=w})}function e({trans:c,values:h,query:N,reverse:k,unique:t}){return new Promise((S,a)=>{S=WU(S);let{index:T,range:C}=N,D=c.objectStore(E),p=T.isPrimaryKey?D:D.index(T.name),o=k?t?"prevunique":"prev":t?"nextunique":"next",s=h||!("openKeyCursor"in p)?p.openCursor(R(C),o):p.openKeyCursor(R(C),o);s.onerror=BF(a),s.onsuccess=WU(v=>{let y=s.result;if(!y){S(null);return}y.___id=++QZ,y.done=!1;let i=y.continue.bind(y),w=y.continuePrimaryKey;w&&(w=w.bind(y));let g=y.advance.bind(y),L=()=>{throw new Error("Cursor not started")},M=()=>{throw new Error("Cursor not stopped")};y.trans=c,y.stop=y.continue=y.continuePrimaryKey=y.advance=L,y.fail=WU(a),y.next=function(){let m=1;return this.start(()=>m--?this.continue():this.stop()).then(()=>this)},y.start=m=>{let Y=new Promise((X,lU)=>{X=WU(X),s.onerror=BF(lU),y.fail=lU,y.stop=EU=>{y.stop=y.continue=y.continuePrimaryKey=y.advance=M,X(EU)}}),I=()=>{if(s.result)try{m()}catch(X){y.fail(X)}else y.done=!0,y.start=()=>{throw new Error("Cursor behind last entry")},y.stop()};return s.onsuccess=WU(X=>{s.onsuccess=I,I()}),y.continue=i,y.continuePrimaryKey=w,y.advance=g,I(),Y},S(y)},a)})}function r(c){return h=>new Promise((N,k)=>{N=WU(N);let{trans:t,values:S,limit:a,query:T}=h,C=a===1/0?void 0:a,{index:D,range:p}=T,o=t.objectStore(E),s=D.isPrimaryKey?o:o.index(D.name),v=R(p);if(a===0)return N({result:[]});if(c){let y=S?s.getAll(v,C):s.getAllKeys(v,C);y.onsuccess=i=>N({result:i.target.result}),y.onerror=BF(k)}else{let y=0,i=S||!("openKeyCursor"in s)?s.openCursor(v):s.openKeyCursor(v),w=[];i.onsuccess=g=>{let L=i.result;if(!L)return N({result:w});if(w.push(S?L.value:L.primaryKey),++y===a)return N({result:w});L.continue()},i.onerror=BF(k)}})}return{name:E,schema:W,mutate:Z,getMany({trans:c,keys:h}){return new Promise((N,k)=>{N=WU(N);let t=c.objectStore(E),S=h.length,a=new Array(S),T=0,C=0,D,p=s=>{let v=s.target;(a[v._pos]=v.result)!=null,++C===T&&N(a)},o=BF(k);for(let s=0;s{N=WU(N);let S=c.objectStore(E).get(h);S.onsuccess=a=>N(a.target.result),S.onerror=BF(k)})},query:r(l),openCursor:e,count({query:c,trans:h}){let{index:N,range:k}=c;return new Promise((t,S)=>{let a=h.objectStore(E),T=N.isPrimaryKey?a:a.index(N.name),C=R(k),D=C?T.count(C):T.count();D.onsuccess=WU(p=>t(p.target.result)),D.onerror=BF(S)})}}}let{schema:d,hasGetAll:l}=B(F,Q),n=d.tables.map(W=>V(W)),J={};return n.forEach(W=>J[W.name]=W),{stack:"dbcore",transaction:F.transaction.bind(F),table(W){if(!J[W])throw new Error(`Table '${W}' not found`);return J[W]},MIN_KEY:-1/0,MAX_KEY:ZB(U),schema:d}}function RZ(F,U){return U.reduce((Q,{create:B})=>z(z({},Q),B(Q)),F)}function VZ(F,U,{IDBKeyRange:Q,indexedDB:B},R){return{dbcore:RZ(BZ(U,Q,R),F.dbcore)}}function LV({_novip:F},U){let Q=U.db,B=VZ(F._middlewares,Q,F._deps,U);F.core=B.dbcore,F.tables.forEach(R=>{let V=R.name;F.core.schema.tables.some(d=>d.name===V)&&(R.core=F.core.table(V),F[V]instanceof F.Table&&(F[V].core=R.core))})}function tR({_novip:F},U,Q,B){Q.forEach(R=>{let V=B[R];U.forEach(d=>{let l=NV(d,R);(!l||"value"in l&&l.value===void 0)&&(d===F.Transaction.prototype||d instanceof F.Transaction?nF(d,R,{get(){return this.table(R)},set(n){vd(this,R,{value:n,writable:!0,configurable:!0,enumerable:!0})}}):d[R]=new F.Table(R,V))})})}function jV({_novip:F},U){U.forEach(Q=>{for(let B in Q)Q[B]instanceof F.Table&&delete Q[B]})}function dZ(F,U){return F._cfg.version-U._cfg.version}function lZ(F,U,Q,B){let R=F._dbSchema,V=F._createTransaction("readwrite",F._storeNames,R);V.create(Q),V._completion.catch(B);let d=V._reject.bind(V),l=u.transless||u;pF(()=>{u.trans=V,u.transless=l,U===0?(SU(R).forEach(n=>{IV(Q,n,R[n].primKey,R[n].indexes)}),LV(F,Q),G.follow(()=>F.on.populate.fire(V)).catch(d)):nZ(F,U,V,Q).catch(d)})}function nZ({_novip:F},U,Q,B){let R=[],V=F._versions,d=F._dbSchema=KV(F,F.idbdb,B),l=!1;V.filter(W=>W._cfg.version>=U).forEach(W=>{R.push(()=>{let E=d,Z=W._cfg.dbschema;gV(F,E,B),gV(F,Z,B),d=F._dbSchema=Z;let e=al(E,Z);e.add.forEach(c=>{IV(B,c[0],c[1].primKey,c[1].indexes)}),e.change.forEach(c=>{if(c.recreate)throw new f.Upgrade("Not yet support for changing primary key");{let h=B.objectStore(c.name);c.add.forEach(N=>fV(h,N)),c.change.forEach(N=>{h.deleteIndex(N.name),fV(h,N)}),c.del.forEach(N=>h.deleteIndex(N))}});let r=W._cfg.contentUpgrade;if(r&&W._cfg.version>U){LV(F,B),Q._memoizedTables={},l=!0;let c=Od(Z);e.del.forEach(t=>{c[t]=E[t]}),jV(F,[F.Transaction.prototype]),tR(F,[F.Transaction.prototype],SU(c),c),Q.schema=c;let h=eV(r);h&&rQ();let N,k=G.follow(()=>{if(N=r(Q),N&&h){var t=ZF.bind(null,null);N.then(t,t)}});return N&&typeof N.then=="function"?G.resolve(N):k.then(()=>N)}}),R.push(E=>{if(!l||!uW){let Z=W._cfg.dbschema;WZ(Z,E)}jV(F,[F.Transaction.prototype]),tR(F,[F.Transaction.prototype],F._storeNames,F._dbSchema),Q.schema=F._dbSchema})});function J(){return R.length?G.resolve(R.shift()(Q.idbtrans)).then(J):G.resolve()}return J().then(()=>{JZ(d,B)})}function al(F,U){let Q={del:[],add:[],change:[]},B;for(B in F)U[B]||Q.del.push(B);for(B in U){let R=F[B],V=U[B];if(!R)Q.add.push([B,V]);else{let d={name:B,def:V,recreate:!1,del:[],add:[],change:[]};if(""+(R.primKey.keyPath||"")!=""+(V.primKey.keyPath||"")||R.primKey.auto!==V.primKey.auto&&!nR)d.recreate=!0,Q.change.push(d);else{let l=R.idxByName,n=V.idxByName,J;for(J in l)n[J]||d.del.push(J);for(J in n){let W=l[J],E=n[J];W?W.src!==E.src&&d.change.push(E):d.add.push(E)}(d.del.length>0||d.add.length>0||d.change.length>0)&&Q.change.push(d)}}}return Q}function IV(F,U,Q,B){let R=F.db.createObjectStore(U,Q.keyPath?{keyPath:Q.keyPath,autoIncrement:Q.auto}:{autoIncrement:Q.auto});return B.forEach(V=>fV(R,V)),R}function JZ(F,U){SU(F).forEach(Q=>{U.db.objectStoreNames.contains(Q)||IV(U,Q,F[Q].primKey,F[Q].indexes)})}function WZ(F,U){[].slice.call(U.db.objectStoreNames).forEach(Q=>F[Q]==null&&U.db.deleteObjectStore(Q))}function fV(F,U){F.createIndex(U.name,U.keyPath,{unique:U.unique,multiEntry:U.multi})}function KV(F,U,Q){let B={};return gB(U.objectStoreNames,0).forEach(V=>{let d=Q.objectStore(V),l=d.keyPath,n=xV(Sl(l),l||"",!1,!1,!!d.autoIncrement,l&&typeof l!="string",!0),J=[];for(let E=0;ER.add.length||R.change.length))}function gV({_novip:F},U,Q){let B=Q.db.objectStoreNames;for(let R=0;R{U=U.trim();let B=U.replace(/([&*]|\+\+)/g,""),R=/^\[/.test(B)?B.match(/^\[(.*)\]$/)[1].split("+"):B;return xV(B,R||null,/\&/.test(U),/\*/.test(U),/\+\+/.test(U),MU(R),Q===0)})}var Tl=class{_parseStoresSpec(U,Q){SU(U).forEach(B=>{if(U[B]!==null){var R=EZ(U[B]),V=R.shift();if(V.multi)throw new f.Schema("Primary key cannot be multi-valued");R.forEach(d=>{if(d.auto)throw new f.Schema("Only primary key can be marked as autoIncrement (++)");if(!d.keyPath)throw new f.Schema("Index must have a name and cannot be an empty string")}),Q[B]=el(B,V,R)}})}stores(U){let Q=this.db;this._cfg.storesSource=this._cfg.storesSource?yU(this._cfg.storesSource,U):U;let B=Q._versions,R={},V={};return B.forEach(d=>{yU(R,d._cfg.storesSource),V=d._cfg.dbschema={},d._parseStoresSpec(R,V)}),Q._dbSchema=V,jV(Q,[Q._allTables,Q,Q.Transaction.prototype]),tR(Q,[Q._allTables,Q,Q.Transaction.prototype,this._cfg.tables],SU(V),V),Q._storeNames=SU(V),this}upgrade(U){return this._cfg.contentUpgrade=hV(this._cfg.contentUpgrade||VU,U),this}};function tZ(F){return nB(Tl.prototype,function(Q){this.db=F,this._cfg={version:Q,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}function PV(F,U){let Q=F._dbNamesDB;return Q||(Q=F._dbNamesDB=new tF(JR,{addons:[],indexedDB:F,IDBKeyRange:U}),Q.version(1).stores({dbnames:"name"})),Q.table("dbnames")}function qV(F){return F&&typeof F.databases=="function"}function SZ({indexedDB:F,IDBKeyRange:U}){return qV(F)?Promise.resolve(F.databases()).then(Q=>Q.map(B=>B.name).filter(B=>B!==JR)):PV(F,U).toCollection().primaryKeys()}function eZ({indexedDB:F,IDBKeyRange:U},Q){!qV(F)&&Q!==JR&&PV(F,U).put({name:Q}).catch(VU)}function kZ({indexedDB:F,IDBKeyRange:U},Q){!qV(F)&&Q!==JR&&PV(F,U).delete(Q).catch(VU)}function _V(F){return pF(function(){return u.letThrough=!0,F()})}function aZ(){var F=!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent);if(!F||!indexedDB.databases)return Promise.resolve();var U;return new Promise(function(Q){var B=function(){return indexedDB.databases().finally(Q)};U=setInterval(B,100),B()}).finally(function(){return clearInterval(U)})}function TZ(F){let U=F._state,{indexedDB:Q}=F._deps;if(U.isBeingOpened||F.idbdb)return U.dbReadyPromise.then(()=>U.dbOpenError?aU(U.dbOpenError):F);QF&&(U.openCanceller._stackHolder=IF()),U.isBeingOpened=!0,U.dbOpenError=null,U.openComplete=!1;let B=U.openCanceller;function R(){if(U.openCanceller!==B)throw new f.DatabaseClosed("db.open() was cancelled")}let V=U.dbReadyResolve,d=null,l=!1;return G.race([B,(typeof navigator=="undefined"?G.resolve():aZ()).then(()=>new G((n,J)=>{if(R(),!Q)throw new f.MissingAPI;let W=F.name,E=U.autoSchema?Q.open(W):Q.open(W,Math.round(F.verno*10));if(!E)throw new f.MissingAPI;E.onerror=BF(J),E.onblocked=WU(F._fireOnBlocked),E.onupgradeneeded=WU(Z=>{if(d=E.transaction,U.autoSchema&&!F._options.allowEmptyDB){E.onerror=JB,d.abort(),E.result.close();let r=Q.deleteDatabase(W);r.onsuccess=r.onerror=WU(()=>{J(new f.NoSuchDatabase(`Database ${W} doesnt exist`))})}else{d.onerror=BF(J);var e=Z.oldVersion>Math.pow(2,62)?0:Z.oldVersion;l=e<1,F._novip.idbdb=E.result,lZ(F,e/10,d,J)}},J),E.onsuccess=WU(()=>{d=null;let Z=F._novip.idbdb=E.result,e=gB(Z.objectStoreNames);if(e.length>0)try{let r=Z.transaction(UZ(e),"readonly");U.autoSchema?ZZ(F,Z,r):(gV(F,F._dbSchema,r),NZ(F,r)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),LV(F,r)}catch{}dB.push(F),Z.onversionchange=WU(r=>{U.vcFired=!0,F.on("versionchange").fire(r)}),Z.onclose=WU(r=>{F.on("close").fire(r)}),l&&eZ(F._deps,W),n()},J)}))]).then(()=>(R(),U.onReadyBeingFired=[],G.resolve(_V(()=>F.on.ready.fire(F.vip))).then(function n(){if(U.onReadyBeingFired.length>0){let J=U.onReadyBeingFired.reduce(hV,VU);return U.onReadyBeingFired=[],G.resolve(_V(()=>J(F.vip))).then(n)}}))).finally(()=>{U.onReadyBeingFired=null,U.isBeingOpened=!1}).then(()=>F).catch(n=>{U.dbOpenError=n;try{d&&d.abort()}catch{}return B===U.openCanceller&&F._close(),aU(n)}).finally(()=>{U.openComplete=!0,V()})}function AV(F){var U=d=>F.next(d),Q=d=>F.throw(d),B=V(U),R=V(Q);function V(d){return l=>{var n=d(l),J=n.value;return n.done?J:!J||typeof J.then!="function"?MU(J)?Promise.all(J).then(B,R):B(J):J.then(B,R)}}return V(U)()}function hZ(F,U,Q){var B=arguments.length;if(B<2)throw new f.InvalidArgument("Too few arguments");for(var R=new Array(B-1);--B;)R[B-1]=arguments[B];Q=R.pop();var V=Hd(R);return[F,V,Q]}function hl(F,U,Q,B,R){return G.resolve().then(()=>{let V=u.transless||u,d=F._createTransaction(U,Q,F._dbSchema,B),l={trans:d,transless:V};if(B)d.idbtrans=B.idbtrans;else try{d.create(),F._state.PR1398_maxLoop=3}catch(E){return E.name===TV.InvalidState&&F.isOpen()&&--F._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),F._close(),F.open().then(()=>hl(F,U,Q,null,R))):aU(E)}let n=eV(R);n&&rQ();let J,W=G.follow(()=>{if(J=R.call(d,d),J)if(n){var E=ZF.bind(null,null);J.then(E,E)}else typeof J.next=="function"&&typeof J.throw=="function"&&(J=AV(J))},l);return(J&&typeof J.then=="function"?G.resolve(J).then(E=>d.active?E:aU(new f.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):W.then(()=>J)).then(E=>(B&&d._resolve(),d._completion.then(()=>E))).catch(E=>(d._reject(E),aU(E)))})}function SR(F,U,Q){let B=MU(F)?F.slice():[F];for(let R=0;R0,t=q(z({},r),{isVirtual:k,keyTail:e,keyLength:N,extractKey:wV(Z),unique:!k&&r.unique});if(h.push(t),t.isPrimaryKey||V.push(t),N>1){let S=N===2?Z[0]:Z.slice(0,N-1);d(S,e+1,r)}return h.sort((S,a)=>S.keyTail-a.keyTail),t}let l=d(B.primaryKey.keyPath,0,B.primaryKey);R[":id"]=[l];for(let Z of B.indexes)d(Z.keyPath,0,Z);function n(Z){let e=R[NB(Z)];return e&&e[0]}function J(Z,e){return{type:Z.type===1?2:Z.type,lower:SR(Z.lower,Z.lowerOpen?F.MAX_KEY:F.MIN_KEY,e),lowerOpen:!0,upper:SR(Z.upper,Z.upperOpen?F.MIN_KEY:F.MAX_KEY,e),upperOpen:!0}}function W(Z){let e=Z.query.index;return e.isVirtual?q(z({},Z),{query:{index:e,range:J(Z.query.range,e.keyTail)}}):Z}return q(z({},Q),{schema:q(z({},B),{primaryKey:l,indexes:V,getIndexByKeyPath:n}),count(Z){return Q.count(W(Z))},query(Z){return Q.query(W(Z))},openCursor(Z){let{keyTail:e,isVirtual:r,keyLength:c}=Z.query.index;if(!r)return Q.openCursor(Z);function h(N){function k(S){S!=null?N.continue(SR(S,Z.reverse?F.MAX_KEY:F.MIN_KEY,e)):Z.unique?N.continue(N.key.slice(0,c).concat(Z.reverse?F.MIN_KEY:F.MAX_KEY,e)):N.continue()}return Object.create(N,{continue:{value:k},continuePrimaryKey:{value(S,a){N.continuePrimaryKey(SR(S,F.MAX_KEY,e),a)}},primaryKey:{get(){return N.primaryKey}},key:{get(){let S=N.key;return c===1?S[0]:S.slice(0,c)}},value:{get(){return N.value}}})}return Q.openCursor(W(Z)).then(N=>N&&h(N))}})}})}var rZ={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:cZ};function $V(F,U,Q,B){return Q=Q||{},B=B||"",SU(F).forEach(R=>{if(!wU(U,R))Q[B+R]=void 0;else{var V=F[R],d=U[R];if(typeof V=="object"&&typeof d=="object"&&V&&d){let l=tV(V),n=tV(d);l!==n?Q[B+R]=U[R]:l==="Object"?$V(V,d,Q,B+R+"."):V!==d&&(Q[B+R]=U[R])}else V!==d&&(Q[B+R]=U[R])}}),SU(U).forEach(R=>{wU(F,R)||(Q[B+R]=U[R])}),Q}function CZ(F,U){return U.type==="delete"?U.keys:U.keys||U.values.map(F.extractKey)}var DZ={stack:"dbcore",name:"HooksMiddleware",level:2,create:F=>q(z({},F),{table(U){let Q=F.table(U),{primaryKey:B}=Q.schema;return q(z({},Q),{mutate(V){let d=u.trans,{deleting:l,creating:n,updating:J}=d.table(U).hook;switch(V.type){case"add":if(n.fire===VU)break;return d._promise("readwrite",()=>W(V),!0);case"put":if(n.fire===VU&&J.fire===VU)break;return d._promise("readwrite",()=>W(V),!0);case"delete":if(l.fire===VU)break;return d._promise("readwrite",()=>W(V),!0);case"deleteRange":if(l.fire===VU)break;return d._promise("readwrite",()=>E(V),!0)}return Q.mutate(V);function W(e){let r=u.trans,c=e.keys||CZ(B,e);if(!c)throw new Error("Keys missing");return e=e.type==="add"||e.type==="put"?q(z({},e),{keys:c}):z({},e),e.type!=="delete"&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),pZ(Q,e,c).then(h=>{let N=c.map((k,t)=>{let S=h[t],a={onerror:null,onsuccess:null};if(e.type==="delete")l.fire.call(a,k,S,r);else if(e.type==="add"||S===void 0){let T=n.fire.call(a,k,e.values[t],r);k==null&&T!=null&&(k=T,e.keys[t]=k,B.outbound||qU(e.values[t],B.keyPath,k))}else{let T=$V(S,e.values[t]),C=J.fire.call(a,T,k,S,r);if(C){let D=e.values[t];Object.keys(C).forEach(p=>{wU(D,p)?D[p]=C[p]:qU(D,p,C[p])})}}return a});return Q.mutate(e).then(({failures:k,results:t,numFailures:S,lastResult:a})=>{for(let T=0;T(N.forEach(t=>t.onerror&&t.onerror(k)),Promise.reject(k)))})}function E(e){return Z(e.trans,e.range,1e4)}function Z(e,r,c){return Q.query({trans:e,values:!1,query:{index:B,range:r},limit:c}).then(({result:h})=>W({type:"delete",keys:h,trans:e}).then(N=>N.numFailures>0?Promise.reject(N.failures[0]):h.length({table:U=>{let Q=F.table(U);return q(z({},Q),{getMany:B=>{if(!B.cache)return Q.getMany(B);let R=cl(B.keys,B.trans._cache,B.cache==="clone");return R?G.resolve(R):Q.getMany(B).then(V=>(B.trans._cache={keys:B.keys,values:B.cache==="clone"?AQ(V):V},V))},mutate:B=>(B.type!=="add"&&(B.trans._cache=null),Q.mutate(B))})}})};function U0(F){return!("from"in F)}var EF=function(F,U){if(this)yU(this,arguments.length?{d:1,from:F,to:arguments.length>1?U:F}:{d:0});else{let Q=new EF;return F&&"d"in F&&yU(Q,F),Q}};kQ(EF.prototype,{add(F){return eR(this,F),this},addKey(F){return EB(this,F,F),this},addKeys(F){return F.forEach(U=>EB(this,U,U)),this},[SV](){return F0(this)}});function EB(F,U,Q){let B=vU(U,Q);if(isNaN(B))return;if(B>0)throw RangeError();if(U0(F))return yU(F,{from:U,to:Q,d:1});let R=F.l,V=F.r;if(vU(Q,F.from)<0)return R?EB(R,U,Q):F.l={from:U,to:Q,d:1,l:null,r:null},rl(F);if(vU(U,F.to)>0)return V?EB(V,U,Q):F.r={from:U,to:Q,d:1,l:null,r:null},rl(F);vU(U,F.from)<0&&(F.from=U,F.l=null,F.d=V?V.d+1:1),vU(Q,F.to)>0&&(F.to=Q,F.r=null,F.d=F.l?F.l.d+1:1);let d=!F.r;R&&!F.l&&eR(F,R),V&&d&&eR(F,V)}function eR(F,U){function Q(B,{from:R,to:V,l:d,r:l}){EB(B,R,V),d&&Q(B,d),l&&Q(B,l)}U0(U)||Q(F,U)}function MZ(F,U){let Q=F0(U),B=Q.next();if(B.done)return!1;let R=B.value,V=F0(F),d=V.next(R.from),l=d.value;for(;!B.done&&!d.done;){if(vU(l.from,R.to)<=0&&vU(l.to,R.from)>=0)return!0;vU(R.from,l.from)<0?R=(B=Q.next(l.from)).value:l=(d=V.next(R.from)).value}return!1}function F0(F){let U=U0(F)?null:{s:0,n:F};return{next(Q){let B=arguments.length>0;for(;U;)switch(U.s){case 0:if(U.s=1,B)for(;U.n.l&&vU(Q,U.n.from)<0;)U={up:U,n:U.n.l,s:1};else for(;U.n.l;)U={up:U,n:U.n.l,s:1};case 1:if(U.s=2,!B||vU(Q,U.n.to)<=0)return{value:U.n,done:!1};case 2:if(U.n.r){U.s=3,U={up:U,n:U.n.r,s:0};continue}case 3:U=U.up}return{done:!0}}}}function rl(F){var U,Q;let B=(((U=F.r)===null||U===void 0?void 0:U.d)||0)-(((Q=F.l)===null||Q===void 0?void 0:Q.d)||0),R=B>1?"r":B<-1?"l":"";if(R){let V=R==="r"?"l":"r",d=z({},F),l=F[R];F.from=l.from,F.to=l.to,F[R]=l[R],d[R]=l[V],F[V]=d,d.d=Cl(d)}F.d=Cl(F)}function Cl({r:F,l:U}){return(F?U?Math.max(F.d,U.d):F.d:U?U.d:0)+1}var oZ={stack:"dbcore",level:0,create:F=>{let U=F.schema.name,Q=new EF(F.MIN_KEY,F.MAX_KEY);return q(z({},F),{table:B=>{let R=F.table(B),{schema:V}=R,{primaryKey:d}=V,{extractKey:l,outbound:n}=d,J=q(z({},R),{mutate:Z=>{let e=Z.trans,r=e.mutatedParts||(e.mutatedParts={}),c=T=>{let C=`idb://${U}/${B}/${T}`;return r[C]||(r[C]=new EF)},h=c(""),N=c(":dels"),{type:k}=Z,[t,S]=Z.type==="deleteRange"?[Z.range]:Z.type==="delete"?[Z.keys]:Z.values.length<50?[[],Z.values]:[],a=Z.trans._cache;return R.mutate(Z).then(T=>{if(MU(t)){k!=="delete"&&(t=T.results),h.addKeys(t);let C=cl(t,a);!C&&k!=="add"&&N.addKeys(t),(C||S)&&iZ(c,V,C,S)}else if(t){let C={from:t.lower,to:t.upper};N.add(C),h.add(C)}else h.add(Q),N.add(Q),V.indexes.forEach(C=>c(C.name).add(Q));return T})}}),W=({query:{index:Z,range:e}})=>{var r,c;return[Z,new EF((r=e.lower)!==null&&r!==void 0?r:F.MIN_KEY,(c=e.upper)!==null&&c!==void 0?c:F.MAX_KEY)]},E={get:Z=>[d,new EF(Z.key)],getMany:Z=>[d,new EF().addKeys(Z.keys)],count:W,query:W,openCursor:W};return SU(E).forEach(Z=>{J[Z]=function(e){let{subscr:r}=u;if(r){let c=S=>{let a=`idb://${U}/${B}/${S}`;return r[a]||(r[a]=new EF)},h=c(""),N=c(":dels"),[k,t]=E[Z](e);if(c(k.name||"").add(t),!k.isPrimaryKey)if(Z==="count")N.add(Q);else{let S=Z==="query"&&n&&e.values&&R.query(q(z({},e),{values:!1}));return R[Z].apply(this,arguments).then(a=>{if(Z==="query"){if(n&&e.values)return S.then(({result:C})=>(h.addKeys(C),a));let T=e.values?a.result.map(l):a.result;e.values?h.addKeys(T):N.addKeys(T)}else if(Z==="openCursor"){let T=a,C=e.values;return T&&Object.create(T,{key:{get(){return N.addKey(T.primaryKey),T.key}},primaryKey:{get(){let D=T.primaryKey;return N.addKey(D),D}},value:{get(){return C&&h.addKey(T.primaryKey),T.value}}})}return a})}}return R[Z].apply(this,arguments)}}),J}})}};function iZ(F,U,Q,B){function R(V){let d=F(V.name||"");function l(J){return J!=null?V.extractKey(J):null}let n=J=>V.multiEntry&&MU(J)?J.forEach(W=>d.addKey(W)):d.addKey(J);(Q||B).forEach((J,W)=>{let E=Q&&l(Q[W]),Z=B&&l(B[W]);vU(E,Z)!==0&&(E!=null&&n(E),Z!=null&&n(Z))})}U.indexes.forEach(R)}var tF=class{constructor(U,Q){this._middlewares={},this.verno=0;let B=tF.dependencies;this._options=Q=z({addons:tF.addons,autoOpen:!0,indexedDB:B.indexedDB,IDBKeyRange:B.IDBKeyRange},Q),this._deps={indexedDB:Q.indexedDB,IDBKeyRange:Q.IDBKeyRange};let{addons:R}=Q;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;let V={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:VU,dbReadyPromise:null,cancelOpen:VU,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};V.dbReadyPromise=new G(d=>{V.dbReadyResolve=d}),V.openCanceller=new G((d,l)=>{V.cancelOpen=l}),this._state=V,this.name=U,this.on=lB(this,"populate","blocked","versionchange","close",{ready:[hV,VU]}),this.on.ready.subscribe=Gd(this.on.ready.subscribe,d=>(l,n)=>{tF.vip(()=>{let J=this._state;if(J.openComplete)J.dbOpenError||G.resolve().then(l),n&&d(l);else if(J.onReadyBeingFired)J.onReadyBeingFired.push(l),n&&d(l);else{d(l);let W=this;n||d(function E(){W.on.ready.unsubscribe(l),W.on.ready.unsubscribe(E)})}})}),this.Collection=fW(this),this.Table=wW(this),this.Transaction=$W(this),this.Version=tZ(this),this.WhereClause=AW(this),this.on("versionchange",d=>{d.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",d=>{!d.newVersion||d.newVersionnew this.Transaction(d,l,n,this._options.chromeTransactionDurability,J),this._fireOnBlocked=d=>{this.on("blocked").fire(d),dB.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(d))},this.use(rZ),this.use(DZ),this.use(oZ),this.use(mZ),this.vip=Object.create(this,{_vip:{value:!0}}),R.forEach(d=>d(this))}version(U){if(isNaN(U)||U<.1)throw new f.Type("Given version is not a positive number");if(U=Math.round(U*10)/10,this.idbdb||this._state.isBeingOpened)throw new f.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,U);let Q=this._versions;var B=Q.filter(R=>R._cfg.version===U)[0];return B||(B=new this.Version(U),Q.push(B),Q.sort(dZ),B.stores({}),this._state.autoSchema=!1,B)}_whenReady(U){return this.idbdb&&(this._state.openComplete||u.letThrough||this._vip)?U():new G((Q,B)=>{if(this._state.openComplete)return B(new f.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen){B(new f.DatabaseClosed);return}this.open().catch(VU)}this._state.dbReadyPromise.then(Q,B)}).then(U)}use({stack:U,create:Q,level:B,name:R}){R&&this.unuse({stack:U,name:R});let V=this._middlewares[U]||(this._middlewares[U]=[]);return V.push({stack:U,create:Q,level:B??10,name:R}),V.sort((d,l)=>d.level-l.level),this}unuse({stack:U,name:Q,create:B}){return U&&this._middlewares[U]&&(this._middlewares[U]=this._middlewares[U].filter(R=>B?R.create!==B:Q?R.name!==Q:!1)),this}open(){return TZ(this)}_close(){let U=this._state,Q=dB.indexOf(this);if(Q>=0&&dB.splice(Q,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}U.dbReadyPromise=new G(B=>{U.dbReadyResolve=B}),U.openCanceller=new G((B,R)=>{U.cancelOpen=R})}close(){this._close();let U=this._state;this._options.autoOpen=!1,U.dbOpenError=new f.DatabaseClosed,U.isBeingOpened&&U.cancelOpen(U.dbOpenError)}delete(){let U=arguments.length>0,Q=this._state;return new G((B,R)=>{let V=()=>{this.close();var d=this._deps.indexedDB.deleteDatabase(this.name);d.onsuccess=WU(()=>{kZ(this._deps,this.name),B()}),d.onerror=BF(R),d.onblocked=this._fireOnBlocked};if(U)throw new f.InvalidArgument("Arguments not allowed in db.delete()");Q.isBeingOpened?Q.dbReadyPromise.then(V):V()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){let U=this._state.dbOpenError;return U&&U.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return SU(this._allTables).map(U=>this._allTables[U])}transaction(){let U=hZ.apply(this,arguments);return this._transaction.apply(this,U)}_transaction(U,Q,B){let R=u.trans;(!R||R.db!==this||U.indexOf("!")!==-1)&&(R=null);let V=U.indexOf("?")!==-1;U=U.replace("!","").replace("?","");let d,l;try{if(l=Q.map(J=>{var W=J instanceof this.Table?J.name:J;if(typeof W!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return W}),U=="r"||U===bV)d=bV;else if(U=="rw"||U==XV)d=XV;else throw new f.InvalidArgument("Invalid transaction mode: "+U);if(R){if(R.mode===bV&&d===XV)if(V)R=null;else throw new f.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");R&&l.forEach(J=>{if(R&&R.storeNames.indexOf(J)===-1)if(V)R=null;else throw new f.SubTransaction("Table "+J+" not included in parent transaction.")}),V&&R&&!R.active&&(R=null)}}catch(J){return R?R._promise(null,(W,E)=>{E(J)}):aU(J)}let n=hl.bind(null,this,d,l,R,B);return R?R._promise(d,n,"lock"):u.trans?CQ(u.transless,()=>this._whenReady(n)):this._whenReady(n)}table(U){if(!wU(this._allTables,U))throw new f.InvalidTable(`Table ${U} does not exist`);return this._allTables[U]}},sZ=typeof Symbol!="undefined"&&"observable"in Symbol?Symbol.observable:"@@observable",Dl=class{constructor(U){this._subscribe=U}subscribe(U,Q,B){return this._subscribe(!U||typeof U=="function"?{next:U,error:Q,complete:B}:U)}[sZ](){return this}};function pl(F,U){return SU(U).forEach(Q=>{let B=F[Q]||(F[Q]=new EF);eR(B,U[Q])}),F}function YZ(F){return new Dl(U=>{let Q=eV(F);function B(e){Q&&rQ();let r=()=>pF(F,{subscr:e,trans:null}),c=u.trans?CQ(u.transless,r):r();return Q&&c.then(ZF,ZF),c}let R=!1,V={},d={},l={get closed(){return R},unsubscribe:()=>{R=!0,iF.storagemutated.unsubscribe(E)}};U.start&&U.start(l);let n=!1,J=!1;function W(){return SU(d).some(e=>V[e]&&MZ(V[e],d[e]))}let E=e=>{pl(V,e),W()&&Z()},Z=()=>{if(n||R)return;V={};let e={},r=B(e);J||(iF(WB,E),J=!0),n=!0,Promise.resolve(r).then(c=>{n=!1,!R&&(W()?Z():(V={},d=e,U.next&&U.next(c)))},c=>{n=!1,U.error&&U.error(c),l.unsubscribe()})};return Z(),l})}var Q0;try{Q0={indexedDB:nU.indexedDB||nU.mozIndexedDB||nU.webkitIndexedDB||nU.msIndexedDB,IDBKeyRange:nU.IDBKeyRange||nU.webkitIDBKeyRange}}catch{Q0={indexedDB:null,IDBKeyRange:null}}var _F=tF;kQ(_F,q(z({},qB),{delete(F){return new _F(F,{addons:[]}).delete()},exists(F){return new _F(F,{addons:[]}).open().then(U=>(U.close(),!0)).catch("NoSuchDatabaseError",()=>!1)},getDatabaseNames(F){try{return SZ(_F.dependencies).then(F)}catch{return aU(new f.MissingAPI)}},defineClass(){function F(U){yU(this,U)}return F},ignoreTransaction(F){return u.trans?CQ(u.transless,F):F()},vip:_V,async:function(F){return function(){try{var U=AV(F.apply(this,arguments));return!U||typeof U.then!="function"?G.resolve(U):U}catch(Q){return aU(Q)}}},spawn:function(F,U,Q){try{var B=AV(F.apply(Q,U||[]));return!B||typeof B.then!="function"?G.resolve(B):B}catch(R){return aU(R)}},currentTransaction:{get:()=>u.trans||null},waitFor:function(F,U){let Q=G.resolve(typeof F=="function"?_F.ignoreTransaction(F):F).timeout(U||6e4);return u.trans?u.trans.waitFor(Q):Q},Promise:G,debug:{get:()=>QF,set:F=>{ud(F,F==="dexie"?()=>!0:Vl)}},derive:aQ,extend:yU,props:kQ,override:Gd,Events:lB,on:iF,liveQuery:YZ,extendObservabilitySet:pl,getByKeyPath:JF,setByKeyPath:qU,delByKeyPath:tW,shallowClone:Od,deepClone:AQ,getObjectDiff:$V,cmp:vU,asap:bd,minKey:GV,addons:[],connections:dB,errnames:TV,dependencies:Q0,semVer:Bl,version:Bl.split(".").map(F=>parseInt(F)).reduce((F,U,Q)=>F+U/Math.pow(10,Q*2))}));_F.maxKey=ZB(_F.dependencies.IDBKeyRange);typeof dispatchEvent!="undefined"&&typeof addEventListener!="undefined"&&(iF(WB,F=>{if(!SF){let U;nR?(U=document.createEvent("CustomEvent"),U.initCustomEvent(oF,!0,!0,F)):U=new CustomEvent(oF,{detail:F}),SF=!0,dispatchEvent(U),SF=!1}}),addEventListener(oF,({detail:F})=>{SF||kR(F)}));function kR(F){let U=SF;try{SF=!0,iF.storagemutated.fire(F)}finally{SF=U}}var SF=!1;if(typeof BroadcastChannel!="undefined"){let F=new BroadcastChannel(oF);iF(WB,U=>{SF||F.postMessage(U)}),F.onmessage=U=>{U.data&&kR(U.data)}}else if(typeof self!="undefined"&&typeof navigator!="undefined"){iF(WB,U=>{try{SF||(typeof localStorage!="undefined"&&localStorage.setItem(oF,JSON.stringify({trig:Math.random(),changedParts:U})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(Q=>Q.postMessage({type:oF,changedParts:U})))}catch{}}),typeof addEventListener!="undefined"&&addEventListener("storage",U=>{if(U.key===oF){let Q=JSON.parse(U.newValue);Q&&kR(Q.changedParts)}});let F=self.document&&navigator.serviceWorker;F&&F.addEventListener("message",yZ)}function yZ({data:F}){F&&F.type===oF&&kR(F.changedParts)}G.rejectionMapper=CW;ud(QF,Vl);var RF=class extends tF{constructor(){super(RF.dbName);this.version(RF.dbVersion).stores({searchHistory:"++id",minisearch:"date"})}static async clearOldDatabases(){let U=(await indexedDB.databases()).filter(Q=>Q.name===RF.dbName&&Q.version!==RF.dbVersion*10);if(U.length){console.log("Omnisearch - Those IndexedDb databases will be deleted:");for(let Q of U)Q.name&&indexedDB.deleteDatabase(Q.name)}}static getInstance(){return RF.instance||(RF.instance=new RF),RF.instance}async clearCache(){await this.minisearch.clear()}},mQ=RF;mQ.dbVersion=8,mQ.dbName="omnisearch/cache/"+app.appId;var fU=mQ.getInstance();var AF=KB(!1),B0=class extends QU.PluginSettingTab{constructor(U){super(app,U);this.plugin=U,AF.subscribe(async Q=>{O.showExcerpt=Q,await HU(this.plugin)})}display(){let{containerEl:U}=this;U.empty(),U.createEl("h2",{text:"Omnisearch"});let Q=U.createDiv();if(Q.innerHTML=` Buy Me a Coffee at ko-fi.com `,new QU.Setting(U).setName("Indexing").setHeading(),!QU.Platform.isMobileApp){let d=new DocumentFragment;d.createSpan({},l=>{l.innerHTML=`Omnisearch will include PDFs in search results.
  • \u26A0\uFE0F Each PDF can take anywhere from a few seconds to 2 minutes to be processed.
  • \u26A0\uFE0F Texts extracted from PDFs may contain errors such as missing spaces, or spaces in the middle of words.
  • \u26A0\uFE0F Some PDFs can't be processed correctly and will return an empty text.
  • This feature is currently a work-in-progress, please report issues that you might experience.
Needs a restart to fully take effect.`}),new QU.Setting(U).setName("PDF Indexing").setDesc(d).addToggle(l=>l.setValue(O.PDFIndexing).onChange(async n=>{O.PDFIndexing=n,await HU(this.plugin)}))}if(!QU.Platform.isMobileApp){let d=new DocumentFragment;d.createSpan({},l=>{l.innerHTML=`Omnisearch will use Tesseract to index images from their text.
  • Only English is supported at the moment.
  • Not all images can be correctly read by the OCR, this feature works best with scanned documents.
Needs a restart to fully take effect.`}),new QU.Setting(U).setName("BETA - Images Indexing").setDesc(d).addToggle(l=>l.setValue(O.imagesIndexing).onChange(async n=>{O.imagesIndexing=n,await HU(this.plugin)}))}let B=new DocumentFragment;B.createSpan({},d=>{d.innerHTML=`In addition to standard md files, Omnisearch can also index other plain text files.
Add extensions separated by a space, without the dot. Example: "txt org".
Needs a restart to fully take effect.`}),new QU.Setting(U).setName("Additional files to index").setDesc(B).addText(d=>{d.setValue(O.indexedFileTypes.join(" ")).setPlaceholder("Example: txt org").onChange(async l=>{O.indexedFileTypes=l.split(" "),await HU(this.plugin)})}),new QU.Setting(U).setName("Behavior").setHeading(),new QU.Setting(U).setName(`Respect Obsidian's "Excluded Files"`).setDesc(`By default, fFiles that are in Obsidian's "Options > Files & Links > Excluded Files" list are downranked in results. Enable this option to completely hide them`).addToggle(d=>d.setValue(O.hideExcluded).onChange(async l=>{O.hideExcluded=l,await HU(this.plugin)}));let R=new DocumentFragment;R.createSpan({},d=>{d.innerHTML=`Normalize diacritics in search terms. Words like "br\xFBl\xE9e" or "\u017Elu\u0165ou\u010Dk\xFD" will be indexed as "brulee" and "zlutoucky".
You probably shouldn't disable this.
Needs a restart to fully take effect.
`}),new QU.Setting(U).setName("Ignore diacritics").setDesc(R).addToggle(d=>d.setValue(O.ignoreDiacritics).onChange(async l=>{O.ignoreDiacritics=l,await HU(this.plugin)})),new QU.Setting(U).setName("Simpler search").setDesc("Enable this if Obsidian often freezes while making searches. This will return more strict results.").addToggle(d=>d.setValue(O.simpleSearch).onChange(async l=>{O.simpleSearch=l,await HU(this.plugin)})),new QU.Setting(U).setName("User Interface").setHeading(),new QU.Setting(U).setName("Show ribbon button").setDesc("Add a button on the sidebar to open the Vault search modal.").addToggle(d=>d.setValue(O.ribbonIcon).onChange(async l=>{O.ribbonIcon=l,await HU(this.plugin),l?this.plugin.addRibbonButton():this.plugin.removeRibbonButton()})),new QU.Setting(U).setName("Show excerpts").setDesc("Shows the contextual part of the note that matches the search. Disable this to only show filenames in results.").addToggle(d=>d.setValue(O.showExcerpt).onChange(async l=>{AF.set(l)})),new QU.Setting(U).setName("Render line return in excerpts").setDesc("Activate this option to render line returns in result excerpts.").addToggle(d=>d.setValue(O.renderLineReturnInExcerpts).onChange(async l=>{O.renderLineReturnInExcerpts=l,await HU(this.plugin)})),new QU.Setting(U).setName("Show previous query results").setDesc("Re-executes the previous query when opening Omnisearch.").addToggle(d=>d.setValue(O.showPreviousQueryResults).onChange(async l=>{O.showPreviousQueryResults=l,await HU(this.plugin)}));let V=new DocumentFragment;if(V.createSpan({},d=>{d.innerHTML=`Shows a button next to the search input, to create a note. Acts the same as the shift \u21B5 shortcut, can be useful for mobile device users.`}),new QU.Setting(U).setName('Show "Create note" button').setDesc(V).addToggle(d=>d.setValue(O.showCreateButton).onChange(async l=>{O.showCreateButton=l,await HU(this.plugin)})),new QU.Setting(U).setName("Hide full path in results list").setDesc("In the search results, only show the note name, without the full path.").addToggle(d=>d.setValue(O.showShortName).onChange(async l=>{O.showShortName=l,await HU(this.plugin)})),new QU.Setting(U).setName("Highlight matching words in results").setDesc("Will highlight matching results when enabled. See README for more customization options.").addToggle(d=>d.setValue(O.hightlight).onChange(async l=>{O.hightlight=l,await HU(this.plugin)})),new QU.Setting(U).setName("Results weighting").setHeading(),new QU.Setting(U).setName(`File name & declared aliases (default: ${MQ.weightBasename})`).addSlider(d=>this.weightSlider(d,"weightBasename")),new QU.Setting(U).setName(`Headings level 1 (default: ${MQ.weightH1})`).addSlider(d=>this.weightSlider(d,"weightH1")),new QU.Setting(U).setName(`Headings level 2 (default: ${MQ.weightH2})`).addSlider(d=>this.weightSlider(d,"weightH2")),new QU.Setting(U).setName(`Headings level 3 (default: ${MQ.weightH3})`).addSlider(d=>this.weightSlider(d,"weightH3")),!QU.Platform.isIosApp){new QU.Setting(U).setName("Danger Zone").setHeading();let d=new DocumentFragment;d.createSpan({},l=>{l.innerHTML=`Erase all Omnisearch cache data. Use this if Omnisearch results are inconsistent, missing, or appear outdated.
Needs a restart to fully take effect.`}),new QU.Setting(U).setName("Clear cache data").setDesc(d).addButton(l=>{l.setButtonText("Clear cache"),l.onClick(async()=>{await fU.clearCache(),new QU.Notice("Omnisearch - Cache cleared. Please restart Obsidian.")})})}}weightSlider(U,Q){U.setLimits(1,3,.1).setValue(O[Q]).setDynamicTooltip().onChange(B=>{O[Q]=B,HU(this.plugin)})}},MQ={hideExcluded:!1,ignoreDiacritics:!0,indexedFileTypes:[],PDFIndexing:!1,imagesIndexing:!1,showShortName:!1,ribbonIcon:!0,showExcerpt:!0,renderLineReturnInExcerpts:!0,showCreateButton:!1,hightlight:!0,showPreviousQueryResults:!0,simpleSearch:!1,weightBasename:2,weightH1:1.5,weightH2:1.3,weightH3:1.1,welcomeMessage:""},O=Object.assign({},MQ);async function ml(F){O=Object.assign({},MQ,await F.loadData()),AF.set(O.showExcerpt)}async function HU(F){await F.saveData(O)}var Ml=/^"|"$|^'|'$/g,ol=/[\u4e00-\u9fa5]/,tB=app.plugins.plugins["cm-chs-patch"],il=100,SB=300,sl=`suggestion-highlight omnisearch-highlight ${O.hightlight?"omnisearch-default-highlight":""}`,$=new ZV,aR={ToggleExcerpts:"toggle-excerpts"},KU=(V=>(V[V.Done=0]="Done",V[V.LoadingCache=1]="LoadingCache",V[V.ReadingFiles=2]="ReadingFiles",V[V.IndexingFiles=3]="IndexingFiles",V[V.WritingCache=4]="WritingCache",V))(KU||{});var sF=KB(0),Yl=!1;function R0(F){Yl=F}function yl(){return Yl}var vl=/[|\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;var dJ=XU(require("obsidian"));var _U=XU(require("obsidian"));var bl=XU(require("crypto")),Xl=XU(Gl());function YF(F){return`${F}`}function vZ(F){return F.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function GZ(F){return F.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function yF(F){if(!F.length)return/^$/g;let U=F.map(B=>(tB?"":"\\b")+GZ(B)).join("|");return new RegExp(`(${U})`,"gi")}function TR(F,U){return F.headings?.filter(Q=>Q.level===U).map(Q=>Q.heading)??[]}function hR(F,U){return(F+U)%U}function cR(F,U){try{let Q=U??-1,B=Math.max(0,Q-il),R=Math.min(F.length,Q+SB);if(Q>-1?F=(B>0?"\u2026":"")+F.slice(B,R).trim()+(Rl).join(` `);let d=F.lastIndexOf(` `,Q-B);d>0&&(F=F.slice(d))}return F=vZ(F),O.renderLineReturnInExcerpts&&(F=F.trim().replaceAll(` `,"
")),F}catch(Q){return new _U.Notice("Omnisearch - Error while creating excerpt, see developer console"),console.error("Omnisearch - Error while creating excerpt"),console.error(Q),""}}function Ol(F){return F.replace(Ml,"")}function d0(F){return F.replace(/(\*|_)+(.+?)(\*|_)+/g,(U,Q,B)=>B)}function Hl(F){return F?.frontmatter?(0,_U.parseFrontMatterAliases)(F.frontmatter)??[]:[]}function zl(F){return F?(0,_U.getAllTags)(F)??[]:[]}function $F(F){return F.normalize("NFD").replace(/\p{Diacritic}/gu,"")}function ul(){return _U.Platform.isMacOS?"\u2318":"ctrl"}function kB(F){return l0(F)||!_U.Platform.isMobileApp&&O.PDFIndexing&&TB(F)||!_U.Platform.isMobileApp&&O.imagesIndexing&&aB(F)}function aB(F){return F.endsWith(".png")||F.endsWith(".jpg")||F.endsWith(".jpeg")}function TB(F){return F.endsWith(".pdf")}function l0(F){return bZ().some(U=>F.endsWith(`.${U}`))}function bZ(){return[...O.indexedFileTypes,"md"]}function xl(F){let U=F.split(".");return U[U.length-1]??""}function wl(F){return _U.Platform.isMobileApp?(0,Xl.md5)(F.toString()):(0,bl.createHash)("md5").update(F).digest("hex")}function Ll(F,U){for(var Q=[],B=0,R=F.length;B>8*k+4&15]+B[h>>8*k&15];return N},V=function(h){for(var N=h.length,k=0;k>>32-D,p)}(N=function(C,D,p,o){return d(d(D,C),d(p,o))}(h,N,t,a),S,k)},n=function(h,N,k,t,S,a,T,C){return l(k&t|~k&S,N,k,a,T,C)},J=function(h,N,k,t,S,a,T,C){return l(k&S|t&~S,N,k,a,T,C)},W=function(h,N,k,t,S,a,T,C){return l(k^t^S,N,k,a,T,C)},E=function(h,N,k,t,S,a,T,C){return l(t^(k|~S),N,k,a,T,C)},Z=function(h,N,k){k===void 0&&(k=d);var t=h[0],S=h[1],a=h[2],T=h[3],C=n.bind(null,k);t=C(t,S,a,T,N[0],7,-680876936),T=C(T,t,S,a,N[1],12,-389564586),a=C(a,T,t,S,N[2],17,606105819),S=C(S,a,T,t,N[3],22,-1044525330),t=C(t,S,a,T,N[4],7,-176418897),T=C(T,t,S,a,N[5],12,1200080426),a=C(a,T,t,S,N[6],17,-1473231341),S=C(S,a,T,t,N[7],22,-45705983),t=C(t,S,a,T,N[8],7,1770035416),T=C(T,t,S,a,N[9],12,-1958414417),a=C(a,T,t,S,N[10],17,-42063),S=C(S,a,T,t,N[11],22,-1990404162),t=C(t,S,a,T,N[12],7,1804603682),T=C(T,t,S,a,N[13],12,-40341101),a=C(a,T,t,S,N[14],17,-1502002290),S=C(S,a,T,t,N[15],22,1236535329);var D=J.bind(null,k);t=D(t,S,a,T,N[1],5,-165796510),T=D(T,t,S,a,N[6],9,-1069501632),a=D(a,T,t,S,N[11],14,643717713),S=D(S,a,T,t,N[0],20,-373897302),t=D(t,S,a,T,N[5],5,-701558691),T=D(T,t,S,a,N[10],9,38016083),a=D(a,T,t,S,N[15],14,-660478335),S=D(S,a,T,t,N[4],20,-405537848),t=D(t,S,a,T,N[9],5,568446438),T=D(T,t,S,a,N[14],9,-1019803690),a=D(a,T,t,S,N[3],14,-187363961),S=D(S,a,T,t,N[8],20,1163531501),t=D(t,S,a,T,N[13],5,-1444681467),T=D(T,t,S,a,N[2],9,-51403784),a=D(a,T,t,S,N[7],14,1735328473),S=D(S,a,T,t,N[12],20,-1926607734);var p=W.bind(null,k);t=p(t,S,a,T,N[5],4,-378558),T=p(T,t,S,a,N[8],11,-2022574463),a=p(a,T,t,S,N[11],16,1839030562),S=p(S,a,T,t,N[14],23,-35309556),t=p(t,S,a,T,N[1],4,-1530992060),T=p(T,t,S,a,N[4],11,1272893353),a=p(a,T,t,S,N[7],16,-155497632),S=p(S,a,T,t,N[10],23,-1094730640),t=p(t,S,a,T,N[13],4,681279174),T=p(T,t,S,a,N[0],11,-358537222),a=p(a,T,t,S,N[3],16,-722521979),S=p(S,a,T,t,N[6],23,76029189),t=p(t,S,a,T,N[9],4,-640364487),T=p(T,t,S,a,N[12],11,-421815835),a=p(a,T,t,S,N[15],16,530742520),S=p(S,a,T,t,N[2],23,-995338651);var o=E.bind(null,k);t=o(t,S,a,T,N[0],6,-198630844),T=o(T,t,S,a,N[7],10,1126891415),a=o(a,T,t,S,N[14],15,-1416354905),S=o(S,a,T,t,N[5],21,-57434055),t=o(t,S,a,T,N[12],6,1700485571),T=o(T,t,S,a,N[3],10,-1894986606),a=o(a,T,t,S,N[10],15,-1051523),S=o(S,a,T,t,N[1],21,-2054922799),t=o(t,S,a,T,N[8],6,1873313359),T=o(T,t,S,a,N[15],10,-30611744),a=o(a,T,t,S,N[6],15,-1560198380),S=o(S,a,T,t,N[13],21,1309151649),t=o(t,S,a,T,N[4],6,-145523070),T=o(T,t,S,a,N[11],10,-1120210379),a=o(a,T,t,S,N[2],15,718787259),S=o(S,a,T,t,N[9],21,-343485551),h[0]=k(t,h[0]),h[1]=k(S,h[1]),h[2]=k(a,h[2]),h[3]=k(T,h[3])},e=function(h){for(var N=[],k=0;k<64;k+=4)N[k>>2]=h.charCodeAt(k)+(h.charCodeAt(k+1)<<8)+(h.charCodeAt(k+2)<<16)+(h.charCodeAt(k+3)<<24);return N},r=function(h,N){var k,t=h.length,S=[1732584193,-271733879,-1732584194,271733878];for(k=64;k<=t;k+=64)Z(S,e(h.substring(k-64,k)),N);var a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],T=(h=h.substring(k-64)).length;for(k=0;k>2]|=h.charCodeAt(k)<<(k%4<<3);if(a[k>>2]|=128<<(k%4<<3),k>55)for(Z(S,a,N),k=16;k--;)a[k]=0;return a[14]=8*t,Z(S,a,N),S};function c(h){var N;return V(r("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(N=function(k,t){var S=(65535&k)+(65535&t);return(k>>16)+(t>>16)+(S>>16)<<16|65535&S}),V(r(h,N))}}]);var JU=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,eU=Object.keys,iU=Array.isArray;function GU(F,U){return typeof U!="object"||eU(U).forEach(function(Q){F[Q]=U[Q]}),F}typeof Promise=="undefined"||JU.Promise||(JU.Promise=Promise);var cB=Object.getPrototypeOf,HZ={}.hasOwnProperty;function jU(F,U){return HZ.call(F,U)}function oQ(F,U){typeof U=="function"&&(U=U(cB(F))),(typeof Reflect=="undefined"?eU:Reflect.ownKeys)(U).forEach(Q=>{eF(F,Q,U[Q])})}var ql=Object.defineProperty;function eF(F,U,Q,B){ql(F,U,GU(Q&&jU(Q,"get")&&typeof Q.get=="function"?{get:Q.get,set:Q.set,configurable:!0}:{value:Q,configurable:!0,writable:!0},B))}function iQ(F){return{from:function(U){return F.prototype=Object.create(U.prototype),eF(F.prototype,"constructor",F),{extend:oQ.bind(null,F.prototype)}}}}var zZ=Object.getOwnPropertyDescriptor;function J0(F,U){let Q;return zZ(F,U)||(Q=cB(F))&&J0(Q,U)}var uZ=[].slice;function rR(F,U,Q){return uZ.call(F,U,Q)}function _l(F,U){return U(F)}function rB(F){if(!F)throw new Error("Assertion Failed")}function Al(F){JU.setImmediate?setImmediate(F):setTimeout(F,0)}function $l(F,U){return F.reduce((Q,B,R)=>{var V=U(B,R);return V&&(Q[V[0]]=V[1]),Q},{})}function kF(F,U){if(jU(F,U))return F[U];if(!U)return F;if(typeof U!="string"){for(var Q=[],B=0,R=U.length;B["Int","Uint","Float"].map(U=>U+F+"Array")))).filter(F=>JU[F]),wZ=Qn.map(F=>JU[F]);$l(Qn,F=>[F,!0]);var vF=null;function CB(F){vF=typeof WeakMap!="undefined"&&new WeakMap;let U=W0(F);return vF=null,U}function W0(F){if(!F||typeof F!="object")return F;let U=vF&&vF.get(F);if(U)return U;if(iU(F)){U=[],vF&&vF.set(F,U);for(var Q=0,B=F.length;Q=0)U=F;else{let V=cB(F);for(var R in U=V===Object.prototype?{}:Object.create(V),vF&&vF.set(F,U),F)jU(F,R)&&(U[R]=W0(F[R]))}return U}var{toString:LZ}={};function Z0(F){return LZ.call(F).slice(8,-1)}var N0=typeof Symbol!="undefined"?Symbol.iterator:"@@iterator",jZ=typeof N0=="symbol"?function(F){var U;return F!=null&&(U=F[N0])&&U.apply(F)}:function(){return null},sQ={};function aF(F){var U,Q,B,R;if(arguments.length===1){if(iU(F))return F.slice();if(this===sQ&&typeof F=="string")return[F];if(R=jZ(F)){for(Q=[];!(B=R.next()).done;)Q.push(B.value);return Q}if(F==null)return[F];if(typeof(U=F.length)=="number"){for(Q=new Array(U);U--;)Q[U]=F[U];return Q}return[F]}for(U=arguments.length,Q=new Array(U);U--;)Q[U]=arguments[U];return Q}var E0=typeof Symbol!="undefined"?F=>F[Symbol.toStringTag]==="AsyncFunction":()=>!1,VF=typeof location!="undefined"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Bn(F,U){VF=F,Rn=U}var Rn=()=>!0,IZ=!new Error("").stack;function UQ(){if(IZ)try{throw UQ.arguments,new Error}catch(F){return F}return new Error}function t0(F,U){var Q=F.stack;return Q?(U=U||0,Q.indexOf(F.name)===0&&(U+=(F.name+F.message).split(` `).length),Q.split(` `).slice(U).filter(Rn).map(B=>` `+B).join("")):""}var Vn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],S0=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Vn),fZ={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function YQ(F,U){this._e=UQ(),this.name=F,this.message=U}function dn(F,U){return F+". Errors: "+Object.keys(U).map(Q=>U[Q].toString()).filter((Q,B,R)=>R.indexOf(Q)===B).join(` `)}function CR(F,U,Q,B){this._e=UQ(),this.failures=U,this.failedKeys=B,this.successCount=Q,this.message=dn(F,U)}function DB(F,U){this._e=UQ(),this.name="BulkError",this.failures=Object.keys(U).map(Q=>U[Q]),this.failuresByPos=U,this.message=dn(F,U)}iQ(YQ).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+t0(this._e,2))}},toString:function(){return this.name+": "+this.message}}),iQ(CR).from(YQ),iQ(DB).from(YQ);var e0=S0.reduce((F,U)=>(F[U]=U+"Error",F),{}),KZ=YQ,K=S0.reduce((F,U)=>{var Q=U+"Error";function B(R,V){this._e=UQ(),this.name=Q,R?typeof R=="string"?(this.message=`${R}${V?` `+V:""}`,this.inner=V||null):typeof R=="object"&&(this.message=`${R.name} ${R.message}`,this.inner=R):(this.message=fZ[U]||Q,this.inner=null)}return iQ(B).from(KZ),F[U]=B,F},{});K.Syntax=SyntaxError,K.Type=TypeError,K.Range=RangeError;var ln=Vn.reduce((F,U)=>(F[U+"Error"]=K[U],F),{}),DR=S0.reduce((F,U)=>(["Syntax","Type","Range"].indexOf(U)===-1&&(F[U+"Error"]=K[U]),F),{});function dU(){}function pB(F){return F}function gZ(F,U){return F==null||F===pB?U:function(Q){return U(F(Q))}}function FQ(F,U){return function(){F.apply(this,arguments),U.apply(this,arguments)}}function PZ(F,U){return F===dU?U:function(){var Q=F.apply(this,arguments);Q!==void 0&&(arguments[0]=Q);var B=this.onsuccess,R=this.onerror;this.onsuccess=null,this.onerror=null;var V=U.apply(this,arguments);return B&&(this.onsuccess=this.onsuccess?FQ(B,this.onsuccess):B),R&&(this.onerror=this.onerror?FQ(R,this.onerror):R),V!==void 0?V:Q}}function qZ(F,U){return F===dU?U:function(){F.apply(this,arguments);var Q=this.onsuccess,B=this.onerror;this.onsuccess=this.onerror=null,U.apply(this,arguments),Q&&(this.onsuccess=this.onsuccess?FQ(Q,this.onsuccess):Q),B&&(this.onerror=this.onerror?FQ(B,this.onerror):B)}}function _Z(F,U){return F===dU?U:function(Q){var B=F.apply(this,arguments);GU(Q,B);var R=this.onsuccess,V=this.onerror;this.onsuccess=null,this.onerror=null;var d=U.apply(this,arguments);return R&&(this.onsuccess=this.onsuccess?FQ(R,this.onsuccess):R),V&&(this.onerror=this.onerror?FQ(V,this.onerror):V),B===void 0?d===void 0?void 0:d:GU(B,d)}}function AZ(F,U){return F===dU?U:function(){return U.apply(this,arguments)!==!1&&F.apply(this,arguments)}}function k0(F,U){return F===dU?U:function(){var Q=F.apply(this,arguments);if(Q&&typeof Q.then=="function"){for(var B=this,R=arguments.length,V=new Array(R);R--;)V[R]=arguments[R];return Q.then(function(){return U.apply(B,V)})}return U.apply(this,arguments)}}DR.ModifyError=CR,DR.DexieError=YQ,DR.BulkError=DB;var mB={},[a0,pR,T0]=typeof Promise=="undefined"?[]:(()=>{let F=Promise.resolve();if(typeof crypto=="undefined"||!crypto.subtle)return[F,cB(F),F];let U=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[U,cB(U),F]})(),nn=pR&&pR.then,mR=a0&&a0.constructor,h0=!!T0,c0=!1,$Z=T0?()=>{T0.then(sR)}:JU.setImmediate?setImmediate.bind(null,sR):JU.MutationObserver?()=>{var F=document.createElement("div");new MutationObserver(()=>{sR(),F=null}).observe(F,{attributes:!0}),F.setAttribute("i","1")}:()=>{setTimeout(sR,0)},MB=function(F,U){oB.push([F,U]),MR&&($Z(),MR=!1)},r0=!0,MR=!0,QQ=[],oR=[],C0=null,D0=pB,yQ={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:kn,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(F=>{try{kn(F[0],F[1])}catch{}})}},x=yQ,oB=[],BQ=0,iR=[];function b(F){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=dU,this._lib=!1;var U=this._PSD=x;if(VF&&(this._stackHolder=UQ(),this._prev=null,this._numPrev=0),typeof F!="function"){if(F!==mB)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&m0(this,this._value))}this._state=null,this._value=null,++U.ref,Wn(this,F)}var p0={get:function(){var F=x,U=vR;function Q(B,R){var V=!F.global&&(F!==x||U!==vR);let d=V&&!TF();var l=new b((n,J)=>{M0(this,new Jn(bR(B,F,V,d),bR(R,F,V,d),n,J,F))});return VF&&En(l,this),l}return Q.prototype=mB,Q},set:function(F){eF(this,"then",F&&F.prototype===mB?p0:{get:function(){return F},set:p0.set})}};function Jn(F,U,Q,B,R){this.onFulfilled=typeof F=="function"?F:null,this.onRejected=typeof U=="function"?U:null,this.resolve=Q,this.reject=B,this.psd=R}function Wn(F,U){try{U(Q=>{if(F._state===null){if(Q===F)throw new TypeError("A promise cannot be resolved with itself.");var B=F._lib&&iB();Q&&typeof Q.then=="function"?Wn(F,(R,V)=>{Q instanceof b?Q._then(R,V):Q.then(R,V)}):(F._state=!0,F._value=Q,Zn(F)),B&&sB()}},m0.bind(null,F))}catch(Q){m0(F,Q)}}function m0(F,U){if(oR.push(U),F._state===null){var Q=F._lib&&iB();U=D0(U),F._state=!1,F._value=U,VF&&U!==null&&typeof U=="object"&&!U._promise&&function(B,R,V){try{B.apply(null,V)}catch(d){R&&R(d)}}(()=>{var B=J0(U,"stack");U._promise=F,eF(U,"stack",{get:()=>c0?B&&(B.get?B.get.apply(U):B.value):F.stack})}),function(B){QQ.some(R=>R._value===B._value)||QQ.push(B)}(F),Zn(F),Q&&sB()}}function Zn(F){var U=F._listeners;F._listeners=[];for(var Q=0,B=U.length;Q{--BQ==0&&o0()},[]))}function M0(F,U){if(F._state!==null){var Q=F._state?U.onFulfilled:U.onRejected;if(Q===null)return(F._state?U.resolve:U.reject)(F._value);++U.psd.ref,++BQ,MB(UN,[Q,F,U])}else F._listeners.push(U)}function UN(F,U,Q){try{C0=U;var B,R=U._value;U._state?B=F(R):(oR.length&&(oR=[]),B=F(R),oR.indexOf(R)===-1&&function(V){for(var d=QQ.length;d;)if(QQ[--d]._value===V._value)return void QQ.splice(d,1)}(U)),Q.resolve(B)}catch(V){Q.reject(V)}finally{C0=null,--BQ==0&&o0(),--Q.psd.ref||Q.psd.finalize()}}function Nn(F,U,Q){if(U.length===Q)return U;var B="";if(F._state===!1){var R,V,d=F._value;d!=null?(R=d.name||"Error",V=d.message||d,B=t0(d,0)):(R=d,V=""),U.push(R+(V?": "+V:"")+B)}return VF&&((B=t0(F._stackHolder,2))&&U.indexOf(B)===-1&&U.push(B),F._prev&&Nn(F._prev,U,Q)),U}function En(F,U){var Q=U?U._numPrev+1:0;Q<100&&(F._prev=U,F._numPrev=Q)}function sR(){iB()&&sB()}function iB(){var F=r0;return r0=!1,MR=!1,F}function sB(){var F,U,Q;do for(;oB.length>0;)for(F=oB,oB=[],Q=F.length,U=0;U0);r0=!0,MR=!0}function o0(){var F=QQ;QQ=[],F.forEach(B=>{B._PSD.onunhandled.call(null,B._value,B)});for(var U=iR.slice(0),Q=U.length;Q;)U[--Q]()}function YR(F){return new b(mB,!1,F)}function ZU(F,U){var Q=x;return function(){var B=iB(),R=x;try{return bF(Q,!0),F.apply(this,arguments)}catch(V){U&&U(V)}finally{bF(R,!1),B&&sB()}}}oQ(b.prototype,{then:p0,_then:function(F,U){M0(this,new Jn(null,null,F,U,x))},catch:function(F){if(arguments.length===1)return this.then(null,F);var U=arguments[0],Q=arguments[1];return typeof U=="function"?this.then(null,B=>B instanceof U?Q(B):YR(B)):this.then(null,B=>B&&B.name===U?Q(B):YR(B))},finally:function(F){return this.then(U=>(F(),U),U=>(F(),YR(U)))},stack:{get:function(){if(this._stack)return this._stack;try{c0=!0;var F=Nn(this,[],20).join(` From previous: `);return this._state!==null&&(this._stack=F),F}finally{c0=!1}}},timeout:function(F,U){return F<1/0?new b((Q,B)=>{var R=setTimeout(()=>B(new K.Timeout(U)),F);this.then(Q,B).finally(clearTimeout.bind(null,R))}):this}}),typeof Symbol!="undefined"&&Symbol.toStringTag&&eF(b.prototype,Symbol.toStringTag,"Dexie.Promise"),yQ.env=tn(),oQ(b,{all:function(){var F=aF.apply(null,arguments).map(GR);return new b(function(U,Q){F.length===0&&U([]);var B=F.length;F.forEach((R,V)=>b.resolve(R).then(d=>{F[V]=d,--B||U(F)},Q))})},resolve:F=>{if(F instanceof b)return F;if(F&&typeof F.then=="function")return new b((Q,B)=>{F.then(Q,B)});var U=new b(mB,!0,F);return En(U,C0),U},reject:YR,race:function(){var F=aF.apply(null,arguments).map(GR);return new b((U,Q)=>{F.map(B=>b.resolve(B).then(U,Q))})},PSD:{get:()=>x,set:F=>x=F},totalEchoes:{get:()=>vR},newPSD:GF,usePSD:GQ,scheduler:{get:()=>MB,set:F=>{MB=F}},rejectionMapper:{get:()=>D0,set:F=>{D0=F}},follow:(F,U)=>new b((Q,B)=>GF((R,V)=>{var d=x;d.unhandleds=[],d.onunhandled=V,d.finalize=FQ(function(){(function(l){function n(){l(),iR.splice(iR.indexOf(n),1)}iR.push(n),++BQ,MB(()=>{--BQ==0&&o0()},[])})(()=>{this.unhandleds.length===0?R():V(this.unhandleds[0])})},d.finalize),F()},U,Q,B))}),mR&&(mR.allSettled&&eF(b,"allSettled",function(){let F=aF.apply(null,arguments).map(GR);return new b(U=>{F.length===0&&U([]);let Q=F.length,B=new Array(Q);F.forEach((R,V)=>b.resolve(R).then(d=>B[V]={status:"fulfilled",value:d},d=>B[V]={status:"rejected",reason:d}).then(()=>--Q||U(B)))})}),mR.any&&typeof AggregateError!="undefined"&&eF(b,"any",function(){let F=aF.apply(null,arguments).map(GR);return new b((U,Q)=>{F.length===0&&Q(new AggregateError([]));let B=F.length,R=new Array(B);F.forEach((V,d)=>b.resolve(V).then(l=>U(l),l=>{R[d]=l,--B||Q(new AggregateError(R))}))})}));var sU={awaits:0,echoes:0,id:0},FN=0,yR=[],i0=0,vR=0,QN=0;function GF(F,U,Q,B){var R=x,V=Object.create(R);V.parent=R,V.ref=0,V.global=!1,V.id=++QN;var d=yQ.env;V.env=h0?{Promise:b,PromiseProp:{value:b,configurable:!0,writable:!0},all:b.all,race:b.race,allSettled:b.allSettled,any:b.any,resolve:b.resolve,reject:b.reject,nthen:en(d.nthen,V),gthen:en(d.gthen,V)}:{},U&&GU(V,U),++R.ref,V.finalize=function(){--this.parent.ref||this.parent.finalize()};var l=GQ(V,F,Q,B);return V.ref===0&&V.finalize(),l}function vQ(){return sU.id||(sU.id=++FN),++sU.awaits,sU.echoes+=100,sU.id}function TF(){return!!sU.awaits&&(--sU.awaits==0&&(sU.id=0),sU.echoes=100*sU.awaits,!0)}function GR(F){return sU.echoes&&F&&F.constructor===mR?(vQ(),F.then(U=>(TF(),U),U=>(TF(),TU(U)))):F}function BN(F){++vR,sU.echoes&&--sU.echoes!=0||(sU.echoes=sU.id=0),yR.push(x),bF(F,!0)}function RN(){var F=yR[yR.length-1];yR.pop(),bF(F,!1)}function bF(F,U){var Q=x;if((U?!sU.echoes||i0++&&F===x:!i0||--i0&&F===x)||Sn(U?BN.bind(null,F):RN),F!==x&&(x=F,Q===yQ&&(yQ.env=tn()),h0)){var B=yQ.env.Promise,R=F.env;pR.then=R.nthen,B.prototype.then=R.gthen,(Q.global||F.global)&&(Object.defineProperty(JU,"Promise",R.PromiseProp),B.all=R.all,B.race=R.race,B.resolve=R.resolve,B.reject=R.reject,R.allSettled&&(B.allSettled=R.allSettled),R.any&&(B.any=R.any))}}function tn(){var F=JU.Promise;return h0?{Promise:F,PromiseProp:Object.getOwnPropertyDescriptor(JU,"Promise"),all:F.all,race:F.race,allSettled:F.allSettled,any:F.any,resolve:F.resolve,reject:F.reject,nthen:pR.then,gthen:F.prototype.then}:{}}function GQ(F,U,Q,B,R){var V=x;try{return bF(F,!0),U(Q,B,R)}finally{bF(V,!1)}}function Sn(F){nn.call(a0,F)}function bR(F,U,Q,B){return typeof F!="function"?F:function(){var R=x;Q&&vQ(),bF(U,!0);try{return F.apply(this,arguments)}finally{bF(R,!1),B&&Sn(TF)}}}function en(F,U){return function(Q,B){return F.call(this,bR(Q,U),bR(B,U))}}(""+nn).indexOf("[native code]")===-1&&(vQ=TF=dU);function kn(F,U){var Q;try{Q=U.onuncatched(F)}catch{}if(Q!==!1)try{var B,R={promise:U,reason:F};if(JU.document&&document.createEvent?((B=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),GU(B,R)):JU.CustomEvent&&GU(B=new CustomEvent("unhandledrejection",{detail:R}),R),B&&JU.dispatchEvent&&(dispatchEvent(B),!JU.PromiseRejectionEvent&&JU.onunhandledrejection))try{JU.onunhandledrejection(B)}catch{}VF&&B&&!B.defaultPrevented&&console.warn(`Unhandled rejection: ${F.stack||F}`)}catch{}}var TU=b.reject;function s0(F,U,Q,B){if(F.idbdb&&(F._state.openComplete||x.letThrough||F._vip)){var R=F._createTransaction(U,Q,F._dbSchema);try{R.create(),F._state.PR1398_maxLoop=3}catch(V){return V.name===e0.InvalidState&&F.isOpen()&&--F._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),F._close(),F.open().then(()=>s0(F,U,Q,B))):TU(V)}return R._promise(U,(V,d)=>GF(()=>(x.trans=R,B(V,d,R)))).then(V=>R._completion.then(()=>V))}if(F._state.openComplete)return TU(new K.DatabaseClosed(F._state.dbOpenError));if(!F._state.isBeingOpened){if(!F._options.autoOpen)return TU(new K.DatabaseClosed);F.open().catch(dU)}return F._state.dbReadyPromise.then(()=>s0(F,U,Q,B))}var RQ=String.fromCharCode(65535),hF="Invalid key provided. Keys must be of type string, number, Date or Array.",YB=[],XR=typeof navigator!="undefined"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),VN=XR,dN=XR,an=F=>!/(dexie\.js|dexie\.min\.js)/.test(F);function VQ(F,U){return F?U?function(){return F.apply(this,arguments)&&U.apply(this,arguments)}:F:U}var Tn={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function OR(F){return typeof F!="string"||/\./.test(F)?U=>U:U=>(U[F]===void 0&&F in U&&delete(U=CB(U))[F],U)}var hn=class{_trans(U,Q,B){let R=this._tx||x.trans,V=this.name;function d(n,J,W){if(!W.schema[V])throw new K.NotFound("Table "+V+" not part of transaction");return Q(W.idbtrans,W)}let l=iB();try{return R&&R.db===this.db?R===x.trans?R._promise(U,d,B):GF(()=>R._promise(U,d,B),{trans:R,transless:x.transless||x}):s0(this.db,U,[this.name],d)}finally{l&&sB()}}get(U,Q){return U&&U.constructor===Object?this.where(U).first(Q):this._trans("readonly",B=>this.core.get({trans:B,key:U}).then(R=>this.hook.reading.fire(R))).then(Q)}where(U){if(typeof U=="string")return new this.db.WhereClause(this,U);if(iU(U))return new this.db.WhereClause(this,`[${U.join("+")}]`);let Q=eU(U);if(Q.length===1)return this.where(Q[0]).equals(U[Q[0]]);let B=this.schema.indexes.concat(this.schema.primKey).filter(J=>J.compound&&Q.every(W=>J.keyPath.indexOf(W)>=0)&&J.keyPath.every(W=>Q.indexOf(W)>=0))[0];if(B&&this.db._maxKey!==RQ)return this.where(B.name).equals(B.keyPath.map(J=>U[J]));!B&&VF&&console.warn(`The query ${JSON.stringify(U)} on ${this.name} would benefit of a compound index [${Q.join("+")}]`);let{idxByName:R}=this.schema,V=this.db._deps.indexedDB;function d(J,W){try{return V.cmp(J,W)===0}catch{return!1}}let[l,n]=Q.reduce(([J,W],E)=>{let Z=R[E],e=U[E];return[J||Z,J||!Z?VQ(W,Z&&Z.multi?r=>{let c=kF(r,E);return iU(c)&&c.some(h=>d(e,h))}:r=>d(e,kF(r,E))):W]},[null,null]);return l?this.where(l.name).equals(U[l.keyPath]).filter(n):B?this.filter(n):this.where(Q).equals("")}filter(U){return this.toCollection().and(U)}count(U){return this.toCollection().count(U)}offset(U){return this.toCollection().offset(U)}limit(U){return this.toCollection().limit(U)}each(U){return this.toCollection().each(U)}toArray(U){return this.toCollection().toArray(U)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(U){return new this.db.Collection(new this.db.WhereClause(this,iU(U)?`[${U.join("+")}]`:U))}reverse(){return this.toCollection().reverse()}mapToClass(U){this.schema.mappedClass=U;let Q=B=>{if(!B)return B;let R=Object.create(U.prototype);for(var V in B)if(jU(B,V))try{R[V]=B[V]}catch{}return R};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=Q,this.hook("reading",Q),U}defineClass(){return this.mapToClass(function(U){GU(this,U)})}add(U,Q){let{auto:B,keyPath:R}=this.schema.primKey,V=U;return R&&B&&(V=OR(R)(U)),this._trans("readwrite",d=>this.core.mutate({trans:d,type:"add",keys:Q!=null?[Q]:null,values:[V]})).then(d=>d.numFailures?b.reject(d.failures[0]):d.lastResult).then(d=>{if(R)try{AU(U,R,d)}catch{}return d})}update(U,Q){if(typeof U!="object"||iU(U))return this.where(":id").equals(U).modify(Q);{let B=kF(U,this.schema.primKey.keyPath);if(B===void 0)return TU(new K.InvalidArgument("Given object does not contain its primary key"));try{typeof Q!="function"?eU(Q).forEach(R=>{AU(U,R,Q[R])}):Q(U,{value:U,primKey:B})}catch{}return this.where(":id").equals(B).modify(Q)}}put(U,Q){let{auto:B,keyPath:R}=this.schema.primKey,V=U;return R&&B&&(V=OR(R)(U)),this._trans("readwrite",d=>this.core.mutate({trans:d,type:"put",values:[V],keys:Q!=null?[Q]:null})).then(d=>d.numFailures?b.reject(d.failures[0]):d.lastResult).then(d=>{if(R)try{AU(U,R,d)}catch{}return d})}delete(U){return this._trans("readwrite",Q=>this.core.mutate({trans:Q,type:"delete",keys:[U]})).then(Q=>Q.numFailures?b.reject(Q.failures[0]):void 0)}clear(){return this._trans("readwrite",U=>this.core.mutate({trans:U,type:"deleteRange",range:Tn})).then(U=>U.numFailures?b.reject(U.failures[0]):void 0)}bulkGet(U){return this._trans("readonly",Q=>this.core.getMany({keys:U,trans:Q}).then(B=>B.map(R=>this.hook.reading.fire(R))))}bulkAdd(U,Q,B){let R=Array.isArray(Q)?Q:void 0,V=(B=B||(R?void 0:Q))?B.allKeys:void 0;return this._trans("readwrite",d=>{let{auto:l,keyPath:n}=this.schema.primKey;if(n&&R)throw new K.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(R&&R.length!==U.length)throw new K.InvalidArgument("Arguments objects and keys must have the same length");let J=U.length,W=n&&l?U.map(OR(n)):U;return this.core.mutate({trans:d,type:"add",keys:R,values:W,wantResults:V}).then(({numFailures:E,results:Z,lastResult:e,failures:r})=>{if(E===0)return V?Z:e;throw new DB(`${this.name}.bulkAdd(): ${E} of ${J} operations failed`,r)})})}bulkPut(U,Q,B){let R=Array.isArray(Q)?Q:void 0,V=(B=B||(R?void 0:Q))?B.allKeys:void 0;return this._trans("readwrite",d=>{let{auto:l,keyPath:n}=this.schema.primKey;if(n&&R)throw new K.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(R&&R.length!==U.length)throw new K.InvalidArgument("Arguments objects and keys must have the same length");let J=U.length,W=n&&l?U.map(OR(n)):U;return this.core.mutate({trans:d,type:"put",keys:R,values:W,wantResults:V}).then(({numFailures:E,results:Z,lastResult:e,failures:r})=>{if(E===0)return V?Z:e;throw new DB(`${this.name}.bulkPut(): ${E} of ${J} operations failed`,r)})})}bulkDelete(U){let Q=U.length;return this._trans("readwrite",B=>this.core.mutate({trans:B,type:"delete",keys:U})).then(({numFailures:B,lastResult:R,failures:V})=>{if(B===0)return R;throw new DB(`${this.name}.bulkDelete(): ${B} of ${Q} operations failed`,V)})}};function yB(F){var U={},Q=function(l,n){if(n){for(var J=arguments.length,W=new Array(J-1);--J;)W[J-1]=arguments[J];return U[l].subscribe.apply(null,W),F}if(typeof l=="string")return U[l]};Q.addEventType=V;for(var B=1,R=arguments.length;BVQ(B(),U()):U,F.justLimit=Q&&!B}function HR(F,U){if(F.isPrimKey)return U.primaryKey;let Q=U.getIndexByKeyPath(F.index);if(!Q)throw new K.Schema("KeyPath "+F.index+" on object store "+U.name+" is not indexed");return Q}function cn(F,U,Q){let B=HR(F,U.schema);return U.openCursor({trans:Q,values:!F.keysOnly,reverse:F.dir==="prev",unique:!!F.unique,query:{index:B,range:F.range}})}function zR(F,U,Q,B){let R=F.replayFilter?VQ(F.filter,F.replayFilter()):F.filter;if(F.or){let V={},d=(l,n,J)=>{if(!R||R(n,J,Z=>n.stop(Z),Z=>n.fail(Z))){var W=n.primaryKey,E=""+W;E==="[object ArrayBuffer]"&&(E=""+new Uint8Array(W)),jU(V,E)||(V[E]=!0,U(l,n,J))}};return Promise.all([F.or._iterate(d,Q),rn(cn(F,B,Q),F.algorithm,d,!F.keysOnly&&F.valueMapper)])}return rn(cn(F,B,Q),VQ(F.algorithm,R),U,!F.keysOnly&&F.valueMapper)}function rn(F,U,Q,B){var R=ZU(B?(V,d,l)=>Q(B(V),d,l):Q);return F.then(V=>{if(V)return V.start(()=>{var d=()=>V.continue();U&&!U(V,l=>d=l,l=>{V.stop(l),d=dU},l=>{V.fail(l),d=dU})||R(V.value,V,l=>d=l),d()})})}function bU(F,U){try{let Q=Cn(F),B=Cn(U);if(Q!==B)return Q==="Array"?1:B==="Array"?-1:Q==="binary"?1:B==="binary"?-1:Q==="string"?1:B==="string"?-1:Q==="Date"?1:B!=="Date"?NaN:-1;switch(Q){case"number":case"Date":case"string":return F>U?1:FzR(Q,U,B,Q.table.core))}count(U){return this._read(Q=>{let B=this._ctx,R=B.table.core;if(bQ(B,!0))return R.count({trans:Q,query:{index:HR(B,R.schema),range:B.range}}).then(d=>Math.min(d,B.limit));var V=0;return zR(B,()=>(++V,!1),Q,R).then(()=>V)}).then(U)}sortBy(U,Q){let B=U.split(".").reverse(),R=B[0],V=B.length-1;function d(J,W){return W?d(J[B[W]],W-1):J[R]}var l=this._ctx.dir==="next"?1:-1;function n(J,W){var E=d(J,V),Z=d(W,V);return EZ?l:0}return this.toArray(function(J){return J.sort(n)}).then(Q)}toArray(U){return this._read(Q=>{var B=this._ctx;if(B.dir==="next"&&bQ(B,!0)&&B.limit>0){let{valueMapper:R}=B,V=HR(B,B.table.core.schema);return B.table.core.query({trans:Q,limit:B.limit,values:!0,query:{index:V,range:B.range}}).then(({result:d})=>R?d.map(R):d)}{let R=[];return zR(B,V=>R.push(V),Q,B.table.core).then(()=>R)}},U)}offset(U){var Q=this._ctx;return U<=0||(Q.offset+=U,bQ(Q)?y0(Q,()=>{var B=U;return(R,V)=>B===0||(B===1?(--B,!1):(V(()=>{R.advance(B),B=0}),!1))}):y0(Q,()=>{var B=U;return()=>--B<0})),this}limit(U){return this._ctx.limit=Math.min(this._ctx.limit,U),y0(this._ctx,()=>{var Q=U;return function(B,R,V){return--Q<=0&&R(V),Q>=0}},!0),this}until(U,Q){return Y0(this._ctx,function(B,R,V){return!U(B.value)||(R(V),Q)}),this}first(U){return this.limit(1).toArray(function(Q){return Q[0]}).then(U)}last(U){return this.reverse().first(U)}filter(U){var Q,B;return Y0(this._ctx,function(R){return U(R.value)}),Q=this._ctx,B=U,Q.isMatch=VQ(Q.isMatch,B),this}and(U){return this.filter(U)}or(U){return new this.db.WhereClause(this._ctx.table,U,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(U){var Q=this._ctx;return Q.keysOnly=!Q.isMatch,this.each(function(B,R){U(R.key,R)})}eachUniqueKey(U){return this._ctx.unique="unique",this.eachKey(U)}eachPrimaryKey(U){var Q=this._ctx;return Q.keysOnly=!Q.isMatch,this.each(function(B,R){U(R.primaryKey,R)})}keys(U){var Q=this._ctx;Q.keysOnly=!Q.isMatch;var B=[];return this.each(function(R,V){B.push(V.key)}).then(function(){return B}).then(U)}primaryKeys(U){var Q=this._ctx;if(Q.dir==="next"&&bQ(Q,!0)&&Q.limit>0)return this._read(R=>{var V=HR(Q,Q.table.core.schema);return Q.table.core.query({trans:R,values:!1,limit:Q.limit,query:{index:V,range:Q.range}})}).then(({result:R})=>R).then(U);Q.keysOnly=!Q.isMatch;var B=[];return this.each(function(R,V){B.push(V.primaryKey)}).then(function(){return B}).then(U)}uniqueKeys(U){return this._ctx.unique="unique",this.keys(U)}firstKey(U){return this.limit(1).keys(function(Q){return Q[0]}).then(U)}lastKey(U){return this.reverse().firstKey(U)}distinct(){var U=this._ctx,Q=U.index&&U.table.schema.idxByName[U.index];if(!Q||!Q.multi)return this;var B={};return Y0(this._ctx,function(R){var V=R.primaryKey.toString(),d=jU(B,V);return B[V]=!0,!d}),this}modify(U){var Q=this._ctx;return this._write(B=>{var R;if(typeof U=="function")R=U;else{var V=eU(U),d=V.length;R=function(c){for(var h=!1,N=0;N{let{failures:N,numFailures:k}=h;Z+=c-k;for(let t of eU(N))E.push(N[t])};return this.clone().primaryKeys().then(c=>{let h=N=>{let k=Math.min(W,c.length-N);return l.getMany({trans:B,keys:c.slice(N,N+k),cache:"immutable"}).then(t=>{let S=[],a=[],T=n?[]:null,C=[];for(let p=0;p0&&l.mutate({trans:B,type:"add",values:S}).then(p=>{for(let o in p.failures)C.splice(parseInt(o),1);r(S.length,p)})).then(()=>(a.length>0||D&&typeof U=="object")&&l.mutate({trans:B,type:"put",keys:T,values:a,criteria:D,changeSpec:typeof U!="function"&&U}).then(p=>r(a.length,p))).then(()=>(C.length>0||D&&U===v0)&&l.mutate({trans:B,type:"delete",keys:C,criteria:D}).then(p=>r(C.length,p))).then(()=>c.length>N+k&&h(N+W))})};return h(0).then(()=>{if(E.length>0)throw new CR("Error modifying one or more objects",E,Z,e);return c.length})})})}delete(){var U=this._ctx,Q=U.range;return bQ(U)&&(U.isPrimKey&&!dN||Q.type===3)?this._write(B=>{let{primaryKey:R}=U.table.core.schema,V=Q;return U.table.core.count({trans:B,query:{index:R,range:V}}).then(d=>U.table.core.mutate({trans:B,type:"deleteRange",range:V}).then(({failures:l,lastResult:n,results:J,numFailures:W})=>{if(W)throw new CR("Could not delete some values",Object.keys(l).map(E=>l[E]),d-W);return d-W}))}):this.modify(v0)}},v0=(F,U)=>U.value=null;function lN(F,U){return FU?-1:F===U?0:1}function IU(F,U,Q){var B=F instanceof G0?new F.Collection(F):F;return B._ctx.error=Q?new Q(U):new TypeError(U),B}function XQ(F){return new F.Collection(F,()=>mn("")).limit(0)}function JN(F,U,Q,B,R,V){for(var d=Math.min(F.length,B.length),l=-1,n=0;n=0?F.substr(0,l)+U[l]+Q.substr(l+1):null;R(F[n],J)<0&&(l=n)}return dtypeof c=="string"))return IU(F,"String expected.");function Z(c){R=function(N){return N==="next"?k=>k.toUpperCase():k=>k.toLowerCase()}(c),V=function(N){return N==="next"?k=>k.toLowerCase():k=>k.toUpperCase()}(c),d=c==="next"?lN:nN;var h=Q.map(function(N){return{lower:V(N),upper:R(N)}}).sort(function(N,k){return d(N.lower,k.lower)});l=h.map(function(N){return N.upper}),n=h.map(function(N){return N.lower}),J=c,W=c==="next"?"":B}Z("next");var e=new F.Collection(F,()=>XF(l[0],n[E-1]+B));e._ondirectionchange=function(c){Z(c)};var r=0;return e._addAlgorithm(function(c,h,N){var k=c.key;if(typeof k!="string")return!1;var t=V(k);if(U(t,n,r))return!0;for(var S=null,a=r;a0)&&(S=T)}return h(S!==null?function(){c.continue(S+W)}:N),!1}),e}function XF(F,U,Q,B){return{type:2,lower:F,upper:U,lowerOpen:Q,upperOpen:B}}function mn(F){return{type:1,lower:F,upper:F}}var G0=class{get Collection(){return this._ctx.table.db.Collection}between(U,Q,B,R){B=B!==!1,R=R===!0;try{return this._cmp(U,Q)>0||this._cmp(U,Q)===0&&(B||R)&&(!B||!R)?XQ(this):new this.Collection(this,()=>XF(U,Q,!B,!R))}catch{return IU(this,hF)}}equals(U){return U==null?IU(this,hF):new this.Collection(this,()=>mn(U))}above(U){return U==null?IU(this,hF):new this.Collection(this,()=>XF(U,void 0,!0))}aboveOrEqual(U){return U==null?IU(this,hF):new this.Collection(this,()=>XF(U,void 0,!1))}below(U){return U==null?IU(this,hF):new this.Collection(this,()=>XF(void 0,U,!1,!0))}belowOrEqual(U){return U==null?IU(this,hF):new this.Collection(this,()=>XF(void 0,U))}startsWith(U){return typeof U!="string"?IU(this,"String expected."):this.between(U,U+RQ,!0,!0)}startsWithIgnoreCase(U){return U===""?this.startsWith(U):uR(this,(Q,B)=>Q.indexOf(B[0])===0,[U],RQ)}equalsIgnoreCase(U){return uR(this,(Q,B)=>Q===B[0],[U],"")}anyOfIgnoreCase(){var U=aF.apply(sQ,arguments);return U.length===0?XQ(this):uR(this,(Q,B)=>B.indexOf(Q)!==-1,U,"")}startsWithAnyOfIgnoreCase(){var U=aF.apply(sQ,arguments);return U.length===0?XQ(this):uR(this,(Q,B)=>B.some(R=>Q.indexOf(R)===0),U,RQ)}anyOf(){let U=aF.apply(sQ,arguments),Q=this._cmp;try{U.sort(Q)}catch{return IU(this,hF)}if(U.length===0)return XQ(this);let B=new this.Collection(this,()=>XF(U[0],U[U.length-1]));B._ondirectionchange=V=>{Q=V==="next"?this._ascending:this._descending,U.sort(Q)};let R=0;return B._addAlgorithm((V,d,l)=>{let n=V.key;for(;Q(n,U[R])>0;)if(++R,R===U.length)return d(l),!1;return Q(n,U[R])===0||(d(()=>{V.continue(U[R])}),!1)}),B}notEqual(U){return this.inAnyRange([[-(1/0),U],[U,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let U=aF.apply(sQ,arguments);if(U.length===0)return new this.Collection(this);try{U.sort(this._ascending)}catch{return IU(this,hF)}let Q=U.reduce((B,R)=>B?B.concat([[B[B.length-1][1],R]]):[[-(1/0),R]],null);return Q.push([U[U.length-1],this.db._maxKey]),this.inAnyRange(Q,{includeLowers:!1,includeUppers:!1})}inAnyRange(U,Q){let B=this._cmp,R=this._ascending,V=this._descending,d=this._min,l=this._max;if(U.length===0)return XQ(this);if(!U.every(k=>k[0]!==void 0&&k[1]!==void 0&&R(k[0],k[1])<=0))return IU(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",K.InvalidArgument);let n=!Q||Q.includeLowers!==!1,J=Q&&Q.includeUppers===!0,W,E=R;function Z(k,t){return E(k[0],t[0])}try{W=U.reduce(function(k,t){let S=0,a=k.length;for(;S0){T[0]=d(T[0],t[0]),T[1]=l(T[1],t[1]);break}}return S===a&&k.push(t),k},[]),W.sort(Z)}catch{return IU(this,hF)}let e=0,r=J?k=>R(k,W[e][1])>0:k=>R(k,W[e][1])>=0,c=n?k=>V(k,W[e][0])>0:k=>V(k,W[e][0])>=0,h=r,N=new this.Collection(this,()=>XF(W[0][0],W[W.length-1][1],!n,!J));return N._ondirectionchange=k=>{k==="next"?(h=r,E=R):(h=c,E=V),W.sort(Z)},N._addAlgorithm((k,t,S)=>{for(var a=k.key;h(a);)if(++e,e===W.length)return t(S),!1;return!!function(T){return!r(T)&&!c(T)}(a)||(this._cmp(a,W[e][1])===0||this._cmp(a,W[e][0])===0||t(()=>{E===R?k.continue(W[e][0]):k.continue(W[e][1])}),!1)}),N}startsWithAnyOf(){let U=aF.apply(sQ,arguments);return U.every(Q=>typeof Q=="string")?U.length===0?XQ(this):this.inAnyRange(U.map(Q=>[Q,Q+RQ])):IU(this,"startsWithAnyOf() only works with strings")}};function dF(F){return ZU(function(U){return GB(U),F(U.target.error),!1})}function GB(F){F.stopPropagation&&F.stopPropagation(),F.preventDefault&&F.preventDefault()}var OF=yB(null,"storagemutated"),Mn=class{_lock(){return rB(!x.global),++this._reculock,this._reculock!==1||x.global||(x.lockOwnerFor=this),this}_unlock(){if(rB(!x.global),--this._reculock==0)for(x.global||(x.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var U=this._blockedFuncs.shift();try{GQ(U[1],U[0])}catch{}}return this}_locked(){return this._reculock&&x.lockOwnerFor!==this}create(U){if(!this.mode)return this;let Q=this.db.idbdb,B=this.db._state.dbOpenError;if(rB(!this.idbtrans),!U&&!Q)switch(B&&B.name){case"DatabaseClosedError":throw new K.DatabaseClosed(B);case"MissingAPIError":throw new K.MissingAPI(B.message,B);default:throw new K.OpenFailed(B)}if(!this.active)throw new K.TransactionInactive;return rB(this._completion._state===null),(U=this.idbtrans=U||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):Q.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=ZU(R=>{GB(R),this._reject(U.error)}),U.onabort=ZU(R=>{GB(R),this.active&&this._reject(new K.Abort(U.error)),this.active=!1,this.on("abort").fire(R)}),U.oncomplete=ZU(()=>{this.active=!1,this._resolve(),"mutatedParts"in U&&OF.storagemutated.fire(U.mutatedParts)}),this}_promise(U,Q,B){if(U==="readwrite"&&this.mode!=="readwrite")return TU(new K.ReadOnly("Transaction is readonly"));if(!this.active)return TU(new K.TransactionInactive);if(this._locked())return new b((V,d)=>{this._blockedFuncs.push([()=>{this._promise(U,Q,B).then(V,d)},x])});if(B)return GF(()=>{var V=new b((d,l)=>{this._lock();let n=Q(d,l,this);n&&n.then&&n.then(d,l)});return V.finally(()=>this._unlock()),V._lib=!0,V});var R=new b((V,d)=>{var l=Q(V,d,this);l&&l.then&&l.then(V,d)});return R._lib=!0,R}_root(){return this.parent?this.parent._root():this}waitFor(U){var Q=this._root();let B=b.resolve(U);if(Q._waitingFor)Q._waitingFor=Q._waitingFor.then(()=>B);else{Q._waitingFor=B,Q._waitingQueue=[];var R=Q.idbtrans.objectStore(Q.storeNames[0]);(function d(){for(++Q._spinCount;Q._waitingQueue.length;)Q._waitingQueue.shift()();Q._waitingFor&&(R.get(-1/0).onsuccess=d)})()}var V=Q._waitingFor;return new b((d,l)=>{B.then(n=>Q._waitingQueue.push(ZU(d.bind(null,n))),n=>Q._waitingQueue.push(ZU(l.bind(null,n)))).finally(()=>{Q._waitingFor===V&&(Q._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new K.Abort))}table(U){let Q=this._memoizedTables||(this._memoizedTables={});if(jU(Q,U))return Q[U];let B=this.schema[U];if(!B)throw new K.NotFound("Table "+U+" not part of transaction");let R=new this.db.Table(U,B,this);return R.core=this.db.core.table(U),Q[U]=R,R}};function b0(F,U,Q,B,R,V,d){return{name:F,keyPath:U,unique:Q,multi:B,auto:R,compound:V,src:(Q&&!d?"&":"")+(B?"*":"")+(R?"++":"")+on(U)}}function on(F){return typeof F=="string"?F:F?"["+[].join.call(F,"+")+"]":""}function sn(F,U,Q){return{name:F,primKey:U,indexes:Q,mappedClass:null,idxByName:$l(Q,B=>[B.name,B])}}var bB=F=>{try{return F.only([[]]),bB=()=>[[]],[[]]}catch{return bB=()=>RQ,RQ}};function X0(F){return F==null?()=>{}:typeof F=="string"?function(U){return U.split(".").length===1?Q=>Q[U]:Q=>kF(Q,U)}(F):U=>kF(U,F)}function Yn(F){return[].slice.call(F)}var WN=0;function XB(F){return F==null?":id":typeof F=="string"?F:`[${F.join("+")}]`}function ZN(F,U,Q){function B(n){if(n.type===3)return null;if(n.type===4)throw new Error("Cannot convert never type to IDBKeyRange");let{lower:J,upper:W,lowerOpen:E,upperOpen:Z}=n;return J===void 0?W===void 0?null:U.upperBound(W,!!Z):W===void 0?U.lowerBound(J,!!E):U.bound(J,W,!!E,!!Z)}let{schema:R,hasGetAll:V}=function(n,J){let W=Yn(n.objectStoreNames);return{schema:{name:n.name,tables:W.map(E=>J.objectStore(E)).map(E=>{let{keyPath:Z,autoIncrement:e}=E,r=iU(Z),c=Z==null,h={},N={name:E.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:c,compound:r,keyPath:Z,autoIncrement:e,unique:!0,extractKey:X0(Z)},indexes:Yn(E.indexNames).map(k=>E.index(k)).map(k=>{let{name:t,unique:S,multiEntry:a,keyPath:T}=k,C={name:t,compound:iU(T),keyPath:T,unique:S,multiEntry:a,extractKey:X0(T)};return h[XB(T)]=C,C}),getIndexByKeyPath:k=>h[XB(k)]};return h[":id"]=N.primaryKey,Z!=null&&(h[XB(Z)]=N.primaryKey),N})},hasGetAll:W.length>0&&"getAll"in J.objectStore(W[0])&&!(typeof navigator!="undefined"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(F,Q),d=R.tables.map(n=>function(J){let W=J.name;return{name:W,schema:J,mutate:function({trans:E,type:Z,keys:e,values:r,range:c}){return new Promise((h,N)=>{h=ZU(h);let k=E.objectStore(W),t=k.keyPath==null,S=Z==="put"||Z==="add";if(!S&&Z!=="delete"&&Z!=="deleteRange")throw new Error("Invalid operation type: "+Z);let{length:a}=e||r||{length:1};if(e&&r&&e.length!==r.length)throw new Error("Given keys array must have same length as given values array.");if(a===0)return h({numFailures:0,failures:{},results:[],lastResult:void 0});let T,C=[],D=[],p=0,o=v=>{++p,GB(v)};if(Z==="deleteRange"){if(c.type===4)return h({numFailures:p,failures:D,results:[],lastResult:void 0});c.type===3?C.push(T=k.clear()):C.push(T=k.delete(B(c)))}else{let[v,y]=S?t?[r,e]:[r,null]:[e,null];if(S)for(let i=0;i{let y=v.target.result;C.forEach((i,w)=>i.error!=null&&(D[w]=i.error)),h({numFailures:p,failures:D,results:Z==="delete"?e:C.map(i=>i.result),lastResult:y})};T.onerror=v=>{o(v),s(v)},T.onsuccess=s})},getMany:({trans:E,keys:Z})=>new Promise((e,r)=>{e=ZU(e);let c=E.objectStore(W),h=Z.length,N=new Array(h),k,t=0,S=0,a=C=>{let D=C.target;N[D._pos]=D.result,++S===t&&e(N)},T=dF(r);for(let C=0;Cnew Promise((e,r)=>{e=ZU(e);let c=E.objectStore(W).get(Z);c.onsuccess=h=>e(h.target.result),c.onerror=dF(r)}),query:function(E){return Z=>new Promise((e,r)=>{e=ZU(e);let{trans:c,values:h,limit:N,query:k}=Z,t=N===1/0?void 0:N,{index:S,range:a}=k,T=c.objectStore(W),C=S.isPrimaryKey?T:T.index(S.name),D=B(a);if(N===0)return e({result:[]});if(E){let p=h?C.getAll(D,t):C.getAllKeys(D,t);p.onsuccess=o=>e({result:o.target.result}),p.onerror=dF(r)}else{let p=0,o=h||!("openKeyCursor"in C)?C.openCursor(D):C.openKeyCursor(D),s=[];o.onsuccess=v=>{let y=o.result;return y?(s.push(h?y.value:y.primaryKey),++p===N?e({result:s}):void y.continue()):e({result:s})},o.onerror=dF(r)}})}(V),openCursor:function({trans:E,values:Z,query:e,reverse:r,unique:c}){return new Promise((h,N)=>{h=ZU(h);let{index:k,range:t}=e,S=E.objectStore(W),a=k.isPrimaryKey?S:S.index(k.name),T=r?c?"prevunique":"prev":c?"nextunique":"next",C=Z||!("openKeyCursor"in a)?a.openCursor(B(t),T):a.openKeyCursor(B(t),T);C.onerror=dF(N),C.onsuccess=ZU(D=>{let p=C.result;if(!p)return void h(null);p.___id=++WN,p.done=!1;let o=p.continue.bind(p),s=p.continuePrimaryKey;s&&(s=s.bind(p));let v=p.advance.bind(p),y=()=>{throw new Error("Cursor not stopped")};p.trans=E,p.stop=p.continue=p.continuePrimaryKey=p.advance=()=>{throw new Error("Cursor not started")},p.fail=ZU(N),p.next=function(){let i=1;return this.start(()=>i--?this.continue():this.stop()).then(()=>this)},p.start=i=>{let w=new Promise((L,M)=>{L=ZU(L),C.onerror=dF(M),p.fail=M,p.stop=m=>{p.stop=p.continue=p.continuePrimaryKey=p.advance=y,L(m)}}),g=()=>{if(C.result)try{i()}catch(L){p.fail(L)}else p.done=!0,p.start=()=>{throw new Error("Cursor behind last entry")},p.stop()};return C.onsuccess=ZU(L=>{C.onsuccess=g,g()}),p.continue=o,p.continuePrimaryKey=s,p.advance=v,g(),w},h(p)},N)})},count({query:E,trans:Z}){let{index:e,range:r}=E;return new Promise((c,h)=>{let N=Z.objectStore(W),k=e.isPrimaryKey?N:N.index(e.name),t=B(r),S=t?k.count(t):k.count();S.onsuccess=ZU(a=>c(a.target.result)),S.onerror=dF(h)})}}}(n)),l={};return d.forEach(n=>l[n.name]=n),{stack:"dbcore",transaction:F.transaction.bind(F),table(n){if(!l[n])throw new Error(`Table '${n}' not found`);return l[n]},MIN_KEY:-1/0,MAX_KEY:bB(U),schema:R}}function O0({_novip:F},U){let Q=U.db,B=function(R,V,{IDBKeyRange:d,indexedDB:l},n){return{dbcore:function(W,E){return E.reduce((Z,{create:e})=>z(z({},Z),e(Z)),W)}(ZN(V,d,n),R.dbcore)}}(F._middlewares,Q,F._deps,U);F.core=B.dbcore,F.tables.forEach(R=>{let V=R.name;F.core.schema.tables.some(d=>d.name===V)&&(R.core=F.core.table(V),F[V]instanceof F.Table&&(F[V].core=R.core))})}function xR({_novip:F},U,Q,B){Q.forEach(R=>{let V=B[R];U.forEach(d=>{let l=J0(d,R);(!l||"value"in l&&l.value===void 0)&&(d===F.Transaction.prototype||d instanceof F.Transaction?eF(d,R,{get(){return this.table(R)},set(n){ql(this,R,{value:n,writable:!0,configurable:!0,enumerable:!0})}}):d[R]=new F.Table(R,V))})})}function H0({_novip:F},U){U.forEach(Q=>{for(let B in Q)Q[B]instanceof F.Table&&delete Q[B]})}function NN(F,U){return F._cfg.version-U._cfg.version}function EN(F,U,Q,B){let R=F._dbSchema,V=F._createTransaction("readwrite",F._storeNames,R);V.create(Q),V._completion.catch(B);let d=V._reject.bind(V),l=x.transless||x;GF(()=>{x.trans=V,x.transless=l,U===0?(eU(R).forEach(n=>{z0(Q,n,R[n].primKey,R[n].indexes)}),O0(F,Q),b.follow(()=>F.on.populate.fire(V)).catch(d)):function({_novip:n},J,W,E){let Z=[],e=n._versions,r=n._dbSchema=x0(n,n.idbdb,E),c=!1;function h(){return Z.length?b.resolve(Z.shift()(W.idbtrans)).then(h):b.resolve()}return e.filter(N=>N._cfg.version>=J).forEach(N=>{Z.push(()=>{let k=r,t=N._cfg.dbschema;w0(n,k,E),w0(n,t,E),r=n._dbSchema=t;let S=yn(k,t);S.add.forEach(T=>{z0(E,T[0],T[1].primKey,T[1].indexes)}),S.change.forEach(T=>{if(T.recreate)throw new K.Upgrade("Not yet support for changing primary key");{let C=E.objectStore(T.name);T.add.forEach(D=>u0(C,D)),T.change.forEach(D=>{C.deleteIndex(D.name),u0(C,D)}),T.del.forEach(D=>C.deleteIndex(D))}});let a=N._cfg.contentUpgrade;if(a&&N._cfg.version>J){O0(n,E),W._memoizedTables={},c=!0;let T=Un(t);S.del.forEach(o=>{T[o]=k[o]}),H0(n,[n.Transaction.prototype]),xR(n,[n.Transaction.prototype],eU(T),T),W.schema=T;let C=E0(a),D;C&&vQ();let p=b.follow(()=>{if(D=a(W),D&&C){var o=TF.bind(null,null);D.then(o,o)}});return D&&typeof D.then=="function"?b.resolve(D):p.then(()=>D)}}),Z.push(k=>{(!c||!VN)&&function(t,S){[].slice.call(S.db.objectStoreNames).forEach(a=>t[a]==null&&S.db.deleteObjectStore(a))}(N._cfg.dbschema,k),H0(n,[n.Transaction.prototype]),xR(n,[n.Transaction.prototype],n._storeNames,n._dbSchema),W.schema=n._dbSchema})}),h().then(()=>{var N,k;k=E,eU(N=r).forEach(t=>{k.db.objectStoreNames.contains(t)||z0(k,t,N[t].primKey,N[t].indexes)})})}(F,U,V,Q).catch(d)})}function yn(F,U){let Q={del:[],add:[],change:[]},B;for(B in F)U[B]||Q.del.push(B);for(B in U){let R=F[B],V=U[B];if(R){let d={name:B,def:V,recreate:!1,del:[],add:[],change:[]};if(""+(R.primKey.keyPath||"")!=""+(V.primKey.keyPath||"")||R.primKey.auto!==V.primKey.auto&&!XR)d.recreate=!0,Q.change.push(d);else{let l=R.idxByName,n=V.idxByName,J;for(J in l)n[J]||d.del.push(J);for(J in n){let W=l[J],E=n[J];W?W.src!==E.src&&d.change.push(E):d.add.push(E)}(d.del.length>0||d.add.length>0||d.change.length>0)&&Q.change.push(d)}}else Q.add.push([B,V])}return Q}function z0(F,U,Q,B){let R=F.db.createObjectStore(U,Q.keyPath?{keyPath:Q.keyPath,autoIncrement:Q.auto}:{autoIncrement:Q.auto});return B.forEach(V=>u0(R,V)),R}function u0(F,U){F.createIndex(U.name,U.keyPath,{unique:U.unique,multiEntry:U.multi})}function x0(F,U,Q){let B={};return rR(U.objectStoreNames,0).forEach(R=>{let V=Q.objectStore(R),d=V.keyPath,l=b0(on(d),d||"",!1,!1,!!V.autoIncrement,d&&typeof d!="string",!0),n=[];for(let W=0;W{if(U[B]!==null){var R=U[B].split(",").map((d,l)=>{let n=(d=d.trim()).replace(/([&*]|\+\+)/g,""),J=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return b0(n,J||null,/\&/.test(d),/\*/.test(d),/\+\+/.test(d),iU(J),l===0)}),V=R.shift();if(V.multi)throw new K.Schema("Primary key cannot be multi-valued");R.forEach(d=>{if(d.auto)throw new K.Schema("Only primary key can be marked as autoIncrement (++)");if(!d.keyPath)throw new K.Schema("Index must have a name and cannot be an empty string")}),Q[B]=sn(B,V,R)}})}stores(U){let Q=this.db;this._cfg.storesSource=this._cfg.storesSource?GU(this._cfg.storesSource,U):U;let B=Q._versions,R={},V={};return B.forEach(d=>{GU(R,d._cfg.storesSource),V=d._cfg.dbschema={},d._parseStoresSpec(R,V)}),Q._dbSchema=V,H0(Q,[Q._allTables,Q,Q.Transaction.prototype]),xR(Q,[Q._allTables,Q,Q.Transaction.prototype,this._cfg.tables],eU(V),V),Q._storeNames=eU(V),this}upgrade(U){return this._cfg.contentUpgrade=k0(this._cfg.contentUpgrade||dU,U),this}};function L0(F,U){let Q=F._dbNamesDB;return Q||(Q=F._dbNamesDB=new HF("__dbnames",{addons:[],indexedDB:F,IDBKeyRange:U}),Q.version(1).stores({dbnames:"name"})),Q.table("dbnames")}function j0(F){return F&&typeof F.databases=="function"}function I0(F){return GF(function(){return x.letThrough=!0,F()})}function tN(){var F;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(U){var Q=function(){return indexedDB.databases().finally(U)};F=setInterval(Q,100),Q()}).finally(function(){return clearInterval(F)}):Promise.resolve()}function SN(F){let U=F._state,{indexedDB:Q}=F._deps;if(U.isBeingOpened||F.idbdb)return U.dbReadyPromise.then(()=>U.dbOpenError?TU(U.dbOpenError):F);VF&&(U.openCanceller._stackHolder=UQ()),U.isBeingOpened=!0,U.dbOpenError=null,U.openComplete=!1;let B=U.openCanceller;function R(){if(U.openCanceller!==B)throw new K.DatabaseClosed("db.open() was cancelled")}let V=U.dbReadyResolve,d=null,l=!1;return b.race([B,(typeof navigator=="undefined"?b.resolve():tN()).then(()=>new b((n,J)=>{if(R(),!Q)throw new K.MissingAPI;let W=F.name,E=U.autoSchema?Q.open(W):Q.open(W,Math.round(10*F.verno));if(!E)throw new K.MissingAPI;E.onerror=dF(J),E.onblocked=ZU(F._fireOnBlocked),E.onupgradeneeded=ZU(Z=>{if(d=E.transaction,U.autoSchema&&!F._options.allowEmptyDB){E.onerror=GB,d.abort(),E.result.close();let r=Q.deleteDatabase(W);r.onsuccess=r.onerror=ZU(()=>{J(new K.NoSuchDatabase(`Database ${W} doesnt exist`))})}else{d.onerror=dF(J);var e=Z.oldVersion>Math.pow(2,62)?0:Z.oldVersion;l=e<1,F._novip.idbdb=E.result,EN(F,e/10,d,J)}},J),E.onsuccess=ZU(()=>{d=null;let Z=F._novip.idbdb=E.result,e=rR(Z.objectStoreNames);if(e.length>0)try{let c=Z.transaction((r=e).length===1?r[0]:r,"readonly");U.autoSchema?function({_novip:h},N,k){h.verno=N.version/10;let t=h._dbSchema=x0(0,N,k);h._storeNames=rR(N.objectStoreNames,0),xR(h,[h._allTables],eU(t),t)}(F,Z,c):(w0(F,F._dbSchema,c),function(h,N){let k=yn(x0(0,h.idbdb,N),h._dbSchema);return!(k.add.length||k.change.some(t=>t.add.length||t.change.length))}(F,c)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),O0(F,c)}catch{}var r;YB.push(F),Z.onversionchange=ZU(c=>{U.vcFired=!0,F.on("versionchange").fire(c)}),Z.onclose=ZU(c=>{F.on("close").fire(c)}),l&&function({indexedDB:c,IDBKeyRange:h},N){!j0(c)&&N!=="__dbnames"&&L0(c,h).put({name:N}).catch(dU)}(F._deps,W),n()},J)}))]).then(()=>(R(),U.onReadyBeingFired=[],b.resolve(I0(()=>F.on.ready.fire(F.vip))).then(function n(){if(U.onReadyBeingFired.length>0){let J=U.onReadyBeingFired.reduce(k0,dU);return U.onReadyBeingFired=[],b.resolve(I0(()=>J(F.vip))).then(n)}}))).finally(()=>{U.onReadyBeingFired=null,U.isBeingOpened=!1}).then(()=>F).catch(n=>{U.dbOpenError=n;try{d&&d.abort()}catch{}return B===U.openCanceller&&F._close(),TU(n)}).finally(()=>{U.openComplete=!0,V()})}function f0(F){var U=V=>F.next(V),Q=R(U),B=R(V=>F.throw(V));function R(V){return d=>{var l=V(d),n=l.value;return l.done?n:n&&typeof n.then=="function"?n.then(Q,B):iU(n)?Promise.all(n).then(Q,B):Q(n)}}return R(U)()}function eN(F,U,Q){var B=arguments.length;if(B<2)throw new K.InvalidArgument("Too few arguments");for(var R=new Array(B-1);--B;)R[B-1]=arguments[B];Q=R.pop();var V=Fn(R);return[F,V,Q]}function Gn(F,U,Q,B,R){return b.resolve().then(()=>{let V=x.transless||x,d=F._createTransaction(U,Q,F._dbSchema,B),l={trans:d,transless:V};if(B)d.idbtrans=B.idbtrans;else try{d.create(),F._state.PR1398_maxLoop=3}catch(E){return E.name===e0.InvalidState&&F.isOpen()&&--F._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),F._close(),F.open().then(()=>Gn(F,U,Q,null,R))):TU(E)}let n=E0(R),J;n&&vQ();let W=b.follow(()=>{if(J=R.call(d,d),J)if(n){var E=TF.bind(null,null);J.then(E,E)}else typeof J.next=="function"&&typeof J.throw=="function"&&(J=f0(J))},l);return(J&&typeof J.then=="function"?b.resolve(J).then(E=>d.active?E:TU(new K.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):W.then(()=>J)).then(E=>(B&&d._resolve(),d._completion.then(()=>E))).catch(E=>(d._reject(E),TU(E)))})}function wR(F,U,Q){let B=iU(F)?F.slice():[F];for(let R=0;R0,N=q(z({},Z),{isVirtual:h,keyTail:E,keyLength:c,extractKey:X0(W),unique:!h&&Z.unique});return r.push(N),N.isPrimaryKey||V.push(N),c>1&&d(c===2?W[0]:W.slice(0,c-1),E+1,Z),r.sort((k,t)=>k.keyTail-t.keyTail),N}let l=d(B.primaryKey.keyPath,0,B.primaryKey);R[":id"]=[l];for(let W of B.indexes)d(W.keyPath,0,W);function n(W){let E=W.query.index;return E.isVirtual?q(z({},W),{query:{index:E,range:(Z=W.query.range,e=E.keyTail,{type:Z.type===1?2:Z.type,lower:wR(Z.lower,Z.lowerOpen?F.MAX_KEY:F.MIN_KEY,e),lowerOpen:!0,upper:wR(Z.upper,Z.upperOpen?F.MIN_KEY:F.MAX_KEY,e),upperOpen:!0})}}):W;var Z,e}return q(z({},Q),{schema:q(z({},B),{primaryKey:l,indexes:V,getIndexByKeyPath:function(W){let E=R[XB(W)];return E&&E[0]}}),count:W=>Q.count(n(W)),query:W=>Q.query(n(W)),openCursor(W){let{keyTail:E,isVirtual:Z,keyLength:e}=W.query.index;return Z?Q.openCursor(n(W)).then(r=>r&&function(c){return Object.create(c,{continue:{value:function(N){N!=null?c.continue(wR(N,W.reverse?F.MAX_KEY:F.MIN_KEY,E)):W.unique?c.continue(c.key.slice(0,e).concat(W.reverse?F.MIN_KEY:F.MAX_KEY,E)):c.continue()}},continuePrimaryKey:{value(N,k){c.continuePrimaryKey(wR(N,F.MAX_KEY,E),k)}},primaryKey:{get:()=>c.primaryKey},key:{get(){let N=c.key;return e===1?N[0]:N.slice(0,e)}},value:{get:()=>c.value}})}(r)):Q.openCursor(W)}})}})}};function K0(F,U,Q,B){return Q=Q||{},B=B||"",eU(F).forEach(R=>{if(jU(U,R)){var V=F[R],d=U[R];if(typeof V=="object"&&typeof d=="object"&&V&&d){let l=Z0(V);l!==Z0(d)?Q[B+R]=U[R]:l==="Object"?K0(V,d,Q,B+R+"."):V!==d&&(Q[B+R]=U[R])}else V!==d&&(Q[B+R]=U[R])}else Q[B+R]=void 0}),eU(U).forEach(R=>{jU(F,R)||(Q[B+R]=U[R])}),Q}var aN={stack:"dbcore",name:"HooksMiddleware",level:2,create:F=>q(z({},F),{table(U){let Q=F.table(U),{primaryKey:B}=Q.schema;return q(z({},Q),{mutate(V){let d=x.trans,{deleting:l,creating:n,updating:J}=d.table(U).hook;switch(V.type){case"add":if(n.fire===dU)break;return d._promise("readwrite",()=>W(V),!0);case"put":if(n.fire===dU&&J.fire===dU)break;return d._promise("readwrite",()=>W(V),!0);case"delete":if(l.fire===dU)break;return d._promise("readwrite",()=>W(V),!0);case"deleteRange":if(l.fire===dU)break;return d._promise("readwrite",()=>function(Z){return E(Z.trans,Z.range,1e4)}(V),!0)}return Q.mutate(V);function W(Z){let e=x.trans,r=Z.keys||function(c,h){return h.type==="delete"?h.keys:h.keys||h.values.map(c.extractKey)}(B,Z);if(!r)throw new Error("Keys missing");return(Z=Z.type==="add"||Z.type==="put"?q(z({},Z),{keys:r}):z({},Z)).type!=="delete"&&(Z.values=[...Z.values]),Z.keys&&(Z.keys=[...Z.keys]),function(c,h,N){return h.type==="add"?Promise.resolve([]):c.getMany({trans:h.trans,keys:N,cache:"immutable"})}(Q,Z,r).then(c=>{let h=r.map((N,k)=>{let t=c[k],S={onerror:null,onsuccess:null};if(Z.type==="delete")l.fire.call(S,N,t,e);else if(Z.type==="add"||t===void 0){let a=n.fire.call(S,N,Z.values[k],e);N==null&&a!=null&&(N=a,Z.keys[k]=N,B.outbound||AU(Z.values[k],B.keyPath,N))}else{let a=K0(t,Z.values[k]),T=J.fire.call(S,a,N,t,e);if(T){let C=Z.values[k];Object.keys(T).forEach(D=>{jU(C,D)?C[D]=T[D]:AU(C,D,T[D])})}}return S});return Q.mutate(Z).then(({failures:N,results:k,numFailures:t,lastResult:S})=>{for(let a=0;a(h.forEach(k=>k.onerror&&k.onerror(N)),Promise.reject(N)))})}function E(Z,e,r){return Q.query({trans:Z,values:!1,query:{index:B,range:e},limit:r}).then(({result:c})=>W({type:"delete",keys:c,trans:Z}).then(h=>h.numFailures>0?Promise.reject(h.failures[0]):c.length({table:U=>{let Q=F.table(U);return q(z({},Q),{getMany:B=>{if(!B.cache)return Q.getMany(B);let R=bn(B.keys,B.trans._cache,B.cache==="clone");return R?b.resolve(R):Q.getMany(B).then(V=>(B.trans._cache={keys:B.keys,values:B.cache==="clone"?CB(V):V},V))},mutate:B=>(B.type!=="add"&&(B.trans._cache=null),Q.mutate(B))})}})};function g0(F){return!("from"in F)}var cF=function(F,U){if(!this){let Q=new cF;return F&&"d"in F&&GU(Q,F),Q}GU(this,arguments.length?{d:1,from:F,to:arguments.length>1?U:F}:{d:0})};function OB(F,U,Q){let B=bU(U,Q);if(isNaN(B))return;if(B>0)throw RangeError();if(g0(F))return GU(F,{from:U,to:Q,d:1});let R=F.l,V=F.r;if(bU(Q,F.from)<0)return R?OB(R,U,Q):F.l={from:U,to:Q,d:1,l:null,r:null},Xn(F);if(bU(U,F.to)>0)return V?OB(V,U,Q):F.r={from:U,to:Q,d:1,l:null,r:null},Xn(F);bU(U,F.from)<0&&(F.from=U,F.l=null,F.d=V?V.d+1:1),bU(Q,F.to)>0&&(F.to=Q,F.r=null,F.d=F.l?F.l.d+1:1);let d=!F.r;R&&!F.l&&LR(F,R),V&&d&&LR(F,V)}function LR(F,U){g0(U)||function Q(B,{from:R,to:V,l:d,r:l}){OB(B,R,V),d&&Q(B,d),l&&Q(B,l)}(F,U)}function P0(F){let U=g0(F)?null:{s:0,n:F};return{next(Q){let B=arguments.length>0;for(;U;)switch(U.s){case 0:if(U.s=1,B)for(;U.n.l&&bU(Q,U.n.from)<0;)U={up:U,n:U.n.l,s:1};else for(;U.n.l;)U={up:U,n:U.n.l,s:1};case 1:if(U.s=2,!B||bU(Q,U.n.to)<=0)return{value:U.n,done:!1};case 2:if(U.n.r){U.s=3,U={up:U,n:U.n.r,s:0};continue}case 3:U=U.up}return{done:!0}}}}function Xn(F){var U,Q;let B=(((U=F.r)===null||U===void 0?void 0:U.d)||0)-(((Q=F.l)===null||Q===void 0?void 0:Q.d)||0),R=B>1?"r":B<-1?"l":"";if(R){let V=R==="r"?"l":"r",d=z({},F),l=F[R];F.from=l.from,F.to=l.to,F[R]=l[R],d[R]=l[V],F[V]=d,d.d=On(d)}F.d=On(F)}function On({r:F,l:U}){return(F?U?Math.max(F.d,U.d):F.d:U?U.d:0)+1}oQ(cF.prototype,{add(F){return LR(this,F),this},addKey(F){return OB(this,F,F),this},addKeys(F){return F.forEach(U=>OB(this,U,U)),this},[N0](){return P0(this)}});var hN={stack:"dbcore",level:0,create:F=>{let U=F.schema.name,Q=new cF(F.MIN_KEY,F.MAX_KEY);return q(z({},F),{table:B=>{let R=F.table(B),{schema:V}=R,{primaryKey:d}=V,{extractKey:l,outbound:n}=d,J=q(z({},R),{mutate:Z=>{let e=Z.trans,r=e.mutatedParts||(e.mutatedParts={}),c=T=>{let C=`idb://${U}/${B}/${T}`;return r[C]||(r[C]=new cF)},h=c(""),N=c(":dels"),{type:k}=Z,[t,S]=Z.type==="deleteRange"?[Z.range]:Z.type==="delete"?[Z.keys]:Z.values.length<50?[[],Z.values]:[],a=Z.trans._cache;return R.mutate(Z).then(T=>{if(iU(t)){k!=="delete"&&(t=T.results),h.addKeys(t);let C=bn(t,a);C||k==="add"||N.addKeys(t),(C||S)&&function(D,p,o,s){function v(y){let i=D(y.name||"");function w(L){return L!=null?y.extractKey(L):null}let g=L=>y.multiEntry&&iU(L)?L.forEach(M=>i.addKey(M)):i.addKey(L);(o||s).forEach((L,M)=>{let m=o&&w(o[M]),Y=s&&w(s[M]);bU(m,Y)!==0&&(m!=null&&g(m),Y!=null&&g(Y))})}p.indexes.forEach(v)}(c,V,C,S)}else if(t){let C={from:t.lower,to:t.upper};N.add(C),h.add(C)}else h.add(Q),N.add(Q),V.indexes.forEach(C=>c(C.name).add(Q));return T})}}),W=({query:{index:Z,range:e}})=>{var r,c;return[Z,new cF((r=e.lower)!==null&&r!==void 0?r:F.MIN_KEY,(c=e.upper)!==null&&c!==void 0?c:F.MAX_KEY)]},E={get:Z=>[d,new cF(Z.key)],getMany:Z=>[d,new cF().addKeys(Z.keys)],count:W,query:W,openCursor:W};return eU(E).forEach(Z=>{J[Z]=function(e){let{subscr:r}=x;if(r){let c=S=>{let a=`idb://${U}/${B}/${S}`;return r[a]||(r[a]=new cF)},h=c(""),N=c(":dels"),[k,t]=E[Z](e);if(c(k.name||"").add(t),!k.isPrimaryKey){if(Z!=="count"){let S=Z==="query"&&n&&e.values&&R.query(q(z({},e),{values:!1}));return R[Z].apply(this,arguments).then(a=>{if(Z==="query"){if(n&&e.values)return S.then(({result:C})=>(h.addKeys(C),a));let T=e.values?a.result.map(l):a.result;e.values?h.addKeys(T):N.addKeys(T)}else if(Z==="openCursor"){let T=a,C=e.values;return T&&Object.create(T,{key:{get:()=>(N.addKey(T.primaryKey),T.key)},primaryKey:{get(){let D=T.primaryKey;return N.addKey(D),D}},value:{get:()=>(C&&h.addKey(T.primaryKey),T.value)}})}return a})}N.add(Q)}}return R[Z].apply(this,arguments)}}),J}})}},HF=class{constructor(U,Q){this._middlewares={},this.verno=0;let B=HF.dependencies;this._options=Q=z({addons:HF.addons,autoOpen:!0,indexedDB:B.indexedDB,IDBKeyRange:B.IDBKeyRange},Q),this._deps={indexedDB:Q.indexedDB,IDBKeyRange:Q.IDBKeyRange};let{addons:R}=Q;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;let V={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:dU,dbReadyPromise:null,cancelOpen:dU,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var d;V.dbReadyPromise=new b(l=>{V.dbReadyResolve=l}),V.openCanceller=new b((l,n)=>{V.cancelOpen=n}),this._state=V,this.name=U,this.on=yB(this,"populate","blocked","versionchange","close",{ready:[k0,dU]}),this.on.ready.subscribe=_l(this.on.ready.subscribe,l=>(n,J)=>{HF.vip(()=>{let W=this._state;if(W.openComplete)W.dbOpenError||b.resolve().then(n),J&&l(n);else if(W.onReadyBeingFired)W.onReadyBeingFired.push(n),J&&l(n);else{l(n);let E=this;J||l(function Z(){E.on.ready.unsubscribe(n),E.on.ready.unsubscribe(Z)})}})}),this.Collection=(d=this,vB(pn.prototype,function(l,n){this.db=d;let J=Tn,W=null;if(n)try{J=n()}catch(r){W=r}let E=l._ctx,Z=E.table,e=Z.hook.reading.fire;this._ctx={table:Z,index:E.index,isPrimKey:!E.index||Z.schema.primKey.keyPath&&E.index===Z.schema.primKey.name,range:J,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:W,or:E.or,valueMapper:e!==pB?e:null}})),this.Table=function(l){return vB(hn.prototype,function(n,J,W){this.db=l,this._tx=W,this.name=n,this.schema=J,this.hook=l._allTables[n]?l._allTables[n].hook:yB(null,{creating:[PZ,dU],reading:[gZ,pB],updating:[_Z,dU],deleting:[qZ,dU]})})}(this),this.Transaction=function(l){return vB(Mn.prototype,function(n,J,W,E,Z){this.db=l,this.mode=n,this.storeNames=J,this.schema=W,this.chromeTransactionDurability=E,this.idbtrans=null,this.on=yB(this,"complete","error","abort"),this.parent=Z||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new b((e,r)=>{this._resolve=e,this._reject=r}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var r=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):r&&this.idbtrans&&this.idbtrans.abort(),TU(e)})})}(this),this.Version=function(l){return vB(vn.prototype,function(n){this.db=l,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(l){return vB(G0.prototype,function(n,J,W){this.db=l,this._ctx={table:n,index:J===":id"?null:J,or:W};let E=l._deps.indexedDB;if(!E)throw new K.MissingAPI;this._cmp=this._ascending=E.cmp.bind(E),this._descending=(Z,e)=>E.cmp(e,Z),this._max=(Z,e)=>E.cmp(Z,e)>0?Z:e,this._min=(Z,e)=>E.cmp(Z,e)<0?Z:e,this._IDBKeyRange=l._deps.IDBKeyRange})}(this),this.on("versionchange",l=>{l.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",l=>{!l.newVersion||l.newVersionnew this.Transaction(l,n,J,this._options.chromeTransactionDurability,W),this._fireOnBlocked=l=>{this.on("blocked").fire(l),YB.filter(n=>n.name===this.name&&n!==this&&!n._state.vcFired).map(n=>n.on("versionchange").fire(l))},this.use(kN),this.use(aN),this.use(hN),this.use(TN),this.vip=Object.create(this,{_vip:{value:!0}}),R.forEach(l=>l(this))}version(U){if(isNaN(U)||U<.1)throw new K.Type("Given version is not a positive number");if(U=Math.round(10*U)/10,this.idbdb||this._state.isBeingOpened)throw new K.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,U);let Q=this._versions;var B=Q.filter(R=>R._cfg.version===U)[0];return B||(B=new this.Version(U),Q.push(B),Q.sort(NN),B.stores({}),this._state.autoSchema=!1,B)}_whenReady(U){return this.idbdb&&(this._state.openComplete||x.letThrough||this._vip)?U():new b((Q,B)=>{if(this._state.openComplete)return B(new K.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void B(new K.DatabaseClosed);this.open().catch(dU)}this._state.dbReadyPromise.then(Q,B)}).then(U)}use({stack:U,create:Q,level:B,name:R}){R&&this.unuse({stack:U,name:R});let V=this._middlewares[U]||(this._middlewares[U]=[]);return V.push({stack:U,create:Q,level:B??10,name:R}),V.sort((d,l)=>d.level-l.level),this}unuse({stack:U,name:Q,create:B}){return U&&this._middlewares[U]&&(this._middlewares[U]=this._middlewares[U].filter(R=>B?R.create!==B:!!Q&&R.name!==Q)),this}open(){return SN(this)}_close(){let U=this._state,Q=YB.indexOf(this);if(Q>=0&&YB.splice(Q,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}U.dbReadyPromise=new b(B=>{U.dbReadyResolve=B}),U.openCanceller=new b((B,R)=>{U.cancelOpen=R})}close(){this._close();let U=this._state;this._options.autoOpen=!1,U.dbOpenError=new K.DatabaseClosed,U.isBeingOpened&&U.cancelOpen(U.dbOpenError)}delete(){let U=arguments.length>0,Q=this._state;return new b((B,R)=>{let V=()=>{this.close();var d=this._deps.indexedDB.deleteDatabase(this.name);d.onsuccess=ZU(()=>{(function({indexedDB:l,IDBKeyRange:n},J){!j0(l)&&J!=="__dbnames"&&L0(l,n).delete(J).catch(dU)})(this._deps,this.name),B()}),d.onerror=dF(R),d.onblocked=this._fireOnBlocked};if(U)throw new K.InvalidArgument("Arguments not allowed in db.delete()");Q.isBeingOpened?Q.dbReadyPromise.then(V):V()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){let U=this._state.dbOpenError;return U&&U.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return eU(this._allTables).map(U=>this._allTables[U])}transaction(){let U=eN.apply(this,arguments);return this._transaction.apply(this,U)}_transaction(U,Q,B){let R=x.trans;R&&R.db===this&&U.indexOf("!")===-1||(R=null);let V=U.indexOf("?")!==-1,d,l;U=U.replace("!","").replace("?","");try{if(l=Q.map(J=>{var W=J instanceof this.Table?J.name:J;if(typeof W!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return W}),U=="r"||U==="readonly")d="readonly";else{if(U!="rw"&&U!="readwrite")throw new K.InvalidArgument("Invalid transaction mode: "+U);d="readwrite"}if(R){if(R.mode==="readonly"&&d==="readwrite"){if(!V)throw new K.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");R=null}R&&l.forEach(J=>{if(R&&R.storeNames.indexOf(J)===-1){if(!V)throw new K.SubTransaction("Table "+J+" not included in parent transaction.");R=null}}),V&&R&&!R.active&&(R=null)}}catch(J){return R?R._promise(null,(W,E)=>{E(J)}):TU(J)}let n=Gn.bind(null,this,d,l,R,B);return R?R._promise(d,n,"lock"):x.trans?GQ(x.transless,()=>this._whenReady(n)):this._whenReady(n)}table(U){if(!jU(this._allTables,U))throw new K.InvalidTable(`Table ${U} does not exist`);return this._allTables[U]}},cN=typeof Symbol!="undefined"&&"observable"in Symbol?Symbol.observable:"@@observable",Hn=class{constructor(U){this._subscribe=U}subscribe(U,Q,B){return this._subscribe(U&&typeof U!="function"?U:{next:U,error:Q,complete:B})}[cN](){return this}};function zn(F,U){return eU(U).forEach(Q=>{LR(F[Q]||(F[Q]=new cF),U[Q])}),F}var q0;try{q0={indexedDB:JU.indexedDB||JU.mozIndexedDB||JU.webkitIndexedDB||JU.msIndexedDB,IDBKeyRange:JU.IDBKeyRange||JU.webkitIDBKeyRange}}catch{q0={indexedDB:null,IDBKeyRange:null}}var dQ=HF;function jR(F){let U=rF;try{rF=!0,OF.storagemutated.fire(F)}finally{rF=U}}oQ(dQ,q(z({},DR),{delete:F=>new dQ(F,{addons:[]}).delete(),exists:F=>new dQ(F,{addons:[]}).open().then(U=>(U.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(F){try{return function({indexedDB:U,IDBKeyRange:Q}){return j0(U)?Promise.resolve(U.databases()).then(B=>B.map(R=>R.name).filter(R=>R!=="__dbnames")):L0(U,Q).toCollection().primaryKeys()}(dQ.dependencies).then(F)}catch{return TU(new K.MissingAPI)}},defineClass:()=>function(F){GU(this,F)},ignoreTransaction:F=>x.trans?GQ(x.transless,F):F(),vip:I0,async:function(F){return function(){try{var U=f0(F.apply(this,arguments));return U&&typeof U.then=="function"?U:b.resolve(U)}catch(Q){return TU(Q)}}},spawn:function(F,U,Q){try{var B=f0(F.apply(Q,U||[]));return B&&typeof B.then=="function"?B:b.resolve(B)}catch(R){return TU(R)}},currentTransaction:{get:()=>x.trans||null},waitFor:function(F,U){let Q=b.resolve(typeof F=="function"?dQ.ignoreTransaction(F):F).timeout(U||6e4);return x.trans?x.trans.waitFor(Q):Q},Promise:b,debug:{get:()=>VF,set:F=>{Bn(F,F==="dexie"?()=>!0:an)}},derive:iQ,extend:GU,props:oQ,override:_l,Events:yB,on:OF,liveQuery:function(F){return new Hn(U=>{let Q=E0(F),B=!1,R={},V={},d={get closed(){return B},unsubscribe:()=>{B=!0,OF.storagemutated.unsubscribe(W)}};U.start&&U.start(d);let l=!1,n=!1;function J(){return eU(V).some(Z=>R[Z]&&function(e,r){let c=P0(r),h=c.next();if(h.done)return!1;let N=h.value,k=P0(e),t=k.next(N.from),S=t.value;for(;!h.done&&!t.done;){if(bU(S.from,N.to)<=0&&bU(S.to,N.from)>=0)return!0;bU(N.from,S.from)<0?N=(h=c.next(S.from)).value:S=(t=k.next(N.from)).value}return!1}(R[Z],V[Z]))}let W=Z=>{zn(R,Z),J()&&E()},E=()=>{if(l||B)return;R={};let Z={},e=function(r){Q&&vQ();let c=()=>GF(F,{subscr:r,trans:null}),h=x.trans?GQ(x.transless,c):c();return Q&&h.then(TF,TF),h}(Z);n||(OF("storagemutated",W),n=!0),l=!0,Promise.resolve(e).then(r=>{l=!1,B||(J()?E():(R={},V=Z,U.next&&U.next(r)))},r=>{l=!1,U.error&&U.error(r),d.unsubscribe()})};return E(),d})},extendObservabilitySet:zn,getByKeyPath:kF,setByKeyPath:AU,delByKeyPath:function(F,U){typeof U=="string"?AU(F,U,void 0):"length"in U&&[].map.call(U,function(Q){AU(F,Q,void 0)})},shallowClone:Un,deepClone:CB,getObjectDiff:K0,cmp:bU,asap:Al,minKey:-(1/0),addons:[],connections:YB,errnames:e0,dependencies:q0,semVer:"3.2.2",version:"3.2.2".split(".").map(F=>parseInt(F)).reduce((F,U,Q)=>F+U/Math.pow(10,2*Q))})),dQ.maxKey=bB(dQ.dependencies.IDBKeyRange),typeof dispatchEvent!="undefined"&&typeof addEventListener!="undefined"&&(OF("storagemutated",F=>{if(!rF){let U;XR?(U=document.createEvent("CustomEvent"),U.initCustomEvent("x-storagemutated-1",!0,!0,F)):U=new CustomEvent("x-storagemutated-1",{detail:F}),rF=!0,dispatchEvent(U),rF=!1}}),addEventListener("x-storagemutated-1",({detail:F})=>{rF||jR(F)}));var rF=!1;if(typeof BroadcastChannel!="undefined"){let F=new BroadcastChannel("x-storagemutated-1");OF("storagemutated",U=>{rF||F.postMessage(U)}),F.onmessage=U=>{U.data&&jR(U.data)}}else if(typeof self!="undefined"&&typeof navigator!="undefined"){OF("storagemutated",U=>{try{rF||(typeof localStorage!="undefined"&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:U})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(Q=>Q.postMessage({type:"x-storagemutated-1",changedParts:U})))}catch{}}),typeof addEventListener!="undefined"&&addEventListener("storage",U=>{if(U.key==="x-storagemutated-1"){let Q=JSON.parse(U.newValue);Q&&jR(Q.changedParts)}});let F=self.document&&navigator.serviceWorker;F&&F.addEventListener("message",function({data:U}){U&&U.type==="x-storagemutated-1"&&jR(U.changedParts)})}b.rejectionMapper=function(F,U){if(!F||F instanceof YQ||F instanceof TypeError||F instanceof SyntaxError||!F.name||!ln[F.name])return F;var Q=new ln[F.name](U||F.message,F);return"stack"in F&&eF(Q,"stack",{get:function(){return this.inner.stack}}),Q},Bn(VF,an);var CF=new class extends HF{constructor(){super("obsidian-text-extract/cache/"+app.appId),this.version(3).stores({pdf:"path, hash, size",images:"path, hash, size"}),this.clearOldDatabases()}clearOldDatabases(){indexedDB.deleteDatabase("obsidian-text-extract/cache")}},un=class{value;next;constructor(U){this.value=U}},xn=class{#U;#F;#Q;constructor(){this.clear()}enqueue(U){let Q=new un(U);this.#U?(this.#F.next=Q,this.#F=Q):(this.#U=Q,this.#F=Q),this.#Q++}dequeue(){let U=this.#U;if(U)return this.#U=this.#U.next,this.#Q--,U.value}clear(){this.#U=void 0,this.#F=void 0,this.#Q=0}get size(){return this.#Q}*[Symbol.iterator](){let U=this.#U;for(;U;)yield U.value,U=U.next}},wn=hB.Platform.isMobileApp?1:require("os").cpus().length,IR=Math.max(1,Math.floor(.7*wn));IR==wn&&(IR=1);var _0=Symbol.for("be.scambier.obsidian-text-extract");globalThis[_0]||(console.info("Text Extract - Number of available workers: "+IR),globalThis[_0]=function(F){if(!Number.isInteger(F)&&F!==Number.POSITIVE_INFINITY||!(F>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let U=new xn,Q=0,B=async(V,d,l)=>{Q++;let n=(async()=>V(...l))();d(n);try{await n}catch{}Q--,U.size>0&&U.dequeue()()},R=(V,...d)=>new Promise(l=>{((n,J,W)=>{U.enqueue(B.bind(void 0,n,J,W)),(async()=>{await Promise.resolve(),Q0&&U.dequeue()()})()})(V,l,d)});return Object.defineProperties(R,{activeCount:{get:()=>Q},pendingCount:{get:()=>U.size},clearQueue:{value:()=>{U.clear()}}}),R}(IR));var Ln=globalThis[_0],lQ=class{constructor(U){this.worker=U,this.running=!1}static getWorker(){let U=lQ.pool.find(B=>!B.running);if(U)return U;let Q=new lQ(new OZ({name:"PDF Text Extractor"}));return lQ.pool.push(Q),Q}async run(U){return new Promise((Q,B)=>{this.running=!0;let R=setTimeout(()=>{this.worker.terminate(),console.warn("Omnisearch - Worker timeout"),B("timeout"),this.running=!1},12e4);this.worker.postMessage(U),this.worker.onmessage=V=>{clearTimeout(R),Q(V),this.running=!1}})}};lQ.pool=[];var jn=new class{async getPdfText(F){return hB.Platform.isMobile?"":Ln(this._getPdfText,F)}async _getPdfText(F){let U=await CF.pdf.get({path:F.path,size:F.stat.size});if(U)return U.text;let Q=new Uint8Array(await app.vault.readBinary(F)),B=Pl(Q),R=await CF.pdf.get(B);if(R)return R.text;let V=lQ.getWorker();return new Promise(async(d,l)=>{try{let n=(await V.run({data:Q,name:F.basename})).data.text.replace(/\n/g," ").replace(/ +/g," ").trim();CF.pdf.add({hash:B,text:n,path:F.path,size:F.stat.size,libVersion:"1.0.4"}).then(()=>{d(n)})}catch{CF.pdf.add({hash:B,text:"",path:F.path,size:F.stat.size,libVersion:"1.0.4"}).then(()=>{d("")})}})}async cleanCache(){CF.pdf.each(async F=>{await app.vault.adapter.exists(F.path)||console.log(F.path+" does not exist")})}};(function(F){var U=function(Q){var B,R=Object.prototype,V=R.hasOwnProperty,d=Object.defineProperty||function(M,m,Y){M[m]=Y.value},l=typeof Symbol=="function"?Symbol:{},n=l.iterator||"@@iterator",J=l.asyncIterator||"@@asyncIterator",W=l.toStringTag||"@@toStringTag";function E(M,m,Y){return Object.defineProperty(M,m,{value:Y,enumerable:!0,configurable:!0,writable:!0}),M[m]}try{E({},"")}catch{E=function(m,Y,I){return m[Y]=I}}function Z(M,m,Y,I){var X=m&&m.prototype instanceof k?m:k,lU=Object.create(X.prototype),EU=new w(I||[]);return d(lU,"_invoke",{value:s(M,Y,EU)}),lU}function e(M,m,Y){try{return{type:"normal",arg:M.call(m,Y)}}catch(I){return{type:"throw",arg:I}}}Q.wrap=Z;var r="suspendedStart",c="executing",h="completed",N={};function k(){}function t(){}function S(){}var a={};E(a,n,function(){return this});var T=Object.getPrototypeOf,C=T&&T(T(g([])));C&&C!==R&&V.call(C,n)&&(a=C);var D=S.prototype=k.prototype=Object.create(a);function p(M){["next","throw","return"].forEach(function(m){E(M,m,function(Y){return this._invoke(m,Y)})})}function o(M,m){function Y(X,lU,EU,zU){var uU=e(M[X],M,lU);if(uU.type!=="throw"){var ZQ=uU.arg,uQ=ZQ.value;return uQ&&typeof uQ=="object"&&V.call(uQ,"__await")?m.resolve(uQ.__await).then(function(xF){Y("next",xF,EU,zU)},function(xF){Y("throw",xF,EU,zU)}):m.resolve(uQ).then(function(xF){ZQ.value=xF,EU(ZQ)},function(xF){return Y("throw",xF,EU,zU)})}zU(uU.arg)}var I;d(this,"_invoke",{value:function(X,lU){function EU(){return new m(function(zU,uU){Y(X,lU,zU,uU)})}return I=I?I.then(EU,EU):EU()}})}function s(M,m,Y){var I=r;return function(X,lU){if(I===c)throw new Error("Generator is already running");if(I===h){if(X==="throw")throw lU;return L()}for(Y.method=X,Y.arg=lU;;){var EU=Y.delegate;if(EU){var zU=v(EU,Y);if(zU){if(zU===N)continue;return zU}}if(Y.method==="next")Y.sent=Y._sent=Y.arg;else if(Y.method==="throw"){if(I===r)throw I=h,Y.arg;Y.dispatchException(Y.arg)}else Y.method==="return"&&Y.abrupt("return",Y.arg);I=c;var uU=e(M,m,Y);if(uU.type==="normal"){if(I=Y.done?h:"suspendedYield",uU.arg===N)continue;return{value:uU.arg,done:Y.done}}uU.type==="throw"&&(I=h,Y.method="throw",Y.arg=uU.arg)}}}function v(M,m){var Y=M.iterator[m.method];if(Y===B){if(m.delegate=null,m.method==="throw"){if(M.iterator.return&&(m.method="return",m.arg=B,v(M,m),m.method==="throw"))return N;m.method="throw",m.arg=new TypeError("The iterator does not provide a 'throw' method")}return N}var I=e(Y,M.iterator,m.arg);if(I.type==="throw")return m.method="throw",m.arg=I.arg,m.delegate=null,N;var X=I.arg;return X?X.done?(m[M.resultName]=X.value,m.next=M.nextLoc,m.method!=="return"&&(m.method="next",m.arg=B),m.delegate=null,N):X:(m.method="throw",m.arg=new TypeError("iterator result is not an object"),m.delegate=null,N)}function y(M){var m={tryLoc:M[0]};1 in M&&(m.catchLoc=M[1]),2 in M&&(m.finallyLoc=M[2],m.afterLoc=M[3]),this.tryEntries.push(m)}function i(M){var m=M.completion||{};m.type="normal",delete m.arg,M.completion=m}function w(M){this.tryEntries=[{tryLoc:"root"}],M.forEach(y,this),this.reset(!0)}function g(M){if(M){var m=M[n];if(m)return m.call(M);if(typeof M.next=="function")return M;if(!isNaN(M.length)){var Y=-1,I=function X(){for(;++Y=0;--I){var X=this.tryEntries[I],lU=X.completion;if(X.tryLoc==="root")return Y("end");if(X.tryLoc<=this.prev){var EU=V.call(X,"catchLoc"),zU=V.call(X,"finallyLoc");if(EU&&zU){if(this.prev=0;--Y){var I=this.tryEntries[Y];if(I.tryLoc<=this.prev&&V.call(I,"finallyLoc")&&this.prev=0;--m){var Y=this.tryEntries[m];if(Y.finallyLoc===M)return this.complete(Y.completion,Y.afterLoc),i(Y),N}},catch:function(M){for(var m=this.tryEntries.length-1;m>=0;--m){var Y=this.tryEntries[m];if(Y.tryLoc===M){var I=Y.completion;if(I.type==="throw"){var X=I.arg;i(Y)}return X}}throw new Error("illegal catch attempt")},delegateYield:function(M,m,Y){return this.delegate={iterator:g(M),resultName:m,nextLoc:Y},this.method==="next"&&(this.arg=B),N}},Q}(F.exports);try{regeneratorRuntime=U}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=U:Function("r","regeneratorRuntime = r")(U)}})({exports:{}});var A0=(F,U)=>`${F}-${U}-${Math.random().toString(16).slice(3,8)}`,rN=A0,In=0,fn=({id:F,action:U,payload:Q={}})=>{let B=F;return B===void 0&&(B=rN("Job",In),In+=1),{id:B,action:U,payload:Q}},OQ={},$0=!1;OQ.logging=$0,OQ.setLogging=F=>{$0=F},OQ.log=(...F)=>$0?console.log.apply(void 0,F):null;var CN=fn,{log:fR}=OQ,DN=A0,Kn=0,pN=function(){return typeof window!="undefined"&&typeof window.process=="object"&&window.process.type==="renderer"||!(typeof process=="undefined"||typeof process.versions!="object"||!process.versions.electron)||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0},gn,Pn={exports:{}};function Ud(){return gn?Pn.exports:(gn=1,Pn.exports=function(){function F(){var U=arguments.length;if(U===0)throw new Error("resolveUrl requires at least one argument; got none.");var Q=document.createElement("base");if(Q.href=arguments[0],U===1)return Q.href;var B=document.getElementsByTagName("head")[0];B.insertBefore(Q,B.firstChild);for(var R,V=document.createElement("a"),d=1;d{let U={};return typeof WorkerGlobalScope!="undefined"?U.type="webworker":pN()?U.type="electron":typeof window=="object"?U.type="browser":typeof process=="object"&&(U.type="node"),F===void 0?U:U[F]})("type")==="browser"?Ud():F=>F,qn={TESSERACT_ONLY:0,LSTM_ONLY:1,TESSERACT_LSTM_COMBINED:2,DEFAULT:3},MN={defaultOEM:qn.DEFAULT},oN={name:"tesseract.js",version:"3.0.3",description:"Pure Javascript Multilingual OCR",main:"src/index.js",types:"src/index.d.ts",unpkg:"dist/tesseract.min.js",jsdelivr:"dist/tesseract.min.js",scripts:{start:"node scripts/server.js",build:"rimraf dist && webpack --config scripts/webpack.config.prod.js && rollup -c scripts/rollup.esm.js","profile:tesseract":"webpack-bundle-analyzer dist/tesseract-stats.json","profile:worker":"webpack-bundle-analyzer dist/worker-stats.json",prepublishOnly:"npm run build",wait:"rimraf dist && wait-on http://localhost:3000/dist/tesseract.dev.js",test:"npm-run-all -p -r start test:all","test:all":"npm-run-all wait test:browser:* test:node:all","test:node":"nyc mocha --exit --bail --require ./scripts/test-helper.js","test:node:all":"npm run test:node -- ./tests/*.test.js","test:browser-tpl":"mocha-headless-chrome -a incognito -a no-sandbox -a disable-setuid-sandbox -a disable-logging -t 300000","test:browser:detect":"npm run test:browser-tpl -- -f ./tests/detect.test.html","test:browser:recognize":"npm run test:browser-tpl -- -f ./tests/recognize.test.html","test:browser:scheduler":"npm run test:browser-tpl -- -f ./tests/scheduler.test.html","test:browser:FS":"npm run test:browser-tpl -- -f ./tests/FS.test.html",lint:"eslint src","lint:fix":"eslint --fix src",postinstall:"opencollective-postinstall || true"},browser:{"./src/worker/node/index.js":"./src/worker/browser/index.js"},author:"",contributors:["jeromewu"],license:"Apache-2.0",devDependencies:{"@babel/core":"^7.18.7","@babel/preset-env":"^7.18.7","@rollup/plugin-commonjs":"^22.0.2",acorn:"^6.4.0","babel-loader":"^8.2.0",buffer:"^6.0.3",cors:"^2.8.5",eslint:"^7.2.0","eslint-config-airbnb-base":"^14.2.0","eslint-plugin-import":"^2.22.1","expect.js":"^0.3.1",express:"^4.17.1",mocha:"^8.1.3","mocha-headless-chrome":"^2.0.3","npm-run-all":"^4.1.5",nyc:"^15.1.0",rimraf:"^2.7.1",rollup:"^2.79.0","wait-on":"^3.3.0",webpack:"^5.74.0","webpack-bundle-analyzer":"^4.6.0","webpack-cli":"^4.10.0","webpack-dev-middleware":"^5.3.3"},dependencies:{"babel-eslint":"^10.1.0","bmp-js":"^0.1.0","file-type":"^12.4.1","idb-keyval":"^3.2.0","is-electron":"^2.2.0","is-url":"^1.2.4","node-fetch":"^2.6.0","opencollective-postinstall":"^2.0.2","regenerator-runtime":"^0.13.3","resolve-url":"^0.2.1","tesseract.js-core":"^3.0.2","wasm-feature-detect":"^1.2.11",zlibjs:"^0.3.1"},repository:{type:"git",url:"https://github.com/naptha/tesseract.js.git"},bugs:{url:"https://github.com/naptha/tesseract.js/issues"},homepage:"https://github.com/naptha/tesseract.js",collective:{type:"opencollective",url:"https://opencollective.com/tesseractjs"}},iN=Ud(),{version:sN}=oN,YN={langPath:"https://tessdata.projectnaptha.com/4.0.0",workerBlobURL:!0,logger:()=>{},workerPath:typeof process!="undefined"&&process.env.TESS_ENV==="development"?iN(`/dist/worker.dev.js?nocache=${Math.random().toString(36).slice(3)}`):`https://unpkg.com/tesseract.js@v${sN}/dist/worker.min.js`,corePath:null},yN=Ud(),_n=F=>new Promise((U,Q)=>{let B=new FileReader;B.onload=()=>{U(B.result)},B.onerror=({target:{error:{code:R}}})=>{Q(Error(`File could not be read! Code=${R}`))},B.readAsArrayBuffer(F)}),Fd=async F=>{let U=F;return F===void 0?"undefined":(typeof F=="string"?/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(F)?U=atob(F.split(",")[1]).split("").map(Q=>Q.charCodeAt(0)):U=await(await fetch(yN(F))).arrayBuffer():F instanceof HTMLElement?(F.tagName==="IMG"&&(U=await Fd(F.src)),F.tagName==="VIDEO"&&(U=await Fd(F.poster)),F.tagName==="CANVAS"&&await new Promise(Q=>{F.toBlob(async B=>{U=await _n(B),Q()})})):(F instanceof File||F instanceof Blob)&&(U=await _n(F)),new Uint8Array(U))},vN={defaultOptions:YN,spawnWorker:({workerPath:F,workerBlobURL:U})=>{let Q;if(Blob&&URL&&U){let B=new Blob([`importScripts("${F}");`],{type:"application/javascript"});Q=new Worker(URL.createObjectURL(B))}else Q=new Worker(F);return Q},terminateWorker:F=>{F.terminate()},onMessage:(F,U)=>{F.onmessage=({data:Q})=>{U(Q)}},send:async(F,U)=>{F.postMessage(U)},loadImage:Fd},GN=F=>{let U=z({},F);return["corePath","workerPath","langPath"].forEach(Q=>{F[Q]&&(U[Q]=mN(U[Q]))}),U},bN=F=>{let U=[],Q=[],B=[],R=[],V=[];return F.blocks.forEach(d=>{d.paragraphs.forEach(l=>{l.lines.forEach(n=>{n.words.forEach(J=>{J.symbols.forEach(W=>{V.push(q(z({},W),{page:F,block:d,paragraph:l,line:n,word:J}))}),R.push(q(z({},J),{page:F,block:d,paragraph:l,line:n}))}),B.push(q(z({},n),{page:F,block:d,paragraph:l}))}),Q.push(q(z({},l),{page:F,block:d}))}),U.push(q(z({},d),{page:F}))}),q(z({},F),{blocks:U,paragraphs:Q,lines:B,words:R,symbols:V})},$U=fn,{log:An}=OQ,XN=A0,{defaultOEM:ON}=MN,{defaultOptions:HN,spawnWorker:zN,terminateWorker:uN,onMessage:xN,loadImage:$n,send:wN}=vN,UJ=0,FJ=(F={})=>{let U=XN("Worker",UJ),E=GN(z(z({},HN),F)),{logger:Q,errorHandler:B}=E,R=Cd(E,["logger","errorHandler"]),V={},d={},l=zN(R);UJ+=1;let n=(Z,e)=>{V[Z]=e},J=(Z,e)=>{d[Z]=e},W=({id:Z,action:e,payload:r})=>new Promise((c,h)=>{An(`[${U}]: Start ${Z}, action=${e}`),n(e,c),J(e,h),wN(l,{workerId:U,jobId:Z,action:e,payload:r})});return xN(l,({workerId:Z,jobId:e,status:r,action:c,data:h})=>{if(r==="resolve"){An(`[${Z}]: Complete ${e}`);let N=h;c==="recognize"?N=bN(h):c==="getPDF"&&(N=Array.from(q(z({},h),{length:Object.keys(h).length}))),V[c]({jobId:e,data:N})}else if(r==="reject"){if(d[c](h),!B)throw Error(h);B(h)}else r==="progress"&&Q(q(z({},h),{userJobId:e}))}),{id:U,worker:l,setResolve:n,setReject:J,load:Z=>W($U({id:Z,action:"load",payload:{options:R}})),writeText:(Z,e,r)=>W($U({id:r,action:"FS",payload:{method:"writeFile",args:[Z,e]}})),readText:(Z,e)=>W($U({id:e,action:"FS",payload:{method:"readFile",args:[Z,{encoding:"utf8"}]}})),removeFile:(Z,e)=>W($U({id:e,action:"FS",payload:{method:"unlink",args:[Z]}})),FS:(Z,e,r)=>W($U({id:r,action:"FS",payload:{method:Z,args:e}})),loadLanguage:(Z="eng",e)=>W($U({id:e,action:"loadLanguage",payload:{langs:Z,options:R}})),initialize:(Z="eng",e=ON,r)=>W($U({id:r,action:"initialize",payload:{langs:Z,oem:e}})),setParameters:(Z={},e)=>W($U({id:e,action:"setParameters",payload:{params:Z}})),recognize:async(Z,e={},r)=>W($U({id:r,action:"recognize",payload:{image:await $n(Z),options:e}})),getPDF:(Z="Tesseract OCR Result",e=!1,r)=>W($U({id:r,action:"getPDF",payload:{title:Z,textonly:e}})),detect:async(Z,e)=>W($U({id:e,action:"detect",payload:{image:await $n(Z)}})),terminate:async()=>(l!==null&&(uN(l),l=null),Promise.resolve())}},QJ=FJ,LN=()=>{let F=DN("Scheduler",Kn),U={},Q={},B=[];Kn+=1;let R=()=>Object.keys(U).length,V=()=>{if(B.length!==0){let d=Object.keys(U);for(let l=0;l(U[d.id]=d,fR(`[${F}]: Add ${d.id}`),fR(`[${F}]: Number of workers=${R()}`),V(),d.id),addJob:async(d,...l)=>{if(R()===0)throw Error(`[${F}]: You need to have at least one worker before adding jobs`);return((n,J)=>new Promise((W,E)=>{let Z=CN({action:n,payload:J});B.push(async e=>{B.shift(),Q[e.id]=Z;try{W(await e[n].apply(void 0,[...J,Z.id]))}catch(r){E(r)}finally{delete Q[e.id],V()}}),fR(`[${F}]: Add ${Z.id} to JobQueue`),fR(`[${F}]: JobQueue length=${B.length}`),V()}))(d,l)},terminate:async()=>{Object.keys(U).forEach(async d=>{await U[d].terminate()}),B=[]},getQueueLen:()=>B.length,getNumWorkers:R}},jN=FJ,IN={recognize:async(F,U,Q)=>{let B=QJ(Q);return await B.load(),await B.loadLanguage(U),await B.initialize(U),B.recognize(F).finally(async()=>{await B.terminate()})},detect:async(F,U)=>{let Q=QJ(U);return await Q.load(),await Q.loadLanguage("osd"),await Q.initialize("osd"),Q.detect(F).finally(async()=>{await Q.terminate()})}},fN={AFR:"afr",AMH:"amh",ARA:"ara",ASM:"asm",AZE:"aze",AZE_CYRL:"aze_cyrl",BEL:"bel",BEN:"ben",BOD:"bod",BOS:"bos",BUL:"bul",CAT:"cat",CEB:"ceb",CES:"ces",CHI_SIM:"chi_sim",CHI_TRA:"chi_tra",CHR:"chr",CYM:"cym",DAN:"dan",DEU:"deu",DZO:"dzo",ELL:"ell",ENG:"eng",ENM:"enm",EPO:"epo",EST:"est",EUS:"eus",FAS:"fas",FIN:"fin",FRA:"fra",FRK:"frk",FRM:"frm",GLE:"gle",GLG:"glg",GRC:"grc",GUJ:"guj",HAT:"hat",HEB:"heb",HIN:"hin",HRV:"hrv",HUN:"hun",IKU:"iku",IND:"ind",ISL:"isl",ITA:"ita",ITA_OLD:"ita_old",JAV:"jav",JPN:"jpn",KAN:"kan",KAT:"kat",KAT_OLD:"kat_old",KAZ:"kaz",KHM:"khm",KIR:"kir",KOR:"kor",KUR:"kur",LAO:"lao",LAT:"lat",LAV:"lav",LIT:"lit",MAL:"mal",MAR:"mar",MKD:"mkd",MLT:"mlt",MSA:"msa",MYA:"mya",NEP:"nep",NLD:"nld",NOR:"nor",ORI:"ori",PAN:"pan",POL:"pol",POR:"por",PUS:"pus",RON:"ron",RUS:"rus",SAN:"san",SIN:"sin",SLK:"slk",SLV:"slv",SPA:"spa",SPA_OLD:"spa_old",SQI:"sqi",SRP:"srp",SRP_LATN:"srp_latn",SWA:"swa",SWE:"swe",SYR:"syr",TAM:"tam",TEL:"tel",TGK:"tgk",TGL:"tgl",THA:"tha",TIR:"tir",TUR:"tur",UIG:"uig",UKR:"ukr",URD:"urd",UZB:"uzb",UZB_CYRL:"uzb_cyrl",VIE:"vie",YID:"yid"},KN=qn,gN={OSD_ONLY:"0",AUTO_OSD:"1",AUTO_ONLY:"2",AUTO:"3",SINGLE_COLUMN:"4",SINGLE_BLOCK_VERT_TEXT:"5",SINGLE_BLOCK:"6",SINGLE_LINE:"7",SINGLE_WORD:"8",CIRCLE_WORD:"9",SINGLE_CHAR:"10",SPARSE_TEXT:"11",SPARSE_TEXT_OSD:"12"},{setLogging:PN}=OQ,qN=z({languages:fN,OEM:KN,PSM:gN,createScheduler:LN,createWorker:jN,setLogging:PN},IN),nQ=class{constructor(U){this.worker=U,this.running=!1,this.ready=!1}static getWorker(){let U=nQ.pool.find(B=>!B.running&&B.ready);if(U)return U;let Q=new nQ(qN.createWorker({cachePath:"tesseract"}));return nQ.pool.push(Q),Q}async run(U){return new Promise(async(Q,B)=>{this.running=!0,this.ready||(await this.worker.load(),await this.worker.loadLanguage("eng"),await this.worker.initialize("eng"),this.ready=!0);let R=setTimeout(()=>{this.worker.terminate(),console.warn("Omnisearch - Worker timeout"),B("timeout"),this.running=!1},12e4);try{let{data:V}=await this.worker.recognize(U.imageData);return clearTimeout(R),Q(V)}catch{console.error("Omnisearch - OCR Worker timeout for "+name),Q({text:""})}finally{this.running=!1}})}};nQ.pool=[];var BJ=new class{async getImageText(F){return hB.Platform.isMobile?"":Ln(this._getImageText,F)}async _getImageText(F){let U=await CF.images.get({path:F.path,size:F.stat.size});if(U)return U.text;let Q=new Uint8ClampedArray(await app.vault.readBinary(F)),B=Pl(Q),R=await CF.images.get(B);if(R)return R.text;let V=nQ.getWorker();return new Promise(async(d,l)=>{try{let n=(await V.run({imageData:Buffer.from(Q.buffer),name:F.basename})).text.replace(/\n/g," ").replace(/ +/g," ").trim();CF.images.add({hash:B,text:n,path:F.path,size:F.stat.size,libVersion:"1.0.4"}).then(()=>{d(n)})}catch{CF.images.add({hash:B,text:"",path:F.path,size:F.stat.size,libVersion:"1.0.4"}).then(()=>{d("")})}})}},RJ=jn.getPdfText.bind(jn),VJ=BJ.getImageText.bind(BJ);async function _N(F){let U=app.vault.getFiles().find(R=>R.path===F);if(!U)throw new Error(`Invalid file path: "${F}"`);let Q;if(l0(F))Q=await app.vault.cachedRead(U);else if(TB(F))Q=await RJ(U);else if(aB(U.path))Q=await VJ(U);else throw new Error("Invalid file format: "+U.path);Q=$F(Q);let B=app.metadataCache.getFileCache(U);if(B&&B.frontmatter?.["excalidraw-plugin"]){let R=B.sections?.filter(V=>V.type==="comment")??[];for(let{start:V,end:d}of R.map(l=>l.position))Q=Q.substring(0,V.offset-1)+Q.substring(d.offset)}return{basename:$F(U.basename),content:Q,path:U.path,mtime:U.stat.mtime,tags:zl(B),aliases:Hl(B).join(""),headings1:B?TR(B,1).join(" "):"",headings2:B?TR(B,2).join(" "):"",headings3:B?TR(B,3).join(" "):""}}var lJ=class{constructor(){this.nextQueryIsEmpty=!1;this.documents=new Map}async addToLiveCache(U){let Q=await _N(U);this.documents.set(U,Q)}removeFromLiveCache(U){this.documents.delete(U)}async getDocument(U){return this.documents.has(U)?this.documents.get(U):(await this.addToLiveCache(U),this.documents.get(U))}async addToSearchHistory(U){if(!U){this.nextQueryIsEmpty=!0;return}this.nextQueryIsEmpty=!1;let Q=await fU.searchHistory.toArray();Q=Q.filter(B=>B.query!==U).reverse(),Q.unshift({query:U}),Q=Q.slice(0,10),await fU.searchHistory.clear(),await fU.searchHistory.bulkAdd(Q)}async getSearchHistory(){let U=(await fU.searchHistory.toArray()).reverse().map(Q=>Q.query);return this.nextQueryIsEmpty&&U.unshift(""),U}getDocumentsChecksum(U){return wl(JSON.stringify(U.sort((Q,B)=>Q.pathB.path?1:0)))}async getMinisearchCache(){try{return(await fU.minisearch.toArray())[0]}catch(U){return new dJ.Notice("Omnisearch - Cache missing or invalid. Some freezes may occur while Omnisearch indexes your vault."),console.error("Omnisearch - Error while loading Minisearch cache"),console.error(U),null}}async writeMinisearchCache(U,Q){let B=Array.from(Q).map(([R,V])=>({path:R,mtime:V}));await fU.minisearch.clear(),await fU.minisearch.add({date:new Date().toISOString(),paths:B,data:U.toJSON()}),console.log("Omnisearch - Search cache written")}},hU=new lJ;function AN(F){let U,Q,B,R,V,d,l,n=F[7].default,J=NQ(n,F,F[6],null);return{c(){U=j("div"),Q=j("div"),B=j("input"),R=FU(),J&&J.c(),P(B,"class","prompt-input"),P(B,"placeholder",F[0]),P(B,"spellcheck","false"),P(B,"type","text"),P(Q,"class","omnisearch-input-field"),P(U,"class","omnisearch-input-container")},m(W,E){UU(W,U,E),H(U,Q),H(Q,B),F[8](B),RV(B,F[1]),H(U,R),J&&J.m(U,null),V=!0,d||(l=[xU(B,"input",F[9]),xU(B,"compositionend",F[10]),xU(B,"compositionstart",F[11]),xU(B,"input",F[3])],d=!0)},p(W,[E]){(!V||E&1)&&P(B,"placeholder",W[0]),E&2&&B.value!==W[1]&&RV(B,W[1]),J&&J.p&&(!V||E&64)&&tQ(J,n,W,W[6],V?EQ(n,W[6],E,null):SQ(W[6]),null)},i(W){V||(BU(J,W),V=!0)},o(W){RU(J,W),V=!1},d(W){W&&A(U),F[8](null),J&&J.d(W),d=!1,gU(l)}}}function $N(F,U,Q){let{$$slots:B={},$$scope:R}=U,{initialValue:V=""}=U,d=!1,{placeholder:l=""}=U,n="",J,W=lV();async function E(){await lF(),J.focus(),await lF(),J.select(),await lF()}let Z=(0,nJ.debounce)(()=>{hU.addToSearchHistory(""),W("input",n)},500);function e(N){LB[N?"unshift":"push"](()=>{J=N,Q(2,J)})}function r(){n=this.value,Q(1,n),Q(4,V),Q(5,d)}let c=N=>R0(!1),h=N=>R0(!0);return F.$$set=N=>{"initialValue"in N&&Q(4,V=N.initialValue),"placeholder"in N&&Q(0,l=N.placeholder),"$$scope"in N&&Q(6,R=N.$$scope)},F.$$.update=()=>{if(F.$$.dirty&50){U:V&&!d&&!n&&(Q(5,d=!0),Q(1,n=V),E())}},[l,n,J,Z,V,d,R,B,e,r,c,h]}var JJ=class extends CU{constructor(U){super();mU(this,U,$N,AN,rU,{initialValue:4,placeholder:0})}},KR=JJ;function UE(F){let U,Q,B,R,V=F[1].default,d=NQ(V,F,F[0],null);return{c(){U=j("div"),d&&d.c(),P(U,"class","prompt-results")},m(l,n){UU(l,U,n),d&&d.m(U,null),Q=!0,B||(R=xU(U,"mousedown",FE),B=!0)},p(l,[n]){d&&d.p&&(!Q||n&1)&&tQ(d,V,l,l[0],Q?EQ(V,l[0],n,null):SQ(l[0]),null)},i(l){Q||(BU(d,l),Q=!0)},o(l){RU(d,l),Q=!1},d(l){l&&A(U),d&&d.d(l),B=!1,R()}}}var FE=F=>F.preventDefault();function QE(F,U,Q){let{$$slots:B={},$$scope:R}=U;return F.$$set=V=>{"$$scope"in V&&Q(0,R=V.$$scope)},[R,B]}var WJ=class extends CU{constructor(U){super();mU(this,U,QE,UE,rU,{})}},gR=WJ;var Qd=XU(require("obsidian"));async function PR(F,U=!1){let Q=yF(F.foundWords);Q.exec(F.content);let B=Q.lastIndex,R=!1;app.workspace.iterateAllLeaves(l=>{l.view instanceof Qd.MarkdownView&&!U&&l.getViewState().state?.file===F.path&&l.getViewState()?.pinned&&(app.workspace.setActiveLeaf(l,{focus:!0}),R=!0)}),R||await app.workspace.openLinkText(F.path,"",U);let V=app.workspace.getActiveViewOfType(Qd.MarkdownView);if(!V)return;let d=V.editor.offsetToPos(B);d.ch=0,V.editor.setCursor(d),V.editor.scrollIntoView({from:{line:d.line-10,ch:0},to:{line:d.line+10,ch:0}})}async function ZJ(F,U=!1){try{let Q;switch(app.vault.getConfig("newFileLocation")){case"current":Q=(app.workspace.getActiveFile()?.parent.path??"")+"/";break;case"folder":Q=app.vault.getConfig("newFileFolderPath")+"/";break;default:Q="";break}await app.workspace.openLinkText(`${Q}${F}.md`,"",U)}catch(Q){throw Q.message="OmniSearch - Could not create note: "+Q.message,console.error(Q),Q}}function BE(F){let U;return{c(){U=j("span"),U.innerHTML='',P(U,"class","suggestion-flair"),P(U,"aria-label","Not created yet, select to create")},m(Q,B){UU(Q,U,B)},p:tU,i:tU,o:tU,d(Q){Q&&A(U)}}}function RE(F){"use strict";return[]}var NJ=class extends CU{constructor(U){super();mU(this,U,RE,BE,rU,{})}},EJ=NJ;function tJ(F){let U,Q;return U=new EJ({}),{c(){OU(U.$$.fragment)},m(B,R){YU(U,B,R),Q=!0},i(B){Q||(BU(U.$$.fragment,B),Q=!0)},o(B){RU(U.$$.fragment,B),Q=!1},d(B){pU(U,B)}}}function VE(F){let U,Q,B,R,V,d=F[2]&&tJ(F),l=F[4].default,n=NQ(l,F,F[3],null);return{c(){U=j("div"),d&&d.c(),Q=FU(),n&&n.c(),P(U,"data-result-id",F[0]),P(U,"class","suggestion-item omnisearch-result"),VV(U,"is-selected",F[1])},m(J,W){UU(J,U,W),d&&d.m(U,null),H(U,Q),n&&n.m(U,null),B=!0,R||(V=[xU(U,"mousemove",F[5]),xU(U,"click",F[6]),xU(U,"auxclick",F[7])],R=!0)},p(J,[W]){J[2]?d?W&4&&BU(d,1):(d=tJ(J),d.c(),BU(d,1),d.m(U,Q)):d&&(LF(),RU(d,1,1,()=>{d=null}),jF()),n&&n.p&&(!B||W&8)&&tQ(n,l,J,J[3],B?EQ(l,J[3],W,null):SQ(J[3]),null),(!B||W&1)&&P(U,"data-result-id",J[0]),(!B||W&2)&&VV(U,"is-selected",J[1])},i(J){B||(BU(d),BU(n,J),B=!0)},o(J){RU(d),RU(n,J),B=!1},d(J){J&&A(U),d&&d.d(),n&&n.d(J),R=!1,gU(V)}}}function dE(F,U,Q){let{$$slots:B={},$$scope:R}=U,{id:V}=U,{selected:d=!1}=U,{glyph:l=!1}=U;function n(E){FF.call(this,F,E)}function J(E){FF.call(this,F,E)}function W(E){FF.call(this,F,E)}return F.$$set=E=>{"id"in E&&Q(0,V=E.id),"selected"in E&&Q(1,d=E.selected),"glyph"in E&&Q(2,l=E.glyph),"$$scope"in E&&Q(3,R=E.$$scope)},[V,d,l,R,B,n,J,W]}var SJ=class extends CU{constructor(U){super();mU(this,U,dE,VE,rU,{id:0,selected:1,glyph:2})}},qR=SJ;function eJ(F){let U,Q=F[1].matches.length+"",B,R,V=(F[1].matches.length>1?"matches":"match")+"",d;return{c(){U=j("span"),B=PU(Q),R=PU("\xA0"),d=PU(V),P(U,"class","omnisearch-result__counter")},m(l,n){UU(l,U,n),H(U,B),H(U,R),H(U,d)},p(l,n){n&2&&Q!==(Q=l[1].matches.length+"")&&jQ(B,Q),n&2&&V!==(V=(l[1].matches.length>1?"matches":"match")+"")&&jQ(d,V)},d(l){l&&A(U)}}}function kJ(F){let U,Q=F[5].replace(F[6],YF)+"";return{c(){U=j("div"),P(U,"class","omnisearch-result__body")},m(B,R){UU(B,U,R),U.innerHTML=Q},p(B,R){R&96&&Q!==(Q=B[5].replace(B[6],YF)+"")&&(U.innerHTML=Q)},d(B){B&&A(U)}}}function aJ(F){let U,Q;return{c(){U=j("img"),UF(U,"width","100px"),BV(U.src,Q=F[2])||P(U,"src",Q),P(U,"alt","")},m(B,R){UU(B,U,R)},p(B,R){R&4&&!BV(U.src,Q=B[2])&&P(U,"src",Q)},d(B){B&&A(U)}}}function lE(F){let U,Q,B,R,V=F[3].replace(F[6],YF)+"",d,l,n,J=F[1].matches.length>0&&eJ(F),W=F[7]&&kJ(F),E=F[2]&&aJ(F);return{c(){U=j("div"),Q=j("div"),B=j("div"),R=j("span"),d=FU(),J&&J.c(),l=FU(),W&&W.c(),n=FU(),E&&E.c(),P(R,"class","omnisearch-result__title"),UF(U,"display","flex")},m(Z,e){UU(Z,U,e),H(U,Q),H(Q,B),H(B,R),R.innerHTML=V,H(B,d),J&&J.m(B,null),H(Q,l),W&&W.m(Q,null),H(U,n),E&&E.m(U,null)},p(Z,e){e&72&&V!==(V=Z[3].replace(Z[6],YF)+"")&&(R.innerHTML=V),Z[1].matches.length>0?J?J.p(Z,e):(J=eJ(Z),J.c(),J.m(B,null)):J&&(J.d(1),J=null),Z[7]?W?W.p(Z,e):(W=kJ(Z),W.c(),W.m(Q,null)):W&&(W.d(1),W=null),Z[2]?E?E.p(Z,e):(E=aJ(Z),E.c(),E.m(U,null)):E&&(E.d(1),E=null)},d(Z){Z&&A(U),J&&J.d(),W&&W.d(),E&&E.d()}}}function nE(F){let U,Q;return U=new qR({props:{id:F[1].path,selected:F[0],glyph:F[4],$$slots:{default:[lE]},$$scope:{ctx:F}}}),U.$on("mousemove",F[8]),U.$on("click",F[9]),{c(){OU(U.$$.fragment)},m(B,R){YU(U,B,R),Q=!0},p(B,[R]){let V={};R&2&&(V.id=B[1].path),R&1&&(V.selected=B[0]),R&16&&(V.glyph=B[4]),R&1262&&(V.$$scope={dirty:R,ctx:B}),U.$set(V)},i(B){Q||(BU(U.$$.fragment,B),Q=!0)},o(B){RU(U.$$.fragment,B),Q=!1},d(B){pU(U,B)}}}function JE(F,U,Q){let B,R,V,d,l;xB(F,AF,e=>Q(7,l=e));let{selected:n=!1}=U,{note:J}=U,W=null;function E(e){FF.call(this,F,e)}function Z(e){FF.call(this,F,e)}F.$$set=e=>{"selected"in e&&Q(0,n=e.selected),"note"in e&&Q(1,J=e.note)},F.$$.update=()=>{if(F.$$.dirty&2){U:if(Q(2,W=null),aB(J.path)){let e=app.vault.getFiles().find(r=>r.path===J.path);e&&Q(2,W=app.vault.getResourcePath(e))}}if(F.$$.dirty&2){U:Q(6,B=yF(J.foundWords))}if(F.$$.dirty&2){U:Q(5,R=cR(J.content,J.matches[0]?.offset??-1))}if(F.$$.dirty&2){U:Q(3,d=O.showShortName?J.basename:J.path)}};U:Q(4,V=!1);return[n,J,W,d,V,R,B,l,E,Z]}var TJ=class extends CU{constructor(U){super();mU(this,U,JE,nE,rU,{selected:0,note:1})}},hJ=TJ;function cJ(F,U){U?U.offsets=typeof U.offsets=="undefined"?!0:U.offsets:U={offsets:!0,tokenize:!0},F||(F="");let Q={text:[],offsets:[],exclude:{text:[]}};U.offsets&&(Q.offsets=[]);let B={text:[]},R=[],V=/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|(-?"(?:[^"\\]|\\.)*")|(-?'(?:[^'\\]|\\.)*')|\S+|\S+:\S+/g,d,l=0;for(;(d=V.exec(F))!==null&&!(++l>=100);){let J=d[0],W=J.indexOf(":");if(W!==-1){let E=J.slice(0,W),Z=J.slice(W+1);Z=(Z+"").replace(/\\(.?)/g,function(e,r){switch(r){case"\\":return"\\";case"0":return"\0";case"":return"";default:return r}}),R.push({keyword:E,value:Z,offsetStart:d.index,offsetEnd:d.index+J.length})}else{let E=!1;J[0]==="-"&&(E=!0,J=J.slice(1)),J=(J+"").replace(/\\(.?)/g,function(Z,e){switch(e){case"\\":return"\\";case"0":return"\0";case"":return"";default:return e}}),E?B.text.push(J):R.push({text:J,offsetStart:d.index,offsetEnd:d.index+J.length})}}R.reverse();let n;for(;n=R.pop();)if(n.text)Q.text.push(n.text),U.offsets&&Q.offsets.push(n);else if(n.keyword){let J=n.keyword;U.keywords=U.keywords||[];let W=!1,E=!1;if(!/^-/.test(J))W=U.keywords.indexOf(J)!==-1;else if(J[0]==="-"){let e=J.slice(1);W=U.keywords.indexOf(e)!==-1,W&&(J=e,E=!0)}U.ranges=U.ranges||[];let Z=U.ranges.indexOf(J)!==-1;if(W){U.offsets&&Q.offsets.push({keyword:J,value:n.value,offsetStart:E?n.offsetStart+1:n.offsetStart,offsetEnd:n.offsetEnd});let e=n.value;if(e.length){let r=e.split(",");E?B[J]?B[J]instanceof Array?r.length>1?B[J]=B[J].concat(r):B[J].push(e):(B[J]=[B[J]],B[J].push(e)):r.length>1?B[J]=r:U.alwaysArray?B[J]=[e]:B[J]=e:Q[J]?Q[J]instanceof Array?r.length>1?Q[J]=Q[J].concat(r):Q[J].push(e):(Q[J]=[Q[J]],Q[J].push(e)):r.length>1?Q[J]=r:U.alwaysArray?Q[J]=[e]:Q[J]=e}}else if(Z){U.offsets&&Q.offsets.push(n);let e=n.value,r=e.split("-");Q[J]={},r.length===2?(Q[J].from=r[0],Q[J].to=r[1]):Q[J].from=e}else{let e=n.keyword+":"+n.value;Q.text.push(e),U.offsets&&Q.offsets.push({text:e,offsetStart:n.offsetStart,offsetEnd:n.offsetEnd})}}return Q.exclude=B,Q}var JQ=class{constructor(U=""){this.segments=[];this.exclusions=[];O.ignoreDiacritics&&(U=$F(U));let Q=cJ(U.toLowerCase(),{tokenize:!0});this.exclusions=Q.exclude.text.map(this.formatToken).filter(B=>!!B.value),this.segments=Q.text.reduce((B,R)=>{let V=this.formatToken(R);return V.value&&B.push(V),B},[])}isEmpty(){return this.segments.length===0}segmentsToStr(){return this.segments.map(({value:U})=>U).join(" ")}getExactTerms(){return this.segments.filter(({exact:U})=>U).map(({value:U})=>U)}formatToken(U){let Q=Ol(U);return{value:Q,exact:Q!==U}}};var NU=function(){return NU=Object.assign||function(U){for(var Q,B=1,R=arguments.length;B0&&V[V.length-1])&&(J[0]===6||J[0]===2)){Q=0;continue}if(J[0]===3&&(!V||J[1]>V[0]&&J[1]=F.length&&(F=void 0),{value:F&&F[B++],done:!F}}};throw new TypeError(U?"Object is not iterable.":"Symbol.iterator is not defined.")}function kU(F,U){var Q=typeof Symbol=="function"&&F[Symbol.iterator];if(!Q)return F;var B=Q.call(F),R,V=[],d;try{for(;(U===void 0||U-- >0)&&!(R=B.next()).done;)V.push(R.value)}catch(l){d={error:l}}finally{try{R&&!R.done&&(Q=B.return)&&Q.call(B)}finally{if(d)throw d.error}}return V}var NE="ENTRIES",rJ="KEYS",CJ="VALUES",DU="",Bd=function(){function F(U,Q){var B=U._tree,R=Array.from(B.keys());this.set=U,this._type=Q,this._path=R.length>0?[{node:B,keys:R}]:[]}return F.prototype.next=function(){var U=this.dive();return this.backtrack(),U},F.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var U=HQ(this._path),Q=U.node,B=U.keys;if(HQ(B)===DU)return{done:!1,value:this.result()};var R=Q.get(HQ(B));return this._path.push({node:R,keys:Array.from(R.keys())}),this.dive()},F.prototype.backtrack=function(){if(this._path.length!==0){var U=HQ(this._path).keys;U.pop(),!(U.length>0)&&(this._path.pop(),this.backtrack())}},F.prototype.key=function(){return this.set._prefix+this._path.map(function(U){var Q=U.keys;return HQ(Q)}).filter(function(U){return U!==DU}).join("")},F.prototype.value=function(){return HQ(this._path).node.get(DU)},F.prototype.result=function(){switch(this._type){case CJ:return this.value();case rJ:return this.key();default:return[this.key(),this.value()]}},F.prototype[Symbol.iterator]=function(){return this},F}(),HQ=function(F){return F[F.length-1]},EE=function(F,U,Q){var B=new Map;if(U===void 0)return B;for(var R=U.length+1,V=R+Q,d=new Uint8Array(V*R).fill(Q+1),l=0;lQ)continue U}DJ(F.get(e),U,Q,B,R,c,d,l+e)}}}catch(y){n={error:y}}finally{try{Z&&!Z.done&&(J=E.return)&&J.call(E)}finally{if(n)throw n.error}}},Rd=function(){function F(U,Q){U===void 0&&(U=new Map),Q===void 0&&(Q=""),this._size=void 0,this._tree=U,this._prefix=Q}return F.prototype.atPrefix=function(U){var Q,B;if(!U.startsWith(this._prefix))throw new Error("Mismatched prefix");var R=kU(_R(this._tree,U.slice(this._prefix.length)),2),V=R[0],d=R[1];if(V===void 0){var l=kU(ld(d),2),n=l[0],J=l[1];try{for(var W=_(n.keys()),E=W.next();!E.done;E=W.next()){var Z=E.value;if(Z!==DU&&Z.startsWith(J)){var e=new Map;return e.set(Z.slice(J.length),n.get(Z)),new F(e,U)}}}catch(r){Q={error:r}}finally{try{E&&!E.done&&(B=W.return)&&B.call(W)}finally{if(Q)throw Q.error}}}return new F(V,U)},F.prototype.clear=function(){this._size=void 0,this._tree.clear()},F.prototype.delete=function(U){return this._size=void 0,tE(this._tree,U)},F.prototype.entries=function(){return new Bd(this,NE)},F.prototype.forEach=function(U){var Q,B;try{for(var R=_(this),V=R.next();!V.done;V=R.next()){var d=kU(V.value,2),l=d[0],n=d[1];U(l,n,this)}}catch(J){Q={error:J}}finally{try{V&&!V.done&&(B=R.return)&&B.call(R)}finally{if(Q)throw Q.error}}},F.prototype.fuzzyGet=function(U,Q){return EE(this._tree,U,Q)},F.prototype.get=function(U){var Q=Vd(this._tree,U);return Q!==void 0?Q.get(DU):void 0},F.prototype.has=function(U){var Q=Vd(this._tree,U);return Q!==void 0&&Q.has(DU)},F.prototype.keys=function(){return new Bd(this,rJ)},F.prototype.set=function(U,Q){if(typeof U!="string")throw new Error("key must be a string");this._size=void 0;var B=dd(this._tree,U);return B.set(DU,Q),this},Object.defineProperty(F.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var U=this.entries();!U.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),F.prototype.update=function(U,Q){if(typeof U!="string")throw new Error("key must be a string");this._size=void 0;var B=dd(this._tree,U);return B.set(DU,Q(B.get(DU))),this},F.prototype.fetch=function(U,Q){if(typeof U!="string")throw new Error("key must be a string");this._size=void 0;var B=dd(this._tree,U),R=B.get(DU);return R===void 0&&B.set(DU,R=Q()),R},F.prototype.values=function(){return new Bd(this,CJ)},F.prototype[Symbol.iterator]=function(){return this.entries()},F.from=function(U){var Q,B,R=new F;try{for(var V=_(U),d=V.next();!d.done;d=V.next()){var l=kU(d.value,2),n=l[0],J=l[1];R.set(n,J)}}catch(W){Q={error:W}}finally{try{d&&!d.done&&(B=V.return)&&B.call(V)}finally{if(Q)throw Q.error}}return R},F.fromObject=function(U){return F.from(Object.entries(U))},F}(),_R=function(F,U,Q){var B,R;if(Q===void 0&&(Q=[]),U.length===0||F==null)return[F,Q];try{for(var V=_(F.keys()),d=V.next();!d.done;d=V.next()){var l=d.value;if(l!==DU&&U.startsWith(l))return Q.push([F,l]),_R(F.get(l),U.slice(l.length),Q)}}catch(n){B={error:n}}finally{try{d&&!d.done&&(R=V.return)&&R.call(V)}finally{if(B)throw B.error}}return Q.push([F,U]),_R(void 0,"",Q)},Vd=function(F,U){var Q,B;if(U.length===0||F==null)return F;try{for(var R=_(F.keys()),V=R.next();!V.done;V=R.next()){var d=V.value;if(d!==DU&&U.startsWith(d))return Vd(F.get(d),U.slice(d.length))}}catch(l){Q={error:l}}finally{try{V&&!V.done&&(B=R.return)&&B.call(R)}finally{if(Q)throw Q.error}}},dd=function(F,U){var Q,B,R=U.length;U:for(var V=0;F&&V0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new Rd,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},F.prototype.discard=function(U){var Q=this,B=this._idToShortId.get(U);if(B==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(U,": it is not in the index"));this._idToShortId.delete(U),this._documentIds.delete(B),this._storedFields.delete(B),(this._fieldLength.get(B)||[]).forEach(function(R,V){Q.removeFieldLength(B,V,Q._documentCount,R)}),this._fieldLength.delete(B),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},F.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var U=this._options.autoVacuum,Q=U.minDirtFactor,B=U.minDirtCount,R=U.batchSize,V=U.batchWait;this.conditionalVacuum({batchSize:R,batchWait:V},{minDirtCount:B,minDirtFactor:Q})}},F.prototype.discardAll=function(U){var Q,B,R=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var V=_(U),d=V.next();!d.done;d=V.next()){var l=d.value;this.discard(l)}}catch(n){Q={error:n}}finally{try{d&&!d.done&&(B=V.return)&&B.call(V)}finally{if(Q)throw Q.error}}}finally{this._options.autoVacuum=R}this.maybeAutoVacuum()},F.prototype.replace=function(U){var Q=this._options,B=Q.idField,R=Q.extractField,V=R(U,B);this.discard(V),this.add(U)},F.prototype.vacuum=function(U){return U===void 0&&(U={}),this.conditionalVacuum(U)},F.prototype.conditionalVacuum=function(U,Q){var B=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&Q,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var R=B._enqueuedVacuumConditions;return B._enqueuedVacuumConditions=Ed,B.performVacuuming(U,R)}),this._enqueuedVacuum)):this.vacuumConditionsMet(Q)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(U),this._currentVacuum)},F.prototype.performVacuuming=function(U,Q){return WE(this,void 0,void 0,function(){var B,R,V,d,l,n,J,W,E,Z,e,r,c,h,N,k,t,S,a,T,C,D,p,o,s;return ZE(this,function(v){switch(v.label){case 0:if(B=this._dirtCount,!this.vacuumConditionsMet(Q))return[3,10];R=U.batchSize||Nd.batchSize,V=U.batchWait||Nd.batchWait,d=1,v.label=1;case 1:v.trys.push([1,7,8,9]),l=_(this._index),n=l.next(),v.label=2;case 2:if(n.done)return[3,6];J=kU(n.value,2),W=J[0],E=J[1];try{for(Z=(D=void 0,_(E)),e=Z.next();!e.done;e=Z.next()){r=kU(e.value,2),c=r[0],h=r[1];try{for(N=(o=void 0,_(h)),k=N.next();!k.done;k=N.next())t=kU(k.value,1),S=t[0],!this._documentIds.has(S)&&(h.size<=1?E.delete(c):h.delete(S))}catch(y){o={error:y}}finally{try{k&&!k.done&&(s=N.return)&&s.call(N)}finally{if(o)throw o.error}}}}catch(y){D={error:y}}finally{try{e&&!e.done&&(p=Z.return)&&p.call(Z)}finally{if(D)throw D.error}}return this._index.get(W).size===0&&this._index.delete(W),d%R!=0?[3,4]:[4,new Promise(function(y){return setTimeout(y,V)})];case 3:v.sent(),v.label=4;case 4:d+=1,v.label=5;case 5:return n=l.next(),[3,2];case 6:return[3,9];case 7:return a=v.sent(),T={error:a},[3,9];case 8:try{n&&!n.done&&(C=l.return)&&C.call(l)}finally{if(T)throw T.error}return[7];case 9:this._dirtCount-=B,v.label=10;case 10:return[4,null];case 11:return v.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},F.prototype.vacuumConditionsMet=function(U){if(U==null)return!0;var Q=U.minDirtCount,B=U.minDirtFactor;return Q=Q||td.minDirtCount,B=B||td.minDirtFactor,this.dirtCount>=Q&&this.dirtFactor>=B},Object.defineProperty(F.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),F.prototype.has=function(U){return this._idToShortId.has(U)},F.prototype.search=function(U,Q){var B,R;Q===void 0&&(Q={});var V=this.executeQuery(U,Q),d=[];try{for(var l=_(V),n=l.next();!n.done;n=l.next()){var J=kU(n.value,2),W=J[0],E=J[1],Z=E.score,e=E.terms,r=E.match,c=e.length,h={id:this._documentIds.get(W),score:Z*c,terms:Object.keys(r),match:r};Object.assign(h,this._storedFields.get(W)),(Q.filter==null||Q.filter(h))&&d.push(h)}}catch(N){B={error:N}}finally{try{n&&!n.done&&(R=l.return)&&R.call(l)}finally{if(B)throw B.error}}return d.sort(sJ),d},F.prototype.autoSuggest=function(U,Q){var B,R,V,d;Q===void 0&&(Q={}),Q=NU(NU({},this._options.autoSuggestOptions),Q);var l=new Map;try{for(var n=_(this.search(U,Q)),J=n.next();!J.done;J=n.next()){var W=J.value,E=W.score,Z=W.terms,e=Z.join(" "),r=l.get(e);r!=null?(r.score+=E,r.count+=1):l.set(e,{score:E,terms:Z,count:1})}}catch(a){B={error:a}}finally{try{J&&!J.done&&(R=n.return)&&R.call(n)}finally{if(B)throw B.error}}var c=[];try{for(var h=_(l),N=h.next();!N.done;N=h.next()){var k=kU(N.value,2),r=k[0],t=k[1],E=t.score,Z=t.terms,S=t.count;c.push({suggestion:r,terms:Z,score:E/S})}}catch(a){V={error:a}}finally{try{N&&!N.done&&(d=h.return)&&d.call(h)}finally{if(V)throw V.error}}return c.sort(sJ),c},Object.defineProperty(F.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),F.loadJSON=function(U,Q){if(Q==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(U),Q)},F.getDefault=function(U){if(Zd.hasOwnProperty(U))return Wd(Zd,U);throw new Error('MiniSearch: unknown option "'.concat(U,'"'))},F.loadJS=function(U,Q){var B,R,V,d,l,n,J=U.index,W=U.documentCount,E=U.nextId,Z=U.documentIds,e=U.fieldIds,r=U.fieldLength,c=U.averageFieldLength,h=U.storedFields,N=U.dirtCount,k=U.serializationVersion;if(k!==1&&k!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var t=new F(Q);t._documentCount=W,t._nextId=E,t._documentIds=AR(Z),t._idToShortId=new Map,t._fieldIds=e,t._fieldLength=AR(r),t._avgFieldLength=c,t._storedFields=AR(h),t._dirtCount=N||0,t._index=new Rd;try{for(var S=_(t._documentIds),a=S.next();!a.done;a=S.next()){var T=kU(a.value,2),C=T[0],D=T[1];t._idToShortId.set(D,C)}}catch(m){B={error:m}}finally{try{a&&!a.done&&(R=S.return)&&R.call(S)}finally{if(B)throw B.error}}try{for(var p=_(J),o=p.next();!o.done;o=p.next()){var s=kU(o.value,2),v=s[0],y=s[1],i=new Map;try{for(var w=(l=void 0,_(Object.keys(y))),g=w.next();!g.done;g=w.next()){var L=g.value,M=y[L];k===1&&(M=M.ds),i.set(parseInt(L,10),AR(M))}}catch(m){l={error:m}}finally{try{g&&!g.done&&(n=w.return)&&n.call(w)}finally{if(l)throw l.error}}t._index.set(v,i)}}catch(m){V={error:m}}finally{try{o&&!o.done&&(d=p.return)&&d.call(p)}finally{if(V)throw V.error}}return t},F.prototype.executeQuery=function(U,Q){var B=this;if(Q===void 0&&(Q={}),typeof U!="string"){var R=NU(NU(NU({},Q),U),{queries:void 0}),V=U.queries.map(function(h){return B.executeQuery(h,R)});return this.combineResults(V,U.combineWith)}var d=this._options,l=d.tokenize,n=d.processTerm,J=d.searchOptions,W=NU(NU({tokenize:l,processTerm:n},J),Q),E=W.tokenize,Z=W.processTerm,e=E(U).flatMap(function(h){return Z(h)}).filter(function(h){return!!h}),r=e.map(TE(W)),c=r.map(function(h){return B.executeQuerySpec(h,W)});return this.combineResults(c,W.combineWith)},F.prototype.executeQuerySpec=function(U,Q){var B,R,V,d,l=NU(NU({},this._options.searchOptions),Q),n=(l.fields||this._options.fields).reduce(function(L,M){var m;return NU(NU({},L),(m={},m[M]=Wd(L,M)||1,m))},l.boost||{}),J=l.boostDocument,W=l.weights,E=l.maxFuzzy,Z=l.bm25,e=NU(NU({},oJ.weights),W),r=e.fuzzy,c=e.prefix,h=this._index.get(U.term),N=this.termResults(U.term,U.term,1,h,n,J,Z),k,t;if(U.prefix&&(k=this._index.atPrefix(U.term)),U.fuzzy){var S=U.fuzzy===!0?.2:U.fuzzy,a=S<1?Math.min(E,Math.round(U.term.length*S)):S;a&&(t=this._index.fuzzyGet(U.term,a))}if(k)try{for(var T=_(k),C=T.next();!C.done;C=T.next()){var D=kU(C.value,2),p=D[0],o=D[1],s=p.length-U.term.length;if(!!s){t==null||t.delete(p);var v=c*p.length/(p.length+.3*s);this.termResults(U.term,p,v,o,n,J,Z,N)}}}catch(L){B={error:L}}finally{try{C&&!C.done&&(R=T.return)&&R.call(T)}finally{if(B)throw B.error}}if(t)try{for(var y=_(t.keys()),i=y.next();!i.done;i=y.next()){var p=i.value,w=kU(t.get(p),2),g=w[0],s=w[1];if(!!s){var v=r*p.length/(p.length+s);this.termResults(U.term,p,v,g,n,J,Z,N)}}}catch(L){V={error:L}}finally{try{i&&!i.done&&(d=y.return)&&d.call(y)}finally{if(V)throw V.error}}return N},F.prototype.combineResults=function(U,Q){if(Q===void 0&&(Q=nd),U.length===0)return new Map;var B=Q.toLowerCase();return U.reduce(eE[B])||new Map},F.prototype.toJSON=function(){var U,Q,B,R,V=[];try{for(var d=_(this._index),l=d.next();!l.done;l=d.next()){var n=kU(l.value,2),J=n[0],W=n[1],E={};try{for(var Z=(B=void 0,_(W)),e=Z.next();!e.done;e=Z.next()){var r=kU(e.value,2),c=r[0],h=r[1];E[c]=Object.fromEntries(h)}}catch(N){B={error:N}}finally{try{e&&!e.done&&(R=Z.return)&&R.call(Z)}finally{if(B)throw B.error}}V.push([J,E])}}catch(N){U={error:N}}finally{try{l&&!l.done&&(Q=d.return)&&Q.call(d)}finally{if(U)throw U.error}}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:V,serializationVersion:2}},F.prototype.termResults=function(U,Q,B,R,V,d,l,n){var J,W,E,Z,e;if(n===void 0&&(n=new Map),R==null)return n;try{for(var r=_(Object.keys(V)),c=r.next();!c.done;c=r.next()){var h=c.value,N=V[h],k=this._fieldIds[h],t=R.get(k);if(t!=null){var S=t.size,a=this._avgFieldLength[k];try{for(var T=(E=void 0,_(t.keys())),C=T.next();!C.done;C=T.next()){var D=C.value;if(!this._documentIds.has(D)){this.removeTerm(k,D,Q),S-=1;continue}var p=d?d(this._documentIds.get(D),Q):1;if(!!p){var o=t.get(D),s=this._fieldLength.get(D)[k],v=aE(o,S,this._documentCount,s,a,l),y=B*N*p*v,i=n.get(D);if(i){i.score+=y,cE(i.terms,U);var w=Wd(i.match,Q);w?w.push(h):i.match[Q]=[h]}else n.set(D,{score:y,terms:[U],match:(e={},e[Q]=[h],e)})}}}catch(g){E={error:g}}finally{try{C&&!C.done&&(Z=T.return)&&Z.call(T)}finally{if(E)throw E.error}}}}}catch(g){J={error:g}}finally{try{c&&!c.done&&(W=r.return)&&W.call(r)}finally{if(J)throw J.error}}return n},F.prototype.addTerm=function(U,Q,B){var R=this._index.fetch(B,YJ),V=R.get(U);if(V==null)V=new Map,V.set(Q,1),R.set(U,V);else{var d=V.get(Q);V.set(Q,(d||0)+1)}},F.prototype.removeTerm=function(U,Q,B){if(!this._index.has(B)){this.warnDocumentChanged(Q,U,B);return}var R=this._index.fetch(B,YJ),V=R.get(U);V==null||V.get(Q)==null?this.warnDocumentChanged(Q,U,B):V.get(Q)<=1?V.size<=1?R.delete(U):V.delete(Q):V.set(Q,V.get(Q)-1),this._index.get(B).size===0&&this._index.delete(B)},F.prototype.warnDocumentChanged=function(U,Q,B){var R,V;try{for(var d=_(Object.keys(this._fieldIds)),l=d.next();!l.done;l=d.next()){var n=l.value;if(this._fieldIds[n]===Q){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(U),' has changed before removal: term "').concat(B,'" was not present in field "').concat(n,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(J){R={error:J}}finally{try{l&&!l.done&&(V=d.return)&&V.call(d)}finally{if(R)throw R.error}}},F.prototype.addDocumentId=function(U){var Q=this._nextId;return this._idToShortId.set(U,Q),this._documentIds.set(Q,U),this._documentCount+=1,this._nextId+=1,Q},F.prototype.addFields=function(U){for(var Q=0;Q{let U=F.split(vl);return tB?U.flatMap(Q=>ol.test(Q)?tB.cut(Q):[Q]):U},UV=class{constructor(){this.indexedDocuments=new Map;this.previousResults=[];this.minisearch=new Jd(UV.options)}async loadCache(){let U=await hU.getMinisearchCache();U&&(this.minisearch=Jd.loadJS(U.data,UV.options),this.indexedDocuments=new Map(U.paths.map(Q=>[Q.path,Q.mtime])))}getDiff(U){let Q=new Map(U.map(V=>[V.path,V.mtime])),B=U.filter(V=>!this.indexedDocuments.has(V.path)||this.indexedDocuments.get(V.path)!==V.mtime),R=[...this.indexedDocuments].filter(([V,d])=>!Q.has(V)||Q.get(V)!==d).map(V=>({path:V[0],mtime:V[1]}));return{toAdd:B,toRemove:R}}async addFromPaths(U){let Q=await Promise.all(U.map(async R=>await hU.getDocument(R)));this.removeFromPaths(Q.filter(R=>this.indexedDocuments.has(R.path)).map(R=>R.path));let B=Ll(Q,500);for(let R of B){R.forEach(d=>this.indexedDocuments.set(d.path,d.mtime));let V=R.filter(d=>this.minisearch.has(d.path));this.removeFromPaths(V.map(d=>d.path)),await this.minisearch.addAllAsync(R)}}removeFromPaths(U){U.forEach(B=>this.indexedDocuments.delete(B));let Q=U.filter(B=>this.minisearch.has(B));this.minisearch.discardAll(Q)}async search(U,Q){if(U.isEmpty())return this.previousResults=[],[];let B=this.minisearch.search(U.segmentsToStr(),{prefix:n=>n.length>=Q.prefixLength,fuzzy:.2,combineWith:"AND",boost:{basename:O.weightBasename,aliases:O.weightBasename,headings1:O.weightH1,headings2:O.weightH2,headings3:O.weightH3}});if(!B.length)return this.previousResults;if(Q.singleFilePath)return B.filter(n=>n.id===Q.singleFilePath);O.hideExcluded?B=B.filter(n=>!(app.metadataCache.isUserIgnored&&app.metadataCache.isUserIgnored(n.id))):B.forEach(n=>{app.metadataCache.isUserIgnored&&app.metadataCache.isUserIgnored(n.id)&&(n.score/=10)});let R=U.segments.filter(n=>n.value.startsWith("#")).map(n=>n.value);for(let n of R)for(let J of B)(J.tags??[]).includes(n)&&(J.score*=100);B=B.slice(0,50);let V=await Promise.all(B.map(async n=>await hU.getDocument(n.id))),d=U.getExactTerms();d.length&&(B=B.filter(n=>{let J=V.find(Z=>Z.path===n.id),W=J?.path.toLowerCase()??"",E=d0(J?.content??"").toLowerCase();return d.every(Z=>E.includes(Z)||W.includes(Z))}));let l=U.exclusions;return l.length&&(B=B.filter(n=>{let J=d0(V.find(W=>W.path===n.id)?.content??"").toLowerCase();return l.every(W=>!J.includes(W.value))})),B=B.filter((n,J,W)=>W.findIndex(E=>E.id===n.id)===J),this.previousResults=B,B}getMatches(U,Q,B){let R=null,V=[],d=0;for(;(R=Q.exec(U))!==null&&!(++d>=100);){let n=R[0];n&&V.push({match:n,offset:R.index})}let l=U.toLowerCase().indexOf(B.segmentsToStr());return l>-1&&V.unshift({offset:l,match:B.segmentsToStr()}),V}async getSuggestions(U,Q){let B;O.simpleSearch?B=await this.search(U,{prefixLength:1,singleFilePath:Q?.singleFilePath}):B=await this.search(U,{prefixLength:3,singleFilePath:Q?.singleFilePath});let R=U.segments.filter(l=>l.value.startsWith("#")).map(l=>l.value),V=await Promise.all(B.map(async l=>await hU.getDocument(l.id)));return B.map(l=>{let n=V.find(Z=>Z.path===l.id);n||(console.warn(`Omnisearch - Note "${l.id}" not in the live cache`),n={content:"",basename:l.id,path:l.id}),U.segments.forEach(Z=>{Z.value=Z.value.replace(/^#/,"")});let J=[...Object.keys(l.match),...U.segments.filter(Z=>Z.exact).map(Z=>Z.value),...R].filter(Z=>Z.length>1),W=this.getMatches(n.content,yF(J),U);return z({score:l.score,foundWords:J,matches:W},n)})}async writeToCache(){$R.Platform.isIosApp||await hU.writeMinisearchCache(this.minisearch,this.indexedDocuments)}},Sd=UV;Sd.options={tokenize:CE,processTerm:U=>(O.ignoreDiacritics?$F(U):U).toLowerCase(),idField:"path",fields:["basename","aliases","content","headings1","headings2","headings3"],storeFields:["tags"],logger(U,Q,B){B==="version_conflict"&&new $R.Notice("Omnisearch - Your index cache may be incorrect or corrupted. If this message keeps appearing, go to Settings to clear the cache.",5e3)}};var cU=new Sd;var ed=new Set;function yJ(F){ed.add(F)}async function vJ(){let F=[...ed].map(U=>U.path);F.length&&(cU.removeFromPaths(F),cU.addFromPaths(F),ed.clear())}function GJ(F,U,Q){let B=F.slice();return B[27]=U[Q],B[29]=Q,B}function DE(F){let U,Q,B;return{c(){U=j("button"),U.textContent="Create note"},m(R,V){UU(R,U,V),Q||(B=xU(U,"click",F[6]),Q=!0)},p:tU,d(R){R&&A(U),Q=!1,B()}}}function pE(F){let U,Q=O.showCreateButton&&DE(F);return{c(){Q&&Q.c(),U=LQ()},m(B,R){Q&&Q.m(B,R),UU(B,U,R)},p(B,R){O.showCreateButton&&Q.p(B,R)},d(B){Q&&Q.d(B),B&&A(U)}}}function bJ(F){let U,Q,B;return{c(){U=j("div"),Q=PU("\u23F3 Work in progress: "),B=PU(F[3]),UF(U,"text-align","center"),UF(U,"color","var(--text-accent)"),UF(U,"margin-top","10px")},m(R,V){UU(R,U,V),H(U,Q),H(U,B)},p(R,V){V&8&&jQ(B,R[3])},d(R){R&&A(U)}}}function XJ(F){let U,Q;function B(...R){return F[11](F[29],...R)}return U=new hJ({props:{selected:F[29]===F[0],note:F[27]}}),U.$on("mousemove",B),U.$on("click",F[5]),{c(){OU(U.$$.fragment)},m(R,V){YU(U,R,V),Q=!0},p(R,V){F=R;let d={};V&1&&(d.selected=F[29]===F[0]),V&4&&(d.note=F[27]),U.$set(d)},i(R){Q||(BU(U.$$.fragment,R),Q=!0)},o(R){RU(U.$$.fragment,R),Q=!1},d(R){pU(U,R)}}}function mE(F){let U;return{c(){U=PU("Searching...")},m(Q,B){UU(Q,U,B)},d(Q){Q&&A(U)}}}function ME(F){let U;return{c(){U=PU("We found 0 result for your search here.")},m(Q,B){UU(Q,U,B)},d(Q){Q&&A(U)}}}function oE(F){let U,Q,B,R=F[2],V=[];for(let W=0;WRU(V[W],1,1,()=>{V[W]=null});function l(W,E){if(!W[2].length&&W[1]&&!W[4])return ME;if(W[4])return mE}let n=l(F,-1),J=n&&n(F);return{c(){for(let W=0;W\u2191\u2193to navigate',n=FU(),J=j("div"),J.innerHTML=`alt \u2191\u2193 to cycle history`,W=FU(),E=j("div"),E.innerHTML='\u21B5to open',Z=FU(),e=j("div"),e.innerHTML=`\u21B9 to switch to In-File Search`,r=FU(),c=j("br"),h=FU(),N=j("div"),k=j("span"),k.textContent=`${ul()} \u21B5`,t=FU(),S=j("span"),S.textContent="to open in a new pane",a=FU(),T=j("div"),T.innerHTML=`shift \u21B5 to create`,C=FU(),D=j("div"),D.innerHTML=`ctrl shift \u21B5 to create in a new pane`,p=FU(),o=j("br"),s=FU(),v=j("div"),v.innerHTML=`alt \u21B5 to insert a link`,y=FU(),i=j("div"),i.innerHTML=`ctrl+h to toggle excerpts`,w=FU(),g=j("div"),g.innerHTML='escto close',P(l,"class","prompt-instruction"),P(J,"class","prompt-instruction"),P(E,"class","prompt-instruction"),P(e,"class","prompt-instruction"),P(k,"class","prompt-instruction-command"),P(N,"class","prompt-instruction"),P(T,"class","prompt-instruction"),P(D,"class","prompt-instruction"),P(v,"class","prompt-instruction"),P(i,"class","prompt-instruction"),P(g,"class","prompt-instruction"),P(d,"class","prompt-instructions")},m(m,Y){YU(U,m,Y),UU(m,Q,Y),M&&M.m(m,Y),UU(m,B,Y),YU(R,m,Y),UU(m,V,Y),UU(m,d,Y),H(d,l),H(d,n),H(d,J),H(d,W),H(d,E),H(d,Z),H(d,e),H(d,r),H(d,c),H(d,h),H(d,N),H(N,k),H(N,t),H(N,S),H(d,a),H(d,T),H(d,C),H(d,D),H(d,p),H(d,o),H(d,s),H(d,v),H(d,y),H(d,i),H(d,w),H(d,g),L=!0},p(m,[Y]){let I={};Y&2&&(I.initialValue=m[1]),Y&1073741824&&(I.$$scope={dirty:Y,ctx:m}),U.$set(I),m[3]?M?M.p(m,Y):(M=bJ(m),M.c(),M.m(B.parentNode,B)):M&&(M.d(1),M=null);let X={};Y&1073741847&&(X.$$scope={dirty:Y,ctx:m}),R.$set(X)},i(m){L||(BU(U.$$.fragment,m),BU(R.$$.fragment,m),L=!0)},o(m){RU(U.$$.fragment,m),RU(R.$$.fragment,m),L=!1},d(m){pU(U,m),m&&A(Q),M&&M.d(m),m&&A(B),pU(R,m),m&&A(V),m&&A(d)}}}function sE(F,U,Q){let B,R;xB(F,sF,i=>Q(9,R=i));let{modal:V}=U,{previousQuery:d}=U,l=0,n=0,J,W=[],E,Z="",e=!0;KQ(async()=>{$.enable("vault"),$.on("vault","enter",k),$.on("vault","create-note",C),$.on("vault","open-in-new-pane",t),$.on("vault","insert-link",D),$.on("vault","tab",p),$.on("vault","arrow-up",()=>o(-1)),$.on("vault","arrow-down",()=>o(1)),$.on("vault","prev-search-history",r),$.on("vault","next-search-history",c),await vJ(),O.showPreviousQueryResults&&Q(7,d=(await hU.getSearchHistory())[0])}),gQ(()=>{$.disable("vault")});async function r(){let i=(await hU.getSearchHistory()).filter(w=>w);++n>=i.length&&(n=0),Q(7,d=i[n])}async function c(){let i=(await hU.getSearchHistory()).filter(w=>w);--n<0&&(n=i.length?i.length-1:0),Q(7,d=i[n])}async function h(){E=new JQ(J),Q(2,W=(await cU.getSuggestions(E)).sort((i,w)=>w.score-i.score)),Q(0,l=0),await s()}function N(i){!B||(i?.ctrlKey?t():k(),V.close())}function k(){!B||(a(B),V.close())}function t(){!B||(a(B,!0),V.close())}function S(){J&&hU.addToSearchHistory(J)}function a(i,w=!1){S(),PR(i,w)}async function T(i){await C()}async function C(i){if(J){try{await ZJ(J,i?.newLeaf)}catch(w){new zF.Notice(w.message);return}V.close()}}function D(){if(!B)return;let i=app.vault.getMarkdownFiles().find(m=>m.path===B.path),w=app.workspace.getActiveFile(),g=app.workspace.getActiveViewOfType(zF.MarkdownView);if(!g?.editor){new zF.Notice("Omnisearch - Error - No active editor",3e3);return}let L;i&&w?L=app.fileManager.generateMarkdownLink(i,w.path):L=`[[${B.basename}.${xl(B.path)}]]`;let M=g.editor.getCursor();g.editor.replaceRange(L,M,M),M.ch+=L.length,g.editor.setCursor(M),V.close()}function p(){if(!(B&&(TB(B?.path)||!B?.matches.length)))if(S(),V.close(),B){let i=app.vault.getAbstractFileByPath(B.path);i&&i instanceof zF.TFile&&new zQ(app,i,J).open()}else{let i=app.workspace.getActiveViewOfType(zF.MarkdownView);i&&new zQ(app,i.file,J).open()}}function o(i){Q(0,l=hR(l+i,W.length)),s()}async function s(){await lF(),B&&document.querySelector(`[data-result-id="${B.path}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}let v=i=>Q(1,J=i.detail),y=(i,w)=>Q(0,l=i);return F.$$set=i=>{"modal"in i&&Q(8,V=i.modal),"previousQuery"in i&&Q(7,d=i.previousQuery)},F.$$.update=()=>{if(F.$$.dirty&130){U:Q(1,J=J??d)}if(F.$$.dirty&2){U:J?(Q(2,W=[]),Q(4,e=!0),h().then(()=>{Q(4,e=!1)})):(Q(4,e=!1),Q(2,W=[]))}if(F.$$.dirty&5){U:B=W[l]}if(F.$$.dirty&512){U:switch(R){case KU.LoadingCache:Q(3,Z="Loading cache...");break;case KU.ReadingFiles:Q(3,Z="Reading files...");break;case KU.IndexingFiles:Q(3,Z="Indexing files...");break;case KU.WritingCache:h(),Q(3,Z="Updating cache...");break;default:h(),Q(3,Z="");break}}},[l,J,W,Z,e,N,T,d,V,R,v,y]}var OJ=class extends CU{constructor(U){super();mU(this,U,sE,iE,rU,{modal:8,previousQuery:7})}},HJ=OJ;var xJ=XU(require("obsidian"));function YE(F){let U,Q=F[2].replace(F[3],YF)+"";return{c(){U=j("div"),P(U,"class","omnisearch-result__body")},m(B,R){UU(B,U,R),U.innerHTML=Q},p(B,R){R&12&&Q!==(Q=B[2].replace(B[3],YF)+"")&&(U.innerHTML=Q)},d(B){B&&A(U)}}}function yE(F){let U,Q;return U=new qR({props:{id:F[0].toString(),selected:F[1],$$slots:{default:[YE]},$$scope:{ctx:F}}}),U.$on("mousemove",F[6]),U.$on("click",F[7]),{c(){OU(U.$$.fragment)},m(B,R){YU(U,B,R),Q=!0},p(B,[R]){let V={};R&1&&(V.id=B[0].toString()),R&2&&(V.selected=B[1]),R&268&&(V.$$scope={dirty:R,ctx:B}),U.$set(V)},i(B){Q||(BU(U.$$.fragment,B),Q=!0)},o(B){RU(U.$$.fragment,B),Q=!1},d(B){pU(U,B)}}}function vE(F,U,Q){let B,R,{offset:V}=U,{note:d}=U,{index:l=0}=U,{selected:n=!1}=U;function J(E){FF.call(this,F,E)}function W(E){FF.call(this,F,E)}return F.$$set=E=>{"offset"in E&&Q(4,V=E.offset),"note"in E&&Q(5,d=E.note),"index"in E&&Q(0,l=E.index),"selected"in E&&Q(1,n=E.selected)},F.$$.update=()=>{if(F.$$.dirty&32){U:Q(3,B=yF(d.foundWords))}if(F.$$.dirty&48){U:Q(2,R=cR(d?.content??"",V))}},[l,n,R,B,V,d,J,W]}var zJ=class extends CU{constructor(U){super();mU(this,U,vE,yE,rU,{offset:4,note:5,index:0,selected:1})}},uJ=zJ;function wJ(F,U,Q){let B=F.slice();return B[16]=U[Q],B[18]=Q,B}function GE(F){let U;return{c(){U=j("div"),U.textContent="We found 0 result for your search here.",UF(U,"text-align","center")},m(Q,B){UU(Q,U,B)},p:tU,i:tU,o:tU,d(Q){Q&&A(U)}}}function bE(F){let U,Q,B=F[4],R=[];for(let d=0;dRU(R[d],1,1,()=>{R[d]=null});return{c(){for(let d=0;d{d[W]=null}),jF(),Q=d[U],Q?Q.p(n,J):(Q=d[U]=V[U](n),Q.c()),BU(Q,1),Q.m(B.parentNode,B))},i(n){R||(BU(Q),R=!0)},o(n){RU(Q),R=!1},d(n){d[U].d(n),n&&A(B)}}}function OE(F){let U;return{c(){U=j("span"),U.textContent="to close"},m(Q,B){UU(Q,U,B)},d(Q){Q&&A(U)}}}function HE(F){let U;return{c(){U=j("span"),U.textContent="to go back to Vault Search"},m(Q,B){UU(Q,U,B)},d(Q){Q&&A(U)}}}function zE(F){let U,Q,B,R,V,d,l,n,J,W,E,Z,e,r,c;U=new KR({props:{placeholder:"Omnisearch - File",initialValue:F[1]}}),U.$on("input",F[10]),B=new gR({props:{$$slots:{default:[XE]},$$scope:{ctx:F}}});function h(t,S){return t[0]?HE:OE}let N=h(F,-1),k=N(F);return{c(){OU(U.$$.fragment),Q=FU(),OU(B.$$.fragment),R=FU(),V=j("div"),d=j("div"),d.innerHTML='\u2191\u2193to navigate',l=FU(),n=j("div"),n.innerHTML='\u21B5to open',J=FU(),W=j("div"),W.innerHTML=`\u21B9 to switch to Vault Search`,E=FU(),Z=j("div"),e=j("span"),e.textContent="esc",r=FU(),k.c(),P(d,"class","prompt-instruction"),P(n,"class","prompt-instruction"),P(W,"class","prompt-instruction"),P(e,"class","prompt-instruction-command"),P(Z,"class","prompt-instruction"),P(V,"class","prompt-instructions")},m(t,S){YU(U,t,S),UU(t,Q,S),YU(B,t,S),UU(t,R,S),UU(t,V,S),H(V,d),H(V,l),H(V,n),H(V,J),H(V,W),H(V,E),H(V,Z),H(Z,e),H(Z,r),k.m(Z,null),c=!0},p(t,[S]){let a={};S&2&&(a.initialValue=t[1]),U.$set(a);let T={};S&524344&&(T.$$scope={dirty:S,ctx:t}),B.$set(T),N!==(N=h(t,S))&&(k.d(1),k=N(t),k&&(k.c(),k.m(Z,null)))},i(t){c||(BU(U.$$.fragment,t),BU(B.$$.fragment,t),c=!0)},o(t){RU(U.$$.fragment,t),RU(B.$$.fragment,t),c=!1},d(t){pU(U,t),t&&A(Q),pU(B,t),t&&A(R),t&&A(V),k.d()}}}function uE(F,U,Q){let B=F.find(R=>R.offset>U);return B?F.filter(R=>R.offset>U&&R.offset<=B.offset+Q):[]}function xE(F,U,Q){let{modal:B}=U,{parent:R=null}=U,{singleFilePath:V=""}=U,{previousQuery:d}=U,l,n=[],J=0,W,E;KQ(()=>{$.enable("infile"),$.on("infile","enter",c),$.on("infile","arrow-up",()=>e(-1)),$.on("infile","arrow-down",()=>e(1)),$.on("infile","tab",h)}),gQ(()=>{$.disable("infile")});function Z(t){let S=[],a=-1,T=0;for(;;){let C=uE(t,a,SB);if(!C.length||(a=C.last().offset,S.push(C),++T>100))break}return S}function e(t){Q(5,J=hR(J+t,n.length)),r()}async function r(){await lF(),document.querySelector(`[data-result-id="${J}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}async function c(t){if(W){B.close(),R&&R.close(),await PR(W,t?.ctrlKey);let S=app.workspace.getActiveViewOfType(xJ.MarkdownView);if(!S)return;let a=n[J]??0,T=S.editor.offsetToPos(a);T.ch=0,S.editor.setCursor(T),S.editor.scrollIntoView({from:{line:T.line-10,ch:0},to:{line:T.line+10,ch:0}})}}function h(){new WQ(app,d).open(),B.close()}let N=t=>Q(2,l=t.detail),k=(t,S)=>Q(5,J=t);return F.$$set=t=>{"modal"in t&&Q(7,B=t.modal),"parent"in t&&Q(0,R=t.parent),"singleFilePath"in t&&Q(8,V=t.singleFilePath),"previousQuery"in t&&Q(1,d=t.previousQuery)},F.$$.update=()=>{if(F.$$.dirty&2){U:Q(2,l=d??"")}if(F.$$.dirty&772){U:(async()=>{l&&(Q(9,E=new JQ(l)),Q(3,W=(await cU.getSuggestions(E,{singleFilePath:V}))[0]??null)),Q(5,J=0),await r()})()}if(F.$$.dirty&8){U:if(W){let t=Z(W.matches);Q(4,n=t.map(S=>Math.round((S.first().offset+S.last().offset)/2)))}}},[R,d,l,W,n,J,c,B,V,E,N,k]}var jJ=class extends CU{constructor(U){super();mU(this,U,xE,zE,rU,{modal:7,parent:0,singleFilePath:8,previousQuery:1})}},IJ=jJ;var kd=class extends fJ.Modal{constructor(U){super(U);this.modalEl.replaceChildren(),this.modalEl.addClass("omnisearch-modal","prompt"),this.modalEl.removeClass("modal"),this.modalEl.tabIndex=-1,this.scope.register([],"ArrowDown",Q=>{Q.preventDefault(),$.emit("arrow-down")}),this.scope.register([],"ArrowUp",Q=>{Q.preventDefault(),$.emit("arrow-up")});for(let Q of[{k:"J",dir:"down"},{k:"K",dir:"up"}])for(let B of["Ctrl","Mod"])this.scope.register([B],Q.k,R=>{this.app.vault.getConfig("vimMode")&&$.emit("arrow-"+Q.dir)});for(let Q of[{k:"N",dir:"down"},{k:"P",dir:"up"}])for(let B of["Ctrl","Mod"])this.scope.register([B],Q.k,R=>{this.app.vault.getConfig("vimMode")&&$.emit("arrow-"+Q.dir)});this.scope.register(["Mod"],"Enter",Q=>{Q.preventDefault(),$.emit("open-in-new-pane")}),this.scope.register(["Alt"],"Enter",Q=>{Q.preventDefault(),$.emit("insert-link")}),this.scope.register(["Shift"],"Enter",Q=>{Q.preventDefault(),$.emit("create-note")}),this.scope.register(["Ctrl","Shift"],"Enter",Q=>{Q.preventDefault(),$.emit("create-note",{newLeaf:!0})}),this.scope.register([],"Enter",Q=>{yl()||(Q.preventDefault(),$.emit("enter"))}),this.scope.register([],"Tab",Q=>{Q.preventDefault(),$.emit("tab")}),this.scope.register(["Alt"],"ArrowDown",Q=>{Q.preventDefault(),$.emit("next-search-history")}),this.scope.register(["Alt"],"ArrowUp",Q=>{Q.preventDefault(),$.emit("prev-search-history")}),this.scope.register(["Ctrl"],"H",Q=>{$.emit(aR.ToggleExcerpts)})}},WQ=class extends kd{constructor(U,Q){super(U);let B=new HJ({target:this.modalEl,props:{modal:this,previousQuery:Q}});this.onClose=()=>{B.$destroy()}}},zQ=class extends kd{constructor(U,Q,B="",R){super(U);let V=new IJ({target:this.modalEl,props:{modal:this,singleFilePath:Q.path,parent:R,previousQuery:B}});R&&R.containerEl.toggleVisibility(!1),this.onClose=()=>{R&&R.containerEl.toggleVisibility(!0),V.$destroy()}}};function wE(F){return F.map(U=>{let{score:Q,path:B,basename:R,foundWords:V,matches:d}=U;return{score:Q,path:B,basename:R,foundWords:V,matches:d.map(l=>({match:l.match,offset:l.offset}))}})}async function LE(F){let U=new JQ(F),Q=await cU.getSuggestions(U);return wE(Q)}var ad={search:LE};var Td=class extends uF.Plugin{async onload(){await ml(this),await IE(),await mQ.clearOldDatabases(),KE(this),O.ribbonIcon&&this.addRibbonButton(),this.addSettingTab(new B0(this)),$.disable("vault"),$.disable("infile"),$.on("global",aR.ToggleExcerpts,()=>{AF.set(!O.showExcerpt)}),this.addCommand({id:"show-modal",name:"Vault search",callback:()=>{new WQ(app).open()}}),this.addCommand({id:"show-modal-infile",name:"In-file search",editorCallback:(U,Q)=>{new zQ(app,Q.file).open()}}),app.workspace.onLayoutReady(async()=>{this.registerEvent(this.app.vault.on("create",async U=>{kB(U.path)&&(await hU.addToLiveCache(U.path),cU.addFromPaths([U.path]))})),this.registerEvent(this.app.vault.on("delete",U=>{hU.removeFromLiveCache(U.path),cU.removeFromPaths([U.path])})),this.registerEvent(this.app.vault.on("modify",async U=>{kB(U.path)&&(await hU.addToLiveCache(U.path),yJ(U))})),this.registerEvent(this.app.vault.on("rename",async(U,Q)=>{kB(U.path)&&(hU.removeFromLiveCache(Q),hU.addToLiveCache(U.path),cU.removeFromPaths([Q]),await cU.addFromPaths([U.path]))})),await jE()}),fE(this)}async onunload(){delete globalThis.omnisearch,await fU.clearCache()}addRibbonButton(){this.ribbonButton=this.addRibbonIcon("search","Omnisearch",U=>{new WQ(app).open()})}removeRibbonButton(){this.ribbonButton&&this.ribbonButton.parentNode?.removeChild(this.ribbonButton)}};async function jE(){console.time("Omnisearch - Indexing total time"),sF.set(KU.ReadingFiles);let F=app.vault.getFiles().filter(Q=>kB(Q.path));console.log(`Omnisearch - ${F.length} files total`),uF.Platform.isIosApp||(console.time("Omnisearch - Loading index from cache"),sF.set(KU.LoadingCache),await cU.loadCache(),console.timeEnd("Omnisearch - Loading index from cache"));let U=cU.getDiff(F.map(Q=>({path:Q.path,mtime:Q.stat.mtime})));U.toAdd.length&&console.log("Omnisearch - Total number of files to add/update: "+U.toAdd.length),U.toRemove.length&&console.log("Omnisearch - Total number of files to remove: "+U.toRemove.length),U.toAdd.length>=500&&new uF.Notice(`Omnisearch - ${U.toAdd.length} files need to be indexed. Obsidian may experience stutters and freezes during the process`,1e4),sF.set(KU.IndexingFiles),cU.removeFromPaths(U.toRemove.map(Q=>Q.path)),await cU.addFromPaths(U.toAdd.map(Q=>Q.path)),(U.toRemove.length||U.toAdd.length)&&(sF.set(KU.WritingCache),await cU.writeToCache()),console.timeEnd("Omnisearch - Indexing total time"),U.toAdd.length>=500&&new uF.Notice("Omnisearch - Your files have been indexed."),sF.set(KU.Done)}async function IE(){let F=[`${app.vault.configDir}/plugins/omnisearch/searchIndex.json`,`${app.vault.configDir}/plugins/omnisearch/notesCache.json`,`${app.vault.configDir}/plugins/omnisearch/notesCache.data`,`${app.vault.configDir}/plugins/omnisearch/searchIndex.data`,`${app.vault.configDir}/plugins/omnisearch/historyCache.json`,`${app.vault.configDir}/plugins/omnisearch/pdfCache.data`];for(let U of F)if(await app.vault.adapter.exists(U))try{await app.vault.adapter.remove(U)}catch{}}function fE(F){let U="1.8.0-beta.3";if(O.welcomeMessage!==U){let Q=new DocumentFragment;Q.createSpan({},B=>{B.innerHTML=`Omnisearch has been updated You can now enable "Images Indexing" to use Optical Character Recognition on your scanned documents \u{1F50E}\u{1F5BC}`}),new uF.Notice(Q,3e4)}O.welcomeMessage=U,F.saveData(O)}function KE(F){F.registerObsidianProtocolHandler("omnisearch",U=>{new WQ(app,U.query).open()}),globalThis.omnisearch=ad,app.plugins.plugins.omnisearch.api=ad}