/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var Gf=Object.create;var Zr=Object.defineProperty,Qf=Object.defineProperties,qf=Object.getOwnPropertyDescriptor,Yf=Object.getOwnPropertyDescriptors,Jf=Object.getOwnPropertyNames,Hs=Object.getOwnPropertySymbols,Xf=Object.getPrototypeOf,$s=Object.prototype.hasOwnProperty,Zf=Object.prototype.propertyIsEnumerable;var Ws=(t,e,r)=>e in t?Zr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pe=(t,e)=>{for(var r in e||(e={}))$s.call(e,r)&&Ws(t,r,e[r]);if(Hs)for(var r of Hs(e))Zf.call(e,r)&&Ws(t,r,e[r]);return t},Me=(t,e)=>Qf(t,Yf(e)),Us=t=>Zr(t,"__esModule",{value:!0});var Mn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ed=(t,e)=>{Us(t);for(var r in e)Zr(t,r,{get:e[r],enumerable:!0})},td=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Jf(e))!$s.call(t,n)&&n!=="default"&&Zr(t,n,{get:()=>e[n],enumerable:!(r=qf(e,n))||r.enumerable});return t},je=t=>td(Us(Zr(t!=null?Gf(Xf(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ol=Mn((Fn,ds)=>{(function(t,e){if(typeof Fn=="object"&&typeof ds=="object")ds.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var r=e();for(var n in r)(typeof Fn=="object"?Fn:t)[n]=r[n]}})(typeof self!="undefined"?self:Fn,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(n,i,o){r.o(n,i)||Object.defineProperty(n,i,{enumerable:!0,get:o})},r.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,i){if(1&i&&(n=r(n)),8&i||4&i&&typeof n=="object"&&n&&n.__esModule)return n;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&i&&typeof n!="string")for(var s in n)r.d(o,s,function(a){return n[a]}.bind(null,s));return o},r.n=function(n){var i=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(i,"a",i),i},r.o=function(n,i){return Object.prototype.hasOwnProperty.call(n,i)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e),r.d(e,"md5",function(){return x});var n="0123456789abcdef".split(""),i=function(v){for(var d="",b=0;b<4;b++)d+=n[v>>8*b+4&15]+n[v>>8*b&15];return d},o=function(v){for(var d=v.length,b=0;b>>32-A,F)}(d=function(j,A,F,E){return A=s(s(A,j),s(F,E))}(v,d,m,y),g,b)},u=function(v,d,b,m,g,y,_,j){return a(b&m|~b&g,d,b,y,_,j,v)},l=function(v,d,b,m,g,y,_,j){return a(b&g|m&~g,d,b,y,_,j,v)},f=function(v,d,b,m,g,y,_,j){return a(b^m^g,d,b,y,_,j,v)},p=function(v,d,b,m,g,y,_,j){return a(m^(b|~g),d,b,y,_,j,v)},c=function(v,d,b){b===void 0&&(b=s);var m=v[0],g=v[1],y=v[2],_=v[3],j=u.bind(null,b);m=j(m,g,y,_,d[0],7,-680876936),_=j(_,m,g,y,d[1],12,-389564586),y=j(y,_,m,g,d[2],17,606105819),g=j(g,y,_,m,d[3],22,-1044525330),m=j(m,g,y,_,d[4],7,-176418897),_=j(_,m,g,y,d[5],12,1200080426),y=j(y,_,m,g,d[6],17,-1473231341),g=j(g,y,_,m,d[7],22,-45705983),m=j(m,g,y,_,d[8],7,1770035416),_=j(_,m,g,y,d[9],12,-1958414417),y=j(y,_,m,g,d[10],17,-42063),g=j(g,y,_,m,d[11],22,-1990404162),m=j(m,g,y,_,d[12],7,1804603682),_=j(_,m,g,y,d[13],12,-40341101),y=j(y,_,m,g,d[14],17,-1502002290),g=j(g,y,_,m,d[15],22,1236535329);var A=l.bind(null,b);m=A(m,g,y,_,d[1],5,-165796510),_=A(_,m,g,y,d[6],9,-1069501632),y=A(y,_,m,g,d[11],14,643717713),g=A(g,y,_,m,d[0],20,-373897302),m=A(m,g,y,_,d[5],5,-701558691),_=A(_,m,g,y,d[10],9,38016083),y=A(y,_,m,g,d[15],14,-660478335),g=A(g,y,_,m,d[4],20,-405537848),m=A(m,g,y,_,d[9],5,568446438),_=A(_,m,g,y,d[14],9,-1019803690),y=A(y,_,m,g,d[3],14,-187363961),g=A(g,y,_,m,d[8],20,1163531501),m=A(m,g,y,_,d[13],5,-1444681467),_=A(_,m,g,y,d[2],9,-51403784),y=A(y,_,m,g,d[7],14,1735328473),g=A(g,y,_,m,d[12],20,-1926607734);var F=f.bind(null,b);m=F(m,g,y,_,d[5],4,-378558),_=F(_,m,g,y,d[8],11,-2022574463),y=F(y,_,m,g,d[11],16,1839030562),g=F(g,y,_,m,d[14],23,-35309556),m=F(m,g,y,_,d[1],4,-1530992060),_=F(_,m,g,y,d[4],11,1272893353),y=F(y,_,m,g,d[7],16,-155497632),g=F(g,y,_,m,d[10],23,-1094730640),m=F(m,g,y,_,d[13],4,681279174),_=F(_,m,g,y,d[0],11,-358537222),y=F(y,_,m,g,d[3],16,-722521979),g=F(g,y,_,m,d[6],23,76029189),m=F(m,g,y,_,d[9],4,-640364487),_=F(_,m,g,y,d[12],11,-421815835),y=F(y,_,m,g,d[15],16,530742520),g=F(g,y,_,m,d[2],23,-995338651);var E=p.bind(null,b);m=E(m,g,y,_,d[0],6,-198630844),_=E(_,m,g,y,d[7],10,1126891415),y=E(y,_,m,g,d[14],15,-1416354905),g=E(g,y,_,m,d[5],21,-57434055),m=E(m,g,y,_,d[12],6,1700485571),_=E(_,m,g,y,d[3],10,-1894986606),y=E(y,_,m,g,d[10],15,-1051523),g=E(g,y,_,m,d[1],21,-2054922799),m=E(m,g,y,_,d[8],6,1873313359),_=E(_,m,g,y,d[15],10,-30611744),y=E(y,_,m,g,d[6],15,-1560198380),g=E(g,y,_,m,d[13],21,1309151649),m=E(m,g,y,_,d[4],6,-145523070),_=E(_,m,g,y,d[11],10,-1120210379),y=E(y,_,m,g,d[2],15,718787259),g=E(g,y,_,m,d[9],21,-343485551),v[0]=b(m,v[0]),v[1]=b(g,v[1]),v[2]=b(y,v[2]),v[3]=b(_,v[3])},h=function(v){for(var d=[],b=0;b<64;b+=4)d[b>>2]=v.charCodeAt(b)+(v.charCodeAt(b+1)<<8)+(v.charCodeAt(b+2)<<16)+(v.charCodeAt(b+3)<<24);return d},w=function(v,d){var b,m=v.length,g=[1732584193,-271733879,-1732584194,271733878];for(b=64;b<=m;b+=64)c(g,h(v.substring(b-64,b)),d);var y=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],_=(v=v.substring(b-64)).length;for(b=0;b<_;b++)y[b>>2]|=v.charCodeAt(b)<<(b%4<<3);if(y[b>>2]|=128<<(b%4<<3),b>55)for(c(g,y,d),b=16;b--;)y[b]=0;return y[14]=8*m,c(g,y,d),g};function x(v){var d;return o(w("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(d=function(b,m){var g=(65535&b)+(65535&m);return(b>>16)+(m>>16)+(g>>16)<<16|65535&g}),o(w(v,d))}}])})});var df=Mn(Yi=>{Yi.parse=function(t,e){if(e?e.offsets=typeof e.offsets=="undefined"?!0:e.offsets:e={offsets:!0},t||(t=""),t.indexOf(":")===-1&&!e.tokenize)return t;if(!e.keywords&&!e.ranges&&!e.tokenize)return t;var r={text:[]};e.offsets&&(r.offsets=[]);for(var n={},i=[],o=/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|(-?"(?:[^"\\]|\\.)*")|(-?'(?:[^'\\]|\\.)*')|\S+|\S+:\S+/g,s;(s=o.exec(t))!==null;){var c=s[0],a=c.indexOf(":");if(a!==-1){var u=c.split(":"),l=c.slice(0,a),f=c.slice(a+1);f=f.replace(/^\"|\"$|^\'|\'$/g,""),f=(f+"").replace(/\\(.?)/g,function(_,j){switch(j){case"\\":return"\\";case"0":return"\0";case"":return"";default:return j}}),i.push({keyword:l,value:f,offsetStart:s.index,offsetEnd:s.index+c.length})}else{var p=!1;c[0]==="-"&&(p=!0,c=c.slice(1)),c=c.replace(/^\"|\"$|^\'|\'$/g,""),c=(c+"").replace(/\\(.?)/g,function(_,j){switch(j){case"\\":return"\\";case"0":return"\0";case"":return"";default:return j}}),p?n.text?(n.text instanceof Array||(n.text=[n.text]),n.text.push(c)):n.text=c:i.push({text:c,offsetStart:s.index,offsetEnd:s.index+c.length})}}i.reverse();for(var c;c=i.pop();)if(c.text)r.text.push(c.text),e.offsets&&r.offsets.push(c);else{var l=c.keyword;e.keywords=e.keywords||[];var h=!1,w=!1;if(!/^-/.test(l))h=e.keywords.indexOf(l)!==-1;else if(l[0]==="-"){var x=l.slice(1);h=e.keywords.indexOf(x)!==-1,h&&(l=x,w=!0)}e.ranges=e.ranges||[];var v=e.ranges.indexOf(l)!==-1;if(h){e.offsets&&r.offsets.push({keyword:l,value:c.value,offsetStart:w?c.offsetStart+1:c.offsetStart,offsetEnd:c.offsetEnd});var d=c.value;if(d.length){var b=d.split(",");w?n[l]?n[l]instanceof Array?b.length>1?n[l]=n[l].concat(b):n[l].push(d):(n[l]=[n[l]],n[l].push(d)):b.length>1?n[l]=b:e.alwaysArray?n[l]=[d]:n[l]=d:r[l]?r[l]instanceof Array?b.length>1?r[l]=r[l].concat(b):r[l].push(d):(r[l]=[r[l]],r[l].push(d)):b.length>1?r[l]=b:e.alwaysArray?r[l]=[d]:r[l]=d}}else if(v){e.offsets&&r.offsets.push(c);var d=c.value,m=d.split("-");r[l]={},m.length===2?(r[l].from=m[0],r[l].to=m[1]):!m.length%2||(r[l].from=d)}else{var g=c.keyword+":"+c.value;r.text.push(g),e.offsets&&r.offsets.push({text:g,offsetStart:c.offsetStart,offsetEnd:c.offsetEnd})}}return r.text.length?e.tokenize||(r.text=r.text.join(" ").trim()):delete r.text,r.exclude=n,r};Yi.stringify=function(t,e,r){if(e||(e={offsets:!0}),!t)return"";if(typeof t=="string")return t;if(Array.isArray(t))return t.join(" ");if(!Object.keys(t).length)return"";if(Object.keys(t).length===3&&!!t.text&&!!t.offsets&&!!t.exclude&&typeof t.text=="string")return t.text;r||(r="");var n=function(a){return a.indexOf(" ")>-1?JSON.stringify(a):a},i=function(a){return r+a},o=[];if(t.text){var s=[];typeof t.text=="string"?s.push(t.text):s.push.apply(s,t.text),s.length>0&&o.push(s.map(n).map(i).join(" "))}return e.keywords&&e.keywords.forEach(function(a){if(!!t[a]){var u=[];typeof t[a]=="string"?u.push(t[a]):u.push.apply(u,t[a]),u.length>0&&o.push(i(a+":"+u.map(n).join(",")))}}),e.ranges&&e.ranges.forEach(function(a){if(!!t[a]){var u=t[a].from,l=t[a].to;l&&(u=u+"-"+l),u&&o.push(i(a+":"+u))}}),t.exclude&&Object.keys(t.exclude).length>0&&o.push(Yi.stringify(t.exclude,e,"-")),o.join(" ")}});var hf=Mn((HE,pf)=>{pf.exports=df()});var Ef=Mn(to=>{function Bs(t){return Bs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Bs(t)}(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof to!="undefined")e(to);else{var r={exports:{}};e(r.exports),t.CancelablePromise=r.exports}})(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:to,function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CancelablePromise=void 0,t.cancelable=L,t.default=void 0,t.isCancelablePromise=k;function e(C,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function");C.prototype=Object.create(S&&S.prototype,{constructor:{value:C,writable:!0,configurable:!0}}),Object.defineProperty(C,"prototype",{writable:!1}),S&&r(C,S)}function r(C,S){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(N,X){return N.__proto__=X,N},r(C,S)}function n(C){var S=s();return function(){var N=a(C),X;if(S){var P=a(this).constructor;X=Reflect.construct(N,arguments,P)}else X=N.apply(this,arguments);return i(this,X)}}function i(C,S){if(S&&(Bs(S)==="object"||typeof S=="function"))return S;if(S!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return o(C)}function o(C){if(C===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C}function s(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function a(C){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(I){return I.__proto__||Object.getPrototypeOf(I)},a(C)}function u(C,S){var I=typeof Symbol!="undefined"&&C[Symbol.iterator]||C["@@iterator"];if(!I){if(Array.isArray(C)||(I=l(C))||S&&C&&typeof C.length=="number"){I&&(C=I);var N=0,X=function(){};return{s:X,n:function(){return N>=C.length?{done:!0}:{done:!1,value:C[N++]}},e:function(me){throw me},f:X}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var P=!0,re=!1,Ke;return{s:function(){I=I.call(C)},n:function(){var me=I.next();return P=me.done,me},e:function(me){re=!0,Ke=me},f:function(){try{!P&&I.return!=null&&I.return()}finally{if(re)throw Ke}}}}function l(C,S){if(!!C){if(typeof C=="string")return f(C,S);var I=Object.prototype.toString.call(C).slice(8,-1);if(I==="Object"&&C.constructor&&(I=C.constructor.name),I==="Map"||I==="Set")return Array.from(C);if(I==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(I))return f(C,S)}}function f(C,S){(S==null||S>C.length)&&(S=C.length);for(var I=0,N=new Array(S);Izs});var fr=je(require("obsidian"));var ro=je(require("obsidian"));function he(){}function rd(t,e){for(let r in e)t[r]=e[r];return t}function oo(t){return t()}function Gs(){return Object.create(null)}function Xe(t){t.forEach(oo)}function dr(t){return typeof t=="function"}function Ae(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}var Rn;function so(t,e){return Rn||(Rn=document.createElement("a")),Rn.href=e,t===Rn.href}function Qs(t){return Object.keys(t).length===0}function qs(t,...e){if(t==null)return he;let r=t.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Ln(t,e,r){t.$$.on_destroy.push(qs(e,r))}function pr(t,e,r,n){if(t){let i=Ys(t,e,r,n);return t[0](i)}}function Ys(t,e,r,n){return t[1]&&n?rd(r.ctx.slice(),t[1](n(e))):r.ctx}function hr(t,e,r,n){if(t[2]&&n){let i=t[2](n(r));if(e.dirty===void 0)return i;if(typeof i=="object"){let o=[],s=Math.max(e.dirty.length,i.length);for(let a=0;a32){let e=[],r=t.ctx.length/32;for(let n=0;nt.removeEventListener(e,r,n)}function B(t,e,r){r==null?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}function od(t){return Array.from(t.childNodes)}function Ze(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function ao(t,e){t.value=e??""}function Ge(t,e,r,n){r===null?t.style.removeProperty(e):t.style.setProperty(e,r,n?"important":"")}function lo(t,e,r){t.classList[r?"add":"remove"](e)}function sd(t,e,{bubbles:r=!1,cancelable:n=!1}={}){let i=document.createEvent("CustomEvent");return i.initCustomEvent(t,r,n,e),i}var en;function tn(t){en=t}function uo(){if(!en)throw new Error("Function called outside component initialization");return en}function rn(t){uo().$$.on_mount.push(t)}function nn(t){uo().$$.on_destroy.push(t)}function co(){let t=uo();return(e,r,{cancelable:n=!1}={})=>{let i=t.$$.callbacks[e];if(i){let o=sd(e,r,{cancelable:n});return i.slice().forEach(s=>{s.call(t,o)}),!o.defaultPrevented}return!0}}function Qe(t,e){let r=t.$$.callbacks[e.type];r&&r.slice().forEach(n=>n.call(this,e))}var on=[];var lt=[],Nn=[],Zs=[],ea=Promise.resolve(),fo=!1;function ta(){fo||(fo=!0,ea.then(ra))}function jt(){return ta(),ea}function po(t){Nn.push(t)}var ho=new Set,Kn=0;function ra(){let t=en;do{for(;Kn{zn.delete(t),n&&(r&&t.d(1),n())}),t.o(e)}else n&&n()}var Lb=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;function $e(t){t&&t.c()}function Re(t,e,r,n){let{fragment:i,after_update:o}=t.$$;i&&i.m(e,r),n||po(()=>{let s=t.$$.on_mount.map(oo).filter(dr);t.$$.on_destroy?t.$$.on_destroy.push(...s):Xe(s),t.$$.on_mount=[]}),o.forEach(po)}function Ie(t,e){let r=t.$$;r.fragment!==null&&(Xe(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function ld(t,e){t.$$.dirty[0]===-1&&(on.push(t),ta(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{let w=h.length?h[0]:c;return l.ctx&&i(l.ctx[p],l.ctx[p]=w)&&(!l.skip_bound&&l.bound[p]&&l.bound[p](w),f&&ld(t,p)),c}):[],l.update(),f=!0,Xe(l.before_update),l.fragment=n?n(l.ctx):!1,e.target){if(e.hydrate){nd();let p=od(e.target);l.fragment&&l.fragment.l(p),p.forEach(H)}else l.fragment&&l.fragment.c();e.intro&&ee(t.$$.fragment),Re(t,e.target,e.anchor,e.customElement),id(),ra()}tn(u)}var ud;typeof HTMLElement=="function"&&(ud=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(oo).filter(dr);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,r){this[t]=r}disconnectedCallback(){Xe(this.$$.on_disconnect)}$destroy(){Ie(this,1),this.$destroy=he}$on(t,e){if(!dr(e))return he;let r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(e),()=>{let n=r.indexOf(e);n!==-1&&r.splice(n,1)}}$set(t){this.$$set&&!Qs(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var Te=class{$destroy(){Ie(this,1),this.$destroy=he}$on(e,r){if(!dr(r))return he;let n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(r),()=>{let i=n.indexOf(r);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Qs(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var $t=je(require("obsidian"));var vl=je(require("obsidian"));var mo=class{constructor(){this.handlers=new Map;this.disabled=[]}on(e,r,n){if(e.includes("@")||r.includes("@"))throw new Error("Invalid context/event name - Cannot contain @");this.handlers.set(`${e}@${r}`,n)}off(e,r){if(r)this.handlers.delete(`${e}@${r}`);else for(let[n]of this.handlers.entries())n.startsWith(`${e}@`)&&this.handlers.delete(n)}disable(e){this.enable(e),this.disabled.push(e)}enable(e){this.disabled=this.disabled.filter(r=>r!==e)}emit(e,...r){let n=[...this.handlers.entries()].filter(([i,o])=>!this.disabled.includes(i.split("@")[0]));for(let[i,o]of n)i.endsWith(`@${e}`)&&o(...r)}};var _r=[];function Vn(t,e=he){let r,n=new Set;function i(a){if(Ae(t,a)&&(t=a,r)){let u=!_r.length;for(let l of n)l[1](),_r.push(l,t);if(u){for(let l=0;l<_r.length;l+=2)_r[l][0](_r[l+1]);_r.length=0}}}function o(a){i(a(t))}function s(a,u=he){let l=[a,u];return n.add(l),n.size===1&&(r=e(i)||he),a(t),()=>{n.delete(l),n.size===0&&(r(),r=null)}}return{set:i,update:o,subscribe:s}}var G=je(require("obsidian"));var se=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,ge=Object.keys,ke=Array.isArray;typeof Promise!="undefined"&&!se.Promise&&(se.Promise=Promise);function Le(t,e){return typeof e!="object"||ge(e).forEach(function(r){t[r]=e[r]}),t}var sn=Object.getPrototypeOf,cd={}.hasOwnProperty;function qe(t,e){return cd.call(t,e)}function vr(t,e){typeof e=="function"&&(e=e(sn(t))),(typeof Reflect=="undefined"?ge:Reflect.ownKeys)(e).forEach(r=>{ut(t,r,e[r])})}var na=Object.defineProperty;function ut(t,e,r,n){na(t,e,Le(r&&qe(r,"get")&&typeof r.get=="function"?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function br(t){return{from:function(e){return t.prototype=Object.create(e.prototype),ut(t.prototype,"constructor",t),{extend:vr.bind(null,t.prototype)}}}}var fd=Object.getOwnPropertyDescriptor;function go(t,e){let r=fd(t,e),n;return r||(n=sn(t))&&go(n,e)}var dd=[].slice;function Hn(t,e,r){return dd.call(t,e,r)}function ia(t,e){return e(t)}function an(t){if(!t)throw new Error("Assertion Failed")}function oa(t){se.setImmediate?setImmediate(t):setTimeout(t,0)}function sa(t,e){return t.reduce((r,n,i)=>{var o=e(n,i);return o&&(r[o[0]]=o[1]),r},{})}function pd(t,e,r){try{t.apply(null,r)}catch(n){e&&e(n)}}function ct(t,e){if(qe(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var r=[],n=0,i=e.length;n["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>se[t]),gd=ua.map(t=>se[t]);sa(ua,t=>[t,!0]);var At=null;function ln(t){At=typeof WeakMap!="undefined"&&new WeakMap;let e=yo(t);return At=null,e}function yo(t){if(!t||typeof t!="object")return t;let e=At&&At.get(t);if(e)return e;if(ke(t)){e=[],At&&At.set(t,e);for(var r=0,n=t.length;r=0)e=t;else{let o=sn(t);e=o===Object.prototype?{}:Object.create(o),At&&At.set(t,e);for(var i in t)qe(t,i)&&(e[i]=yo(t[i]))}return e}var{toString:yd}={};function _o(t){return yd.call(t).slice(8,-1)}var vo=typeof Symbol!="undefined"?Symbol.iterator:"@@iterator",_d=typeof vo=="symbol"?function(t){var e;return t!=null&&(e=t[vo])&&e.apply(t)}:function(){return null},xr={};function ft(t){var e,r,n,i;if(arguments.length===1){if(ke(t))return t.slice();if(this===xr&&typeof t=="string")return[t];if(i=_d(t)){for(r=[];n=i.next(),!n.done;)r.push(n.value);return r}if(t==null)return[t];if(e=t.length,typeof e=="number"){for(r=new Array(e);e--;)r[e]=t[e];return r}return[t]}for(e=arguments.length,r=new Array(e);e--;)r[e]=arguments[e];return r}var bo=typeof Symbol!="undefined"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1,rt=typeof location!="undefined"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ca(t,e){rt=t,fa=e}var fa=()=>!0,vd=!new Error("").stack;function Qt(){if(vd)try{throw Qt.arguments,new Error}catch(t){return t}return new Error}function xo(t,e){var r=t.stack;return r?(e=e||0,r.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` `).length),r.split(` `).slice(e).filter(fa).map(n=>` `+n).join("")):""}var bd=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],da=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],wo=bd.concat(da),xd={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 wr(t,e){this._e=Qt(),this.name=t,this.message=e}br(wr).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+xo(this._e,2))}},toString:function(){return this.name+": "+this.message}});function pa(t,e){return t+". Errors: "+Object.keys(e).map(r=>e[r].toString()).filter((r,n,i)=>i.indexOf(r)===n).join(` `)}function $n(t,e,r,n){this._e=Qt(),this.failures=e,this.failedKeys=n,this.successCount=r,this.message=pa(t,e)}br($n).from(wr);function un(t,e){this._e=Qt(),this.name="BulkError",this.failures=Object.keys(e).map(r=>e[r]),this.failuresByPos=e,this.message=pa(t,e)}br(un).from(wr);var jo=wo.reduce((t,e)=>(t[e]=e+"Error",t),{}),wd=wr,V=wo.reduce((t,e)=>{var r=e+"Error";function n(i,o){this._e=Qt(),this.name=r,i?typeof i=="string"?(this.message=`${i}${o?` `+o:""}`,this.inner=o||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=xd[e]||r,this.inner=null)}return br(n).from(wd),t[e]=n,t},{});V.Syntax=SyntaxError;V.Type=TypeError;V.Range=RangeError;var ha=da.reduce((t,e)=>(t[e+"Error"]=V[e],t),{});function jd(t,e){if(!t||t instanceof wr||t instanceof TypeError||t instanceof SyntaxError||!t.name||!ha[t.name])return t;var r=new ha[t.name](e||t.message,t);return"stack"in t&&ut(r,"stack",{get:function(){return this.inner.stack}}),r}var Wn=wo.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=V[e]),t),{});Wn.ModifyError=$n;Wn.DexieError=wr;Wn.BulkError=un;function ie(){}function cn(t){return t}function Ad(t,e){return t==null||t===cn?e:function(r){return e(t(r))}}function qt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Cd(t,e){return t===ie?e:function(){var r=t.apply(this,arguments);r!==void 0&&(arguments[0]=r);var n=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?qt(n,this.onsuccess):n),i&&(this.onerror=this.onerror?qt(i,this.onerror):i),o!==void 0?o:r}}function Sd(t,e){return t===ie?e:function(){t.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?qt(r,this.onsuccess):r),n&&(this.onerror=this.onerror?qt(n,this.onerror):n)}}function Fd(t,e){return t===ie?e:function(r){var n=t.apply(this,arguments);Le(r,n);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?qt(i,this.onsuccess):i),o&&(this.onerror=this.onerror?qt(o,this.onerror):o),n===void 0?s===void 0?void 0:s:Le(n,s)}}function Ed(t,e){return t===ie?e:function(){return e.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function Ao(t,e){return t===ie?e:function(){var r=t.apply(this,arguments);if(r&&typeof r.then=="function"){for(var n=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return r.then(function(){return e.apply(n,o)})}return e.apply(this,arguments)}}var fn={},Td=100,Dd=20,ma=100,[Co,Un,So]=typeof Promise=="undefined"?[]:(()=>{let t=Promise.resolve();if(typeof crypto=="undefined"||!crypto.subtle)return[t,sn(t),t];let e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,sn(e),t]})(),ga=Un&&Un.then,Gn=Co&&Co.constructor,Fo=!!So,Eo=!1,Id=So?()=>{So.then(Jn)}:se.setImmediate?setImmediate.bind(null,Jn):se.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{Jn(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Jn,0)},dn=function(t,e){pn.push([t,e]),Qn&&(Id(),Qn=!1)},To=!0,Qn=!0,Yt=[],qn=[],Do=null,Io=cn,jr={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Sa,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{Sa(t[0],t[1])}catch{}})}},K=jr,pn=[],Jt=0,Yn=[];function R(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ie,this._lib=!1;var e=this._PSD=K;if(rt&&(this._stackHolder=Qt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==fn)throw new TypeError("Not a function");this._state=arguments[1],this._value=arguments[2],this._state===!1&&ko(this,this._value);return}this._state=null,this._value=null,++e.ref,_a(this,t)}var Oo={get:function(){var t=K,e=ei;function r(n,i){var o=!t.global&&(t!==K||e!==ei);let s=o&&!dt();var a=new R((u,l)=>{Po(this,new ya(ri(n,t,o,s),ri(i,t,o,s),u,l,t))});return rt&&xa(a,this),a}return r.prototype=fn,r},set:function(t){ut(this,"then",t&&t.prototype===fn?Oo:{get:function(){return t},set:Oo.set})}};vr(R.prototype,{then:Oo,_then:function(t,e){Po(this,new ya(null,null,t,e,K))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],r=arguments[1];return typeof e=="function"?this.then(null,n=>n instanceof e?r(n):Xn(n)):this.then(null,n=>n&&n.name===e?r(n):Xn(n))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Xn(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Eo=!0;var t=ba(this,[],Dd),e=t.join(` From previous: `);return this._state!==null&&(this._stack=e),e}finally{Eo=!1}}},timeout:function(t,e){return t<1/0?new R((r,n)=>{var i=setTimeout(()=>n(new V.Timeout(e)),t);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}});typeof Symbol!="undefined"&&Symbol.toStringTag&&ut(R.prototype,Symbol.toStringTag,"Dexie.Promise");jr.env=wa();function ya(t,e,r,n,i){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=r,this.reject=n,this.psd=i}vr(R,{all:function(){var t=ft.apply(null,arguments).map(ti);return new R(function(e,r){t.length===0&&e([]);var n=t.length;t.forEach((i,o)=>R.resolve(i).then(s=>{t[o]=s,--n||e(t)},r))})},resolve:t=>{if(t instanceof R)return t;if(t&&typeof t.then=="function")return new R((r,n)=>{t.then(r,n)});var e=new R(fn,!0,t);return xa(e,Do),e},reject:Xn,race:function(){var t=ft.apply(null,arguments).map(ti);return new R((e,r)=>{t.map(n=>R.resolve(n).then(e,r))})},PSD:{get:()=>K,set:t=>K=t},totalEchoes:{get:()=>ei},newPSD:Ct,usePSD:Cr,scheduler:{get:()=>dn,set:t=>{dn=t}},rejectionMapper:{get:()=>Io,set:t=>{Io=t}},follow:(t,e)=>new R((r,n)=>Ct((i,o)=>{var s=K;s.unhandleds=[],s.onunhandled=o,s.finalize=qt(function(){kd(()=>{this.unhandleds.length===0?i():o(this.unhandleds[0])})},s.finalize),t()},e,r,n))});Gn&&(Gn.allSettled&&ut(R,"allSettled",function(){let t=ft.apply(null,arguments).map(ti);return new R(e=>{t.length===0&&e([]);let r=t.length,n=new Array(r);t.forEach((i,o)=>R.resolve(i).then(s=>n[o]={status:"fulfilled",value:s},s=>n[o]={status:"rejected",reason:s}).then(()=>--r||e(n)))})}),Gn.any&&typeof AggregateError!="undefined"&&ut(R,"any",function(){let t=ft.apply(null,arguments).map(ti);return new R((e,r)=>{t.length===0&&r(new AggregateError([]));let n=t.length,i=new Array(n);t.forEach((o,s)=>R.resolve(o).then(a=>e(a),a=>{i[s]=a,--n||r(new AggregateError(i))}))})}));function _a(t,e){try{e(r=>{if(t._state===null){if(r===t)throw new TypeError("A promise cannot be resolved with itself.");var n=t._lib&&hn();r&&typeof r.then=="function"?_a(t,(i,o)=>{r instanceof R?r._then(i,o):r.then(i,o)}):(t._state=!0,t._value=r,va(t)),n&&mn()}},ko.bind(null,t))}catch(r){ko(t,r)}}function ko(t,e){if(qn.push(e),t._state===null){var r=t._lib&&hn();e=Io(e),t._state=!1,t._value=e,rt&&e!==null&&typeof e=="object"&&!e._promise&&pd(()=>{var n=go(e,"stack");e._promise=t,ut(e,"stack",{get:()=>Eo?n&&(n.get?n.get.apply(e):n.value):t.stack})}),Pd(t),va(t),r&&mn()}}function va(t){var e=t._listeners;t._listeners=[];for(var r=0,n=e.length;r{--Jt==0&&Mo()},[]))}function Po(t,e){if(t._state===null){t._listeners.push(e);return}var r=t._state?e.onFulfilled:e.onRejected;if(r===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++Jt,dn(Od,[r,t,e])}function Od(t,e,r){try{Do=e;var n,i=e._value;e._state?n=t(i):(qn.length&&(qn=[]),n=t(i),qn.indexOf(i)===-1&&Md(e)),r.resolve(n)}catch(o){r.reject(o)}finally{Do=null,--Jt==0&&Mo(),--r.psd.ref||r.psd.finalize()}}function ba(t,e,r){if(e.length===r)return e;var n="";if(t._state===!1){var i=t._value,o,s;i!=null?(o=i.name||"Error",s=i.message||i,n=xo(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+n)}return rt&&(n=xo(t._stackHolder,2),n&&e.indexOf(n)===-1&&e.push(n),t._prev&&ba(t._prev,e,r)),e}function xa(t,e){var r=e?e._numPrev+1:0;r0;)for(t=pn,pn=[],r=t.length,e=0;e0);To=!0,Qn=!0}function Mo(){var t=Yt;Yt=[],t.forEach(n=>{n._PSD.onunhandled.call(null,n._value,n)});for(var e=Yn.slice(0),r=e.length;r;)e[--r]()}function kd(t){function e(){t(),Yn.splice(Yn.indexOf(e),1)}Yn.push(e),++Jt,dn(()=>{--Jt==0&&Mo()},[])}function Pd(t){Yt.some(e=>e._value===t._value)||Yt.push(t)}function Md(t){for(var e=Yt.length;e;)if(Yt[--e]._value===t._value){Yt.splice(e,1);return}}function Xn(t){return new R(fn,!1,t)}function le(t,e){var r=K;return function(){var n=hn(),i=K;try{return St(r,!0),t.apply(this,arguments)}catch(o){e&&e(o)}finally{St(i,!1),n&&mn()}}}var Pe={awaits:0,echoes:0,id:0},Rd=0,Zn=[],Ro=0,ei=0,Ld=0;function Ct(t,e,r,n){var i=K,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++Ld;var s=jr.env;o.env=Fo?{Promise:R,PromiseProp:{value:R,configurable:!0,writable:!0},all:R.all,race:R.race,allSettled:R.allSettled,any:R.any,resolve:R.resolve,reject:R.reject,nthen:Aa(s.nthen,o),gthen:Aa(s.gthen,o)}:{},e&&Le(o,e),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=Cr(o,t,r,n);return o.ref===0&&o.finalize(),a}function Ar(){return Pe.id||(Pe.id=++Rd),++Pe.awaits,Pe.echoes+=ma,Pe.id}function dt(){return Pe.awaits?(--Pe.awaits==0&&(Pe.id=0),Pe.echoes=Pe.awaits*ma,!0):!1}(""+ga).indexOf("[native code]")===-1&&(Ar=dt=ie);function ti(t){return Pe.echoes&&t&&t.constructor===Gn?(Ar(),t.then(e=>(dt(),e),e=>(dt(),be(e)))):t}function Bd(t){++ei,(!Pe.echoes||--Pe.echoes==0)&&(Pe.echoes=Pe.id=0),Zn.push(K),St(t,!0)}function Nd(){var t=Zn[Zn.length-1];Zn.pop(),St(t,!1)}function St(t,e){var r=K;if((e?Pe.echoes&&(!Ro++||t!==K):Ro&&(!--Ro||t!==K))&&ja(e?Bd.bind(null,t):Nd),t!==K&&(K=t,r===jr&&(jr.env=wa()),Fo)){var n=jr.env.Promise,i=t.env;Un.then=i.nthen,n.prototype.then=i.gthen,(r.global||t.global)&&(Object.defineProperty(se,"Promise",i.PromiseProp),n.all=i.all,n.race=i.race,n.resolve=i.resolve,n.reject=i.reject,i.allSettled&&(n.allSettled=i.allSettled),i.any&&(n.any=i.any))}}function wa(){var t=se.Promise;return Fo?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(se,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:Un.then,gthen:t.prototype.then}:{}}function Cr(t,e,r,n,i){var o=K;try{return St(t,!0),e(r,n,i)}finally{St(o,!1)}}function ja(t){ga.call(Co,t)}function ri(t,e,r,n){return typeof t!="function"?t:function(){var i=K;r&&Ar(),St(e,!0);try{return t.apply(this,arguments)}finally{St(i,!1),n&&ja(dt)}}}function Aa(t,e){return function(r,n){return t.call(this,ri(r,e),ri(n,e))}}var Ca="unhandledrejection";function Sa(t,e){var r;try{r=e.onuncatched(t)}catch{}if(r!==!1)try{var n,i={promise:e,reason:t};if(se.document&&document.createEvent?(n=document.createEvent("Event"),n.initEvent(Ca,!0,!0),Le(n,i)):se.CustomEvent&&(n=new CustomEvent(Ca,{detail:i}),Le(n,i)),n&&se.dispatchEvent&&(dispatchEvent(n),!se.PromiseRejectionEvent&&se.onunhandledrejection))try{se.onunhandledrejection(n)}catch{}rt&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var be=R.reject;function Lo(t,e,r,n){if(!t.idbdb||!t._state.openComplete&&!K.letThrough&&!t._vip){if(t._state.openComplete)return be(new V.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return be(new V.DatabaseClosed);t.open().catch(ie)}return t._state.dbReadyPromise.then(()=>Lo(t,e,r,n))}else{var i=t._createTransaction(e,r,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===jo.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Lo(t,e,r,n))):be(o)}return i._promise(e,(o,s)=>Ct(()=>(K.trans=i,n(o,s,i)))).then(o=>i._completion.then(()=>o))}}var Fa="3.2.2",Xt=String.fromCharCode(65535),Bo=-1/0,pt="Invalid key provided. Keys must be of type string, number, Date or Array.",Ea="String expected.",gn=[],ni=typeof navigator!="undefined"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Kd=ni,zd=ni,Ta=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),ii="__dbnames",No="readonly",Ko="readwrite";function Zt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}var Da={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function oi(t){return typeof t=="string"&&!/\./.test(t)?e=>(e[t]===void 0&&t in e&&(e=ln(e),delete e[t]),e):e=>e}var Ia=class{_trans(e,r,n){let i=this._tx||K.trans,o=this.name;function s(u,l,f){if(!f.schema[o])throw new V.NotFound("Table "+o+" not part of transaction");return r(f.idbtrans,f)}let a=hn();try{return i&&i.db===this.db?i===K.trans?i._promise(e,s,n):Ct(()=>i._promise(e,s,n),{trans:i,transless:K.transless||K}):Lo(this.db,e,[this.name],s)}finally{a&&mn()}}get(e,r){return e&&e.constructor===Object?this.where(e).first(r):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(i=>this.hook.reading.fire(i))).then(r)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(ke(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let r=ge(e);if(r.length===1)return this.where(r[0]).equals(e[r[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(l=>l.compound&&r.every(f=>l.keyPath.indexOf(f)>=0)&&l.keyPath.every(f=>r.indexOf(f)>=0))[0];if(n&&this.db._maxKey!==Xt)return this.where(n.name).equals(n.keyPath.map(l=>e[l]));!n&&rt&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${r.join("+")}]`);let{idxByName:i}=this.schema,o=this.db._deps.indexedDB;function s(l,f){try{return o.cmp(l,f)===0}catch{return!1}}let[a,u]=r.reduce(([l,f],p)=>{let c=i[p],h=e[p];return[l||c,l||!c?Zt(f,c&&c.multi?w=>{let x=ct(w,p);return ke(x)&&x.some(v=>s(h,v))}:w=>s(h,ct(w,p))):f]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(u):n?this.filter(u):this.where(r).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,ke(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let r=n=>{if(!n)return n;let i=Object.create(e.prototype);for(var o in n)if(qe(n,o))try{i[o]=n[o]}catch{}return i};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=r,this.hook("reading",r),e}defineClass(){function e(r){Le(this,r)}return this.mapToClass(e)}add(e,r){let{auto:n,keyPath:i}=this.schema.primKey,o=e;return i&&n&&(o=oi(i)(e)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"add",keys:r!=null?[r]:null,values:[o]})).then(s=>s.numFailures?R.reject(s.failures[0]):s.lastResult).then(s=>{if(i)try{et(e,i,s)}catch{}return s})}update(e,r){if(typeof e=="object"&&!ke(e)){let n=ct(e,this.schema.primKey.keyPath);if(n===void 0)return be(new V.InvalidArgument("Given object does not contain its primary key"));try{typeof r!="function"?ge(r).forEach(i=>{et(e,i,r[i])}):r(e,{value:e,primKey:n})}catch{}return this.where(":id").equals(n).modify(r)}else return this.where(":id").equals(e).modify(r)}put(e,r){let{auto:n,keyPath:i}=this.schema.primKey,o=e;return i&&n&&(o=oi(i)(e)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"put",values:[o],keys:r!=null?[r]:null})).then(s=>s.numFailures?R.reject(s.failures[0]):s.lastResult).then(s=>{if(i)try{et(e,i,s)}catch{}return s})}delete(e){return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:[e]})).then(r=>r.numFailures?R.reject(r.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Da})).then(e=>e.numFailures?R.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",r=>this.core.getMany({keys:e,trans:r}).then(n=>n.map(i=>this.hook.reading.fire(i))))}bulkAdd(e,r,n){let i=Array.isArray(r)?r:void 0;n=n||(i?void 0:r);let o=n?n.allKeys:void 0;return this._trans("readwrite",s=>{let{auto:a,keyPath:u}=this.schema.primKey;if(u&&i)throw new V.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new V.InvalidArgument("Arguments objects and keys must have the same length");let l=e.length,f=u&&a?e.map(oi(u)):e;return this.core.mutate({trans:s,type:"add",keys:i,values:f,wantResults:o}).then(({numFailures:p,results:c,lastResult:h,failures:w})=>{let x=o?c:h;if(p===0)return x;throw new un(`${this.name}.bulkAdd(): ${p} of ${l} operations failed`,w)})})}bulkPut(e,r,n){let i=Array.isArray(r)?r:void 0;n=n||(i?void 0:r);let o=n?n.allKeys:void 0;return this._trans("readwrite",s=>{let{auto:a,keyPath:u}=this.schema.primKey;if(u&&i)throw new V.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new V.InvalidArgument("Arguments objects and keys must have the same length");let l=e.length,f=u&&a?e.map(oi(u)):e;return this.core.mutate({trans:s,type:"put",keys:i,values:f,wantResults:o}).then(({numFailures:p,results:c,lastResult:h,failures:w})=>{let x=o?c:h;if(p===0)return x;throw new un(`${this.name}.bulkPut(): ${p} of ${l} operations failed`,w)})})}bulkDelete(e){let r=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:n,lastResult:i,failures:o})=>{if(n===0)return i;throw new un(`${this.name}.bulkDelete(): ${n} of ${r} operations failed`,o)})}};function yn(t){var e={},r=function(a,u){if(u){for(var l=arguments.length,f=new Array(l-1);--l;)f[l-1]=arguments[l];return e[a].subscribe.apply(null,f),t}else if(typeof a=="string")return e[a]};r.addEventType=o;for(var n=1,i=arguments.length;nZt(n(),e()):e,t.justLimit=r&&!n}function Hd(t,e){t.isMatch=Zt(t.isMatch,e)}function si(t,e){if(t.isPrimKey)return e.primaryKey;let r=e.getIndexByKeyPath(t.index);if(!r)throw new V.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return r}function Oa(t,e,r){let n=si(t,e.schema);return e.openCursor({trans:r,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:n,range:t.range}})}function ai(t,e,r,n){let i=t.replayFilter?Zt(t.filter,t.replayFilter()):t.filter;if(t.or){let o={},s=(a,u,l)=>{if(!i||i(u,l,c=>u.stop(c),c=>u.fail(c))){var f=u.primaryKey,p=""+f;p==="[object ArrayBuffer]"&&(p=""+new Uint8Array(f)),qe(o,p)||(o[p]=!0,e(a,u,l))}};return Promise.all([t.or._iterate(s,r),ka(Oa(t,n,r),t.algorithm,s,!t.keysOnly&&t.valueMapper)])}else return ka(Oa(t,n,r),Zt(t.algorithm,i),e,!t.keysOnly&&t.valueMapper)}function ka(t,e,r,n){var i=n?(s,a,u)=>r(n(s),a,u):r,o=le(i);return t.then(s=>{if(s)return s.start(()=>{var a=()=>s.continue();(!e||e(s,u=>a=u,u=>{s.stop(u),a=ie},u=>{s.fail(u),a=ie}))&&o(s.value,s,u=>a=u),a()})})}function Be(t,e){try{let r=Pa(t),n=Pa(e);if(r!==n)return r==="Array"?1:n==="Array"?-1:r==="binary"?1:n==="binary"?-1:r==="string"?1:n==="string"?-1:r==="Date"?1:n!=="Date"?NaN:-1;switch(r){case"number":case"Date":case"string":return t>e?1:tai(r,e,n,r.table.core))}count(e){return this._read(r=>{let n=this._ctx,i=n.table.core;if(Sr(n,!0))return i.count({trans:r,query:{index:si(n,i.schema),range:n.range}}).then(s=>Math.min(s,n.limit));var o=0;return ai(n,()=>(++o,!1),r,i).then(()=>o)}).then(e)}sortBy(e,r){let n=e.split(".").reverse(),i=n[0],o=n.length-1;function s(l,f){return f?s(l[n[f]],f-1):l[i]}var a=this._ctx.dir==="next"?1:-1;function u(l,f){var p=s(l,o),c=s(f,o);return pc?a:0}return this.toArray(function(l){return l.sort(u)}).then(r)}toArray(e){return this._read(r=>{var n=this._ctx;if(n.dir==="next"&&Sr(n,!0)&&n.limit>0){let{valueMapper:i}=n,o=si(n,n.table.core.schema);return n.table.core.query({trans:r,limit:n.limit,values:!0,query:{index:o,range:n.range}}).then(({result:s})=>i?s.map(i):s)}else{let i=[];return ai(n,o=>i.push(o),r,n.table.core).then(()=>i)}},e)}offset(e){var r=this._ctx;return e<=0?this:(r.offset+=e,Sr(r)?Vo(r,()=>{var n=e;return(i,o)=>n===0?!0:n===1?(--n,!1):(o(()=>{i.advance(n),n=0}),!1)}):Vo(r,()=>{var n=e;return()=>--n<0}),this)}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Vo(this._ctx,()=>{var r=e;return function(n,i,o){return--r<=0&&i(o),r>=0}},!0),this}until(e,r){return zo(this._ctx,function(n,i,o){return e(n.value)?(i(o),r):!0}),this}first(e){return this.limit(1).toArray(function(r){return r[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){return zo(this._ctx,function(r){return e(r.value)}),Hd(this._ctx,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,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(e){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,i){e(i.key,i)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,i){e(i.primaryKey,i)})}keys(e){var r=this._ctx;r.keysOnly=!r.isMatch;var n=[];return this.each(function(i,o){n.push(o.key)}).then(function(){return n}).then(e)}primaryKeys(e){var r=this._ctx;if(r.dir==="next"&&Sr(r,!0)&&r.limit>0)return this._read(i=>{var o=si(r,r.table.core.schema);return r.table.core.query({trans:i,values:!1,limit:r.limit,query:{index:o,range:r.range}})}).then(({result:i})=>i).then(e);r.keysOnly=!r.isMatch;var n=[];return this.each(function(i,o){n.push(o.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(r){return r[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,r=e.index&&e.table.schema.idxByName[e.index];if(!r||!r.multi)return this;var n={};return zo(this._ctx,function(i){var o=i.primaryKey.toString(),s=qe(n,o);return n[o]=!0,!s}),this}modify(e){var r=this._ctx;return this._write(n=>{var i;if(typeof e=="function")i=e;else{var o=ge(e),s=o.length;i=function(x){for(var v=!1,d=0;d{let{failures:d,numFailures:b}=v;c+=x-b;for(let m of ge(d))p.push(d[m])};return this.clone().primaryKeys().then(x=>{let v=d=>{let b=Math.min(f,x.length-d);return a.getMany({trans:n,keys:x.slice(d,d+b),cache:"immutable"}).then(m=>{let g=[],y=[],_=u?[]:null,j=[];for(let F=0;F0&&a.mutate({trans:n,type:"add",values:g}).then(F=>{for(let E in F.failures)j.splice(parseInt(E),1);w(g.length,F)})).then(()=>(y.length>0||A&&typeof e=="object")&&a.mutate({trans:n,type:"put",keys:_,values:y,criteria:A,changeSpec:typeof e!="function"&&e}).then(F=>w(y.length,F))).then(()=>(j.length>0||A&&e===Ho)&&a.mutate({trans:n,type:"delete",keys:j,criteria:A}).then(F=>w(j.length,F))).then(()=>x.length>d+b&&v(d+f))})};return v(0).then(()=>{if(p.length>0)throw new $n("Error modifying one or more objects",p,c,h);return x.length})})})}delete(){var e=this._ctx,r=e.range;return Sr(e)&&(e.isPrimKey&&!zd||r.type===3)?this._write(n=>{let{primaryKey:i}=e.table.core.schema,o=r;return e.table.core.count({trans:n,query:{index:i,range:o}}).then(s=>e.table.core.mutate({trans:n,type:"deleteRange",range:o}).then(({failures:a,lastResult:u,results:l,numFailures:f})=>{if(f)throw new $n("Could not delete some values",Object.keys(a).map(p=>a[p]),s-f);return s-f}))}):this.modify(Ho)}},Ho=(t,e)=>e.value=null;function Ud(t){return _n(Ra.prototype,function(r,n){this.db=t;let i=Da,o=null;if(n)try{i=n()}catch(l){o=l}let s=r._ctx,a=s.table,u=a.hook.reading.fire;this._ctx={table:a,index:s.index,isPrimKey:!s.index||a.schema.primKey.keyPath&&s.index===a.schema.primKey.name,range:i,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:s.or,valueMapper:u!==cn?u:null}})}function Gd(t,e){return te?-1:t===e?0:1}function Ye(t,e,r){var n=t instanceof $o?new t.Collection(t):t;return n._ctx.error=r?new r(e):new TypeError(e),n}function Fr(t){return new t.Collection(t,()=>La("")).limit(0)}function qd(t){return t==="next"?e=>e.toUpperCase():e=>e.toLowerCase()}function Yd(t){return t==="next"?e=>e.toLowerCase():e=>e.toUpperCase()}function Jd(t,e,r,n,i,o){for(var s=Math.min(t.length,n.length),a=-1,u=0;u=0?t.substr(0,a)+e[a]+r.substr(a+1):null;i(t[u],l)<0&&(a=u)}return stypeof x=="string"))return Ye(t,Ea);function c(x){i=qd(x),o=Yd(x),s=x==="next"?Gd:Qd;var v=r.map(function(d){return{lower:o(d),upper:i(d)}}).sort(function(d,b){return s(d.lower,b.lower)});a=v.map(function(d){return d.upper}),u=v.map(function(d){return d.lower}),l=x,f=x==="next"?"":n}c("next");var h=new t.Collection(t,()=>Ft(a[0],u[p-1]+n));h._ondirectionchange=function(x){c(x)};var w=0;return h._addAlgorithm(function(x,v,d){var b=x.key;if(typeof b!="string")return!1;var m=o(b);if(e(m,u,w))return!0;for(var g=null,y=w;y0)&&(g=_)}return v(g!==null?function(){x.continue(g+f)}:d),!1}),h}function Ft(t,e,r,n){return{type:2,lower:t,upper:e,lowerOpen:r,upperOpen:n}}function La(t){return{type:1,lower:t,upper:t}}var $o=class{get Collection(){return this._ctx.table.db.Collection}between(e,r,n,i){n=n!==!1,i=i===!0;try{return this._cmp(e,r)>0||this._cmp(e,r)===0&&(n||i)&&!(n&&i)?Fr(this):new this.Collection(this,()=>Ft(e,r,!n,!i))}catch{return Ye(this,pt)}}equals(e){return e==null?Ye(this,pt):new this.Collection(this,()=>La(e))}above(e){return e==null?Ye(this,pt):new this.Collection(this,()=>Ft(e,void 0,!0))}aboveOrEqual(e){return e==null?Ye(this,pt):new this.Collection(this,()=>Ft(e,void 0,!1))}below(e){return e==null?Ye(this,pt):new this.Collection(this,()=>Ft(void 0,e,!1,!0))}belowOrEqual(e){return e==null?Ye(this,pt):new this.Collection(this,()=>Ft(void 0,e))}startsWith(e){return typeof e!="string"?Ye(this,Ea):this.between(e,e+Xt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):li(this,(r,n)=>r.indexOf(n[0])===0,[e],Xt)}equalsIgnoreCase(e){return li(this,(r,n)=>r===n[0],[e],"")}anyOfIgnoreCase(){var e=ft.apply(xr,arguments);return e.length===0?Fr(this):li(this,(r,n)=>n.indexOf(r)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=ft.apply(xr,arguments);return e.length===0?Fr(this):li(this,(r,n)=>n.some(i=>r.indexOf(i)===0),e,Xt)}anyOf(){let e=ft.apply(xr,arguments),r=this._cmp;try{e.sort(r)}catch{return Ye(this,pt)}if(e.length===0)return Fr(this);let n=new this.Collection(this,()=>Ft(e[0],e[e.length-1]));n._ondirectionchange=o=>{r=o==="next"?this._ascending:this._descending,e.sort(r)};let i=0;return n._addAlgorithm((o,s,a)=>{let u=o.key;for(;r(u,e[i])>0;)if(++i,i===e.length)return s(a),!1;return r(u,e[i])===0?!0:(s(()=>{o.continue(e[i])}),!1)}),n}notEqual(e){return this.inAnyRange([[Bo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=ft.apply(xr,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Ye(this,pt)}let r=e.reduce((n,i)=>n?n.concat([[n[n.length-1][1],i]]):[[Bo,i]],null);return r.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(r,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,r){let n=this._cmp,i=this._ascending,o=this._descending,s=this._min,a=this._max;if(e.length===0)return Fr(this);if(!e.every(g=>g[0]!==void 0&&g[1]!==void 0&&i(g[0],g[1])<=0))return Ye(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",V.InvalidArgument);let u=!r||r.includeLowers!==!1,l=r&&r.includeUppers===!0;function f(g,y){let _=0,j=g.length;for(;_0){A[0]=s(A[0],y[0]),A[1]=a(A[1],y[1]);break}}return _===j&&g.push(y),g}let p=i;function c(g,y){return p(g[0],y[0])}let h;try{h=e.reduce(f,[]),h.sort(c)}catch{return Ye(this,pt)}let w=0,x=l?g=>i(g,h[w][1])>0:g=>i(g,h[w][1])>=0,v=u?g=>o(g,h[w][0])>0:g=>o(g,h[w][0])>=0;function d(g){return!x(g)&&!v(g)}let b=x,m=new this.Collection(this,()=>Ft(h[0][0],h[h.length-1][1],!u,!l));return m._ondirectionchange=g=>{g==="next"?(b=x,p=i):(b=v,p=o),h.sort(c)},m._addAlgorithm((g,y,_)=>{for(var j=g.key;b(j);)if(++w,w===h.length)return y(_),!1;return d(j)?!0:(this._cmp(j,h[w][1])===0||this._cmp(j,h[w][0])===0||y(()=>{p===i?g.continue(h[w][0]):g.continue(h[w][1])}),!1)}),m}startsWithAnyOf(){let e=ft.apply(xr,arguments);return e.every(r=>typeof r=="string")?e.length===0?Fr(this):this.inAnyRange(e.map(r=>[r,r+Xt])):Ye(this,"startsWithAnyOf() only works with strings")}};function Xd(t){return _n($o.prototype,function(r,n,i){this.db=t,this._ctx={table:r,index:n===":id"?null:n,or:i};let o=t._deps.indexedDB;if(!o)throw new V.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(s,a)=>o.cmp(a,s),this._max=(s,a)=>o.cmp(s,a)>0?s:a,this._min=(s,a)=>o.cmp(s,a)<0?s:a,this._IDBKeyRange=t._deps.IDBKeyRange})}function nt(t){return le(function(e){return vn(e),t(e.target.error),!1})}function vn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}var bn="storagemutated",Et="x-storagemutated-1",Tt=yn(null,bn),Ba=class{_lock(){return an(!K.global),++this._reculock,this._reculock===1&&!K.global&&(K.lockOwnerFor=this),this}_unlock(){if(an(!K.global),--this._reculock==0)for(K.global||(K.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{Cr(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&K.lockOwnerFor!==this}create(e){if(!this.mode)return this;let r=this.db.idbdb,n=this.db._state.dbOpenError;if(an(!this.idbtrans),!e&&!r)switch(n&&n.name){case"DatabaseClosedError":throw new V.DatabaseClosed(n);case"MissingAPIError":throw new V.MissingAPI(n.message,n);default:throw new V.OpenFailed(n)}if(!this.active)throw new V.TransactionInactive;return an(this._completion._state===null),e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):r.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})),e.onerror=le(i=>{vn(i),this._reject(e.error)}),e.onabort=le(i=>{vn(i),this.active&&this._reject(new V.Abort(e.error)),this.active=!1,this.on("abort").fire(i)}),e.oncomplete=le(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Tt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,r,n){if(e==="readwrite"&&this.mode!=="readwrite")return be(new V.ReadOnly("Transaction is readonly"));if(!this.active)return be(new V.TransactionInactive);if(this._locked())return new R((o,s)=>{this._blockedFuncs.push([()=>{this._promise(e,r,n).then(o,s)},K])});if(n)return Ct(()=>{var o=new R((s,a)=>{this._lock();let u=r(s,a,this);u&&u.then&&u.then(s,a)});return o.finally(()=>this._unlock()),o._lib=!0,o});var i=new R((o,s)=>{var a=r(o,s,this);a&&a.then&&a.then(o,s)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(e){var r=this._root();let n=R.resolve(e);if(r._waitingFor)r._waitingFor=r._waitingFor.then(()=>n);else{r._waitingFor=n,r._waitingQueue=[];var i=r.idbtrans.objectStore(r.storeNames[0]);(function s(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(i.get(-1/0).onsuccess=s)})()}var o=r._waitingFor;return new R((s,a)=>{n.then(u=>r._waitingQueue.push(le(s.bind(null,u))),u=>r._waitingQueue.push(le(a.bind(null,u)))).finally(()=>{r._waitingFor===o&&(r._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new V.Abort))}table(e){let r=this._memoizedTables||(this._memoizedTables={});if(qe(r,e))return r[e];let n=this.schema[e];if(!n)throw new V.NotFound("Table "+e+" not part of transaction");let i=new this.db.Table(e,n,this);return i.core=this.db.core.table(e),r[e]=i,i}};function Zd(t){return _n(Ba.prototype,function(r,n,i,o,s){this.db=t,this.mode=r,this.storeNames=n,this.schema=i,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=yn(this,"complete","error","abort"),this.parent=s||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 R((a,u)=>{this._resolve=a,this._reject=u}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},a=>{var u=this.active;return this.active=!1,this.on.error.fire(a),this.parent?this.parent._reject(a):u&&this.idbtrans&&this.idbtrans.abort(),be(a)})})}function Wo(t,e,r,n,i,o,s){return{name:t,keyPath:e,unique:r,multi:n,auto:i,compound:o,src:(r&&!s?"&":"")+(n?"*":"")+(i?"++":"")+Na(e)}}function Na(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Ka(t,e,r){return{name:t,primKey:e,indexes:r,mappedClass:null,idxByName:sa(r,n=>[n.name,n])}}function ep(t){return t.length===1?t[0]:t}var xn=t=>{try{return t.only([[]]),xn=()=>[[]],[[]]}catch{return xn=()=>Xt,Xt}};function Uo(t){return t==null?()=>{}:typeof t=="string"?tp(t):e=>ct(e,t)}function tp(t){return t.split(".").length===1?r=>r[t]:r=>ct(r,t)}function za(t){return[].slice.call(t)}var rp=0;function wn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function np(t,e,r){function n(f,p){let c=za(f.objectStoreNames);return{schema:{name:f.name,tables:c.map(h=>p.objectStore(h)).map(h=>{let{keyPath:w,autoIncrement:x}=h,v=ke(w),d=w==null,b={},m={name:h.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:d,compound:v,keyPath:w,autoIncrement:x,unique:!0,extractKey:Uo(w)},indexes:za(h.indexNames).map(g=>h.index(g)).map(g=>{let{name:y,unique:_,multiEntry:j,keyPath:A}=g,F=ke(A),E={name:y,compound:F,keyPath:A,unique:_,multiEntry:j,extractKey:Uo(A)};return b[wn(A)]=E,E}),getIndexByKeyPath:g=>b[wn(g)]};return b[":id"]=m.primaryKey,w!=null&&(b[wn(w)]=m.primaryKey),m})},hasGetAll:c.length>0&&"getAll"in p.objectStore(c[0])&&!(typeof navigator!="undefined"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}function i(f){if(f.type===3)return null;if(f.type===4)throw new Error("Cannot convert never type to IDBKeyRange");let{lower:p,upper:c,lowerOpen:h,upperOpen:w}=f;return p===void 0?c===void 0?null:e.upperBound(c,!!w):c===void 0?e.lowerBound(p,!!h):e.bound(p,c,!!h,!!w)}function o(f){let p=f.name;function c({trans:x,type:v,keys:d,values:b,range:m}){return new Promise((g,y)=>{g=le(g);let _=x.objectStore(p),j=_.keyPath==null,A=v==="put"||v==="add";if(!A&&v!=="delete"&&v!=="deleteRange")throw new Error("Invalid operation type: "+v);let{length:F}=d||b||{length:1};if(d&&b&&d.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(F===0)return g({numFailures:0,failures:{},results:[],lastResult:void 0});let E,O=[],L=[],k=0,z=Y=>{++k,vn(Y)};if(v==="deleteRange"){if(m.type===4)return g({numFailures:k,failures:L,results:[],lastResult:void 0});m.type===3?O.push(E=_.clear()):O.push(E=_.delete(i(m)))}else{let[Y,q]=A?j?[b,d]:[b,null]:[d,null];if(A)for(let C=0;C{let q=Y.target.result;O.forEach((C,S)=>C.error!=null&&(L[S]=C.error)),g({numFailures:k,failures:L,results:v==="delete"?d:O.map(C=>C.result),lastResult:q})};E.onerror=Y=>{z(Y),J(Y)},E.onsuccess=J})}function h({trans:x,values:v,query:d,reverse:b,unique:m}){return new Promise((g,y)=>{g=le(g);let{index:_,range:j}=d,A=x.objectStore(p),F=_.isPrimaryKey?A:A.index(_.name),E=b?m?"prevunique":"prev":m?"nextunique":"next",O=v||!("openKeyCursor"in F)?F.openCursor(i(j),E):F.openKeyCursor(i(j),E);O.onerror=nt(y),O.onsuccess=le(L=>{let k=O.result;if(!k){g(null);return}k.___id=++rp,k.done=!1;let z=k.continue.bind(k),J=k.continuePrimaryKey;J&&(J=J.bind(k));let Y=k.advance.bind(k),q=()=>{throw new Error("Cursor not started")},C=()=>{throw new Error("Cursor not stopped")};k.trans=x,k.stop=k.continue=k.continuePrimaryKey=k.advance=q,k.fail=le(y),k.next=function(){let S=1;return this.start(()=>S--?this.continue():this.stop()).then(()=>this)},k.start=S=>{let I=new Promise((X,P)=>{X=le(X),O.onerror=nt(P),k.fail=P,k.stop=re=>{k.stop=k.continue=k.continuePrimaryKey=k.advance=C,X(re)}}),N=()=>{if(O.result)try{S()}catch(X){k.fail(X)}else k.done=!0,k.start=()=>{throw new Error("Cursor behind last entry")},k.stop()};return O.onsuccess=le(X=>{O.onsuccess=N,N()}),k.continue=z,k.continuePrimaryKey=J,k.advance=Y,N(),I},g(k)},y)})}function w(x){return v=>new Promise((d,b)=>{d=le(d);let{trans:m,values:g,limit:y,query:_}=v,j=y===1/0?void 0:y,{index:A,range:F}=_,E=m.objectStore(p),O=A.isPrimaryKey?E:E.index(A.name),L=i(F);if(y===0)return d({result:[]});if(x){let k=g?O.getAll(L,j):O.getAllKeys(L,j);k.onsuccess=z=>d({result:z.target.result}),k.onerror=nt(b)}else{let k=0,z=g||!("openKeyCursor"in O)?O.openCursor(L):O.openKeyCursor(L),J=[];z.onsuccess=Y=>{let q=z.result;if(!q)return d({result:J});if(J.push(g?q.value:q.primaryKey),++k===y)return d({result:J});q.continue()},z.onerror=nt(b)}})}return{name:p,schema:f,mutate:c,getMany({trans:x,keys:v}){return new Promise((d,b)=>{d=le(d);let m=x.objectStore(p),g=v.length,y=new Array(g),_=0,j=0,A,F=O=>{let L=O.target;(y[L._pos]=L.result)!=null,++j===_&&d(y)},E=nt(b);for(let O=0;O{d=le(d);let g=x.objectStore(p).get(v);g.onsuccess=y=>d(y.target.result),g.onerror=nt(b)})},query:w(a),openCursor:h,count({query:x,trans:v}){let{index:d,range:b}=x;return new Promise((m,g)=>{let y=v.objectStore(p),_=d.isPrimaryKey?y:y.index(d.name),j=i(b),A=j?_.count(j):_.count();A.onsuccess=le(F=>m(F.target.result)),A.onerror=nt(g)})}}}let{schema:s,hasGetAll:a}=n(t,r),u=s.tables.map(f=>o(f)),l={};return u.forEach(f=>l[f.name]=f),{stack:"dbcore",transaction:t.transaction.bind(t),table(f){if(!l[f])throw new Error(`Table '${f}' not found`);return l[f]},MIN_KEY:-1/0,MAX_KEY:xn(e),schema:s}}function ip(t,e){return e.reduce((r,{create:n})=>pe(pe({},r),n(r)),t)}function op(t,e,{IDBKeyRange:r,indexedDB:n},i){return{dbcore:ip(np(e,r,i),t.dbcore)}}function Go({_novip:t},e){let r=e.db,n=op(t._middlewares,r,t._deps,e);t.core=n.dbcore,t.tables.forEach(i=>{let o=i.name;t.core.schema.tables.some(s=>s.name===o)&&(i.core=t.core.table(o),t[o]instanceof t.Table&&(t[o].core=i.core))})}function ui({_novip:t},e,r,n){r.forEach(i=>{let o=n[i];e.forEach(s=>{let a=go(s,i);(!a||"value"in a&&a.value===void 0)&&(s===t.Transaction.prototype||s instanceof t.Transaction?ut(s,i,{get(){return this.table(i)},set(u){na(this,i,{value:u,writable:!0,configurable:!0,enumerable:!0})}}):s[i]=new t.Table(i,o))})})}function Qo({_novip:t},e){e.forEach(r=>{for(let n in r)r[n]instanceof t.Table&&delete r[n]})}function sp(t,e){return t._cfg.version-e._cfg.version}function ap(t,e,r,n){let i=t._dbSchema,o=t._createTransaction("readwrite",t._storeNames,i);o.create(r),o._completion.catch(n);let s=o._reject.bind(o),a=K.transless||K;Ct(()=>{K.trans=o,K.transless=a,e===0?(ge(i).forEach(u=>{qo(r,u,i[u].primKey,i[u].indexes)}),Go(t,r),R.follow(()=>t.on.populate.fire(o)).catch(s)):lp(t,e,o,r).catch(s)})}function lp({_novip:t},e,r,n){let i=[],o=t._versions,s=t._dbSchema=Jo(t,t.idbdb,n),a=!1;o.filter(f=>f._cfg.version>=e).forEach(f=>{i.push(()=>{let p=s,c=f._cfg.dbschema;Xo(t,p,n),Xo(t,c,n),s=t._dbSchema=c;let h=Va(p,c);h.add.forEach(x=>{qo(n,x[0],x[1].primKey,x[1].indexes)}),h.change.forEach(x=>{if(x.recreate)throw new V.Upgrade("Not yet support for changing primary key");{let v=n.objectStore(x.name);x.add.forEach(d=>Yo(v,d)),x.change.forEach(d=>{v.deleteIndex(d.name),Yo(v,d)}),x.del.forEach(d=>v.deleteIndex(d))}});let w=f._cfg.contentUpgrade;if(w&&f._cfg.version>e){Go(t,n),r._memoizedTables={},a=!0;let x=aa(c);h.del.forEach(m=>{x[m]=p[m]}),Qo(t,[t.Transaction.prototype]),ui(t,[t.Transaction.prototype],ge(x),x),r.schema=x;let v=bo(w);v&&Ar();let d,b=R.follow(()=>{if(d=w(r),d&&v){var m=dt.bind(null,null);d.then(m,m)}});return d&&typeof d.then=="function"?R.resolve(d):b.then(()=>d)}}),i.push(p=>{if(!a||!Kd){let c=f._cfg.dbschema;cp(c,p)}Qo(t,[t.Transaction.prototype]),ui(t,[t.Transaction.prototype],t._storeNames,t._dbSchema),r.schema=t._dbSchema})});function l(){return i.length?R.resolve(i.shift()(r.idbtrans)).then(l):R.resolve()}return l().then(()=>{up(s,n)})}function Va(t,e){let r={del:[],add:[],change:[]},n;for(n in t)e[n]||r.del.push(n);for(n in e){let i=t[n],o=e[n];if(!i)r.add.push([n,o]);else{let s={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||i.primKey.auto!==o.primKey.auto&&!ni)s.recreate=!0,r.change.push(s);else{let a=i.idxByName,u=o.idxByName,l;for(l in a)u[l]||s.del.push(l);for(l in u){let f=a[l],p=u[l];f?f.src!==p.src&&s.change.push(p):s.add.push(p)}(s.del.length>0||s.add.length>0||s.change.length>0)&&r.change.push(s)}}}return r}function qo(t,e,r,n){let i=t.db.createObjectStore(e,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(o=>Yo(i,o)),i}function up(t,e){ge(t).forEach(r=>{e.db.objectStoreNames.contains(r)||qo(e,r,t[r].primKey,t[r].indexes)})}function cp(t,e){[].slice.call(e.db.objectStoreNames).forEach(r=>t[r]==null&&e.db.deleteObjectStore(r))}function Yo(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Jo(t,e,r){let n={};return Hn(e.objectStoreNames,0).forEach(o=>{let s=r.objectStore(o),a=s.keyPath,u=Wo(Na(a),a||"",!1,!1,!!s.autoIncrement,a&&typeof a!="string",!0),l=[];for(let p=0;pi.add.length||i.change.length))}function Xo({_novip:t},e,r){let n=r.db.objectStoreNames;for(let i=0;i{e=e.trim();let n=e.replace(/([&*]|\+\+)/g,""),i=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return Wo(n,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),ke(i),r===0)})}var Ha=class{_parseStoresSpec(e,r){ge(e).forEach(n=>{if(e[n]!==null){var i=pp(e[n]),o=i.shift();if(o.multi)throw new V.Schema("Primary key cannot be multi-valued");i.forEach(s=>{if(s.auto)throw new V.Schema("Only primary key can be marked as autoIncrement (++)");if(!s.keyPath)throw new V.Schema("Index must have a name and cannot be an empty string")}),r[n]=Ka(n,o,i)}})}stores(e){let r=this.db;this._cfg.storesSource=this._cfg.storesSource?Le(this._cfg.storesSource,e):e;let n=r._versions,i={},o={};return n.forEach(s=>{Le(i,s._cfg.storesSource),o=s._cfg.dbschema={},s._parseStoresSpec(i,o)}),r._dbSchema=o,Qo(r,[r._allTables,r,r.Transaction.prototype]),ui(r,[r._allTables,r,r.Transaction.prototype,this._cfg.tables],ge(o),o),r._storeNames=ge(o),this}upgrade(e){return this._cfg.contentUpgrade=Ao(this._cfg.contentUpgrade||ie,e),this}};function hp(t){return _n(Ha.prototype,function(r){this.db=t,this._cfg={version:r,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}function Zo(t,e){let r=t._dbNamesDB;return r||(r=t._dbNamesDB=new mt(ii,{addons:[],indexedDB:t,IDBKeyRange:e}),r.version(1).stores({dbnames:"name"})),r.table("dbnames")}function es(t){return t&&typeof t.databases=="function"}function mp({indexedDB:t,IDBKeyRange:e}){return es(t)?Promise.resolve(t.databases()).then(r=>r.map(n=>n.name).filter(n=>n!==ii)):Zo(t,e).toCollection().primaryKeys()}function gp({indexedDB:t,IDBKeyRange:e},r){!es(t)&&r!==ii&&Zo(t,e).put({name:r}).catch(ie)}function yp({indexedDB:t,IDBKeyRange:e},r){!es(t)&&r!==ii&&Zo(t,e).delete(r).catch(ie)}function ts(t){return Ct(function(){return K.letThrough=!0,t()})}function _p(){var t=!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent);if(!t||!indexedDB.databases)return Promise.resolve();var e;return new Promise(function(r){var n=function(){return indexedDB.databases().finally(r)};e=setInterval(n,100),n()}).finally(function(){return clearInterval(e)})}function vp(t){let e=t._state,{indexedDB:r}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?be(e.dbOpenError):t);rt&&(e.openCanceller._stackHolder=Qt()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;let n=e.openCanceller;function i(){if(e.openCanceller!==n)throw new V.DatabaseClosed("db.open() was cancelled")}let o=e.dbReadyResolve,s=null,a=!1;return R.race([n,(typeof navigator=="undefined"?R.resolve():_p()).then(()=>new R((u,l)=>{if(i(),!r)throw new V.MissingAPI;let f=t.name,p=e.autoSchema?r.open(f):r.open(f,Math.round(t.verno*10));if(!p)throw new V.MissingAPI;p.onerror=nt(l),p.onblocked=le(t._fireOnBlocked),p.onupgradeneeded=le(c=>{if(s=p.transaction,e.autoSchema&&!t._options.allowEmptyDB){p.onerror=vn,s.abort(),p.result.close();let w=r.deleteDatabase(f);w.onsuccess=w.onerror=le(()=>{l(new V.NoSuchDatabase(`Database ${f} doesnt exist`))})}else{s.onerror=nt(l);var h=c.oldVersion>Math.pow(2,62)?0:c.oldVersion;a=h<1,t._novip.idbdb=p.result,ap(t,h/10,s,l)}},l),p.onsuccess=le(()=>{s=null;let c=t._novip.idbdb=p.result,h=Hn(c.objectStoreNames);if(h.length>0)try{let w=c.transaction(ep(h),"readonly");e.autoSchema?fp(t,c,w):(Xo(t,t._dbSchema,w),dp(t,w)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Go(t,w)}catch{}gn.push(t),c.onversionchange=le(w=>{e.vcFired=!0,t.on("versionchange").fire(w)}),c.onclose=le(w=>{t.on("close").fire(w)}),a&&gp(t._deps,f),u()},l)}))]).then(()=>(i(),e.onReadyBeingFired=[],R.resolve(ts(()=>t.on.ready.fire(t.vip))).then(function u(){if(e.onReadyBeingFired.length>0){let l=e.onReadyBeingFired.reduce(Ao,ie);return e.onReadyBeingFired=[],R.resolve(ts(()=>l(t.vip))).then(u)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(u=>{e.dbOpenError=u;try{s&&s.abort()}catch{}return n===e.openCanceller&&t._close(),be(u)}).finally(()=>{e.openComplete=!0,o()})}function rs(t){var e=s=>t.next(s),r=s=>t.throw(s),n=o(e),i=o(r);function o(s){return a=>{var u=s(a),l=u.value;return u.done?l:!l||typeof l.then!="function"?ke(l)?Promise.all(l).then(n,i):n(l):l.then(n,i)}}return o(e)()}function bp(t,e,r){var n=arguments.length;if(n<2)throw new V.InvalidArgument("Too few arguments");for(var i=new Array(n-1);--n;)i[n-1]=arguments[n];r=i.pop();var o=la(i);return[t,o,r]}function $a(t,e,r,n,i){return R.resolve().then(()=>{let o=K.transless||K,s=t._createTransaction(e,r,t._dbSchema,n),a={trans:s,transless:o};if(n)s.idbtrans=n.idbtrans;else try{s.create(),t._state.PR1398_maxLoop=3}catch(p){return p.name===jo.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>$a(t,e,r,null,i))):be(p)}let u=bo(i);u&&Ar();let l,f=R.follow(()=>{if(l=i.call(s,s),l)if(u){var p=dt.bind(null,null);l.then(p,p)}else typeof l.next=="function"&&typeof l.throw=="function"&&(l=rs(l))},a);return(l&&typeof l.then=="function"?R.resolve(l).then(p=>s.active?p:be(new V.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):f.then(()=>l)).then(p=>(n&&s._resolve(),s._completion.then(()=>p))).catch(p=>(s._reject(p),be(p)))})}function ci(t,e,r){let n=ke(t)?t.slice():[t];for(let i=0;i0,m=Me(pe({},w),{isVirtual:b,keyTail:h,keyLength:d,extractKey:Uo(c),unique:!b&&w.unique});if(v.push(m),m.isPrimaryKey||o.push(m),d>1){let g=d===2?c[0]:c.slice(0,d-1);s(g,h+1,w)}return v.sort((g,y)=>g.keyTail-y.keyTail),m}let a=s(n.primaryKey.keyPath,0,n.primaryKey);i[":id"]=[a];for(let c of n.indexes)s(c.keyPath,0,c);function u(c){let h=i[wn(c)];return h&&h[0]}function l(c,h){return{type:c.type===1?2:c.type,lower:ci(c.lower,c.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:ci(c.upper,c.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0}}function f(c){let h=c.query.index;return h.isVirtual?Me(pe({},c),{query:{index:h,range:l(c.query.range,h.keyTail)}}):c}return Me(pe({},r),{schema:Me(pe({},n),{primaryKey:a,indexes:o,getIndexByKeyPath:u}),count(c){return r.count(f(c))},query(c){return r.query(f(c))},openCursor(c){let{keyTail:h,isVirtual:w,keyLength:x}=c.query.index;if(!w)return r.openCursor(c);function v(d){function b(g){g!=null?d.continue(ci(g,c.reverse?t.MAX_KEY:t.MIN_KEY,h)):c.unique?d.continue(d.key.slice(0,x).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,h)):d.continue()}return Object.create(d,{continue:{value:b},continuePrimaryKey:{value(g,y){d.continuePrimaryKey(ci(g,t.MAX_KEY,h),y)}},primaryKey:{get(){return d.primaryKey}},key:{get(){let g=d.key;return x===1?g[0]:g.slice(0,x)}},value:{get(){return d.value}}})}return r.openCursor(f(c)).then(d=>d&&v(d))}})}})}var wp={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:xp};function ns(t,e,r,n){return r=r||{},n=n||"",ge(t).forEach(i=>{if(!qe(e,i))r[n+i]=void 0;else{var o=t[i],s=e[i];if(typeof o=="object"&&typeof s=="object"&&o&&s){let a=_o(o),u=_o(s);a!==u?r[n+i]=e[i]:a==="Object"?ns(o,s,r,n+i+"."):o!==s&&(r[n+i]=e[i])}else o!==s&&(r[n+i]=e[i])}}),ge(e).forEach(i=>{qe(t,i)||(r[n+i]=e[i])}),r}function jp(t,e){return e.type==="delete"?e.keys:e.keys||e.values.map(t.extractKey)}var Ap={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>Me(pe({},t),{table(e){let r=t.table(e),{primaryKey:n}=r.schema;return Me(pe({},r),{mutate(o){let s=K.trans,{deleting:a,creating:u,updating:l}=s.table(e).hook;switch(o.type){case"add":if(u.fire===ie)break;return s._promise("readwrite",()=>f(o),!0);case"put":if(u.fire===ie&&l.fire===ie)break;return s._promise("readwrite",()=>f(o),!0);case"delete":if(a.fire===ie)break;return s._promise("readwrite",()=>f(o),!0);case"deleteRange":if(a.fire===ie)break;return s._promise("readwrite",()=>p(o),!0)}return r.mutate(o);function f(h){let w=K.trans,x=h.keys||jp(n,h);if(!x)throw new Error("Keys missing");return h=h.type==="add"||h.type==="put"?Me(pe({},h),{keys:x}):pe({},h),h.type!=="delete"&&(h.values=[...h.values]),h.keys&&(h.keys=[...h.keys]),Cp(r,h,x).then(v=>{let d=x.map((b,m)=>{let g=v[m],y={onerror:null,onsuccess:null};if(h.type==="delete")a.fire.call(y,b,g,w);else if(h.type==="add"||g===void 0){let _=u.fire.call(y,b,h.values[m],w);b==null&&_!=null&&(b=_,h.keys[m]=b,n.outbound||et(h.values[m],n.keyPath,b))}else{let _=ns(g,h.values[m]),j=l.fire.call(y,_,b,g,w);if(j){let A=h.values[m];Object.keys(j).forEach(F=>{qe(A,F)?A[F]=j[F]:et(A,F,j[F])})}}return y});return r.mutate(h).then(({failures:b,results:m,numFailures:g,lastResult:y})=>{for(let _=0;_(d.forEach(m=>m.onerror&&m.onerror(b)),Promise.reject(b)))})}function p(h){return c(h.trans,h.range,1e4)}function c(h,w,x){return r.query({trans:h,values:!1,query:{index:n,range:w},limit:x}).then(({result:v})=>f({type:"delete",keys:v,trans:h}).then(d=>d.numFailures>0?Promise.reject(d.failures[0]):v.length({table:e=>{let r=t.table(e);return Me(pe({},r),{getMany:n=>{if(!n.cache)return r.getMany(n);let i=Wa(n.keys,n.trans._cache,n.cache==="clone");return i?R.resolve(i):r.getMany(n).then(o=>(n.trans._cache={keys:n.keys,values:n.cache==="clone"?ln(o):o},o))},mutate:n=>(n.type!=="add"&&(n.trans._cache=null),r.mutate(n))})}})};function is(t){return!("from"in t)}var ht=function(t,e){if(this)Le(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0});else{let r=new ht;return t&&"d"in t&&Le(r,t),r}};vr(ht.prototype,{add(t){return fi(this,t),this},addKey(t){return jn(this,t,t),this},addKeys(t){return t.forEach(e=>jn(this,e,e)),this},[vo](){return os(this)}});function jn(t,e,r){let n=Be(e,r);if(isNaN(n))return;if(n>0)throw RangeError();if(is(t))return Le(t,{from:e,to:r,d:1});let i=t.l,o=t.r;if(Be(r,t.from)<0)return i?jn(i,e,r):t.l={from:e,to:r,d:1,l:null,r:null},Ua(t);if(Be(e,t.to)>0)return o?jn(o,e,r):t.r={from:e,to:r,d:1,l:null,r:null},Ua(t);Be(e,t.from)<0&&(t.from=e,t.l=null,t.d=o?o.d+1:1),Be(r,t.to)>0&&(t.to=r,t.r=null,t.d=t.l?t.l.d+1:1);let s=!t.r;i&&!t.l&&fi(t,i),o&&s&&fi(t,o)}function fi(t,e){function r(n,{from:i,to:o,l:s,r:a}){jn(n,i,o),s&&r(n,s),a&&r(n,a)}is(e)||r(t,e)}function Fp(t,e){let r=os(e),n=r.next();if(n.done)return!1;let i=n.value,o=os(t),s=o.next(i.from),a=s.value;for(;!n.done&&!s.done;){if(Be(a.from,i.to)<=0&&Be(a.to,i.from)>=0)return!0;Be(i.from,a.from)<0?i=(n=r.next(a.from)).value:a=(s=o.next(i.from)).value}return!1}function os(t){let e=is(t)?null:{s:0,n:t};return{next(r){let n=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,n)for(;e.n.l&&Be(r,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!n||Be(r,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function Ua(t){var e,r;let n=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((r=t.l)===null||r===void 0?void 0:r.d)||0),i=n>1?"r":n<-1?"l":"";if(i){let o=i==="r"?"l":"r",s=pe({},t),a=t[i];t.from=a.from,t.to=a.to,t[i]=a[i],s[i]=a[o],t[o]=s,s.d=Ga(s)}t.d=Ga(t)}function Ga({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}var Ep={stack:"dbcore",level:0,create:t=>{let e=t.schema.name,r=new ht(t.MIN_KEY,t.MAX_KEY);return Me(pe({},t),{table:n=>{let i=t.table(n),{schema:o}=i,{primaryKey:s}=o,{extractKey:a,outbound:u}=s,l=Me(pe({},i),{mutate:c=>{let h=c.trans,w=h.mutatedParts||(h.mutatedParts={}),x=_=>{let j=`idb://${e}/${n}/${_}`;return w[j]||(w[j]=new ht)},v=x(""),d=x(":dels"),{type:b}=c,[m,g]=c.type==="deleteRange"?[c.range]:c.type==="delete"?[c.keys]:c.values.length<50?[[],c.values]:[],y=c.trans._cache;return i.mutate(c).then(_=>{if(ke(m)){b!=="delete"&&(m=_.results),v.addKeys(m);let j=Wa(m,y);!j&&b!=="add"&&d.addKeys(m),(j||g)&&Tp(x,o,j,g)}else if(m){let j={from:m.lower,to:m.upper};d.add(j),v.add(j)}else v.add(r),d.add(r),o.indexes.forEach(j=>x(j.name).add(r));return _})}}),f=({query:{index:c,range:h}})=>{var w,x;return[c,new ht((w=h.lower)!==null&&w!==void 0?w:t.MIN_KEY,(x=h.upper)!==null&&x!==void 0?x:t.MAX_KEY)]},p={get:c=>[s,new ht(c.key)],getMany:c=>[s,new ht().addKeys(c.keys)],count:f,query:f,openCursor:f};return ge(p).forEach(c=>{l[c]=function(h){let{subscr:w}=K;if(w){let x=g=>{let y=`idb://${e}/${n}/${g}`;return w[y]||(w[y]=new ht)},v=x(""),d=x(":dels"),[b,m]=p[c](h);if(x(b.name||"").add(m),!b.isPrimaryKey)if(c==="count")d.add(r);else{let g=c==="query"&&u&&h.values&&i.query(Me(pe({},h),{values:!1}));return i[c].apply(this,arguments).then(y=>{if(c==="query"){if(u&&h.values)return g.then(({result:j})=>(v.addKeys(j),y));let _=h.values?y.result.map(a):y.result;h.values?v.addKeys(_):d.addKeys(_)}else if(c==="openCursor"){let _=y,j=h.values;return _&&Object.create(_,{key:{get(){return d.addKey(_.primaryKey),_.key}},primaryKey:{get(){let A=_.primaryKey;return d.addKey(A),A}},value:{get(){return j&&v.addKey(_.primaryKey),_.value}}})}return y})}}return i[c].apply(this,arguments)}}),l}})}};function Tp(t,e,r,n){function i(o){let s=t(o.name||"");function a(l){return l!=null?o.extractKey(l):null}let u=l=>o.multiEntry&&ke(l)?l.forEach(f=>s.addKey(f)):s.addKey(l);(r||n).forEach((l,f)=>{let p=r&&a(r[f]),c=n&&a(n[f]);Be(p,c)!==0&&(p!=null&&u(p),c!=null&&u(c))})}e.indexes.forEach(i)}var mt=class{constructor(e,r){this._middlewares={},this.verno=0;let n=mt.dependencies;this._options=r=pe({addons:mt.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},r),this._deps={indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange};let{addons:i}=r;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;let o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ie,dbReadyPromise:null,cancelOpen:ie,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new R(s=>{o.dbReadyResolve=s}),o.openCanceller=new R((s,a)=>{o.cancelOpen=a}),this._state=o,this.name=e,this.on=yn(this,"populate","blocked","versionchange","close",{ready:[Ao,ie]}),this.on.ready.subscribe=ia(this.on.ready.subscribe,s=>(a,u)=>{mt.vip(()=>{let l=this._state;if(l.openComplete)l.dbOpenError||R.resolve().then(a),u&&s(a);else if(l.onReadyBeingFired)l.onReadyBeingFired.push(a),u&&s(a);else{s(a);let f=this;u||s(function p(){f.on.ready.unsubscribe(a),f.on.ready.unsubscribe(p)})}})}),this.Collection=Ud(this),this.Table=Vd(this),this.Transaction=Zd(this),this.Version=hp(this),this.WhereClause=Xd(this),this.on("versionchange",s=>{s.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",s=>{!s.newVersion||s.newVersionnew this.Transaction(s,a,u,this._options.chromeTransactionDurability,l),this._fireOnBlocked=s=>{this.on("blocked").fire(s),gn.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(s))},this.use(wp),this.use(Ap),this.use(Ep),this.use(Sp),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(s=>s(this))}version(e){if(isNaN(e)||e<.1)throw new V.Type("Given version is not a positive number");if(e=Math.round(e*10)/10,this.idbdb||this._state.isBeingOpened)throw new V.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let r=this._versions;var n=r.filter(i=>i._cfg.version===e)[0];return n||(n=new this.Version(e),r.push(n),r.sort(sp),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||K.letThrough||this._vip)?e():new R((r,n)=>{if(this._state.openComplete)return n(new V.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen){n(new V.DatabaseClosed);return}this.open().catch(ie)}this._state.dbReadyPromise.then(r,n)}).then(e)}use({stack:e,create:r,level:n,name:i}){i&&this.unuse({stack:e,name:i});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:r,level:n??10,name:i}),o.sort((s,a)=>s.level-a.level),this}unuse({stack:e,name:r,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(i=>n?i.create!==n:r?i.name!==r:!1)),this}open(){return vp(this)}_close(){let e=this._state,r=gn.indexOf(this);if(r>=0&&gn.splice(r,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new R(n=>{e.dbReadyResolve=n}),e.openCanceller=new R((n,i)=>{e.cancelOpen=i})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new V.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,r=this._state;return new R((n,i)=>{let o=()=>{this.close();var s=this._deps.indexedDB.deleteDatabase(this.name);s.onsuccess=le(()=>{yp(this._deps,this.name),n()}),s.onerror=nt(i),s.onblocked=this._fireOnBlocked};if(e)throw new V.InvalidArgument("Arguments not allowed in db.delete()");r.isBeingOpened?r.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){let e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return ge(this._allTables).map(e=>this._allTables[e])}transaction(){let e=bp.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,r,n){let i=K.trans;(!i||i.db!==this||e.indexOf("!")!==-1)&&(i=null);let o=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");let s,a;try{if(a=r.map(l=>{var f=l instanceof this.Table?l.name:l;if(typeof f!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return f}),e=="r"||e===No)s=No;else if(e=="rw"||e==Ko)s=Ko;else throw new V.InvalidArgument("Invalid transaction mode: "+e);if(i){if(i.mode===No&&s===Ko)if(o)i=null;else throw new V.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i&&a.forEach(l=>{if(i&&i.storeNames.indexOf(l)===-1)if(o)i=null;else throw new V.SubTransaction("Table "+l+" not included in parent transaction.")}),o&&i&&!i.active&&(i=null)}}catch(l){return i?i._promise(null,(f,p)=>{p(l)}):be(l)}let u=$a.bind(null,this,s,a,i,n);return i?i._promise(s,u,"lock"):K.trans?Cr(K.transless,()=>this._whenReady(u)):this._whenReady(u)}table(e){if(!qe(this._allTables,e))throw new V.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}},Dp=typeof Symbol!="undefined"&&"observable"in Symbol?Symbol.observable:"@@observable",Qa=class{constructor(e){this._subscribe=e}subscribe(e,r,n){return this._subscribe(!e||typeof e=="function"?{next:e,error:r,complete:n}:e)}[Dp](){return this}};function qa(t,e){return ge(e).forEach(r=>{let n=t[r]||(t[r]=new ht);fi(n,e[r])}),t}function Ip(t){return new Qa(e=>{let r=bo(t);function n(h){r&&Ar();let w=()=>Ct(t,{subscr:h,trans:null}),x=K.trans?Cr(K.transless,w):w();return r&&x.then(dt,dt),x}let i=!1,o={},s={},a={get closed(){return i},unsubscribe:()=>{i=!0,Tt.storagemutated.unsubscribe(p)}};e.start&&e.start(a);let u=!1,l=!1;function f(){return ge(s).some(h=>o[h]&&Fp(o[h],s[h]))}let p=h=>{qa(o,h),f()&&c()},c=()=>{if(u||i)return;o={};let h={},w=n(h);l||(Tt(bn,p),l=!0),u=!0,Promise.resolve(w).then(x=>{u=!1,!i&&(f()?c():(o={},s=h,e.next&&e.next(x)))},x=>{u=!1,e.error&&e.error(x),a.unsubscribe()})};return c(),a})}var ss;try{ss={indexedDB:se.indexedDB||se.mozIndexedDB||se.webkitIndexedDB||se.msIndexedDB,IDBKeyRange:se.IDBKeyRange||se.webkitIDBKeyRange}}catch{ss={indexedDB:null,IDBKeyRange:null}}var er=mt;vr(er,Me(pe({},Wn),{delete(t){return new er(t,{addons:[]}).delete()},exists(t){return new er(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1)},getDatabaseNames(t){try{return mp(er.dependencies).then(t)}catch{return be(new V.MissingAPI)}},defineClass(){function t(e){Le(this,e)}return t},ignoreTransaction(t){return K.trans?Cr(K.transless,t):t()},vip:ts,async:function(t){return function(){try{var e=rs(t.apply(this,arguments));return!e||typeof e.then!="function"?R.resolve(e):e}catch(r){return be(r)}}},spawn:function(t,e,r){try{var n=rs(t.apply(r,e||[]));return!n||typeof n.then!="function"?R.resolve(n):n}catch(i){return be(i)}},currentTransaction:{get:()=>K.trans||null},waitFor:function(t,e){let r=R.resolve(typeof t=="function"?er.ignoreTransaction(t):t).timeout(e||6e4);return K.trans?K.trans.waitFor(r):r},Promise:R,debug:{get:()=>rt,set:t=>{ca(t,t==="dexie"?()=>!0:Ta)}},derive:br,extend:Le,props:vr,override:ia,Events:yn,on:Tt,liveQuery:Ip,extendObservabilitySet:qa,getByKeyPath:ct,setByKeyPath:et,delByKeyPath:hd,shallowClone:aa,deepClone:ln,getObjectDiff:ns,cmp:Be,asap:oa,minKey:Bo,addons:[],connections:gn,errnames:jo,dependencies:ss,semVer:Fa,version:Fa.split(".").map(t=>parseInt(t)).reduce((t,e,r)=>t+e/Math.pow(10,r*2))}));er.maxKey=xn(er.dependencies.IDBKeyRange);typeof dispatchEvent!="undefined"&&typeof addEventListener!="undefined"&&(Tt(bn,t=>{if(!gt){let e;ni?(e=document.createEvent("CustomEvent"),e.initCustomEvent(Et,!0,!0,t)):e=new CustomEvent(Et,{detail:t}),gt=!0,dispatchEvent(e),gt=!1}}),addEventListener(Et,({detail:t})=>{gt||di(t)}));function di(t){let e=gt;try{gt=!0,Tt.storagemutated.fire(t)}finally{gt=e}}var gt=!1;if(typeof BroadcastChannel!="undefined"){let t=new BroadcastChannel(Et);Tt(bn,e=>{gt||t.postMessage(e)}),t.onmessage=e=>{e.data&&di(e.data)}}else if(typeof self!="undefined"&&typeof navigator!="undefined"){Tt(bn,e=>{try{gt||(typeof localStorage!="undefined"&&localStorage.setItem(Et,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(r=>r.postMessage({type:Et,changedParts:e})))}catch{}}),typeof addEventListener!="undefined"&&addEventListener("storage",e=>{if(e.key===Et){let r=JSON.parse(e.newValue);r&&di(r.changedParts)}});let t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",Op)}function Op({data:t}){t&&t.type===Et&&di(t.changedParts)}R.rejectionMapper=jd;ca(rt,Ta);var Ya=je(require("obsidian")),it=class extends mt{constructor(){super(it.dbName);this.version(it.dbVersion).stores({searchHistory:"++id",minisearch:"date"})}static async clearOldDatabases(){let e=(await indexedDB.databases()).filter(r=>r.name===it.dbName&&r.version!==it.dbVersion*10);if(e.length){console.log("Omnisearch - Those IndexedDb databases will be deleted:");for(let r of e)r.name&&indexedDB.deleteDatabase(r.name)}}static getInstance(){return it.instance||(it.instance=new it),it.instance}async clearCache(){new Ya.Notice("Omnisearch - Cache cleared. Please restart Obsidian."),await this.minisearch.clear()}},Er=it;Er.dbVersion=8,Er.dbName="omnisearch/cache/"+app.appId;var Se=Er.getInstance();var tr=Vn(!1),pi='Needs a restart to fully take effect.',as=class extends G.PluginSettingTab{constructor(e){super(app,e);this.plugin=e,tr.subscribe(async r=>{T.showExcerpt=r,await ce(this.plugin)})}display(){let{containerEl:e}=this;if(e.empty(),app.loadLocalStorage(An)=="1"){let c=e.createEl("span");c.innerHTML='\u26A0\uFE0F OMNISEARCH IS DISABLED \u26A0\uFE0F'}e.createEl("h2",{text:"Omnisearch"});let r=e.createDiv();r.innerHTML=` Buy Me a Coffee at ko-fi.com `;let n=new DocumentFragment;n.createSpan({},c=>{c.innerHTML='\u26A0\uFE0F Changing indexing settings will clear the cache, and requires a restart of Obsidian.

',ot()?c.innerHTML+=` \u{1F44D} You have installed Text Extractor, Omnisearch can use it to index PDFs and images contents.
Text extraction only works on desktop, but the cache can be synchronized with your mobile device.`:c.innerHTML+='\u26A0\uFE0F Omnisearch requires Text Extractor to index PDFs and images.'}),new G.Setting(e).setName("Indexing").setHeading().setDesc(n);let i=new DocumentFragment;i.createSpan({},c=>{c.innerHTML="Omnisearch will use Text Extractor to index the content of your PDFs"}),new G.Setting(e).setName(`PDFs content indexing ${ot()?"":"\u26A0\uFE0F Disabled"}`).setDesc(i).addToggle(c=>c.setValue(T.PDFIndexing).onChange(async h=>{await Se.clearCache(),T.PDFIndexing=h,await ce(this.plugin)})).setDisabled(!ot());let o=new DocumentFragment;o.createSpan({},c=>{c.innerHTML="Omnisearch will use Text Extractor to OCR your images and index their content"}),new G.Setting(e).setName(`Images OCR indexing ${ot()?"":"\u26A0\uFE0F Disabled"}`).setDesc(o).addToggle(c=>c.setValue(T.imagesIndexing).onChange(async h=>{await Se.clearCache(),T.imagesIndexing=h,await ce(this.plugin)})).setDisabled(!ot());let s=new DocumentFragment;s.createSpan({},c=>{c.innerHTML=` Omnisearch can index filenames of "unsupported" files, such as e.g.
.mp4
,
.xlsx
, or non-extracted PDFs & images.
"Obsidian setting" will respect the value of "Files & Links > Detect all file extensions"`}),new G.Setting(e).setName("Index paths of unsupported files").setDesc(s).addDropdown(c=>{c.addOptions({yes:"Yes",no:"No",default:"Obsidian setting"}).setValue(T.unsupportedFilesIndexing).onChange(async h=>{await Se.clearCache(),T.unsupportedFilesIndexing=h,await ce(this.plugin)})});let a=new DocumentFragment;a.createSpan({},c=>{c.innerHTML=`In addition to standard md files, Omnisearch can also index other PLAINTEXT files.
Add extensions separated by a space, without the dot. Example: "txt org csv".
\u26A0\uFE0F Using extensions of non-plaintext files (like .docx or .pptx) WILL cause crashes, because Omnisearch will try to index their content.`}),new G.Setting(e).setName("Additional TEXT files to index").setDesc(a).addText(c=>{c.setValue(T.indexedFileTypes.join(" ")).setPlaceholder("Example: txt org csv").onChange(async h=>{await Se.clearCache(),T.indexedFileTypes=h.split(" "),await ce(this.plugin)})}),new G.Setting(e).setName("Behavior").setHeading(),new G.Setting(e).setName("Save index to cache").setDesc("Enable caching to speed up indexing time. In rare cases, the cache write may cause a crash in Obsidian. This option will disable itself if it happens.").addToggle(c=>c.setValue(T.useCache).onChange(async h=>{T.useCache=h,await ce(this.plugin)})),new G.Setting(e).setName(`Respect Obsidian's "Excluded Files"`).setDesc(`By default, files that are in Obsidian's "Options > Files & Links > Excluded Files" list are downranked in results. Enable this option to completely hide them`).addToggle(c=>c.setValue(T.hideExcluded).onChange(async h=>{T.hideExcluded=h,await ce(this.plugin)}));let u=new DocumentFragment;u.createSpan({},c=>{c.innerHTML=`Enable this if you want to be able to search for CamelCaseWords as separate words.
\u26A0\uFE0F Changing this setting will clear the cache.
${pi} `}),new G.Setting(e).setName("Split CamelCaseWords").setDesc(u).addToggle(c=>c.setValue(T.splitCamelCase).onChange(async h=>{await Se.clearCache(),T.splitCamelCase=h,await ce(this.plugin)})),new G.Setting(e).setName("Simpler search").setDesc(`Enable this if Obsidian often freezes while making searches. Words shorter than 3 characters won't be used as prefixes; this can reduce search delay but will return fewer results.`).addToggle(c=>c.setValue(T.simpleSearch).onChange(async h=>{T.simpleSearch=h,await ce(this.plugin)})),new G.Setting(e).setName("Open in new pane").setDesc("Open and create files in a new pane instead of the current pane.").addToggle(c=>c.setValue(T.openInNewPane).onChange(async h=>{T.openInNewPane=h,await ce(this.plugin)})),new G.Setting(e).setName("Set Vim like navigation keys").setDesc("Navigate down the results with Ctrl/\u2318 + J/N, or navigate up with Ctrl/\u2318 + K/P").addToggle(c=>c.setValue(T.vimLikeNavigationShortcut).onChange(async h=>{T.vimLikeNavigationShortcut=h,await ce(this.plugin)})),new G.Setting(e).setName("Fuzziness").setDesc("Define the level of fuzziness for the search. The higher the fuzziness, the more results you'll get.").addDropdown(c=>c.addOptions({0:"Exact match",1:"Not too fuzzy",2:"Fuzzy enough"}).setValue(T.fuzziness).onChange(async h=>{["0","1","2"].includes(h)||(h="2"),T.fuzziness=h,await ce(this.plugin)})),new G.Setting(e).setName("User Interface").setHeading(),new G.Setting(e).setName("Show ribbon button").setDesc("Add a button on the sidebar to open the Vault search modal.").addToggle(c=>c.setValue(T.ribbonIcon).onChange(async h=>{T.ribbonIcon=h,await ce(this.plugin),h?this.plugin.addRibbonButton():this.plugin.removeRibbonButton()})),new G.Setting(e).setName("Show excerpts").setDesc("Shows the contextual part of the note that matches the search. Disable this to only show filenames in results.").addToggle(c=>c.setValue(T.showExcerpt).onChange(async h=>{tr.set(h)})),new G.Setting(e).setName("Render line return in excerpts").setDesc("Activate this option to render line returns in result excerpts.").addToggle(c=>c.setValue(T.renderLineReturnInExcerpts).onChange(async h=>{T.renderLineReturnInExcerpts=h,await ce(this.plugin)})),new G.Setting(e).setName("Show previous query results").setDesc("Re-executes the previous query when opening Omnisearch.").addToggle(c=>c.setValue(T.showPreviousQueryResults).onChange(async h=>{T.showPreviousQueryResults=h,await ce(this.plugin)}));let l=new DocumentFragment;l.createSpan({},c=>{c.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 G.Setting(e).setName('Show "Create note" button').setDesc(l).addToggle(c=>c.setValue(T.showCreateButton).onChange(async h=>{T.showCreateButton=h,await ce(this.plugin)})),new G.Setting(e).setName("Highlight matching words in results").setDesc("Will highlight matching results when enabled. See README for more customization options.").addToggle(c=>c.setValue(T.highlight).onChange(async h=>{T.highlight=h,await ce(this.plugin)})),new G.Setting(e).setName("Results weighting").setHeading(),new G.Setting(e).setName(`File name & declared aliases (default: ${Dt.weightBasename})`).addSlider(c=>this.weightSlider(c,"weightBasename")),new G.Setting(e).setName(`File directory (default: ${Dt.weightDirectory})`).addSlider(c=>this.weightSlider(c,"weightDirectory")),new G.Setting(e).setName(`Headings level 1 (default: ${Dt.weightH1})`).addSlider(c=>this.weightSlider(c,"weightH1")),new G.Setting(e).setName(`Headings level 2 (default: ${Dt.weightH2})`).addSlider(c=>this.weightSlider(c,"weightH2")),new G.Setting(e).setName(`Headings level 3 (default: ${Dt.weightH3})`).addSlider(c=>this.weightSlider(c,"weightH3")),new G.Setting(e).setName(`Tags without the # (default: ${Dt.weightUnmarkedTags})`).addSlider(c=>this.weightSlider(c,"weightUnmarkedTags")),new G.Setting(e).setName("Debugging").setHeading(),new G.Setting(e).setName("Enable verbose logging").setDesc("Adds a LOT of logs for debugging purposes. Don't forget to disable it.").addToggle(c=>c.setValue(T.verboseLogging).onChange(async h=>{T.verboseLogging=h,await ce(this.plugin)})),new G.Setting(e).setName("Danger Zone").setHeading();let f=new DocumentFragment;f.createSpan({},c=>{c.innerHTML=`Normalize diacritics in search terms. Words like "br\xFBl\xE9e" or "\u017Elu\u0165ou\u010Dk\xFD" will be indexed as "brulee" and "zlutoucky".
\u26A0\uFE0F You probably should NOT disable this.
\u26A0\uFE0F Changing this setting will clear the cache.
${pi} `}),new G.Setting(e).setName("Ignore diacritics").setDesc(f).addToggle(c=>c.setValue(T.ignoreDiacritics).onChange(async h=>{await Se.clearCache(),T.ignoreDiacritics=h,await ce(this.plugin)}));let p=new DocumentFragment;if(p.createSpan({},c=>{c.innerHTML=`Disable Omnisearch on this device only.
${pi}`}),new G.Setting(e).setName("Disable on this device").setDesc(p).addToggle(c=>c.setValue(ls()).onChange(async h=>{h?app.saveLocalStorage(An,"1"):app.saveLocalStorage(An),new G.Notice("Omnisearch - Disabled. Please restart Obsidian.")})),It()){let c=new DocumentFragment;c.createSpan({},h=>{h.innerHTML=`Erase all Omnisearch cache data. Use this if Omnisearch results are inconsistent, missing, or appear outdated.
${pi}`}),new G.Setting(e).setName("Clear cache data").setDesc(c).addButton(h=>{h.setButtonText("Clear cache"),h.onClick(async()=>{await Se.clearCache()})})}}weightSlider(e,r){e.setLimits(1,5,.1).setValue(T[r]).setDynamicTooltip().onChange(async n=>{T[r]=n,await ce(this.plugin)})}},Dt={useCache:!0,hideExcluded:!1,ignoreDiacritics:!0,indexedFileTypes:[],PDFIndexing:!1,imagesIndexing:!1,unsupportedFilesIndexing:"no",splitCamelCase:!1,openInNewPane:!1,vimLikeNavigationShortcut:app.vault.getConfig("vimMode"),ribbonIcon:!0,showExcerpt:!0,renderLineReturnInExcerpts:!0,showCreateButton:!1,highlight:!0,showPreviousQueryResults:!0,simpleSearch:!1,fuzziness:"1",weightBasename:3,weightDirectory:2,weightH1:1.5,weightH2:1.3,weightH3:1.1,weightUnmarkedTags:1.1,welcomeMessage:"",verboseLogging:!1},T=Object.assign({},Dt);async function Ja(t){T=Object.assign({},Dt,await t.loadData()),tr.set(T.showExcerpt)}async function ce(t){await t.saveData(T)}function ls(){return app.loadLocalStorage(An)==="1"}function Xa(){return T.unsupportedFilesIndexing==="yes"||T.unsupportedFilesIndexing==="default"&&!!app.vault.getConfig("showUnsupportedFiles")}var Za=je(require("obsidian"));var el=/[\u4e00-\u9fa5]/;var tl=100,Cn=300,rl=`suggestion-highlight omnisearch-highlight ${T.highlight?"omnisearch-default-highlight":""}`,An="omnisearch-disabled",U=new mo,hi={ToggleExcerpts:"toggle-excerpts"},Je=(o=>(o[o.Done=0]="Done",o[o.LoadingCache=1]="LoadingCache",o[o.ReadingFiles=2]="ReadingFiles",o[o.IndexingFiles=3]="IndexingFiles",o[o.WritingCache=4]="WritingCache",o))(Je||{}),te=(f=>(f.Enter="enter",f.OpenInBackground="open-in-background",f.CreateNote="create-note",f.OpenInNewPane="open-in-new-pane",f.InsertLink="insert-link",f.Tab="tab",f.ArrowUp="arrow-up",f.ArrowDown="arrow-down",f.PrevSearchHistory="prev-search-history",f.NextSearchHistory="next-search-history",f))(te||{});var Ot=Vn(0),nl=!1;function us(t){nl=t}function cs(){return nl}function mi(){return app.plugins.plugins["cm-chs-patch"]}function ot(){return app.plugins?.plugins?.["text-extractor"]?.api}function It(){return!Za.Platform.isIosApp&&T.useCache}var il=/[|\t\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]/.toString().slice(1,-1),fs=new RegExp(`${il}`,"u"),Sn=new RegExp(`${il}+`,"u");var yl=je(require("obsidian"));var rr=je(require("obsidian"));var sl=je(require("crypto")),al=je(ol());function ll(t){let e=t.split("/");return e.pop(),e.join("/")}function gi(t,e){return t.headings?.filter(r=>r.level===e).map(r=>r.heading)??[]}function yi(t,e){return(t+e)%e}function ps(t){return t.replace(/(\*|_)+(.+?)(\*|_)+/g,(e,r,n)=>n)}function ul(t){return t?.frontmatter?(0,rr.parseFrontMatterAliases)(t.frontmatter)??[]:[]}function cl(t){let e=t?(0,rr.getAllTags)(t)??[]:[];return e=[...new Set(e.reduce((r,n)=>[...r,...n.split("/").filter(i=>i).map(i=>i.startsWith("#")?i:`#${i}`),n],[]))],e}function yt(t){return t==null?"":(t=t.replaceAll("`","[__omnisearch__backtick__]"),t=t.normalize("NFD").replace(/\p{Diacritic}/gu,""),t=t.replaceAll("[__omnisearch__backtick__]","`"),t)}function nr(){return rr.Platform.isMacOS?"\u2318":"ctrl"}function kp(t){let e=!!ot(),r=e&&T.PDFIndexing,n=e&&T.imagesIndexing;return _i(t)||Dr(t)||vi(t)||r&&ir(t)||n&&Tr(t)}function hs(t){return Xa()||_i(t)||Dr(t)||vi(t)}function En(t){return hs(t)||kp(t)}function Tr(t){let e=or(t);return e==="png"||e==="jpg"||e==="jpeg"||e==="webp"}function ir(t){return or(t)==="pdf"}function _i(t){return[...T.indexedFileTypes,"md"].some(e=>t.endsWith(`.${e}`))}function Dr(t){return t.endsWith(".canvas")}function vi(t){return t.endsWith(".loom")||t.endsWith(".dashboard")}function or(t){let e=t.split(".");return e[e.length-1]??""}function fl(t){return rr.Platform.isMobileApp?(0,al.md5)(t.toString()):(0,sl.createHash)("md5").update(t).digest("hex")}function dl(t,e){let r=[],n=0,i=t.length;for(;nr):[]}function hl(t){return t.includes("-")?t.split("-").filter(e=>e):[]}function fe(...t){gl(console.log,...t)}function ml(...t){gl(console.warn,...t)}function gl(t,...e){if(T.verboseLogging){let r=new Date,n=`${r.getMinutes()}:${r.getSeconds()}:${r.getMilliseconds()}`;t("Omnisearch -",n+" -",...e)}}async function Pp(t){let e=app.vault.getFiles().find(s=>s.path===t);if(!e)throw new Error(`Invalid file path: "${t}"`);let r=null,n=ot();if(_i(t))r=await app.vault.cachedRead(e);else if(Dr(t)){let s=JSON.parse(await app.vault.cachedRead(e)),a=[];for(let u of s.nodes)u.type==="text"?a.push(u.text):u.type==="file"&&a.push(u.file);for(let u of s.edges.filter(l=>!!l.label))a.push(u.label);r=a.join(`\r `)}else if(vi(t))try{let s=JSON.parse(await app.vault.cachedRead(e)),a=[],u=l=>{for(let f in l)typeof l[f]=="object"?u(l[f]):f==="markdown"&&a.push(l[f])};u(s),r=a.join(`\r `)}catch(s){console.error("Omnisearch: Error while parsing Dataloom file",t),console.error(s)}else Tr(t)&&T.imagesIndexing&&n?.canFileBeExtracted(t)?r=await n.extractText(e):ir(t)&&T.PDFIndexing&&n?.canFileBeExtracted(t)?r=await n.extractText(e):hs(t)&&(r=e.path);r==null&&(console.warn(`Omnisearch: ${r} content for file`,e.path),r=""),r=yt(r);let i=app.metadataCache.getFileCache(e);if(i&&i.frontmatter?.["excalidraw-plugin"]){let s=i.sections?.filter(a=>a.type==="comment")??[];for(let{start:a,end:u}of s.map(l=>l.position))r=r.substring(0,a.offset-1)+r.substring(u.offset)}let o=cl(i);return{basename:yt(e.basename),content:r,path:e.path,mtime:e.stat.mtime,tags:o,unmarkedTags:o.map(s=>s.replace("#","")),aliases:ul(i).join(""),headings1:i?gi(i,1).join(" "):"",headings2:i?gi(i,2).join(" "):"",headings3:i?gi(i,3).join(" "):""}}var _l=class{constructor(){this.nextQueryIsEmpty=!1;this.documents=new Map}async addToLiveCache(e){try{let r=await Pp(e);if(!r.path){console.error(`Missing .path field in IndexedDocument "${r.basename}", skipping`);return}this.documents.set(e,r)}catch(r){console.warn(`Omnisearch: Error while adding "${e}" to live cache`,r),this.removeFromLiveCache(e)}}removeFromLiveCache(e){this.documents.delete(e)}async getDocument(e){return this.documents.has(e)?this.documents.get(e):(fe("Generating IndexedDocument from",e),await this.addToLiveCache(e),this.documents.get(e))}async addToSearchHistory(e){if(!e){this.nextQueryIsEmpty=!0;return}this.nextQueryIsEmpty=!1;let r=await Se.searchHistory.toArray();r=r.filter(n=>n.query!==e).reverse(),r.unshift({query:e}),r=r.slice(0,10),await Se.searchHistory.clear(),await Se.searchHistory.bulkAdd(r)}async getSearchHistory(){let e=(await Se.searchHistory.toArray()).reverse().map(r=>r.query);return this.nextQueryIsEmpty&&e.unshift(""),e}getDocumentsChecksum(e){return fl(JSON.stringify(e.sort((r,n)=>r.pathn.path?1:0)))}async getMinisearchCache(){try{return(await Se.minisearch.toArray())[0]}catch(e){return new yl.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(e),null}}async writeMinisearchCache(e,r){let n=Array.from(r).map(([i,o])=>({path:i,mtime:o}));await Se.minisearch.clear(),await Se.minisearch.add({date:new Date().toISOString(),paths:n,data:e.toJSON()}),console.log("Omnisearch - Search cache written")}},Fe=new _l;function Mp(t){let e,r,n,i,o,s,a,u,l=t[8].default,f=pr(l,t,t[7],null);return{c(){e=M("div"),r=M("div"),n=M("input"),o=W(),f&&f.c(),B(n,"class","prompt-input"),B(n,"placeholder",t[0]),B(n,"spellcheck","false"),B(n,"type","text"),B(r,"class","omnisearch-input-field"),B(e,"class","omnisearch-input-container")},m(p,c){$(p,e,c),D(e,r),D(r,n),t[9](n),ao(n,t[1]),D(e,o),f&&f.m(e,null),s=!0,a||(u=[He(n,"input",t[10]),Js(i=t[3].call(null,n)),He(n,"compositionend",t[11]),He(n,"compositionstart",t[12]),He(n,"input",t[4])],a=!0)},p(p,[c]){(!s||c&1)&&B(n,"placeholder",p[0]),c&2&&n.value!==p[1]&&ao(n,p[1]),f&&f.p&&(!s||c&128)&&mr(f,l,p,p[7],s?hr(l,p[7],c,null):gr(p[7]),null)},i(p){s||(ee(f,p),s=!0)},o(p){ne(f,p),s=!1},d(p){p&&H(e),t[9](null),f&&f.d(p),a=!1,Xe(u)}}}function Rp(t,e,r){let{$$slots:n={},$$scope:i}=e,{initialValue:o=""}=e,{placeholder:s=""}=e,a=!1,u="",l,f=co();function p(m){r(1,u=m)}function c(m){m&&!a&&!u&&(a=!0,r(1,u=m),h())}function h(m){jt().then(()=>(l.focus(),jt())).then(()=>{l.select()})}let w=(0,vl.debounce)(()=>{Fe.addToSearchHistory(""),f("input",u)},300);function x(m){lt[m?"unshift":"push"](()=>{l=m,r(2,l)})}function v(){u=this.value,r(1,u)}let d=m=>us(!1),b=m=>us(!0);return t.$$set=m=>{"initialValue"in m&&r(5,o=m.initialValue),"placeholder"in m&&r(0,s=m.placeholder),"$$scope"in m&&r(7,i=m.$$scope)},t.$$.update=()=>{if(t.$$.dirty&32){e:c(o)}},[s,u,l,h,w,o,p,i,n,x,v,d,b]}var bl=class extends Te{constructor(e){super();Oe(this,e,Rp,Mp,Ae,{initialValue:5,placeholder:0,setInputValue:6})}get setInputValue(){return this.$$.ctx[6]}},bi=bl;function Lp(t){let e,r,n,i,o=t[1].default,s=pr(o,t,t[0],null);return{c(){e=M("div"),s&&s.c(),B(e,"class","prompt-results")},m(a,u){$(a,e,u),s&&s.m(e,null),r=!0,n||(i=He(e,"mousedown",Bp),n=!0)},p(a,[u]){s&&s.p&&(!r||u&1)&&mr(s,o,a,a[0],r?hr(o,a[0],u,null):gr(a[0]),null)},i(a){r||(ee(s,a),r=!0)},o(a){ne(s,a),r=!1},d(a){a&&H(e),s&&s.d(a),n=!1,i()}}}var Bp=t=>t.preventDefault();function Np(t,e,r){let{$$slots:n={},$$scope:i}=e;return t.$$set=o=>{"$$scope"in o&&r(0,i=o.$$scope)},[i,n]}var xl=class extends Te{constructor(e){super();Oe(this,e,Np,Lp,Ae,{})}},xi=xl;var ws=je(require("obsidian"));var Zc=je(require("obsidian"));var Kp=typeof global=="object"&&global&&global.Object===Object&&global,wi=Kp;var zp=typeof self=="object"&&self&&self.Object===Object&&self,Vp=wi||zp||Function("return this")(),ye=Vp;var Hp=ye.Symbol,Ee=Hp;var wl=Object.prototype,$p=wl.hasOwnProperty,Wp=wl.toString,Tn=Ee?Ee.toStringTag:void 0;function Up(t){var e=$p.call(t,Tn),r=t[Tn];try{t[Tn]=void 0;var n=!0}catch{}var i=Wp.call(t);return n&&(e?t[Tn]=r:delete t[Tn]),i}var jl=Up;var Gp=Object.prototype,Qp=Gp.toString;function qp(t){return Qp.call(t)}var Al=qp;var Yp="[object Null]",Jp="[object Undefined]",Cl=Ee?Ee.toStringTag:void 0;function Xp(t){return t==null?t===void 0?Jp:Yp:Cl&&Cl in Object(t)?jl(t):Al(t)}var tt=Xp;function Zp(t){return t!=null&&typeof t=="object"}var Ne=Zp;var eh="[object Symbol]";function th(t){return typeof t=="symbol"||Ne(t)&&tt(t)==eh}var _t=th;function rh(t,e){for(var r=-1,n=t==null?0:t.length,i=Array(n);++r0){if(++e>=Ih)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Bl=Ph;function Mh(t){return function(){return t}}var Nl=Mh;var Rh=function(){try{var t=Ue(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Or=Rh;var Lh=Or?function(t,e){return Or(t,"toString",{configurable:!0,enumerable:!1,value:Nl(e),writable:!0})}:kt,Kl=Lh;var Bh=Bl(Kl),zl=Bh;function Nh(t,e){for(var r=-1,n=t==null?0:t.length;++r-1&&t%1==0&&t-1&&t%1==0&&t<=Jh}var Pr=Xh;function Zh(t){return t!=null&&Pr(t.length)&&!ji(t)}var st=Zh;function em(t,e,r){if(!We(r))return!1;var n=typeof e;return(n=="number"?st(r)&&kr(e,r.length):n=="string"&&e in r)?Pt(r[e],t):!1}var ms=em;var tm=Object.prototype;function rm(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||tm;return t===r}var Mr=rm;function nm(t,e){for(var r=-1,n=Array(t);++r-1}var pu=jg;function Ag(t,e){var r=this.__data__,n=Lt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var hu=Ag;function Kr(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e0&&r(a)?e>1?Fu(a,e-1,r,n,i):Hr(i,a):n||(i[i.length]=a)}return i}var Eu=Fu;var Gg=Di(Object.getPrototypeOf,Object),ki=Gg;function Qg(){this.__data__=new Bt,this.size=0}var Tu=Qg;function qg(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Du=qg;function Yg(t){return this.__data__.get(t)}var Iu=Yg;function Jg(t){return this.__data__.has(t)}var Ou=Jg;var Xg=200;function Zg(t,e){var r=this.__data__;if(r instanceof Bt){var n=r.__data__;if(!Nt||n.lengtha))return!1;var l=o.get(t),f=o.get(e);if(l&&f)return l==e&&f==t;var p=-1,c=!0,h=r&H_?new _c:void 0;for(o.set(t,e),o.set(e,t);++pe||o&&s&&u&&!a&&!l||n&&s&&u||!r&&u||!i)return 1;if(!n&&!o&&!l&&t=a)return u;var l=r[n];return u*(l=="desc"?-1:1)}}return t.index-e.index}var Jc=zv;function Vv(t,e,r){e.length?e=Ir(e,function(o){return de(o)?function(s){return Vr(s,o.length===1?o[0]:o)}:o}):e=[kt];var n=-1;e=Ir(e,Rt(zc));var i=Qc(t,function(o,s,a){var u=Ir(e,function(l){return l(o)});return{criteria:u,index:++n,value:o}});return qc(i,function(o,s){return Jc(o,s,r)})}var Xc=Vv;var Hv=Wl(function(t,e){if(t==null)return[];var r=e.length;return r>1&&ms(t,e[0],e[1])?e=[]:r>2&&ms(e[0],e[1],e[2])&&(e=[e[0]]),Xc(t,Eu(e,1),[])}),xs=Hv;function Ht(t,e){try{return t.replace(new RegExp(e.map(r=>`\\b${kn(r.match)}\\b`).join("|"),"giu"),r=>e.find(i=>r.match(new RegExp(`\\b${kn(i.match)}\\b`,"giu")))?`${r}`:r)}catch(r){return console.error("Omnisearch - Error in highlightText()",r),t}}function $v(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Qr(t){if(!t.length)return/^$/g;t.sort((r,n)=>n.length-r.length);let e="("+(mi()?"":T.splitCamelCase?`^|${fs.source}|-|[A-Z]`:`^|${fs.source}|-`)+`)(${t.map(r=>kn(r)).join("|")})`;return new RegExp(`${e}`,"gu")}function Gi(t,e,r){t=t.toLowerCase();let n=new Date().getTime(),i=null,o=[],s=0;for(;(i=e.exec(t))!==null;){if(++s>=100||new Date().getTime()-n>50){ml("Stopped getMatches at",s,"results");break}let a=i[2];a&&i.index>=0&&o.push({match:a,offset:i.index+1})}if(r&&r.query.text.length>1){let a=t.indexOf(r.segmentsToStr());a>-1&&o.find(u=>u.offset===a)&&(o=o.filter(u=>u.offset!==a),o.unshift({offset:a,match:r.segmentsToStr()}))}return o}function qr(t,e){try{let r=e??-1,n=Math.max(0,r-tl),i=Math.min(t.length,r+Cn);if(r>-1?t=(n>0?"\u2026":"")+t.slice(n,i).trim()+(ia).join(` `);let s=t.lastIndexOf(` `,r-n);s>0&&(t=t.slice(s))}return t=$v(t),T.renderLineReturnInExcerpts&&(t=t.trim().replaceAll(` `,"
")),{content:t,offset:r}}catch(r){return new Zc.Notice("Omnisearch - Error while creating excerpt, see developer console"),console.error("Omnisearch - Error while creating excerpt"),console.error(r),{content:"",offset:-1}}}async function Qi(t,e=!1){let r=Qr(t.foundWords);r.exec(t.content);let n=r.lastIndex,i=!1;app.workspace.iterateAllLeaves(a=>{a.view instanceof ws.MarkdownView&&!e&&a.getViewState().state?.file===t.path&&a.getViewState()?.pinned&&(app.workspace.setActiveLeaf(a,{focus:!0}),i=!0)}),i||await app.workspace.openLinkText(t.path,"",e);let o=app.workspace.getActiveViewOfType(ws.MarkdownView);if(!o)return;let s=o.editor.offsetToPos(n);s.ch=0,o.editor.setCursor(s),o.editor.scrollIntoView({from:{line:s.line-10,ch:0},to:{line:s.line+10,ch:0}})}async function ef(t,e=!1){try{let r;switch(app.vault.getConfig("newFileLocation")){case"current":r=(app.workspace.getActiveFile()?.parent?.path??"")+"/";break;case"folder":r=app.vault.getConfig("newFileFolderPath")+"/";break;default:r="";break}await app.workspace.openLinkText(`${r}${t}.md`,"",e)}catch(r){throw r.message="OmniSearch - Could not create note: "+r.message,console.error(r),r}}function Wv(t){let e;return{c(){e=M("span"),e.innerHTML='',B(e,"class","suggestion-flair"),B(e,"aria-label","Not created yet, select to create")},m(r,n){$(r,e,n)},p:he,i:he,o:he,d(r){r&&H(e)}}}function Uv(t){"use strict";return[]}var tf=class extends Te{constructor(e){super();Oe(this,e,Uv,Wv,Ae,{})}},rf=tf;function nf(t){let e,r;return e=new rf({}),{c(){$e(e.$$.fragment)},m(n,i){Re(e,n,i),r=!0},i(n){r||(ee(e.$$.fragment,n),r=!0)},o(n){ne(e.$$.fragment,n),r=!1},d(n){Ie(e,n)}}}function Gv(t){let e,r,n,i,o,s=t[2]&&nf(t),a=t[4].default,u=pr(a,t,t[3],null);return{c(){e=M("div"),s&&s.c(),r=W(),u&&u.c(),B(e,"data-result-id",t[0]),B(e,"class","suggestion-item omnisearch-result"),lo(e,"is-selected",t[1])},m(l,f){$(l,e,f),s&&s.m(e,null),D(e,r),u&&u.m(e,null),n=!0,i||(o=[He(e,"mousemove",t[5]),He(e,"click",t[6]),He(e,"keypress",t[7]),He(e,"auxclick",t[8])],i=!0)},p(l,[f]){l[2]?s?f&4&&ee(s,1):(s=nf(l),s.c(),ee(s,1),s.m(e,r)):s&&(Ut(),ne(s,1,1,()=>{s=null}),Gt()),u&&u.p&&(!n||f&8)&&mr(u,a,l,l[3],n?hr(a,l[3],f,null):gr(l[3]),null),(!n||f&1)&&B(e,"data-result-id",l[0]),(!n||f&2)&&lo(e,"is-selected",l[1])},i(l){n||(ee(s),ee(u,l),n=!0)},o(l){ne(s),ne(u,l),n=!1},d(l){l&&H(e),s&&s.d(),u&&u.d(l),i=!1,Xe(o)}}}function Qv(t,e,r){let{$$slots:n={},$$scope:i}=e,{id:o}=e,{selected:s=!1}=e,{glyph:a=!1}=e;function u(c){Qe.call(this,t,c)}function l(c){Qe.call(this,t,c)}function f(c){Qe.call(this,t,c)}function p(c){Qe.call(this,t,c)}return t.$$set=c=>{"id"in c&&r(0,o=c.id),"selected"in c&&r(1,s=c.selected),"glyph"in c&&r(2,a=c.glyph),"$$scope"in c&&r(3,i=c.$$scope)},[o,s,a,i,n,u,l,f,p]}var of=class extends Te{constructor(e){super();Oe(this,e,Qv,Gv,Ae,{id:0,selected:1,glyph:2})}},qi=of;var Yr=je(require("obsidian"));function sf(t){let e,r=t[1].matches.length+"",n,i,o=(t[1].matches.length>1?"matches":"match")+"",s;return{c(){e=M("span"),n=Ce(r),i=Ce("\xA0"),s=Ce(o),B(e,"class","omnisearch-result__counter")},m(a,u){$(a,e,u),D(e,n),D(e,i),D(e,s)},p(a,u){u&2&&r!==(r=a[1].matches.length+"")&&Ze(n,r),u&2&&o!==(o=(a[1].matches.length>1?"matches":"match")+"")&&Ze(s,o)},d(a){a&&H(e)}}}function af(t){let e,r,n,i,o;return{c(){e=M("div"),r=M("span"),n=W(),i=M("span"),o=Ce(t[7]),B(e,"class","omnisearch-result__folder-path")},m(s,a){$(s,e,a),D(e,r),t[14](r),D(e,n),D(e,i),D(i,o)},p(s,a){a&128&&Ze(o,s[7])},d(s){s&&H(e),t[14](null)}}}function lf(t){let e,r=Ht(t[5].content,t[9])+"";return{c(){e=M("div"),B(e,"class","omnisearch-result__body")},m(n,i){$(n,e,i),e.innerHTML=r},p(n,i){i&544&&r!==(r=Ht(n[5].content,n[9])+"")&&(e.innerHTML=r)},d(n){n&&H(e)}}}function uf(t){let e,r,n;return{c(){e=M("div"),r=M("img"),Ge(r,"width","100px"),so(r.src,n=t[6])||B(r,"src",n),B(r,"alt",""),B(e,"class","omnisearch-result__image-container")},m(i,o){$(i,e,o),D(e,r)},p(i,o){o&64&&!so(r.src,n=i[6])&&B(r,"src",n)},d(i){i&&H(e)}}}function qv(t){let e,r,n,i,o,s,a=Ht(t[2],t[10])+"",u,l,f,p=or(t[1].path)+"",c,h,w,x,v,d,b=t[1].matches.length>0&&sf(t),m=t[7]&&af(t),g=t[11]&&lf(t),y=t[6]&&uf(t);return{c(){e=M("div"),r=M("div"),n=M("span"),i=M("span"),o=W(),s=M("span"),u=W(),l=M("span"),f=Ce("."),c=Ce(p),h=W(),b&&b.c(),w=W(),m&&m.c(),x=W(),v=M("div"),g&&g.c(),d=W(),y&&y.c(),B(l,"class","omnisearch-result__extension"),B(n,"class","omnisearch-result__title"),B(r,"class","omnisearch-result__title-container"),Ge(v,"display","flex"),Ge(v,"flex-direction","row")},m(_,j){$(_,e,j),D(e,r),D(r,n),D(n,i),t[13](i),D(n,o),D(n,s),s.innerHTML=a,D(n,u),D(n,l),D(l,f),D(l,c),D(n,h),b&&b.m(n,null),D(e,w),m&&m.m(e,null),D(e,x),D(e,v),g&&g.m(v,null),D(v,d),y&&y.m(v,null)},p(_,j){j&1028&&a!==(a=Ht(_[2],_[10])+"")&&(s.innerHTML=a),j&2&&p!==(p=or(_[1].path)+"")&&Ze(c,p),_[1].matches.length>0?b?b.p(_,j):(b=sf(_),b.c(),b.m(n,null)):b&&(b.d(1),b=null),_[7]?m?m.p(_,j):(m=af(_),m.c(),m.m(e,x)):m&&(m.d(1),m=null),_[11]?g?g.p(_,j):(g=lf(_),g.c(),g.m(v,d)):g&&(g.d(1),g=null),_[6]?y?y.p(_,j):(y=uf(_),y.c(),y.m(v,null)):y&&(y.d(1),y=null)},d(_){_&&H(e),t[13](null),b&&b.d(),m&&m.d(),g&&g.d(),y&&y.d()}}}function Yv(t){let e,r;return e=new qi({props:{glyph:t[8],id:t[1].path,selected:t[0],$$slots:{default:[qv]},$$scope:{ctx:t}}}),e.$on("click",t[15]),e.$on("auxclick",t[16]),e.$on("mousemove",t[17]),{c(){$e(e.$$.fragment)},m(n,i){Re(e,n,i),r=!0},p(n,[i]){let o={};i&256&&(o.glyph=n[8]),i&2&&(o.id=n[1].path),i&1&&(o.selected=n[0]),i&265982&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(ee(e.$$.fragment,n),r=!0)},o(n){ne(e.$$.fragment,n),r=!1},d(n){Ie(e,n)}}}function Jv(t,e,r){let n,i,o,s,a,u;Ln(t,tr,y=>r(11,u=y));let{selected:l=!1}=e,{note:f}=e,p=null,c="",h="",w,x;function v(y){lt[y?"unshift":"push"](()=>{x=y,r(4,x)})}function d(y){lt[y?"unshift":"push"](()=>{w=y,r(3,w)})}function b(y){Qe.call(this,t,y)}function m(y){Qe.call(this,t,y)}function g(y){Qe.call(this,t,y)}t.$$set=y=>{"selected"in y&&r(0,l=y.selected),"note"in y&&r(1,f=y.note)},t.$$.update=()=>{if(t.$$.dirty&2){e:if(r(6,p=null),Tr(f.path)){let y=app.vault.getFiles().find(_=>_.path===f.path);y&&r(6,p=app.vault.getResourcePath(y))}}if(t.$$.dirty&2){e:r(12,n=Qr(f.foundWords))}if(t.$$.dirty&30){e:r(2,c=f.basename),r(7,h=ll(f.path)),T.ignoreDiacritics&&r(2,c=yt(c)),w&&(0,Yr.setIcon)(w,"folder-open"),x&&(Tr(f.path)?(0,Yr.setIcon)(x,"image"):ir(f.path)?(0,Yr.setIcon)(x,"file-text"):Dr(f.path)?(0,Yr.setIcon)(x,"layout-dashboard"):(0,Yr.setIcon)(x,"file"))}if(t.$$.dirty&4100){e:r(10,i=Gi(c,n))}if(t.$$.dirty&2){e:r(5,s=qr(f.content,f.matches[0]?.offset??-1))}if(t.$$.dirty&34){e:r(9,o=On(f.matches).map(y=>(y.offset=y.offset-s.offset,y)))}};e:r(8,a=!1);return[l,f,c,w,x,s,p,h,a,o,i,u,n,v,d,b,m,g]}var cf=class extends Te{constructor(e){super();Oe(this,e,Jv,Yv,Ae,{selected:0,note:1})}},ff=cf;var mf=je(hf()),js=["ext","path"],ur=class{#e;constructor(e=""){T.ignoreDiacritics&&(e=yt(e));let r=(0,mf.parse)(e.toLowerCase(),{tokenize:!0,keywords:js});r.text=r.text??[],r.exclude=r.exclude??{},r.exclude.text=r.exclude.text??[],Array.isArray(r.exclude.text)||(r.exclude.text=[r.exclude.text]),r.exclude.text=r.exclude.text.filter(n=>n.length);for(let n of js){let i=r[n];i&&(r[n]=Array.isArray(i)?i:[i]);let o=r.exclude[n];o&&(r.exclude[n]=Array.isArray(o)?o:[o])}this.query=r,this.#e=e.match(/"([^"]+)"/g)?.map(n=>n.replace(/"/g,""))??[]}isEmpty(){for(let e of js)if(this.query[e]?.length||this.query.text.length)return!1;return!0}segmentsToStr(){return this.query.text.join(" ")}getTags(){return this.query.text.filter(e=>e.startsWith("#"))}getTagsWithoutHashtag(){return this.getTags().map(e=>e.replace(/^#/,""))}getExactTerms(){return[...new Set([...this.query.text.filter(e=>e.split(" ").length>1),...this.#e].map(e=>e.toLowerCase()))]}};var ue=function(){return ue=Object.assign||function(e){for(var r,n=1,i=arguments.length;n0&&o[o.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _e(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o}var eb="ENTRIES",gf="KEYS",yf="VALUES",De="",As=function(){function t(e,r){var n=e._tree,i=Array.from(n.keys());this.set=e,this._type=r,this._path=i.length>0?[{node:n,keys:i}]:[]}return t.prototype.next=function(){var e=this.dive();return this.backtrack(),e},t.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var e=Jr(this._path),r=e.node,n=e.keys;if(Jr(n)===De)return{done:!1,value:this.result()};var i=r.get(Jr(n));return this._path.push({node:i,keys:Array.from(i.keys())}),this.dive()},t.prototype.backtrack=function(){if(this._path.length!==0){var e=Jr(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}},t.prototype.key=function(){return this.set._prefix+this._path.map(function(e){var r=e.keys;return Jr(r)}).filter(function(e){return e!==De}).join("")},t.prototype.value=function(){return Jr(this._path).node.get(De)},t.prototype.result=function(){switch(this._type){case yf:return this.value();case gf:return this.key();default:return[this.key(),this.value()]}},t.prototype[Symbol.iterator]=function(){return this},t}(),Jr=function(t){return t[t.length-1]},tb=function(t,e,r){var n=new Map;if(e===void 0)return n;for(var i=e.length+1,o=i+r,s=new Uint8Array(o*i).fill(r+1),a=0;ar)continue e}_f(t.get(h),e,r,n,i,x,s,a+h)}}}catch(k){u={error:k}}finally{try{c&&!c.done&&(l=p.return)&&l.call(p)}finally{if(u)throw u.error}}},Cs=function(){function t(e,r){e===void 0&&(e=new Map),r===void 0&&(r=""),this._size=void 0,this._tree=e,this._prefix=r}return t.prototype.atPrefix=function(e){var r,n;if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");var i=_e(Ji(this._tree,e.slice(this._prefix.length)),2),o=i[0],s=i[1];if(o===void 0){var a=_e(Es(s),2),u=a[0],l=a[1];try{for(var f=Q(u.keys()),p=f.next();!p.done;p=f.next()){var c=p.value;if(c!==De&&c.startsWith(l)){var h=new Map;return h.set(c.slice(l.length),u.get(c)),new t(h,e)}}}catch(w){r={error:w}}finally{try{p&&!p.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}}return new t(o,e)},t.prototype.clear=function(){this._size=void 0,this._tree.clear()},t.prototype.delete=function(e){return this._size=void 0,rb(this._tree,e)},t.prototype.entries=function(){return new As(this,eb)},t.prototype.forEach=function(e){var r,n;try{for(var i=Q(this),o=i.next();!o.done;o=i.next()){var s=_e(o.value,2),a=s[0],u=s[1];e(a,u,this)}}catch(l){r={error:l}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},t.prototype.fuzzyGet=function(e,r){return tb(this._tree,e,r)},t.prototype.get=function(e){var r=Ss(this._tree,e);return r!==void 0?r.get(De):void 0},t.prototype.has=function(e){var r=Ss(this._tree,e);return r!==void 0&&r.has(De)},t.prototype.keys=function(){return new As(this,gf)},t.prototype.set=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Fs(this._tree,e);return n.set(De,r),this},Object.defineProperty(t.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var e=this.entries();!e.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),t.prototype.update=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Fs(this._tree,e);return n.set(De,r(n.get(De))),this},t.prototype.fetch=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Fs(this._tree,e),i=n.get(De);return i===void 0&&n.set(De,i=r()),i},t.prototype.values=function(){return new As(this,yf)},t.prototype[Symbol.iterator]=function(){return this.entries()},t.from=function(e){var r,n,i=new t;try{for(var o=Q(e),s=o.next();!s.done;s=o.next()){var a=_e(s.value,2),u=a[0],l=a[1];i.set(u,l)}}catch(f){r={error:f}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},t.fromObject=function(e){return t.from(Object.entries(e))},t}(),Ji=function(t,e,r){var n,i;if(r===void 0&&(r=[]),e.length===0||t==null)return[t,r];try{for(var o=Q(t.keys()),s=o.next();!s.done;s=o.next()){var a=s.value;if(a!==De&&e.startsWith(a))return r.push([t,a]),Ji(t.get(a),e.slice(a.length),r)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r.push([t,e]),Ji(void 0,"",r)},Ss=function(t,e){var r,n;if(e.length===0||t==null)return t;try{for(var i=Q(t.keys()),o=i.next();!o.done;o=i.next()){var s=o.value;if(s!==De&&e.startsWith(s))return Ss(t.get(s),e.slice(s.length))}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},Fs=function(t,e){var r,n,i=e.length;e:for(var o=0;t&&o0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new Cs,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},t.prototype.discard=function(e){var r=this,n=this._idToShortId.get(e);if(n==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(e,": it is not in the index"));this._idToShortId.delete(e),this._documentIds.delete(n),this._storedFields.delete(n),(this._fieldLength.get(n)||[]).forEach(function(i,o){r.removeFieldLength(n,o,r._documentCount,i)}),this._fieldLength.delete(n),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},t.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var e=this._options.autoVacuum,r=e.minDirtFactor,n=e.minDirtCount,i=e.batchSize,o=e.batchWait;this.conditionalVacuum({batchSize:i,batchWait:o},{minDirtCount:n,minDirtFactor:r})}},t.prototype.discardAll=function(e){var r,n,i=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var o=Q(e),s=o.next();!s.done;s=o.next()){var a=s.value;this.discard(a)}}catch(u){r={error:u}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}finally{this._options.autoVacuum=i}this.maybeAutoVacuum()},t.prototype.replace=function(e){var r=this._options,n=r.idField,i=r.extractField,o=i(e,n);this.discard(o),this.add(e)},t.prototype.vacuum=function(e){return e===void 0&&(e={}),this.conditionalVacuum(e)},t.prototype.conditionalVacuum=function(e,r){var n=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&r,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var i=n._enqueuedVacuumConditions;return n._enqueuedVacuumConditions=Ps,n.performVacuuming(e,i)}),this._enqueuedVacuum)):this.vacuumConditionsMet(r)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)},t.prototype.performVacuuming=function(e,r){return Xv(this,void 0,void 0,function(){var n,i,o,s,a,u,l,f,p,c,h,w,x,v,d,b,m,g,y,_,j,A,F,E,O;return Zv(this,function(L){switch(L.label){case 0:if(n=this._dirtCount,!this.vacuumConditionsMet(r))return[3,10];i=e.batchSize||ks.batchSize,o=e.batchWait||ks.batchWait,s=1,L.label=1;case 1:L.trys.push([1,7,8,9]),a=Q(this._index),u=a.next(),L.label=2;case 2:if(u.done)return[3,6];l=_e(u.value,2),f=l[0],p=l[1];try{for(c=(A=void 0,Q(p)),h=c.next();!h.done;h=c.next()){w=_e(h.value,2),x=w[0],v=w[1];try{for(d=(E=void 0,Q(v)),b=d.next();!b.done;b=d.next())m=_e(b.value,1),g=m[0],!this._documentIds.has(g)&&(v.size<=1?p.delete(x):v.delete(g))}catch(k){E={error:k}}finally{try{b&&!b.done&&(O=d.return)&&O.call(d)}finally{if(E)throw E.error}}}}catch(k){A={error:k}}finally{try{h&&!h.done&&(F=c.return)&&F.call(c)}finally{if(A)throw A.error}}return this._index.get(f).size===0&&this._index.delete(f),s%i!=0?[3,4]:[4,new Promise(function(k){return setTimeout(k,o)})];case 3:L.sent(),L.label=4;case 4:s+=1,L.label=5;case 5:return u=a.next(),[3,2];case 6:return[3,9];case 7:return y=L.sent(),_={error:y},[3,9];case 8:try{u&&!u.done&&(j=a.return)&&j.call(a)}finally{if(_)throw _.error}return[7];case 9:this._dirtCount-=n,L.label=10;case 10:return[4,null];case 11:return L.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},t.prototype.vacuumConditionsMet=function(e){if(e==null)return!0;var r=e.minDirtCount,n=e.minDirtFactor;return r=r||Ms.minDirtCount,n=n||Ms.minDirtFactor,this.dirtCount>=r&&this.dirtFactor>=n},Object.defineProperty(t.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),t.prototype.has=function(e){return this._idToShortId.has(e)},t.prototype.search=function(e,r){var n,i;r===void 0&&(r={});var o=this.executeQuery(e,r),s=[];try{for(var a=Q(o),u=a.next();!u.done;u=a.next()){var l=_e(u.value,2),f=l[0],p=l[1],c=p.score,h=p.terms,w=p.match,x=h.length,v={id:this._documentIds.get(f),score:c*x,terms:Object.keys(w),match:w};Object.assign(v,this._storedFields.get(f)),(r.filter==null||r.filter(v))&&s.push(v)}}catch(d){n={error:d}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return s.sort(Af),s},t.prototype.autoSuggest=function(e,r){var n,i,o,s;r===void 0&&(r={}),r=ue(ue({},this._options.autoSuggestOptions),r);var a=new Map;try{for(var u=Q(this.search(e,r)),l=u.next();!l.done;l=u.next()){var f=l.value,p=f.score,c=f.terms,h=c.join(" "),w=a.get(h);w!=null?(w.score+=p,w.count+=1):a.set(h,{score:p,terms:c,count:1})}}catch(y){n={error:y}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}var x=[];try{for(var v=Q(a),d=v.next();!d.done;d=v.next()){var b=_e(d.value,2),w=b[0],m=b[1],p=m.score,c=m.terms,g=m.count;x.push({suggestion:w,terms:c,score:p/g})}}catch(y){o={error:y}}finally{try{d&&!d.done&&(s=v.return)&&s.call(v)}finally{if(o)throw o.error}}return x.sort(Af),x},Object.defineProperty(t.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),t.loadJSON=function(e,r){if(r==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),r)},t.getDefault=function(e){if(Os.hasOwnProperty(e))return Is(Os,e);throw new Error('MiniSearch: unknown option "'.concat(e,'"'))},t.loadJS=function(e,r){var n,i,o,s,a,u,l=e.index,f=e.documentCount,p=e.nextId,c=e.documentIds,h=e.fieldIds,w=e.fieldLength,x=e.averageFieldLength,v=e.storedFields,d=e.dirtCount,b=e.serializationVersion;if(b!==1&&b!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var m=new t(r);m._documentCount=f,m._nextId=p,m._documentIds=Xi(c),m._idToShortId=new Map,m._fieldIds=h,m._fieldLength=Xi(w),m._avgFieldLength=x,m._storedFields=Xi(v),m._dirtCount=d||0,m._index=new Cs;try{for(var g=Q(m._documentIds),y=g.next();!y.done;y=g.next()){var _=_e(y.value,2),j=_[0],A=_[1];m._idToShortId.set(A,j)}}catch(S){n={error:S}}finally{try{y&&!y.done&&(i=g.return)&&i.call(g)}finally{if(n)throw n.error}}try{for(var F=Q(l),E=F.next();!E.done;E=F.next()){var O=_e(E.value,2),L=O[0],k=O[1],z=new Map;try{for(var J=(a=void 0,Q(Object.keys(k))),Y=J.next();!Y.done;Y=J.next()){var q=Y.value,C=k[q];b===1&&(C=C.ds),z.set(parseInt(q,10),Xi(C))}}catch(S){a={error:S}}finally{try{Y&&!Y.done&&(u=J.return)&&u.call(J)}finally{if(a)throw a.error}}m._index.set(L,z)}}catch(S){o={error:S}}finally{try{E&&!E.done&&(s=F.return)&&s.call(F)}finally{if(o)throw o.error}}return m},t.prototype.executeQuery=function(e,r){var n=this;if(r===void 0&&(r={}),typeof e!="string"){var i=ue(ue(ue({},r),e),{queries:void 0}),o=e.queries.map(function(v){return n.executeQuery(v,i)});return this.combineResults(o,e.combineWith)}var s=this._options,a=s.tokenize,u=s.processTerm,l=s.searchOptions,f=ue(ue({tokenize:a,processTerm:u},l),r),p=f.tokenize,c=f.processTerm,h=p(e).flatMap(function(v){return c(v)}).filter(function(v){return!!v}),w=h.map(ab(f)),x=w.map(function(v){return n.executeQuerySpec(v,f)});return this.combineResults(x,f.combineWith)},t.prototype.executeQuerySpec=function(e,r){var n,i,o,s,a=ue(ue({},this._options.searchOptions),r),u=(a.fields||this._options.fields).reduce(function(q,C){var S;return ue(ue({},q),(S={},S[C]=Is(q,C)||1,S))},a.boost||{}),l=a.boostDocument,f=a.weights,p=a.maxFuzzy,c=a.bm25,h=ue(ue({},wf.weights),f),w=h.fuzzy,x=h.prefix,v=this._index.get(e.term),d=this.termResults(e.term,e.term,1,v,u,l,c),b,m;if(e.prefix&&(b=this._index.atPrefix(e.term)),e.fuzzy){var g=e.fuzzy===!0?.2:e.fuzzy,y=g<1?Math.min(p,Math.round(e.term.length*g)):g;y&&(m=this._index.fuzzyGet(e.term,y))}if(b)try{for(var _=Q(b),j=_.next();!j.done;j=_.next()){var A=_e(j.value,2),F=A[0],E=A[1],O=F.length-e.term.length;if(!!O){m==null||m.delete(F);var L=x*F.length/(F.length+.3*O);this.termResults(e.term,F,L,E,u,l,c,d)}}}catch(q){n={error:q}}finally{try{j&&!j.done&&(i=_.return)&&i.call(_)}finally{if(n)throw n.error}}if(m)try{for(var k=Q(m.keys()),z=k.next();!z.done;z=k.next()){var F=z.value,J=_e(m.get(F),2),Y=J[0],O=J[1];if(!!O){var L=w*F.length/(F.length+O);this.termResults(e.term,F,L,Y,u,l,c,d)}}}catch(q){o={error:q}}finally{try{z&&!z.done&&(s=k.return)&&s.call(k)}finally{if(o)throw o.error}}return d},t.prototype.combineResults=function(e,r){if(r===void 0&&(r=Ts),e.length===0)return new Map;var n=r.toLowerCase();return e.reduce(ib[n])||new Map},t.prototype.toJSON=function(){var e,r,n,i,o=[];try{for(var s=Q(this._index),a=s.next();!a.done;a=s.next()){var u=_e(a.value,2),l=u[0],f=u[1],p={};try{for(var c=(n=void 0,Q(f)),h=c.next();!h.done;h=c.next()){var w=_e(h.value,2),x=w[0],v=w[1];p[x]=Object.fromEntries(v)}}catch(d){n={error:d}}finally{try{h&&!h.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}o.push([l,p])}}catch(d){e={error:d}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.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:o,serializationVersion:2}},t.prototype.termResults=function(e,r,n,i,o,s,a,u){var l,f,p,c,h;if(u===void 0&&(u=new Map),i==null)return u;try{for(var w=Q(Object.keys(o)),x=w.next();!x.done;x=w.next()){var v=x.value,d=o[v],b=this._fieldIds[v],m=i.get(b);if(m!=null){var g=m.size,y=this._avgFieldLength[b];try{for(var _=(p=void 0,Q(m.keys())),j=_.next();!j.done;j=_.next()){var A=j.value;if(!this._documentIds.has(A)){this.removeTerm(b,A,r),g-=1;continue}var F=s?s(this._documentIds.get(A),r):1;if(!!F){var E=m.get(A),O=this._fieldLength.get(A)[b],L=sb(E,g,this._documentCount,O,y,a),k=n*d*F*L,z=u.get(A);if(z){z.score+=k,ub(z.terms,e);var J=Is(z.match,r);J?J.push(v):z.match[r]=[v]}else u.set(A,{score:k,terms:[e],match:(h={},h[r]=[v],h)})}}}catch(Y){p={error:Y}}finally{try{j&&!j.done&&(c=_.return)&&c.call(_)}finally{if(p)throw p.error}}}}}catch(Y){l={error:Y}}finally{try{x&&!x.done&&(f=w.return)&&f.call(w)}finally{if(l)throw l.error}}return u},t.prototype.addTerm=function(e,r,n){var i=this._index.fetch(n,Cf),o=i.get(e);if(o==null)o=new Map,o.set(r,1),i.set(e,o);else{var s=o.get(r);o.set(r,(s||0)+1)}},t.prototype.removeTerm=function(e,r,n){if(!this._index.has(n)){this.warnDocumentChanged(r,e,n);return}var i=this._index.fetch(n,Cf),o=i.get(e);o==null||o.get(r)==null?this.warnDocumentChanged(r,e,n):o.get(r)<=1?o.size<=1?i.delete(e):o.delete(r):o.set(r,o.get(r)-1),this._index.get(n).size===0&&this._index.delete(n)},t.prototype.warnDocumentChanged=function(e,r,n){var i,o;try{for(var s=Q(Object.keys(this._fieldIds)),a=s.next();!a.done;a=s.next()){var u=a.value;if(this._fieldIds[u]===r){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(e),' has changed before removal: term "').concat(n,'" was not present in field "').concat(u,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(l){i={error:l}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}},t.prototype.addDocumentId=function(e){var r=this._nextId;return this._idToShortId.set(e,r),this._documentIds.set(r,e),this._documentCount+=1,this._nextId+=1,r},t.prototype.addFields=function(e){for(var r=0;r{let e=t.split(Sn);e=[...e,...e.flatMap(hl)],e=[...e,...e.flatMap(pl)];let r=mi();return r&&(e=e.flatMap(n=>el.test(n)?r.cut(n):[n])),e},Zi=class{constructor(){this.indexedDocuments=new Map;this.minisearch=new Ds(Zi.options)}async loadCache(){let e=await Fe.getMinisearchCache();return e?(this.minisearch=Ds.loadJS(e.data,Zi.options),this.indexedDocuments=new Map(e.paths.map(r=>[r.path,r.mtime])),!0):(console.log("Omnisearch - No cache found"),!1)}getDiff(e){let r=new Map(e.map(o=>[o.path,o.mtime])),n=e.filter(o=>!this.indexedDocuments.has(o.path)||this.indexedDocuments.get(o.path)!==o.mtime),i=[...this.indexedDocuments].filter(([o,s])=>!r.has(o)||r.get(o)!==s).map(o=>({path:o[0],mtime:o[1]}));return{toAdd:n,toRemove:i}}async addFromPaths(e){fe("Adding files",e);let r=(await Promise.all(e.map(async i=>await Fe.getDocument(i)))).filter(i=>!!i?.path);fe("Sorting documents to first index markdown"),r=xs(r,i=>i.path.endsWith(".md")?0:1),this.removeFromPaths(r.filter(i=>this.indexedDocuments.has(i.path)).map(i=>i.path));let n=dl(r,500);for(let i of n){fe("Indexing into search engine",i),i.forEach(s=>this.indexedDocuments.set(s.path,s.mtime));let o=i.filter(s=>this.minisearch.has(s.path));this.removeFromPaths(o.map(s=>s.path)),await this.minisearch.addAllAsync(i)}}removeFromPaths(e){e.forEach(n=>this.indexedDocuments.delete(n));let r=e.filter(n=>this.minisearch.has(n));this.minisearch.discardAll(r)}async search(e,r){if(e.isEmpty())return[];fe("=== New search ==="),fe("Starting search for",e);let n;switch(T.fuzziness){case"0":n=0;break;case"1":n=.1;break;default:n=.2;break}let i=this.minisearch.search(e.segmentsToStr(),{prefix:l=>l.length>=r.prefixLength,fuzzy:l=>l.length<=3?0:l.length<=5?n/2:n,combineWith:"AND",boost:{basename:T.weightBasename,directory:T.weightDirectory,aliases:T.weightBasename,headings1:T.weightH1,headings2:T.weightH2,headings3:T.weightH3,unmarkedTags:T.weightUnmarkedTags}});if(fe("Found",i.length,"results"),e.query.ext?.length&&(i=i.filter(l=>{let f="."+l.id.split(".").pop();return e.query.ext?.some(p=>f.startsWith(p.startsWith(".")?p:"."+p))})),e.query.path&&(i=i.filter(l=>e.query.path?.some(f=>l.id.toLowerCase().includes(f.toLowerCase())))),e.query.exclude.path&&(i=i.filter(l=>!e.query.exclude.path?.some(f=>l.id.toLowerCase().includes(f.toLowerCase())))),!i.length)return[];if(r.singleFilePath)return i.filter(l=>l.id===r.singleFilePath);T.hideExcluded?i=i.filter(l=>!(app.metadataCache.isUserIgnored&&app.metadataCache.isUserIgnored(l.id))):i.forEach(l=>{app.metadataCache.isUserIgnored&&app.metadataCache.isUserIgnored(l.id)&&(l.score/=10)});let o=e.getTags();for(let l of o)for(let f of i)(f.tags??[]).includes(l)&&(f.score*=100);fe("Sorting and limiting results"),i=i.sort((l,f)=>f.score-l.score).slice(0,50),i.length&&fe("First result:",i[0]);let s=await Promise.all(i.map(async l=>await Fe.getDocument(l.id))),a=e.getExactTerms();a.length&&(fe("Filtering with quoted terms: ",a),i=i.filter(l=>{let f=s.find(h=>h.path===l.id),p=f?.path.toLowerCase()??"",c=ps(f?.content??"").toLowerCase();return a.every(h=>c.includes(h)||p.includes(h))}));let u=e.query.exclude.text;return u.length&&(fe("Filtering with exclusions"),i=i.filter(l=>{let f=ps(s.find(p=>p.path===l.id)?.content??"").toLowerCase();return u.every(p=>!f.includes(p))})),fe("Deduping"),i=i.filter((l,f,p)=>p.findIndex(c=>c.id===l.id)===f),i}async getSuggestions(e,r){let n;T.simpleSearch?n=await this.search(e,{prefixLength:3,singleFilePath:r?.singleFilePath}):n=await this.search(e,{prefixLength:1,singleFilePath:r?.singleFilePath});let i=await Promise.all(n.map(async s=>await Fe.getDocument(s.id)));return n.map(s=>{fe("Locating matches for",s.id);let a=i.find(p=>p.path===s.id);a||(console.warn(`Omnisearch - Note "${s.id}" not in the live cache`),a={content:"",basename:s.id,path:s.id});let u=[...Object.keys(s.match),...e.getExactTerms(),...e.getTags()].filter(p=>p.length>1||/\p{Emoji}/u.test(p));fe("Matching tokens:",u),fe("Getting matches locations...");let l=Gi(a.content,Qr(u),e);return fe(`Matches for ${a.basename}`,l),pe({score:s.score,foundWords:u,matches:l},a)})}async writeToCache(){await Fe.writeMinisearchCache(this.minisearch,this.indexedDocuments)}},Rs=Zi;Rs.options={tokenize:fb,extractField:(e,r)=>{if(r==="directory"){let n=e.path.split("/");return n.pop(),n.join("/")}return e[r]},processTerm:e=>(T.ignoreDiacritics?yt(e):e).toLowerCase(),idField:"path",fields:["basename","directory","aliases","content","headings1","headings2","headings3"],storeFields:["tags"],logger(e,r,n){n==="version_conflict"&&new Sf.Notice("Omnisearch - Your index cache may be incorrect or corrupted. If this message keeps appearing, go to Settings to clear the cache.",5e3)}};var xe=new Rs;var Ls=new Set;function Ff(t){Ls.add(t)}async function eo(){let t=[...Ls].map(e=>e.path);t.length&&(xe.removeFromPaths(t),await xe.addFromPaths(t),Ls.clear())}var Tf=je(Ef());function Df(t,e,r){let n=t.slice();return n[36]=e[r],n[38]=r,n}function db(t){let e,r,n;return{c(){e=M("button"),e.textContent="Create note"},m(i,o){$(i,e,o),r||(n=He(e,"click",t[12]),r=!0)},p:he,d(i){i&&H(e),r=!1,n()}}}function pb(t){let e,r=T.showCreateButton&&db(t);return{c(){r&&r.c(),e=yr()},m(n,i){r&&r.m(n,i),$(n,e,i)},p(n,i){T.showCreateButton&&r.p(n,i)},d(n){r&&r.d(n),n&&H(e)}}}function If(t){let e,r,n;return{c(){e=M("div"),r=Ce("\u23F3 Work in progress: "),n=Ce(t[3]),Ge(e,"text-align","center"),Ge(e,"color","var(--text-accent)"),Ge(e,"margin-top","10px")},m(i,o){$(i,e,o),D(e,r),D(e,n)},p(i,o){o[0]&8&&Ze(n,i[3])},d(i){i&&H(e)}}}function Of(t){let e,r;function n(...i){return t[18](t[38],...i)}return e=new ff({props:{selected:t[38]===t[0],note:t[36]}}),e.$on("mousemove",n),e.$on("click",t[10]),e.$on("auxclick",t[19]),{c(){$e(e.$$.fragment)},m(i,o){Re(e,i,o),r=!0},p(i,o){t=i;let s={};o[0]&1&&(s.selected=t[38]===t[0]),o[0]&4&&(s.note=t[36]),e.$set(s)},i(i){r||(ee(e.$$.fragment,i),r=!0)},o(i){ne(e.$$.fragment,i),r=!1},d(i){Ie(e,i)}}}function hb(t){let e;return{c(){e=Ce("Searching...")},m(r,n){$(r,e,n)},p:he,d(r){r&&H(e)}}}function mb(t){let e,r=T.simpleSearch&&t[1].split(Sn).some(Pf),n,i=r&&kf(t);return{c(){e=Ce(`We found 0 result for your search here. `),i&&i.c(),n=yr()},m(o,s){$(o,e,s),i&&i.m(o,s),$(o,n,s)},p(o,s){s[0]&2&&(r=T.simpleSearch&&o[1].split(Sn).some(Pf)),r?i||(i=kf(o),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},d(o){o&&H(e),i&&i.d(o),o&&H(n)}}}function kf(t){let e,r,n;return{c(){e=M("br"),r=W(),n=M("span"),n.textContent=`You have enabled "Simpler Search" in the settings, try to type more characters.`,Ge(n,"color","var(--text-accent)"),Ge(n,"font-size","small")},m(i,o){$(i,e,o),$(i,r,o),$(i,n,o)},d(i){i&&H(e),i&&H(r),i&&H(n)}}}function gb(t){let e,r,n,i=t[2],o=[];for(let f=0;fne(o[f],1,1,()=>{o[f]=null});function a(f,p){if(!f[2].length&&f[1]&&!f[4])return mb;if(f[4])return hb}let u=a(t,[-1,-1]),l=u&&u(t);return{c(){for(let f=0;f\u2191\u2193to navigate',u=W(),l=M("div"),l.innerHTML=`alt \u2191\u2193 to cycle history`,f=W(),p=M("div"),c=M("span"),h=Ce(t[7]),w=W(),x=M("span"),x.textContent="to open",v=W(),d=M("div"),d.innerHTML=`tab to switch to In-File Search`,b=W(),m=M("div"),g=M("span"),y=Ce(t[6]),_=W(),j=M("span"),j.textContent="to open in a new pane",A=W(),F=M("div"),F.innerHTML=`alt o to open in the background`,E=W(),O=M("div"),L=M("span"),k=Ce(t[9]),z=W(),J=M("span"),J.textContent="to create",Y=W(),q=M("div"),C=M("span"),S=Ce(t[8]),I=W(),N=M("span"),N.textContent="to create in a new pane",X=W(),P=M("div"),P.innerHTML=`alt \u21B5 to insert a link`,re=W(),Ke=M("div"),Ke.innerHTML=`ctrl h to toggle excerpts`,we=W(),me=M("div"),me.innerHTML='escto close',B(a,"class","prompt-instruction"),B(l,"class","prompt-instruction"),B(c,"class","prompt-instruction-command"),B(p,"class","prompt-instruction"),B(d,"class","prompt-instruction"),B(g,"class","prompt-instruction-command"),B(m,"class","prompt-instruction"),B(F,"class","prompt-instruction"),B(L,"class","prompt-instruction-command"),B(O,"class","prompt-instruction"),B(C,"class","prompt-instruction-command"),B(q,"class","prompt-instruction"),B(P,"class","prompt-instruction"),B(Ke,"class","prompt-instruction"),B(me,"class","prompt-instruction"),B(s,"class","prompt-instructions")},m(Z,ve){Re(e,Z,ve),$(Z,r,ve),Ve&&Ve.m(Z,ve),$(Z,n,ve),Re(i,Z,ve),$(Z,o,ve),$(Z,s,ve),D(s,a),D(s,u),D(s,l),D(s,f),D(s,p),D(p,c),D(c,h),D(p,w),D(p,x),D(s,v),D(s,d),D(s,b),D(s,m),D(m,g),D(g,y),D(m,_),D(m,j),D(s,A),D(s,F),D(s,E),D(s,O),D(O,L),D(L,k),D(O,z),D(O,J),D(s,Y),D(s,q),D(q,C),D(C,S),D(q,I),D(q,N),D(s,X),D(s,P),D(s,re),D(s,Ke),D(s,we),D(s,me),ze=!0},p(Z,ve){let io={};ve[0]&2&&(io.initialValue=Z[1]),ve[1]&256&&(io.$$scope={dirty:ve,ctx:Z}),e.$set(io),Z[3]?Ve?Ve.p(Z,ve):(Ve=If(Z),Ve.c(),Ve.m(n.parentNode,n)):Ve&&(Ve.d(1),Ve=null);let Vs={};ve[0]&23|ve[1]&256&&(Vs.$$scope={dirty:ve,ctx:Z}),i.$set(Vs),(!ze||ve[0]&128)&&Ze(h,Z[7]),(!ze||ve[0]&64)&&Ze(y,Z[6]),(!ze||ve[0]&512)&&Ze(k,Z[9]),(!ze||ve[0]&256)&&Ze(S,Z[8])},i(Z){ze||(ee(e.$$.fragment,Z),ee(i.$$.fragment,Z),ze=!0)},o(Z){ne(e.$$.fragment,Z),ne(i.$$.fragment,Z),ze=!1},d(Z){t[16](null),Ie(e,Z),Z&&H(r),Ve&&Ve.d(Z),Z&&H(n),Ie(i,Z),Z&&H(o),Z&&H(s)}}}var Pf=t=>t.length<3;function _b(t,e,r){let n,i;Ln(t,Ot,P=>r(15,i=P));let{modal:o}=e,{previousQuery:s}=e,a=0,u=0,l,f=[],p,c="",h=!0,w,x,v,d,b;rn(async()=>{U.enable("vault"),U.on("vault",te.Enter,A),U.on("vault",te.OpenInBackground,F),U.on("vault",te.CreateNote,z),U.on("vault",te.OpenInNewPane,E),U.on("vault",te.InsertLink,J),U.on("vault",te.Tab,Y),U.on("vault",te.ArrowUp,()=>q(-1)),U.on("vault",te.ArrowDown,()=>q(1)),U.on("vault",te.PrevSearchHistory,m),U.on("vault",te.NextSearchHistory,g),await eo(),T.showPreviousQueryResults&&r(13,s=(await Fe.getSearchHistory())[0])}),nn(()=>{U.disable("vault")});async function m(){let P=(await Fe.getSearchHistory()).filter(re=>re);++u>=P.length&&(u=0),r(1,l=P[u]),w?.setInputValue(l)}async function g(){let P=(await Fe.getSearchHistory()).filter(re=>re);--u<0&&(u=P.length?P.length-1:0),r(1,l=P[u]),w?.setInputValue(l)}let y=null;async function _(){y&&(y.cancel(),y=null),p=new ur(l),y=(0,Tf.cancelable)(new Promise(P=>{P(xe.getSuggestions(p))})),r(2,f=await y),r(0,a=0),await C()}function j(P){!n||(P?.ctrlKey?E():A(),o.close())}function A(){!n||(L(n),o.close())}function F(){!n||L(n,!0)}function E(){!n||(L(n,!0),o.close())}function O(){l&&Fe.addToSearchHistory(l)}function L(P,re=!1){O(),Qi(P,re)}async function k(P){await z()}async function z(P){if(l){try{await ef(l,P?.newLeaf)}catch(re){new $t.Notice(re.message);return}o.close()}}function J(){if(!n)return;let P=app.vault.getMarkdownFiles().find(ze=>ze.path===n.path),re=app.workspace.getActiveFile(),Ke=app.workspace.getActiveViewOfType($t.MarkdownView);if(!Ke?.editor){new $t.Notice("Omnisearch - Error - No active editor",3e3);return}let we;P&&re?we=app.fileManager.generateMarkdownLink(P,re.path):we=`[[${n.basename}.${or(n.path)}]]`;let me=Ke.editor.getCursor();Ke.editor.replaceRange(we,me,me),me.ch+=we.length,Ke.editor.setCursor(me),o.close()}function Y(){if(!(n&&(ir(n?.path)||!n?.matches.length)))if(O(),o.close(),n){let P=app.vault.getAbstractFileByPath(n.path);P&&P instanceof $t.TFile&&new Xr(app,P,l).open()}else{let P=app.workspace.getActiveViewOfType($t.MarkdownView);P&&new Xr(app,P.file,l).open()}}function q(P){r(0,a=yi(a+P,f.length)),C()}async function C(){await jt(),n&&activeWindow.document.querySelector(`[data-result-id="${n.path}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}function S(P){lt[P?"unshift":"push"](()=>{w=P,r(5,w)})}let I=P=>r(1,l=P.detail),N=(P,re)=>r(0,a=P),X=P=>{P.button==1&&E()};t.$$set=P=>{"modal"in P&&r(14,o=P.modal),"previousQuery"in P&&r(13,s=P.previousQuery)},t.$$.update=()=>{if(t.$$.dirty[0]&8194){e:r(1,l=l??s)}if(t.$$.dirty[0]&2){e:l?(r(4,h=!0),_().then(()=>{r(4,h=!1)})):(r(4,h=!1),r(2,f=[]))}if(t.$$.dirty[0]&5){e:n=f[a]}if(t.$$.dirty[0]&32768){e:switch(i){case Je.LoadingCache:r(3,c="Loading cache...");break;case Je.ReadingFiles:r(3,c="Reading files...");break;case Je.IndexingFiles:r(3,c="Indexing files...");break;case Je.WritingCache:_(),r(3,c="Updating cache...");break;default:_(),r(3,c="");break}}};e:T.openInNewPane?(r(6,x="\u21B5"),r(7,v=nr()+" \u21B5"),r(8,d="shift \u21B5"),r(9,b=nr()+" shift \u21B5")):(r(6,x=nr()+" \u21B5"),r(7,v="\u21B5"),r(8,d=nr()+" shift \u21B5"),r(9,b="shift \u21B5"));return[a,l,f,c,h,w,x,v,d,b,j,E,k,s,o,i,S,I,N,X]}var Mf=class extends Te{constructor(e){super();Oe(this,e,_b,yb,Ae,{modal:14,previousQuery:13},null,[-1,-1])}},Rf=Mf;var Nf=je(require("obsidian"));function vb(t){let e,r=Ht(t[2].content,t[3])+"";return{c(){e=M("div"),B(e,"class","omnisearch-result__body")},m(n,i){$(n,e,i),e.innerHTML=r},p(n,i){i&12&&r!==(r=Ht(n[2].content,n[3])+"")&&(e.innerHTML=r)},d(n){n&&H(e)}}}function bb(t){let e,r;return e=new qi({props:{id:t[0].toString(),selected:t[1],$$slots:{default:[vb]},$$scope:{ctx:t}}}),e.$on("mousemove",t[6]),e.$on("click",t[7]),e.$on("auxclick",t[8]),{c(){$e(e.$$.fragment)},m(n,i){Re(e,n,i),r=!0},p(n,[i]){let o={};i&1&&(o.id=n[0].toString()),i&2&&(o.selected=n[1]),i&524&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(ee(e.$$.fragment,n),r=!0)},o(n){ne(e.$$.fragment,n),r=!1},d(n){Ie(e,n)}}}function xb(t,e,r){let n,i,{offset:o}=e,{note:s}=e,{index:a=0}=e,{selected:u=!1}=e;function l(c){Qe.call(this,t,c)}function f(c){Qe.call(this,t,c)}function p(c){Qe.call(this,t,c)}return t.$$set=c=>{"offset"in c&&r(4,o=c.offset),"note"in c&&r(5,s=c.note),"index"in c&&r(0,a=c.index),"selected"in c&&r(1,u=c.selected)},t.$$.update=()=>{if(t.$$.dirty&48){e:r(2,n=qr(s?.content??"",o))}if(t.$$.dirty&36){e:r(3,i=On(s.matches).map(c=>(c.offset=c.offset-n.offset,c)))}},[a,u,n,i,o,s,l,f,p]}var Lf=class extends Te{constructor(e){super();Oe(this,e,xb,bb,Ae,{offset:4,note:5,index:0,selected:1})}},Bf=Lf;function Kf(t,e,r){let n=t.slice();return n[19]=e[r],n[21]=r,n}function wb(t){let e;return{c(){e=M("div"),e.textContent="We found 0 result for your search here.",Ge(e,"text-align","center")},m(r,n){$(r,e,n)},p:he,i:he,o:he,d(r){r&&H(e)}}}function jb(t){let e,r,n=t[4],i=[];for(let s=0;sne(i[s],1,1,()=>{i[s]=null});return{c(){for(let s=0;s{s[f]=null}),Gt(),r=s[e],r?r.p(u,l):(r=s[e]=o[e](u),r.c()),ee(r,1),r.m(n.parentNode,n))},i(u){i||(ee(r),i=!0)},o(u){ne(r),i=!1},d(u){s[e].d(u),u&&H(n)}}}function Cb(t){let e;return{c(){e=M("span"),e.textContent="to close"},m(r,n){$(r,e,n)},d(r){r&&H(e)}}}function Sb(t){let e;return{c(){e=M("span"),e.textContent="to go back to Vault Search"},m(r,n){$(r,e,n)},d(r){r&&H(e)}}}function Fb(t){let e,r,n,i,o,s,a,u,l,f,p,c,h,w,x,v,d,b,m,g;e=new bi({props:{placeholder:"Omnisearch - File",initialValue:t[1]}}),e.$on("input",t[10]),n=new xi({props:{$$slots:{default:[Ab]},$$scope:{ctx:t}}});function y(A,F){return A[0]?Sb:Cb}let _=y(t,-1),j=_(t);return{c(){$e(e.$$.fragment),r=W(),$e(n.$$.fragment),i=W(),o=M("div"),s=M("div"),s.innerHTML='\u2191\u2193to navigate',a=W(),u=M("div"),u.innerHTML='\u21B5to open',l=W(),f=M("div"),f.innerHTML=`tab to switch to Vault Search`,p=W(),c=M("div"),h=M("span"),h.textContent="esc",w=W(),j.c(),x=W(),v=M("div"),d=M("span"),d.textContent=`${nr()} \u21B5`,b=W(),m=M("span"),m.textContent="to open in a new pane",B(s,"class","prompt-instruction"),B(u,"class","prompt-instruction"),B(f,"class","prompt-instruction"),B(h,"class","prompt-instruction-command"),B(c,"class","prompt-instruction"),B(d,"class","prompt-instruction-command"),B(v,"class","prompt-instruction"),B(o,"class","prompt-instructions")},m(A,F){Re(e,A,F),$(A,r,F),Re(n,A,F),$(A,i,F),$(A,o,F),D(o,s),D(o,a),D(o,u),D(o,l),D(o,f),D(o,p),D(o,c),D(c,h),D(c,w),j.m(c,null),D(o,x),D(o,v),D(v,d),D(v,b),D(v,m),g=!0},p(A,[F]){let E={};F&2&&(E.initialValue=A[1]),e.$set(E);let O={};F&4194360&&(O.$$scope={dirty:F,ctx:A}),n.$set(O),_!==(_=y(A,F))&&(j.d(1),j=_(A),j&&(j.c(),j.m(c,null)))},i(A){g||(ee(e.$$.fragment,A),ee(n.$$.fragment,A),g=!0)},o(A){ne(e.$$.fragment,A),ne(n.$$.fragment,A),g=!1},d(A){Ie(e,A),A&&H(r),Ie(n,A),A&&H(i),A&&H(o),j.d()}}}function Eb(t,e,r){let n=t.find(i=>i.offset>e);return n?t.filter(i=>i.offset>e&&i.offset<=n.offset+r):[]}function Tb(t,e,r){let{modal:n}=e,{parent:i=null}=e,{singleFilePath:o=""}=e,{previousQuery:s}=e,a,u=[],l=0,f,p;rn(()=>{U.enable("infile"),U.on("infile",te.Enter,v),U.on("infile",te.OpenInNewPane,x),U.on("infile",te.ArrowUp,()=>h(-1)),U.on("infile",te.ArrowDown,()=>h(1)),U.on("infile",te.Tab,d)}),nn(()=>{U.disable("infile")});function c(_){let j=[],A=-1,F=0;for(;;){let E=Eb(_,A,Cn);if(!E.length||(A=E.last().offset,j.push(E),++F>100))break}return j}function h(_){r(5,l=yi(l+_,u.length)),w()}async function w(){await jt(),document.querySelector(`[data-result-id="${l}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}async function x(){return v(!0)}async function v(_=!1){if(f){n.close(),i&&i.close(),await Qi(f,_);let j=app.workspace.getActiveViewOfType(Nf.MarkdownView);if(!j)return;let A=u[l]??0,F=j.editor.offsetToPos(A);F.ch=0,j.editor.setCursor(F),j.editor.scrollIntoView({from:{line:F.line-10,ch:0},to:{line:F.line+10,ch:0}})}}function d(){new cr(app,a??s).open(),n.close()}let b=_=>r(2,a=_.detail),m=(_,j)=>r(5,l=_),g=_=>v(_.ctrlKey),y=_=>{_.button==1&&v(!0)};return t.$$set=_=>{"modal"in _&&r(7,n=_.modal),"parent"in _&&r(0,i=_.parent),"singleFilePath"in _&&r(8,o=_.singleFilePath),"previousQuery"in _&&r(1,s=_.previousQuery)},t.$$.update=()=>{if(t.$$.dirty&2){e:r(2,a=s??"")}if(t.$$.dirty&772){e:(async()=>{a&&(r(9,p=new ur(a)),r(3,f=(await xe.getSuggestions(p,{singleFilePath:o}))[0]??null)),r(5,l=0),await w()})()}if(t.$$.dirty&8){e:if(f){let _=c(f.matches);r(4,u=_.map(j=>Math.round((j.first().offset+j.last().offset)/2)))}}},[i,s,a,f,u,l,v,n,o,p,b,m,g,y]}var Vf=class extends Te{constructor(e){super();Oe(this,e,Tb,Fb,Ae,{modal:7,parent:0,singleFilePath:8,previousQuery:1})}},Hf=Vf;var Ns=class extends ro.Modal{constructor(e){super(e);this.modalEl.replaceChildren(),this.modalEl.addClass("omnisearch-modal","prompt"),this.modalEl.removeClass("modal"),this.modalEl.tabIndex=-1,this.scope.register([],"ArrowDown",s=>{s.preventDefault(),U.emit(te.ArrowDown)}),this.scope.register([],"ArrowUp",s=>{s.preventDefault(),U.emit(te.ArrowUp)});for(let s of[{k:"J",dir:"down"},{k:"K",dir:"up"}])for(let a of["Ctrl","Mod"])this.scope.register([a],s.k,u=>{T.vimLikeNavigationShortcut&&U.emit("arrow-"+s.dir)});for(let s of[{k:"N",dir:"down"},{k:"P",dir:"up"}])for(let a of["Ctrl","Mod"])this.scope.register([a],s.k,u=>{T.vimLikeNavigationShortcut&&U.emit("arrow-"+s.dir)});let r,n,i,o;T.openInNewPane?(r=["Mod"],n=[],i=["Mod","Shift"],o=["Shift"]):(r=[],n=["Mod"],i=["Shift"],o=["Mod","Shift"]),this.scope.register(n,"Enter",s=>{s.preventDefault(),U.emit(te.OpenInNewPane)}),this.scope.register(["Alt"],"Enter",s=>{s.preventDefault(),U.emit(te.InsertLink)}),this.scope.register(i,"Enter",s=>{s.preventDefault(),U.emit(te.CreateNote)}),this.scope.register(o,"Enter",s=>{s.preventDefault(),U.emit(te.CreateNote,{newLeaf:!0})}),this.scope.register(r,"Enter",s=>{cs()||(s.preventDefault(),U.emit(te.Enter))}),this.scope.register(["Alt"],"O",s=>{cs()||(s.preventDefault(),U.emit(te.OpenInBackground))}),this.scope.register([],"Tab",s=>{s.preventDefault(),U.emit(te.Tab)}),this.scope.register(["Alt"],"ArrowDown",s=>{s.preventDefault(),U.emit(te.NextSearchHistory)}),this.scope.register(["Alt"],"ArrowUp",s=>{s.preventDefault(),U.emit(te.PrevSearchHistory)}),this.scope.register(["Ctrl"],"H",s=>{U.emit(hi.ToggleExcerpts)})}},cr=class extends Ns{constructor(e,r){super(e);let n=e.workspace.getActiveViewOfType(ro.MarkdownView)?.editor.getSelection(),i=new Rf({target:this.modalEl,props:{modal:this,previousQuery:n??r}});this.onClose=()=>{i.$destroy()}}},Xr=class extends Ns{constructor(e,r,n="",i){super(e);let o=new Hf({target:this.modalEl,props:{modal:this,singleFilePath:r.path,parent:i,previousQuery:n}});i&&i.containerEl.toggleVisibility(!1),this.onClose=()=>{i&&i.containerEl.toggleVisibility(!0),o.$destroy()}}};var $f=!1,no=[];function Db(t){return t.map(e=>{let{score:r,path:n,basename:i,foundWords:o,matches:s,content:a}=e,u=qr(a,s[0]?.offset??-1);return{score:r,path:n,basename:i,foundWords:o,matches:s.map(f=>({match:f.match,offset:f.offset})),excerpt:u.content}})}async function Ib(t){let e=new ur(t),r=await xe.getSuggestions(e);return Db(r)}function Ob(t){no.push(t),$f&&t()}function kb(t){no=no.filter(e=>e!==t)}function Wf(){$f=!0,no.forEach(t=>t())}var Ks={search:Ib,registerOnIndexed:Ob,unregisterOnIndexed:kb,refreshIndex:eo};var zs=class extends fr.Plugin{async onload(){if(await Ja(this),this.addSettingTab(new as(this)),ls()){console.log("Omnisearch - Plugin disabled");return}await Pb(),await Er.clearOldDatabases(),Mb(this),T.ribbonIcon&&this.addRibbonButton(),U.disable("vault"),U.disable("infile"),U.on("global",hi.ToggleExcerpts,()=>{tr.set(!T.showExcerpt)}),this.addCommand({id:"show-modal",name:"Vault search",callback:()=>{new cr(app).open()}}),this.addCommand({id:"show-modal-infile",name:"In-file search",editorCallback:(e,r)=>{r.file&&new Xr(app,r.file).open()}}),app.workspace.onLayoutReady(async()=>{this.registerEvent(this.app.vault.on("create",e=>{En(e.path)&&(fe("Indexing new file",e.path),xe.addFromPaths([e.path]))})),this.registerEvent(this.app.vault.on("delete",e=>{fe("Removing file",e.path),Fe.removeFromLiveCache(e.path),xe.removeFromPaths([e.path])})),this.registerEvent(this.app.vault.on("modify",async e=>{En(e.path)&&(fe("Updating file",e.path),await Fe.addToLiveCache(e.path),Ff(e))})),this.registerEvent(this.app.vault.on("rename",async(e,r)=>{En(e.path)&&(fe("Renaming file",e.path),Fe.removeFromLiveCache(r),await Fe.addToLiveCache(e.path),xe.removeFromPaths([r]),await xe.addFromPaths([e.path]))})),this.executeFirstLaunchTasks(),await this.populateIndex()})}executeFirstLaunchTasks(){let e="1.10.1";T.welcomeMessage!==e,T.welcomeMessage=e,this.saveData(T)}async onunload(){delete globalThis.omnisearch,await Se.clearCache()}addRibbonButton(){this.ribbonButton=this.addRibbonIcon("search","Omnisearch",e=>{new cr(app).open()})}removeRibbonButton(){this.ribbonButton&&this.ribbonButton.parentNode?.removeChild(this.ribbonButton)}async populateIndex(){console.time("Omnisearch - Indexing total time"),Ot.set(Je.ReadingFiles);let e=app.vault.getFiles().filter(n=>En(n.path));console.log(`Omnisearch - ${e.length} files total`),console.log(`Omnisearch - Cache is ${It()?"enabled":"disabled"}`),It()&&(console.time("Omnisearch - Loading index from cache"),Ot.set(Je.LoadingCache),await xe.loadCache()&&console.timeEnd("Omnisearch - Loading index from cache"));let r=xe.getDiff(e.map(n=>({path:n.path,mtime:n.stat.mtime})));It()&&(r.toAdd.length&&console.log("Omnisearch - Total number of files to add/update: "+r.toAdd.length),r.toRemove.length&&console.log("Omnisearch - Total number of files to remove: "+r.toRemove.length)),r.toAdd.length>=1e3&&It()&&new fr.Notice(`Omnisearch - ${r.toAdd.length} files need to be indexed. Obsidian may experience stutters and freezes during the process`,1e4),Ot.set(Je.IndexingFiles),xe.removeFromPaths(r.toRemove.map(n=>n.path)),await xe.addFromPaths(r.toAdd.map(n=>n.path)),(r.toRemove.length||r.toAdd.length)&&It()&&(Ot.set(Je.WritingCache),T.useCache=!1,await ce(this),await xe.writeToCache(),T.useCache=!0,await ce(this)),console.timeEnd("Omnisearch - Indexing total time"),r.toAdd.length>=1e3&&!fr.Platform.isIosApp&&new fr.Notice("Omnisearch - Your files have been indexed."),Ot.set(Je.Done),Wf()}};async function Pb(){let t=[`${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 e of t)if(await app.vault.adapter.exists(e))try{await app.vault.adapter.remove(e)}catch{}}function Mb(t){t.registerObsidianProtocolHandler("omnisearch",e=>{new cr(app,e.query).open()}),globalThis.omnisearch=Ks,app.plugins.plugins.omnisearch.api=Ks}