obsidian-template/.obsidian/plugins/omnisearch/main.js

46 lines
186 KiB
JavaScript
Raw Normal View History

/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var jc=Object.create;var Fr=Object.defineProperty,Ac=Object.defineProperties,Cc=Object.getOwnPropertyDescriptor,Sc=Object.getOwnPropertyDescriptors,Fc=Object.getOwnPropertyNames,to=Object.getOwnPropertySymbols,Ec=Object.getPrototypeOf,ro=Object.prototype.hasOwnProperty,Dc=Object.prototype.propertyIsEnumerable;var no=(t,e,r)=>e in t?Fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,re=(t,e)=>{for(var r in e||(e={}))ro.call(e,r)&&no(t,r,e[r]);if(to)for(var r of to(e))Dc.call(e,r)&&no(t,r,e[r]);return t},be=(t,e)=>Ac(t,Sc(e)),io=t=>Fr(t,"__esModule",{value:!0});var Tc=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),kc=(t,e)=>{io(t);for(var r in e)Fr(t,r,{get:e[r],enumerable:!0})},Oc=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fc(e))!ro.call(t,n)&&n!=="default"&&Fr(t,n,{get:()=>e[n],enumerable:!(r=Cc(e,n))||r.enumerable});return t},Ce=t=>Oc(io(Fr(t!=null?jc(Ec(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ya=Tc((Xr,xs)=>{(function(t,e){if(typeof Xr=="object"&&typeof xs=="object")xs.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var r=e();for(var n in r)(typeof Xr=="object"?Xr:t)[n]=r[n]}})(typeof self!="undefined"?self:Xr,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,s){r.o(n,i)||Object.defineProperty(n,i,{enumerable:!0,get:s})},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 s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:n}),2&i&&typeof n!="string")for(var o in n)r.d(s,o,function(a){return n[a]}.bind(null,o));return s},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(b){for(var h="",v=0;v<4;v++)h+=n[b>>8*v+4&15]+n[b>>8*v&15];return h},s=function(b){for(var h=b.length,v=0;v<h;v++)b[v]=i(b[v]);return b.join("")},o=function(b,h){return b+h&4294967295},a=function(b,h,v,m,p,_,y){return function(j,A,C){return o(j<<A|j>>>32-A,C)}(h=function(j,A,C,S){return A=o(o(A,j),o(C,S))}(b,h,m,_),p,v)},l=function(b,h,v,m,p,_,y,j){return a(v&m|~v&p,h,v,_,y,j,b)},u=function(b,h,v,m,p,_,y,j){return a(v&p|m&~p,h,v,_,y,j,b)},c=function(b,h,v,m,p,_,y,j){return a(v^m^p,h,v,_,y,j,b)},f=function(b,h,v,m,p,_,y,j){return a(m^(v|~p),h,v,_,y,j,b)},d=function(b,h,v){v===void 0&&(v=o);var m=b[0],p=b[1],_=b[2],y=b[3],j=l.bind(null,v);m=j(m,p,_,y,h[0],7,-680876936),y=j(y,m,p,_,h[1],12,-389564586),_=j(_,y,m,p,h[2],17,606105819),p=j(p,_,y,m,h[3],22,-1044525330),m=j(m,p,_,y,h[4],7,-176418897),y=j(y,m,p,_,h[5],12,1200080426),_=j(_,y,m,p,h[6],17,-1473231341),p=j(p,_,y,m,h[7],22,-45705983),m=j(m,p,_,y,h[8],7,1770035416),y=j(y,m,p,_,h[9],12,-1958414417),_=j(_,y,m,p,h[10],17,-42063),p=j(p,_,y,m,h[11],22,-1990404162),m=j(m,p,_,y,h[12],7,1804603682),y=j(y,m,p,_,h[13],12,-40341101),_=j(_,y,m,p,h[14],17,-1502002290),p=j(p,_,y,m,h[15],22,1236535329);var A=u.bind(null,v);m=A(m,p,_,y,h[1],5,-165796510),y=A(y,m,p,_,h[6],9,-1069501632),_=A(_,y,m,p,h[11],14,643717713),p=A(p,_,y,m,h[0],20,-373897302),m=A(m,p,_,y,h[5],5,-701558691),y=A(y,m,p,_,h[10],9,38016083),_=A(_,y,m,p,h[15],14,-660478335),p=A(p,_,y,m,h[4],20,-405537848),m=A(m,p,_,y,h[9],5,568446438),y=A(y,m,p,_,h[14],9,-1019803690),_=A(_,y,m,p,h[3],14,-187363961),p=A(p,_,y,m,h[8],20,1163531501),m=A(m,p,_,y,h[13],5,-1444681467),y=A(y,m,p,_,h[2],9,-51403784),_=A(_,y,m,p,h[7],14,1735328473),p=A(p,_,y,m,h[12],20,-1926607734);var C=c.bind(null,v);m=C(m,p,_,y,h[5],4,-378558),y=C(y,m,p,_,h[8],11,-2022574463),
`).length),r.split(`
`).slice(e).filter(Ao).map(n=>`
`+n).join("")):""}var Jc=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],Co=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Ii=Jc.concat(Co),Xc={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 rr(t,e){this._e=kt(),this.name=t,this.message=e}er(rr).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Oi(this._e,2))}},toString:function(){return this.name+": "+this.message}});function So(t,e){return t+". Errors: "+Object.keys(e).map(r=>e[r].toString()).filter((r,n,i)=>i.indexOf(r)===n).join(`
`)}function mn(t,e,r,n){this._e=kt(),this.failures=e,this.failedKeys=n,this.successCount=r,this.message=So(t,e)}er(mn).from(rr);function Rr(t,e){this._e=kt(),this.name="BulkError",this.failures=Object.keys(e).map(r=>e[r]),this.failuresByPos=e,this.message=So(t,e)}er(Rr).from(rr);var Mi=Ii.reduce((t,e)=>(t[e]=e+"Error",t),{}),Zc=rr,L=Ii.reduce((t,e)=>{var r=e+"Error";function n(i,s){this._e=kt(),this.name=r,i?typeof i=="string"?(this.message=`${i}${s?`
`+s:""}`,this.inner=s||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=Xc[e]||r,this.inner=null)}return er(n).from(Zc),t[e]=n,t},{});L.Syntax=SyntaxError;L.Type=TypeError;L.Range=RangeError;var Fo=Co.reduce((t,e)=>(t[e+"Error"]=L[e],t),{});function ef(t,e){if(!t||t instanceof rr||t instanceof TypeError||t instanceof SyntaxError||!t.name||!Fo[t.name])return t;var r=new Fo[t.name](e||t.message,t);return"stack"in t&&We(r,"stack",{get:function(){return this.inner.stack}}),r}var gn=Ii.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=L[e]),t),{});gn.ModifyError=mn;gn.DexieError=rr;gn.BulkError=Rr;function Y(){}function Br(t){return t}function tf(t,e){return t==null||t===Br?e:function(r){return e(t(r))}}function Ot(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function rf(t,e){return t===Y?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 s=e.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?Ot(n,this.onsuccess):n),i&&(this.onerror=this.onerror?Ot(i,this.onerror):i),s!==void 0?s:r}}function nf(t,e){return t===Y?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?Ot(r,this.onsuccess):r),n&&(this.onerror=this.onerror?Ot(n,this.onerror):n)}}function sf(t,e){return t===Y?e:function(r){var n=t.apply(this,arguments);we(r,n);var i=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?Ot(i,this.onsuccess):i),s&&(this.onerror=this.onerror?Ot(s,this.onerror):s),n===void 0?o===void 0?void 0:o:we(n,o)}}function of(t,e){return t===Y?e:function(){return e.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function Pi(t,e){return t===Y?e:function(){var r=t.apply(this,arguments);if(r&&typeof r.then=="function"){for(var n=this,i=arguments.length,s=new Array(i);i--;)s[i]=arguments[i];return r.then(function(){return e.apply(n,s)})}return e.apply(this,arguments)}}var Lr={},af=100,lf=20,Eo=100,[Ri,yn,Bi]=typeof Promise=="undefined"?[]:(()=>{let t=Promise.resolve();if(typeof crypto=="undefined"||!crypto.subtle)return[t,Ir(t),t];let e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Ir(e),t]})(),Do=yn&&yn.then,vn=Ri&&Ri.constructor,Li=!!Bi,Ni=!1,uf=Bi?()=>{Bi.then(wn)}:J.setImmediate?setImmediate.bind(null,wn):J.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{wn(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(wn,0)},Nr=function(t,e){Kr.push([t,e]),_n&&(uf(),_n=!1)},Ki=!0,_n=!0,It=[],bn=[],zi=null,Vi=Br,nr={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:No,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{No(t[0],t[1])}catch{}})}},R=nr,Kr=[],Mt=0,xn=[];function O(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=Y,this._lib=!1;var e=this._PSD=R;if(Ke&&(this._stackHolder=kt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Lr)throw new TypeError("Not a function");this._state=arguments[1],this._value=arguments[2],this._state===!1&&$i(this,this._value);return}this._state=null,this._value=null,++e.ref,ko(this,t)}var Hi={get:function(){var t=R,e=Cn;function r(n,i){var s=!t.global&&(t!==R||e!==Cn);let o=s&&!qe();var a=new O((l,u)=>{Wi(this,new To(Fn(n,t,s,o),Fn(i,t,s,o),l,u,t))});return Ke&&Mo(a,this),a}return r.prototype=Lr,r},set:function(t){We(this,"then",t&&t.prototype===Lr?Hi:{get:function(){return t},set:Hi.set})}};Zt(O.prototype,{then:Hi,_then:function(t,e){Wi(this,new To(null,null,t,e,R))},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):jn(n)):this.then(null,n=>n&&n.name===e?r(n):jn(n))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),j
From previous: `);return this._state!==null&&(this._stack=e),e}finally{Ni=!1}}},timeout:function(t,e){return t<1/0?new O((r,n)=>{var i=setTimeout(()=>n(new L.Timeout(e)),t);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}});typeof Symbol!="undefined"&&Symbol.toStringTag&&We(O.prototype,Symbol.toStringTag,"Dexie.Promise");nr.env=Po();function To(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}Zt(O,{all:function(){var t=Ge.apply(null,arguments).map(Sn);return new O(function(e,r){t.length===0&&e([]);var n=t.length;t.forEach((i,s)=>O.resolve(i).then(o=>{t[s]=o,--n||e(t)},r))})},resolve:t=>{if(t instanceof O)return t;if(t&&typeof t.then=="function")return new O((r,n)=>{t.then(r,n)});var e=new O(Lr,!0,t);return Mo(e,zi),e},reject:jn,race:function(){var t=Ge.apply(null,arguments).map(Sn);return new O((e,r)=>{t.map(n=>O.resolve(n).then(e,r))})},PSD:{get:()=>R,set:t=>R=t},totalEchoes:{get:()=>Cn},newPSD:lt,usePSD:sr,scheduler:{get:()=>Nr,set:t=>{Nr=t}},rejectionMapper:{get:()=>Vi,set:t=>{Vi=t}},follow:(t,e)=>new O((r,n)=>lt((i,s)=>{var o=R;o.unhandleds=[],o.onunhandled=s,o.finalize=Ot(function(){ff(()=>{this.unhandleds.length===0?i():s(this.unhandleds[0])})},o.finalize),t()},e,r,n))});vn&&(vn.allSettled&&We(O,"allSettled",function(){let t=Ge.apply(null,arguments).map(Sn);return new O(e=>{t.length===0&&e([]);let r=t.length,n=new Array(r);t.forEach((i,s)=>O.resolve(i).then(o=>n[s]={status:"fulfilled",value:o},o=>n[s]={status:"rejected",reason:o}).then(()=>--r||e(n)))})}),vn.any&&typeof AggregateError!="undefined"&&We(O,"any",function(){let t=Ge.apply(null,arguments).map(Sn);return new O((e,r)=>{t.length===0&&r(new AggregateError([]));let n=t.length,i=new Array(n);t.forEach((s,o)=>O.resolve(s).then(a=>e(a),a=>{i[o]=a,--n||r(new AggregateError(i))}))})}));function ko(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&&zr();r&&typeof r.then=="function"?ko(t,(i,s)=>{r instanceof O?r._then(i,s):r.then(i,s)}):(t._state=!0,t._value=r,Oo(t)),n&&Vr()}},$i.bind(null,t))}catch(r){$i(t,r)}}function $i(t,e){if(bn.push(e),t._state===null){var r=t._lib&&zr();e=Vi(e),t._state=!1,t._value=e,Ke&&e!==null&&typeof e=="object"&&!e._promise&&$c(()=>{var n=Fi(e,"stack");e._promise=t,We(e,"stack",{get:()=>Ni?n&&(n.get?n.get.apply(e):n.value):t.stack})}),df(t),Oo(t),r&&Vr()}}function Oo(t){var e=t._listeners;t._listeners=[];for(var r=0,n=e.length;r<n;++r)Wi(t,e[r]);var i=t._PSD;--i.ref||i.finalize(),Mt===0&&(++Mt,Nr(()=>{--Mt==0&&Ui()},[]))}function Wi(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,++Mt,Nr(cf,[r,t,e])}function cf(t,e,r){try{zi=e;var n,i=e._value;e._state?n=t(i):(bn.length&&(bn=[]),n=t(i),bn.indexOf(i)===-1&&hf(e)),r.resolve(n)}catch(s){r.reject(s)}finally{zi=null,--Mt==0&&Ui(),--r.psd.ref||r.psd.finalize()}}function Io(t,e,r){if(e.length===r)return e;var n="";if(t._state===!1){var i=t._value,s,o;i!=null?(s=i.name||"Error",o=i.message||i,n=Oi(i,0)):(s=i,o=""),e.push(s+(o?": "+o:"")+n)}return Ke&&(n=Oi(t._stackHolder,2),n&&e.indexOf(n)===-1&&e.push(n),t._prev&&Io(t._prev,e,r)),e}function Mo(t,e){var r=e?e._numPrev+1:0;r<af&&(t._prev=e,t._numPrev=r)}function wn(){zr()&&Vr()}function zr(){var t=Ki;return Ki=!1,_n=!1,t}function Vr(){var t,e,r;do for(;Kr.length>0;)for(t=Kr,Kr=[],r=t.length,e=0;e<r;++e){var n=t[e];n[0].apply(null,n[1])}while(Kr.length>0);Ki=!0,_n=!0}function Ui(){var t=It;It=[],t.forEach(n=>{n._PSD.onunhandled.call(null,n._value,n)});for(var e=xn.slice(0),r=e.length;r;)e[--r]()}function ff(t){function e(){t(),xn.splice(xn.indexOf(e),1)}xn.push(e),++Mt,Nr(()=>{--Mt==0&&Ui()},[])}function df(t){It.some(e=>e._value===t._value)||It.push(t)}function hf(t){for(var e=It.length;e;)if(It[--e]._value===t._value){It.splice(e,1);return}}function jn(t){return new O(Lr,!1,t)}function Z(t,e){var r=R;return function(){var n=zr(),i=R;try{return ut(r,!0),t.apply
<iframe src="https://github.com/sponsors/scambier/button" title="Sponsor scambier" height="35" width="116" style="border: 0;"></iframe>
<a href='https://ko-fi.com/B0B6LQ2C' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi2.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
`,new G.Setting(e).setName("Indexing").setHeading();let n=new DocumentFragment;He()?n.createSpan({},c=>{c.innerHTML=`\u{1F44D} You have installed <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a>, Omnisearch will use it to index PDFs and images.
<br />Text extraction only works on desktop, but the cache can be synchronized with your mobile device.`}):n.createSpan({},c=>{c.innerHTML='\u26A0\uFE0F Omnisearch requires <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a> to index PDFs and images.'}),new G.Setting(e).setDesc(n);let i=new DocumentFragment;i.createSpan({},c=>{c.innerHTML="Include PDFs in search results"}),new G.Setting(e).setName(`PDFs Indexing ${He()?"":"\u26A0\uFE0F Disabled"}`).setDesc(i).addToggle(c=>c.setValue(E.PDFIndexing).onChange(async f=>{E.PDFIndexing=f,await ue(this.plugin)})).setDisabled(!He());let s=new DocumentFragment;s.createSpan({},c=>{c.innerHTML="Include images in search results"}),new G.Setting(e).setName(`Images Indexing ${He()?"":"\u26A0\uFE0F Disabled"}`).setDesc(s).addToggle(c=>c.setValue(E.imagesIndexing).onChange(async f=>{E.imagesIndexing=f,await ue(this.plugin)})).setDisabled(!He());let o=new DocumentFragment;o.createSpan({},c=>{c.innerHTML=`In addition to standard <code>md</code> files, Omnisearch can also index other <strong style="color: var(--text-accent)">plaintext</strong> files.<br/>
Add extensions separated by a space, without the dot. Example: "<code>txt org</code>".<br />
\u26A0\uFE0F <span style="color: var(--text-accent)">Using extensions of non-plaintext files (like .docx or .pptx) WILL cause crashes,
because Omnisearch will try to index their content.</span><br />
<strong style="color: var(--text-accent)">Needs a restart to fully take effect.</strong>`}),new G.Setting(e).setName("Additional files to index").setDesc(o).addText(c=>{c.setValue(E.indexedFileTypes.join(" ")).setPlaceholder("Example: txt org").onChange(async f=>{E.indexedFileTypes=f.split(" "),await ue(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 freeze in Obsidian. This option will disable itself if it happens.").addToggle(c=>c.setValue(E.useCache).onChange(async f=>{E.useCache=f,await ue(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(E.hideExcluded).onChange(async f=>{E.hideExcluded=f,await ue(this.plugin)}));let a=new DocumentFragment;a.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".<br/>
\u26A0\uFE0F <span style="color: var(--text-accent)">You probably should <strong>NOT</strong> disable this.</span><br>
\u26A0\uFE0F <span style="color: var(--text-accent)">Changing this setting will clear the cache.</span><br>
<strong style="color: var(--text-accent)">Needs a restart to fully take effect.</strong>
`}),new G.Setting(e).setName("Ignore diacritics").setDesc(a).addToggle(c=>c.setValue(E.ignoreDiacritics).onChange(async f=>{await Ee.clearCache(),E.ignoreDiacritics=f,await ue(this.plugin)}));let l=new DocumentFragment;l.createSpan({},c=>{c.innerHTML=`Enable this if you want to be able to search for CamelCaseWords as separate words.<br/>
\u26A0\uFE0F <span style="color: var(--text-accent)">Changing this setting will clear the cache.</span><br>
<strong style="color: var(--text-accent)">Needs a restart to fully take effect.</strong>
`}),new G.Setting(e).setName("Split CamelCaseWords").setDesc(l).addToggle(c=>c.setValue(E.splitCamelCase).onChange(async f=>{await Ee.clearCache(),E.splitCamelCase=f,await ue(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(E.simpleSearch).onChange(async f=>{E.simpleSearch=f,await ue(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(E.ribbonIcon).onChange(async f=>{E.ribbonIcon=f,await ue(this.plugin),f?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(E.showExcerpt).onChange(async f=>{Lt.set(f)})),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(E.renderLineReturnInExcerpts).onChange(async f=>{E.renderLineReturnInExcerpts=f,await ue(this.plugin)})),new G.Setting(e).setName("Show previous query results").setDesc("Re-executes the previous query when opening Omnisearch.").addToggle(c=>c.setValue(E.showPreviousQueryResults).onChange(async f=>{E.showPreviousQueryResults=f,await ue(this.plugin)}));let u=new DocumentFragment;if(u.createSpan({},c=>{c.innerHTML=`Shows a button next to the search input, to create a note.
Acts the same as the <code>shift \u21B5</code> shortcut, can be useful for mobile device users.`}),new G.Setting(e).setName('Show "Create note" button').setDesc(u).addToggle(c=>c.setValue(E.showCreateButton).onChange(async f=>{E.showCreateButton=f,await ue(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(E.highlight).onChange(async f=>{E.highlight=f,await ue(this.plugin)})),new G.Setting(e).setName("Results weighting").setHeading(),new G.Setting(e).setName(`File name & declared aliases (default: ${Nt.weightBasename})`).addSlider(c=>this.weightSlider(c,"weightBasename")),new G.Setting(e).setName(`File directory (default: ${Nt.weightDirectory})`).addSlider(c=>this.weightSlider(c,"weightDirectory")),new G.Setting(e).setName(`Headings level 1 (default: ${Nt.weightH1})`).addSlider(c=>this.weightSlider(c,"weightH1")),new G.Setting(e).setName(`Headings level 2 (default: ${Nt.weightH2})`).addSlider(c=>this.weightSlider(c,"weightH2")),new G.Setting(e).setName(`Headings level 3 (default: ${Nt.weightH3})`).addSlider(c=>this.weightSlider(c,"weightH3")),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(E.verboseLogging).onChange(async f=>{E.verboseLogging=f,await ue(this.plugin)})),ht()){new G.Setting(e).setName("Danger Zone").setHeading();let c=new DocumentFragment;c.createSpan({},f=>{f.innerHTML=`Erase all Omnisearch cache data.
Use this if Omnisearch results are inconsistent, missing, or appear outdated.<br>
<strong style="color: var(--text-accent)">Needs a restart to fully take effect.</strong>`}),new G.Setting(e).setName("Clear cache data").setDesc(c).addButton(f=>{f.setButtonText("Clear cache"),f.onClick(async()=>{await Ee.clearCache(),new G.Notice("Omnisearch - Cache cleared. Please restart Obsidian.")})})}}weightSlider(e,r){e.setLimits(1,5,.1).setValue(E[r]).setDynamicTooltip().onChange(n=>{E[r]=n,ue(this.plugin)})}},Nt={useCache:!0,hideExcluded:!1,ignoreDiacritics:!0,indexedFileTypes:[],PDFIndexing:!1,imagesIndexing:!1,splitCamelCase:!1,ribbonIcon:!0,showExcerpt:!0,renderLineReturnInExcerpts:!0,showCreateButton:!1,highlight:!0,showPreviousQueryResults:!0,simpleSearch:!1,weightBasename:3,weightDirectory:2,weightH1:1.5,weightH2:1.3,weightH3:1.1,welcomeMessage:"",verboseLogging:!1},E=Object.assign({},Nt);async function ua(t){E=Object.assign({},Nt,await t.loadData()),Lt.set(E.showExcerpt)}async function ue(t){await t.saveData(E)}var ca=Ce(require("obsidian"));var fa=/^"|"$|^'|'$/g,da=/[\u4e00-\u9fa5]/,_s=/(?:^|\s)\.(\w+)/g,ha=100,Jr=300,pa=`suggestion-highlight omnisearch-highlight ${E.highlight?"omnisearch-default-highlight":""}`,$=new Si,Ln={ToggleExcerpts:"toggle-excerpts"},Pe=(s=>(s[s.Done=0]="Done",s[s.LoadingCache=1]="LoadingCache",s[s.ReadingFiles=2]="ReadingFiles",s[s.IndexingFiles=3]="IndexingFiles",s[s.WritingCache=4]="WritingCache",s))(Pe||{});var pt=hn(0),ma=!1;function bs(t){ma=t}function ga(){return ma}function Nn(){return app.plugins.plugins["cm-chs-patch"]}function He(){return app.plugins?.plugins?.["text-extractor"]?.api}function ht(){return!ca.Platform.isIosApp&&E.useCache}var mt=/[|\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;var Ea=Ce(require("obsidian"));var Ze=Ce(require("obsidian"));var va=Ce(require("crypto")),_a=Ce(ya());function gt(...t){return t[1]!==null&&t[1]!==void 0&&t[2]!==null&&t[2]!==void 0?`${t[1]}<span class="${pa}">${t[2]}</span>`:"&lt;no content&gt;"}function fd(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function ba(t){let e=t.split("/");return e.pop(),e.join("/")}function dd(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"[$&]")}function yt(t){if(!t.length)return/^$/g;let e="("+(Nn()?"":E.splitCamelCase?`^|${mt.source}|[A-Z]`:`^|${mt.source}`)+`)(${t.map(n=>dd(n)).join("|")})`;return new RegExp(`${e}`,"giu")}function Kn(t,e){return t.headings?.filter(r=>r.level===e).map(r=>r.heading)??[]}function zn(t,e){return(t+e)%e}function ur(t,e){try{let r=e??-1,n=Math.max(0,r-ha),i=Math.min(t.length,r+Jr);if(r>-1?t=(n>0?"\u2026":"")+t.slice(n,i).trim()+(i<t.length-1?"\u2026":""):t=t.slice(0,Jr),E.renderLineReturnInExcerpts){let s=new RegExp(/(?:\r\n|\r|\n)/g);t=t.split(s).filter(a=>a).join(`
`);let o=t.lastIndexOf(`
`,r-n);o>0&&(t=t.slice(o))}return t=fd(t),E.renderLineReturnInExcerpts&&(t=t.trim().replaceAll(`
`,"<br>")),t}catch(r){return new Ze.Notice("Omnisearch - Error while creating excerpt, see developer console"),console.error("Omnisearch - Error while creating excerpt"),console.error(r),""}}function xa(t){return t.replace(fa,"")}function ws(t){return t.replace(/(\*|_)+(.+?)(\*|_)+/g,(e,r,n)=>n)}function wa(t){return t?.frontmatter?(0,Ze.parseFrontMatterAliases)(t.frontmatter)??[]:[]}function ja(t){let e=t?(0,Ze.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 et(t){return t==null?"":(t=t.replaceAll("`","[__omnisearch__backtick__]"),t=t.normalize("NFD").replace(/\p{Diacritic}/gu,""),t=t.replaceAll("[__omnisearch__backtick__]","`"),t)}function Vn(){return Ze.Platform.isMacOS?"\u2318":"ctrl"}function Zr(t){let e=!!He(),r=e&&E.PDFIndexing,n=e&&E.imagesIndexing;return js(t)||tn(t)||r&&en(t)||n&&Hn(t)}function Hn(t){let e=Kt(t);return e==="png"||e==="jpg"||e==="jpeg"}function en(t){return Kt(t)==="pdf"}function js(t){return[...E.indexedFileTypes,"md"].some(e=>t.endsWith(`.${e}`))}function tn(t){return t.endsWith(".canvas")}function Kt(t){let e=t.split(".");return e[e.length-1]??""}function Aa(t){return Ze.Platform.isMobileApp?(0,_a.md5)(t.toString()):(0,va.createHash)("md5").update(t).digest("hex")}function Ca(t,e){let r=[],n=0,i=t.length;for(;n<i;)r.push(t.slice(n,n+=e));return r}function Sa(t){return t.replace(/([a-z](?=[A-Z]))/g,"$1 ").split(" ")}function ie(...t){Fa(console.log,...t)}function $n(...t){Fa(console.warn,...t)}function Fa(t,...e){if(E.verboseLogging){let r=new Date,n=`${r.getMinutes()}:${r.getSeconds()}:${r.getMilliseconds()}`;t("Omnisearch -",n+" -",...e)}}async function hd(t){let e=app.vault.getFiles().find(s=>s.path===t);if(!e)throw new Error(`Invalid file path: "${t}"`);let r=null,n=He();if(js(t))r=await app.vault.cachedRead(e);else if(tn(t)){let s=JSON.parse(await app.vault.cachedRead(e)),o=[];for(let a of s.nodes)a.type==="text"?o.push(a.text):a.type==="file"&&o.push(a.file);for(let a of s.edges.filter(l=>!!l.label))o.push(a.label);r=o.join(`\r
`)}else if(n?.canFileBeExtracted(t))r=await n.extractText(e);else throw new Error(`Unsupported file type: "${t}"`);r==null&&(console.warn(`Omnisearch: ${r} content for file`,e.path),r=""),r=et(r);let i=app.metadataCache.getFileCache(e);if(i&&i.frontmatter?.["excalidraw-plugin"]){let s=i.sections?.filter(o=>o.type==="comment")??[];for(let{start:o,end:a}of s.map(l=>l.position))r=r.substring(0,o.offset-1)+r.substring(a.offset)}return{basename:et(e.basename),content:r,path:e.path,mtime:e.stat.mtime,tags:ja(i),aliases:wa(i).join(""),headings1:i?Kn(i,1).join(" "):"",headings2:i?Kn(i,2).join(" "):"",headings3:i?Kn(i,3).join(" "):""}}var Da=class{constructor(){this.nextQueryIsEmpty=!1;this.documents=new Map}async addToLiveCache(e){try{let r=await hd(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):(ie("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 Ee.searchHistory.toArray();r=r.filter(n=>n.query!==e).reverse(),r.unshift({query:e}),r=r.slice(0,10),await Ee.searchHistory.clear(),await Ee.searchHistory.bulkAdd(r)}async getSearchHistory(){let e=(await Ee.searchHistory.toArray()).reverse().map(r=>r.query);return this.nextQueryIsEmpty&&e.unshift(""),e}getDocumentsChecksum(e){return Aa(JSON.stringify(e.sort((r,n)=>r.path<n.path?-1:r.path>n.path?1:0)))}async getMinisearchCache(){try{return(await Ee.minisearch.toArray())[0]}catch(e){return new Ea.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,s])=>({path:i,mtime:s}));await Ee.minisearch.clear(),await Ee.minisearch.add({date:new Date().toISOString(),paths:n,data:e.toJSON()}),console.log("Omnisearch - Search cache written")}},de=new Da;function pd(t){let e,r,n,i,s,o,a,l,u=t[9].default,c=Gt(u,t,t[8],null);return{c(){e=I("div"),r=I("div"),n=I("input"),s=U(),c&&c.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(f,d){z(f,e,d),k(e,r),k(r,n),t[10](n),_i(n,t[1]),k(e,s),c&&c.m(e,null),o=!0,a||(l=[Te(n,"input",t[11]),uo(i=t[3].call(null,n)),Te(n,"compositionend",t[12]),Te(n,"compositionstart",t[13]),Te(n,"input",t[4])],a=!0)},p(f,[d]){(!o||d&1)&&B(n,"placeholder",f[0]),d&2&&n.value!==f[1]&&_i(n,f[1]),c&&c.p&&(!o||d&256)&&Qt(c,u,f,f[8],o?qt(u,f[8],d,null):Yt(f[8]),null)},i(f){o||(q(c,f),o=!0)},o(f){Q(c,f),o=!1},d(f){f&&K(e),t[10](null),c&&c.d(f),a=!1,Re(l)}}}function md(t,e,r){let{$$slots:n={},$$scope:i}=e,{initialValue:s=""}=e,o=!1,{placeholder:a=""}=e,l="",u,c=wi();function f(v){r(1,l=v)}function d(v){ot().then(()=>(u.focus(),ot())).then(()=>{u.select()})}let g=(0,Ta.debounce)(()=>{de.addToSearchHistory(""),c("input",l)},250);function w(v){$e[v?"unshift":"push"](()=>{u=v,r(2,u)})}function x(){l=this.value,r(1,l),r(5,s),r(7,o)}let b=v=>bs(!1),h=v=>bs(!0);return t.$$set=v=>{"initialValue"in v&&r(5,s=v.initialValue),"placeholder"in v&&r(0,a=v.placeholder),"$$scope"in v&&r(8,i=v.$$scope)},t.$$.update=()=>{if(t.$$.dirty&162){e:s&&!o&&!l&&(r(7,o=!0),r(1,l=s),d())}},[a,l,u,d,g,s,f,o,i,n,w,x,b,h]}var ka=class extends pe{constructor(e){super();ye(this,e,md,pd,fe,{initialValue:5,placeholder:0,setInputValue:6})}get setInputValue(){return this.$$.ctx[6]}},Wn=ka;function gd(t){let e,r,n,i,s=t[1].default,o=Gt(s,t,t[0],null);return{c(){e=I("div"),o&&o.c(),B(e,"class","prompt-results")},m(a,l){z(a,e,l),o&&o.m(e,null),r=!0,n||(i=Te(e,"mousedown",yd),n=!0)},p(a,[l]){o&&o.p&&(!r||l&1)&&Qt(o,s,a,a[0],r?qt(s,a[0],l,null):Yt(a[0]),nu
`),i&&i.c(),n=Jt()},m(s,o){z(s,e,o),i&&i.m(s,o),z(s,n,o)},p(s,o){o[0]&2&&(r=E.simpleSearch&&s[1].split(mt).some(uc)),r?i||(i=lc(s),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},d(s){s&&K(e),i&&i.d(s),s&&K(n)}}}function lc(t){let e,r,n;return{c(){e=I("br"),r=U(),n=I("span"),n.textContent=`You have enabled "Simpler Search" in the settings, try to type more
characters.`,ke(n,"color","var(--text-accent)"),ke(n,"font-size","small")},m(i,s){z(i,e,s),z(i,r,s),z(i,n,s)},d(i){i&&K(e),i&&K(r),i&&K(n)}}}function dy(t){let e,r,n,i=t[2],s=[];for(let c=0;c<i.length;c+=1)s[c]=ac(sc(t,i,c));let o=c=>Q(s[c],1,1,()=>{s[c]=null});function a(c,f){if(!c[2].length&&c[1]&&!c[4])return fy;if(c[4])return cy}let l=a(t,[-1,-1]),u=l&&l(t);return{c(){for(let c=0;c<s.length;c+=1)s[c].c();e=U(),r=I("div"),u&&u.c(),ke(r,"text-align","center")},m(c,f){for(let d=0;d<s.length;d+=1)s[d].m(c,f);z(c,e,f),z(c,r,f),u&&u.m(r,null),n=!0},p(c,f){if(f[0]&197){i=c[2];let d;for(d=0;d<i.length;d+=1){let g=sc(c,i,d);s[d]?(s[d].p(g,f),q(s[d],1)):(s[d]=ac(g),s[d].c(),q(s[d],1),s[d].m(e.parentNode,e))}for(Dt(),d=i.length;d<s.length;d+=1)o(d);Tt()}l===(l=a(c,f))&&u?u.p(c,f):(u&&u.d(1),u=l&&l(c),u&&(u.c(),u.m(r,null)))},i(c){if(!n){for(let f=0;f<i.length;f+=1)q(s[f]);n=!0}},o(c){s=s.filter(Boolean);for(let f=0;f<s.length;f+=1)Q(s[f]);n=!1},d(c){un(s,c),c&&K(e),c&&K(r),u&&u.d()}}}function hy(t){let e,r,n,i,s,o,a,l,u,c,f,d,g,w,x,b,h,v,m,p,_,y,j,A,C,S,D,P,T,N={initialValue:t[1],placeholder:"Omnisearch - Vault",$$slots:{default:[uy]},$$scope:{ctx:t}};e=new Wn({props:N}),t[12](e),e.$on("input",t[13]);let H=t[3]&&oc(t);return i=new Un({props:{$$slots:{default:[dy]},$$scope:{ctx:t}}}),{c(){Fe(e.$$.fragment),r=U(),H&&H.c(),n=U(),Fe(i.$$.fragment),s=U(),o=I("div"),a=I("div"),a.innerHTML='<span class="prompt-instruction-command">\u2191\u2193</span><span>to navigate</span>',l=U(),u=I("div"),u.innerHTML=`<span class="prompt-instruction-command">alt \u2191\u2193</span>
<span>to cycle history</span>`,c=U(),f=I("div"),f.innerHTML='<span class="prompt-instruction-command">\u21B5</span><span>to open</span>',d=U(),g=I("div"),g.innerHTML=`<span class="prompt-instruction-command">tab</span>
<span>to switch to In-File Search</span>`,w=U(),x=I("div"),b=I("span"),b.textContent=`${Vn()} \u21B5`,h=U(),v=I("span"),v.textContent="to open in a new pane",m=U(),p=I("div"),p.innerHTML=`<span class="prompt-instruction-command">shift \u21B5</span>
<span>to create</span>`,_=U(),y=I("div"),y.innerHTML=`<span class="prompt-instruction-command">ctrl shift \u21B5</span>
<span>to create in a new pane</span>`,j=U(),A=I("div"),A.innerHTML=`<span class="prompt-instruction-command">alt \u21B5</span>
<span>to insert a link</span>`,C=U(),S=I("div"),S.innerHTML=`<span class="prompt-instruction-command">ctrl+h</span>
<span>to toggle excerpts</span>`,D=U(),P=I("div"),P.innerHTML='<span class="prompt-instruction-command">esc</span><span>to close</span>',B(a,"class","prompt-instruction"),B(u,"class","prompt-instruction"),B(f,"class","prompt-instruction"),B(g,"class","prompt-instruction"),B(b,"class","prompt-instruction-command"),B(x,"class","prompt-instruction"),B(p,"class","prompt-instruction"),B(y,"class","prompt-instruction"),B(A,"class","prompt-instruction"),B(S,"class","prompt-instruction"),B(P,"class","prompt-instruction"),B(o,"class","prompt-instructions")},m(M,F){xe(e,M,F),z(M,r,F),H&&H.m(M,F),z(M,n,F),xe(i,M,F),z(M,s,F),z(M,o,F),k(o,a),k(o,l),k(o,u),k(o,c),k(o,f),k(o,d),k(o,g),k(o,w),k(o,x),k(x,b),k(x,h),k(x,v),k(o,m),k(o,p),k(o,_),k(o,y),k(o,j),k(o,A),k(o,C),k(o,S),k(o,D),k(o,P),T=!0},p(M,F){let V={};F[0]&2&&(V.initialValue=M[1]),F[1]&4&&(V.$$scope={dirty:F,ctx:M}),e.$set(V),M[3]?H?H.p(M,F):(H=oc(M),H.c(),H.m(n.parentNode,n)):H&&(H.d(1),H=null);let te={};F[0]&23|F[1]&4&&(te.$$scope={dirty:F,ctx:M}),i.$set(te)},i(M){T||(q(e.$$.fragment,M),q(i.$$.fragment,M),T=!0)},o(M){Q(e.$$.fragment,M),Q(i.$$.fragment,M),T=!1},d(M){t[12](null),ge(e,M),M&&K(r),H&&H.d(M),M&&K(n),ge(i,M),M&&K(s),M&&K(o)}}}var uc=t=>t.length<3;function py(t,e,r){let n,i;ln(t,pt,F=>r(11,i=F));let{modal:s}=e,{previousQuery:o}=e,a=0,l=0,u,c=[],f,d="",g=!0,w;Tr(async()=>{$.enable("vault"),$.on("vault","enter",m),$.on("vault","create-note",A),$.on("vault","open-in-new-pane",p),$.on("vault","insert-link",C),$.on("vault","tab",S),$.on("vault","arrow-up",()=>D(-1)),$.on("vault","arrow-down",()=>D(1)),$.on("vault","prev-search-history",x),$.on("vault","next-search-history",b),await mi(),E.showPreviousQueryResults&&r(9,o=(await de.getSearchHistory())[0])}),kr(()=>{$.disable("vault")});async function x(){let F=(await de.getSearchHistory()).filter(V=>V);++l>=F.length&&(l=0),r(1,u=F[l]),w?.setInputValue(u)}async function b(){let F=(await de.getSearchHistory()).filter(V=>V);--l<0&&(l=F.length?F.length-1:0),r(1,u=F[l]),w?.setInputValue(u)}async function h(){f=new zt(u),r(2,c=await ce.getSuggestions(f)),r(0,a=0),await P()}function v(F){!n||(F?.ctrlKey?p():m(),s.close())}function m(){!n||(y(n),s.close())}function p(){!n||(y(n,!0),s.close())}function _(){u&&de.addToSearchHistory(u)}function y(F,V=!1){_(),Gn(F,V)}async function j(F){await A()}async function A(F){if(u){try{await Ia(u,F?.newLeaf)}catch(V){new St.Notice(V.message);return}s.close()}}function C(){if(!n)return;let F=app.vault.getMarkdownFiles().find(st=>st.path===n.path),V=app.workspace.getActiveFile(),te=app.workspace.getActiveViewOfType(St.MarkdownView);if(!te?.editor){new St.Notice("Omnisearch - Error - No active editor",3e3);return}let Wt;F&&V?Wt=app.fileManager.generateMarkdownLink(F,V.path):Wt=`[[${n.basename}.${Kt(n.path)}]]`;let it=te.editor.getCursor();te.editor.replaceRange(Wt,it,it),it.ch+=Wt.length,te.editor.setCursor(it),s.close()}function S(){if(!(n&&(en(n?.path)||!n?.matches.length)))if(_(),s.close(),n){let F=app.vault.getAbstractFileByPath(n.path);F&&F instanceof St.TFile&&new Cr(app,F,u).open()}else{let F=app.workspace.getActiveViewOfType(St.MarkdownView);F&&new Cr(app,F.file,u).open()}}function D(F){r(0,a=zn(a+F,c.length)),P()}async function P(){await ot(),n&&document.querySelector(`[data-result-id="${n.path}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}function T(F){$e[F?"unshift":"push"](()=>{w=F,r(5,w)})}let N=F=>r(1,u=F.detail),H=(F,V)=>r(0,a=F),M=F=>{F.button==1&&p()};return t.$$set=F=>{"modal"in F&&r(10,s=F.modal),"previousQuery"in F&&r(9,o=F.previousQuery)},t.$$.update=()=>{if(t.$$.dirty[0]&514){e:r(1,u=u??o)}if(t.$$.dirty[0]&2){e:u?(r(4,g=!0),h().then(()=>{r(4,g=!1)})):(r(4,g=!1),r(2,c=[]))}if(t.$$.dirty[0]&5){e:n=c[a]}if(t.$$.dirty[0]&2048){e:switch(i){case Pe.LoadingCache:r(3,d="Loading cache...");break;case Pe.ReadingFiles:r(3,d="Reading files...");break;case Pe.IndexingFiles:r(3,d="Indexing files...");break;case Pe.WritingCache:h(),r(3,d="Updating cache...");break;default:h(),r(3,d="");break}}},[a,u,c,d,g,w,v,p,j,o,s,i,T,N,H,M]}var cc=class extends pe{constructor(e){super();ye
<span>to switch to Vault Search</span>`,f=U(),d=I("div"),g=I("span"),g.textContent="esc",w=U(),j.c(),x=U(),b=I("div"),h=I("span"),h.textContent=`${Vn()} \u21B5`,v=U(),m=I("span"),m.textContent="to open in a new pane",B(o,"class","prompt-instruction"),B(l,"class","prompt-instruction"),B(c,"class","prompt-instruction"),B(g,"class","prompt-instruction-command"),B(d,"class","prompt-instruction"),B(h,"class","prompt-instruction-command"),B(b,"class","prompt-instruction"),B(s,"class","prompt-instructions")},m(A,C){xe(e,A,C),z(A,r,C),xe(n,A,C),z(A,i,C),z(A,s,C),k(s,o),k(s,a),k(s,l),k(s,u),k(s,c),k(s,f),k(s,d),k(d,g),k(d,w),j.m(d,null),k(s,x),k(s,b),k(b,h),k(b,v),k(b,m),p=!0},p(A,[C]){let S={};C&2&&(S.initialValue=A[1]),e.$set(S);let D={};C&4194360&&(D.$$scope={dirty:C,ctx:A}),n.$set(D),y!==(y=_(A,C))&&(j.d(1),j=y(A),j&&(j.c(),j.m(d,null)))},i(A){p||(q(e.$$.fragment,A),q(n.$$.fragment,A),p=!0)},o(A){Q(e.$$.fragment,A),Q(n.$$.fragment,A),p=!1},d(A){ge(e,A),A&&K(r),ge(n,A),A&&K(i),A&&K(s),j.d()}}}function Ay(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 Cy(t,e,r){let{modal:n}=e,{parent:i=null}=e,{singleFilePath:s=""}=e,{previousQuery:o}=e,a,l=[],u=0,c,f;Tr(()=>{$.enable("infile"),$.on("infile","enter",b),$.on("infile","open-in-new-pane",x),$.on("infile","arrow-up",()=>g(-1)),$.on("infile","arrow-down",()=>g(1)),$.on("infile","tab",h)}),kr(()=>{$.disable("infile")});function d(y){let j=[],A=-1,C=0;for(;;){let S=Ay(y,A,Jr);if(!S.length||(A=S.last().offset,j.push(S),++C>100))break}return j}function g(y){r(5,u=zn(u+y,l.length)),w()}async function w(){await ot(),document.querySelector(`[data-result-id="${u}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}async function x(){return b(!0)}async function b(y=!1){if(c){n.close(),i&&i.close(),await Gn(c,y);let j=app.workspace.getActiveViewOfType(pc.MarkdownView);if(!j)return;let A=l[u]??0,C=j.editor.offsetToPos(A);C.ch=0,j.editor.setCursor(C),j.editor.scrollIntoView({from:{line:C.line-10,ch:0},to:{line:C.line+10,ch:0}})}}function h(){new $t(app,o).open(),n.close()}let v=y=>r(2,a=y.detail),m=(y,j)=>r(5,u=y),p=y=>b(y.ctrlKey),_=y=>{y.button==1&&b(!0)};return t.$$set=y=>{"modal"in y&&r(7,n=y.modal),"parent"in y&&r(0,i=y.parent),"singleFilePath"in y&&r(8,s=y.singleFilePath),"previousQuery"in y&&r(1,o=y.previousQuery)},t.$$.update=()=>{if(t.$$.dirty&2){e:r(2,a=o??"")}if(t.$$.dirty&772){e:(async()=>{a&&(r(9,f=new zt(a)),r(3,c=(await ce.getSuggestions(f,{singleFilePath:s}))[0]??null)),r(5,u=0),await w()})()}if(t.$$.dirty&8){e:if(c){let y=d(c.matches);r(4,l=y.map(j=>Math.round((j.first().offset+j.last().offset)/2)))}}},[i,o,a,c,l,u,b,n,s,f,v,m,p,_]}var yc=class extends pe{constructor(e){super();ye(this,e,Cy,jy,fe,{modal:7,parent:0,singleFilePath:8,previousQuery:1})}},vc=yc;var Js=class extends _c.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",r=>{r.preventDefault(),$.emit("arrow-down")}),this.scope.register([],"ArrowUp",r=>{r.preventDefault(),$.emit("arrow-up")});for(let r of[{k:"J",dir:"down"},{k:"K",dir:"up"}])for(let n of["Ctrl","Mod"])this.scope.register([n],r.k,i=>{this.app.vault.getConfig("vimMode")&&$.emit("arrow-"+r.dir)});for(let r of[{k:"N",dir:"down"},{k:"P",dir:"up"}])for(let n of["Ctrl","Mod"])this.scope.register([n],r.k,i=>{this.app.vault.getConfig("vimMode")&&$.emit("arrow-"+r.dir)});this.scope.register(["Mod"],"Enter",r=>{r.preventDefault(),$.emit("open-in-new-pane")}),this.scope.register(["Alt"],"Enter",r=>{r.preventDefault(),$.emit("insert-link")}),this.scope.register(["Shift"],"Enter",r=>{r.preventDefault(),$.emit("create-note")}),this.scope.register(["Ctrl","Shift"],"Enter",r=>{r.preventDefault(),$.emit("create-note",{newLeaf:!0})}),this.scope.register([],"Enter",r=>{ga()||(r.preventDefault(),$.emit("enter"))}),this.scope.register([],"Tab",r=>{r.preventDefault(),$.emit("tab")}),this.scope.register(["Alt"],"ArrowDown",r=>{r.preventDefault(),$.emit("next-sear