21 lines
116 KiB
JavaScript
21 lines
116 KiB
JavaScript
var Un=Object.create;var Ce=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var qn=Object.getOwnPropertyNames;var Gn=Object.getPrototypeOf,Kn=Object.prototype.hasOwnProperty;var Fe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Q=(t,e)=>{for(var n in e)Ce(t,n,{get:e[n],enumerable:!0})},Hn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qn(e))!Kn.call(t,i)&&i!==n&&Ce(t,i,{get:()=>e[i],enumerable:!(r=Vn(e,i))||r.enumerable});return t};var Et=(t,e,n)=>(n=t!=null?Un(Gn(t)):{},Hn(e||!t||!t.__esModule?Ce(n,"default",{value:t,enumerable:!0}):n,t));var bn=Fe((yu,_e)=>{function mn(t){return Array.isArray(t)?t:[t]}var Ds=void 0,mt="",hn=" ",dt="\\",Is=/^\s+$/,zs=/(?:[^\\]|^)\\$/,Os=/^\\!/,Rs=/^\\#/,Ls=/\r?\n/g,js=/^\.{0,2}\/|^\.{1,2}$/,Ns=/\/$/,H="/",yn="node-ignore";typeof Symbol<"u"&&(yn=Symbol.for("node-ignore"));var vn=yn,X=(t,e,n)=>(Object.defineProperty(t,e,{value:n}),n),$s=/([0-z])-([0-z])/g,gn=()=>!1,Ws=t=>t.replace($s,(e,n,r)=>n.charCodeAt(0)<=r.charCodeAt(0)?e:mt),Bs=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Us=[[/^\uFEFF/,()=>mt],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,n)=>e+(n.indexOf("\\")===0?hn:mt)],[/(\\+?)\s/g,(t,e)=>{let{length:n}=e;return e.slice(0,n-n%2)+hn}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,n)=>e+6<n.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,n)=>{let r=n.replace(/\\\*/g,"[^\\/]*");return e+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>dt],[/\\\\/g,()=>dt],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,n,r,i)=>e===dt?`\\[${n}${Bs(r)}${i}`:i==="]"&&r.length%2===0?`[${Ws(n)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`]],Vs=/(^|\\\/)?\\\*$/,ue="regex",be="checkRegex",dn="_",qs={[ue](t,e){return`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`},[be](t,e){return`${e?`${e}[^/]*`:"[^/]*"}(?=$|\\/$)`}},Gs=t=>Us.reduce((e,[n,r])=>e.replace(n,r.bind(t)),t),ke=t=>typeof t=="string",Ks=t=>t&&ke(t)&&!Is.test(t)&&!zs.test(t)&&t.indexOf("#")!==0,Hs=t=>t.split(Ls).filter(Boolean),yt=class{constructor(e,n,r,i,s,o){this.pattern=e,this.mark=n,this.negative=s,X(this,"body",r),X(this,"ignoreCase",i),X(this,"regexPrefix",o)}get regex(){let e=dn+ue;return this[e]?this[e]:this._make(ue,e)}get checkRegex(){let e=dn+be;return this[e]?this[e]:this._make(be,e)}_make(e,n){let r=this.regexPrefix.replace(Vs,qs[e]),i=this.ignoreCase?new RegExp(r,"i"):new RegExp(r);return X(this,n,i)}},Xs=({pattern:t,mark:e},n)=>{let r=!1,i=t;i.indexOf("!")===0&&(r=!0,i=i.substr(1)),i=i.replace(Os,"!").replace(Rs,"#");let s=Gs(i);return new yt(t,e,i,n,r,s)},vt=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[vn]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(ke(e)&&(e={pattern:e}),Ks(e.pattern)){let n=Xs(e,this._ignoreCase);this._added=!0,this._rules.push(n)}}add(e){return this._added=!1,mn(ke(e)?Hs(e):e).forEach(this._add,this),this._added}test(e,n,r){let i=!1,s=!1,o;this._rules.forEach(a=>{let{negative:l}=a;s===l&&i!==s||l&&!i&&!s&&!n||!a[r].test(e)||(i=!l,s=l,o=l?Ds:a)});let u={ignored:i,unignored:s};return o&&(u.rule=o),u}},Js=(t,e)=>{throw new e(t)},L=(t,e,n)=>ke(t)?t?L.isNotRelative(t)?n(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:n("path must not be empty",TypeError):n(`path must be a string, but got \`${e}\``,TypeError),xn=t=>js.test(t);L.isNotRelative=xn;L.convert=t=>t;var gt=class{constructor({ignorecase:e=!0,ignoreCase:n=e,allowRelativePaths:r=!1}={}){X(this,vn,!0),this._rules=new vt(n),this._strictPathCheck=!r,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,n,r,i){let s=e&&L.convert(e);return L(s,e,this._strictPathCheck?Js:gn),this._t(s,n,r,i)}checkIgnore(e){if(!Ns.test(e))return this.test(e);let n=e.split(H).filter(Boolean);if(n.pop(),n.length){let r=this._t(n.join(H)+H,this._testCache,!0,n);if(r.ignored)return r}return this._rules.test(e,!1,be)}_t(e,n,r,i){if(e in n)return n[e];if(i||(i=e.split(H).filter(Boolean)),i.pop(),!i.length)return n[e]=this._rules.test(e,r,ue);let s=this._t(i.join(H)+H,n,r,i);return n[e]=s.ignored?s:this._rules.test(e,r,ue)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return mn(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},xt=t=>new gt(t),Qs=t=>L(t&&L.convert(t),t,gn),wn=()=>{let t=n=>/^\\\\\?\\/.test(n)||/["<>|\u0000-\u001F]+/u.test(n)?n:n.replace(/\\/g,"/");L.convert=t;let e=/^[a-z]:\//i;L.isNotRelative=n=>e.test(n)||xn(n)};typeof process<"u"&&process.platform==="win32"&&wn();_e.exports=xt;xt.default=xt;_e.exports.isPathValid=Qs;X(_e.exports,Symbol.for("setupWindows"),wn)});var En=Fe(Ee=>{Ee.parse=function(t,e){if(e?e.offsets=typeof e.offsets>"u"?!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 n={text:[]};e.offsets&&(n.offsets=[]);for(var r={},i=[],s=/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|(-?"(?:[^"\\]|\\.)*")|(-?'(?:[^'\\]|\\.)*')|\S+|\S+:\S+/g,o;(o=s.exec(t))!==null;){var h=o[0],u=h.indexOf(":");if(u!==-1){var a=h.split(":"),l=h.slice(0,u),f=h.slice(u+1);f=f.replace(/^\"|\"$|^\'|\'$/g,""),f=(f+"").replace(/\\(.?)/g,function(T,M){switch(M){case"\\":return"\\";case"0":return"\0";case"":return"";default:return M}}),i.push({keyword:l,value:f,offsetStart:o.index,offsetEnd:o.index+h.length})}else{var p=!1;h[0]==="-"&&(p=!0,h=h.slice(1)),h=h.replace(/^\"|\"$|^\'|\'$/g,""),h=(h+"").replace(/\\(.?)/g,function(T,M){switch(M){case"\\":return"\\";case"0":return"\0";case"":return"";default:return M}}),p?r.text?(r.text instanceof Array||(r.text=[r.text]),r.text.push(h)):r.text=h:i.push({text:h,offsetStart:o.index,offsetEnd:o.index+h.length})}}i.reverse();for(var h;h=i.pop();)if(h.text)n.text.push(h.text),e.offsets&&n.offsets.push(h);else{var l=h.keyword;e.keywords=e.keywords||[];var d=!1,g=!1;if(!/^-/.test(l))d=e.keywords.indexOf(l)!==-1;else if(l[0]==="-"){var v=l.slice(1);d=e.keywords.indexOf(v)!==-1,d&&(l=v,g=!0)}e.ranges=e.ranges||[];var m=e.ranges.indexOf(l)!==-1;if(d){e.offsets&&n.offsets.push({keyword:l,value:h.value,offsetStart:g?h.offsetStart+1:h.offsetStart,offsetEnd:h.offsetEnd});var y=h.value;if(y.length){var x=y.split(",");g?r[l]?r[l]instanceof Array?x.length>1?r[l]=r[l].concat(x):r[l].push(y):(r[l]=[r[l]],r[l].push(y)):x.length>1?r[l]=x:e.alwaysArray?r[l]=[y]:r[l]=y:n[l]?n[l]instanceof Array?x.length>1?n[l]=n[l].concat(x):n[l].push(y):(n[l]=[n[l]],n[l].push(y)):x.length>1?n[l]=x:e.alwaysArray?n[l]=[y]:n[l]=y}}else if(m){e.offsets&&n.offsets.push(h);var y=h.value,w=y.split("-");n[l]={},w.length===2?(n[l].from=w[0],n[l].to=w[1]):!w.length%2||(n[l].from=y)}else{var k=h.keyword+":"+h.value;n.text.push(k),e.offsets&&n.offsets.push({text:k,offsetStart:h.offsetStart,offsetEnd:h.offsetEnd})}}return n.text.length?e.tokenize||(n.text=n.text.join(" ").trim()):delete n.text,n.exclude=r,n};Ee.stringify=function(t,e,n){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;n||(n="");var r=function(u){return u.indexOf(" ")>-1?JSON.stringify(u):u},i=function(u){return n+u},s=[];if(t.text){var o=[];typeof t.text=="string"?o.push(t.text):o.push.apply(o,t.text),o.length>0&&s.push(o.map(r).map(i).join(" "))}return e.keywords&&e.keywords.forEach(function(u){if(t[u]){var a=[];typeof t[u]=="string"?a.push(t[u]):a.push.apply(a,t[u]),a.length>0&&s.push(i(u+":"+a.map(r).join(",")))}}),e.ranges&&e.ranges.forEach(function(u){if(t[u]){var a=t[u].from,l=t[u].to;l&&(a=a+"-"+l),a&&s.push(i(u+":"+a))}}),t.exclude&&Object.keys(t.exclude).length>0&&s.push(Ee.stringify(t.exclude,e,"-")),s.join(" ")}});var An=Fe((Lu,Pn)=>{Pn.exports=En()});function Xn(t){let e=atob(t),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);return r}function At(t){typeof t=="string"&&(t=new TextEncoder().encode(t));let e="",n=t.byteLength;for(let r=0;r<n;r++)e+=String.fromCharCode(t[r]);return btoa(e)}var eo=new Uint8Array(16),Jn=class{constructor(t="",e=1e3){this.prefix=t,this.maxCaptureSize=e,this.prefix=t,this.originalConsole={log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console)},this.patchConsole()}originalConsole;logBuffer=[];patchConsole(){let t=e=>(...n)=>{let r=this.prefix?[this.prefix,...n]:n;this.originalConsole[e](...r),this.captureLog(e,n)};console.log=t("log"),console.info=t("info"),console.warn=t("warn"),console.error=t("error"),console.debug=t("debug")}captureLog(t,e){let n={level:t,timestamp:Date.now(),message:e.map(r=>{if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}).join(" ")};this.logBuffer.push(n),this.logBuffer.length>this.maxCaptureSize&&this.logBuffer.shift()}async postToServer(t,e){if(this.logBuffer.length>0){let r=[...this.logBuffer];this.logBuffer=[];try{if(!(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r.map(s=>({...s,source:e})))})).ok)throw new Error("Failed to post logs to server")}catch(i){console.warn("Could not post logs to server",i.message),this.logBuffer.unshift(...r)}}}},Pt;function Qn(t=""){return Pt=new Jn(t),Pt}var Z=t=>{throw new Error("Not initialized yet")},Ie=typeof window>"u"&&typeof globalThis.WebSocketPair>"u",De=new Map,Me=0;Ie&&(globalThis.syscall=async(t,...e)=>await new Promise((n,r)=>{Me++,De.set(Me,{resolve:n,reject:r}),Z({type:"sys",id:Me,name:t,args:e})}));function St(t,e,n){Ie&&(Z=n,self.addEventListener("message",r=>{(async()=>{let i=r.data;switch(i.type){case"inv":{let s=t[i.name];if(!s)throw new Error(`Function not loaded: ${i.name}`);try{let o=await Promise.resolve(s(...i.args||[]));Z({type:"invr",id:i.id,result:o})}catch(o){console.error("An exception was thrown as a result of invoking function",i.name,"error:",o.message),Z({type:"invr",id:i.id,error:o.message})}}break;case"sysr":{let s=i.id,o=De.get(s);if(!o)throw Error("Invalid request id");De.delete(s),i.error?o.reject(new Error(i.error)):o.resolve(i.result)}break}})().catch(console.error)}),Z({type:"manifest",manifest:e}),Qn(`[${e.name} plug]`))}async function Zn(t,e){if(typeof t!="string"){let n=new Uint8Array(await t.arrayBuffer()),r=n.length>0?At(n):void 0;e={method:t.method,headers:Object.fromEntries(t.headers.entries()),base64Body:r},t=t.url}return syscall("sandboxFetch.fetch",t,e)}globalThis.nativeFetch=globalThis.fetch;function Yn(){globalThis.fetch=async(t,e)=>{let n=e?.body?At(new Uint8Array(await new Response(e.body).arrayBuffer())):void 0,r=await Zn(t,e&&{method:e.method,headers:e.headers,base64Body:n});return new Response(r.base64Body?Xn(r.base64Body):null,{status:r.status,headers:r.headers})}}Ie&&Yn();var C={};Q(C,{alert:()=>Lr,configureVimMode:()=>ei,confirm:()=>Rr,copyToClipboard:()=>Hr,deleteLine:()=>Xr,dispatch:()=>zr,downloadFile:()=>kr,filterBox:()=>Pr,flashNotification:()=>Er,fold:()=>$r,foldAll:()=>Ur,getCurrentEditor:()=>ir,getCurrentPage:()=>er,getCurrentPageMeta:()=>tr,getCurrentPath:()=>nr,getCursor:()=>ur,getRecentlyOpenedPages:()=>rr,getSelection:()=>lr,getText:()=>sr,getUiOption:()=>jr,goHistory:()=>br,hidePanel:()=>Sr,insertAtCursor:()=>Ir,insertAtPos:()=>Cr,invokeCommand:()=>cr,isMobile:()=>ni,moveCursor:()=>Mr,moveCursorToLine:()=>Dr,moveLineDown:()=>Zr,moveLineUp:()=>Qr,navigate:()=>pr,newWindow:()=>wr,openCommandPalette:()=>dr,openPageNavigator:()=>hr,openSearchPanel:()=>Kr,openUrl:()=>xr,prompt:()=>Or,rebuildEditorState:()=>vr,redo:()=>Gr,reloadConfigAndCommands:()=>gr,reloadPage:()=>mr,reloadUI:()=>yr,replaceRange:()=>Fr,save:()=>fr,sendMessage:()=>ti,setSelection:()=>ar,setText:()=>or,setUiOption:()=>Nr,showPanel:()=>Ar,showProgress:()=>Tr,toggleComment:()=>Jr,toggleFold:()=>Br,undo:()=>qr,unfold:()=>Wr,unfoldAll:()=>Vr,uploadFile:()=>_r,vimEx:()=>Yr});typeof globalThis.syscall>"u"&&(globalThis.syscall=()=>{throw new Error("Not implemented here")});function c(t,...e){return globalThis.syscall(t,...e)}function er(){return c("editor.getCurrentPage")}function tr(){return c("editor.getCurrentPageMeta")}function nr(){return c("editor.getCurrentPath")}function rr(){return c("editor.getRecentlyOpenedPages")}function ir(){return c("editor.getCurrentEditor")}function sr(){return c("editor.getText")}function or(t,e=!1){return c("editor.setText",t,e)}function ur(){return c("editor.getCursor")}function lr(){return c("editor.getSelection")}function ar(t,e){return c("editor.setSelection",t,e)}function cr(t,e){return c("editor.invokeCommand",t,e)}function fr(){return c("editor.save")}function pr(t,e=!1,n=!1){return c("editor.navigate",t,e,n)}function hr(t="page"){return c("editor.openPageNavigator",t)}function dr(){return c("editor.openCommandPalette")}function mr(){return c("editor.reloadPage")}function yr(){return c("editor.reloadUI")}function vr(){return c("editor.rebuildEditorState")}function gr(){return c("editor.reloadConfigAndCommands")}function xr(t,e=!1){return c("editor.openUrl",t,e)}function wr(){return c("editor.newWindow")}function br(t){return c("editor.goHistory",t)}function kr(t,e){return c("editor.downloadFile",t,e)}function _r(t,e){return c("editor.uploadFile",t,e)}function Er(t,e="info"){return c("editor.flashNotification",t,e)}function Pr(t,e,n="",r=""){return c("editor.filterBox",t,e,n,r)}function Ar(t,e,n,r=""){return c("editor.showPanel",t,e,n,r)}function Sr(t){return c("editor.hidePanel",t)}function Tr(t,e){return c("editor.showProgress",t,e)}function Cr(t,e){return c("editor.insertAtPos",t,e)}function Fr(t,e,n){return c("editor.replaceRange",t,e,n)}function Mr(t,e=!1){return c("editor.moveCursor",t,e)}function Dr(t,e=1,n=!1){return c("editor.moveCursorToLine",t,e,n)}function Ir(t,e=!1,n=!1){return c("editor.insertAtCursor",t,e,n)}function zr(t){return c("editor.dispatch",t)}function Or(t,e=""){return c("editor.prompt",t,e)}function Rr(t){return c("editor.confirm",t)}function Lr(t){return c("editor.alert",t)}function jr(t){return c("editor.getUiOption",t)}function Nr(t,e){return c("editor.setUiOption",t,e)}function $r(){return c("editor.fold")}function Wr(){return c("editor.unfold")}function Br(){return c("editor.toggleFold")}function Ur(){return c("editor.foldAll")}function Vr(){return c("editor.unfoldAll")}function qr(){return c("editor.undo")}function Gr(){return c("editor.redo")}function Kr(){return c("editor.openSearchPanel")}function Hr(t){return c("editor.copyToClipboard",t)}function Xr(){return c("editor.deleteLine")}function Jr(){return c("editor.toggleComment")}function Qr(){return c("editor.moveLineUp")}function Zr(){return c("editor.moveLineDown")}function Yr(t){return c("editor.vimEx",t)}function ei(){return c("editor.configureVimMode")}function ti(t,e){return c("editor.sendMessage",t,e)}function ni(){return c("editor.isMobile")}var D={};Q(D,{deleteDocument:()=>yi,deleteFile:()=>_i,deletePage:()=>ci,fileExists:()=>Ei,getDocumentMeta:()=>hi,getFileMeta:()=>bi,getPageMeta:()=>si,listDocuments:()=>pi,listFiles:()=>vi,listPages:()=>ii,listPlugs:()=>fi,pageExists:()=>oi,readDocument:()=>di,readFile:()=>gi,readFileWithMeta:()=>wi,readPage:()=>ui,readPageWithMeta:()=>li,readRef:()=>xi,writeDocument:()=>mi,writeFile:()=>ki,writePage:()=>ai});function ii(){return c("space.listPages")}function si(t){return c("space.getPageMeta",t)}function oi(t){return c("space.pageExists",t)}function ui(t){return c("space.readPage",t)}function li(t){return c("space.readPageWithMeta",t)}function ai(t,e){return c("space.writePage",t,e)}function ci(t){return c("space.deletePage",t)}function fi(){return c("space.listPlugs")}function pi(){return c("space.listDocuments")}function hi(t){return c("space.getDocumentMeta",t)}function di(t){return c("space.readDocument",t)}function mi(t,e){return c("space.writeDocument",t,e)}function yi(t){return c("space.deleteDocument",t)}function vi(){return c("space.listFiles")}function gi(t){return c("space.readFile",t)}function xi(t){return c("space.readRef",t)}function wi(t){return c("space.readFileWithMeta",t)}function bi(t){return c("space.getFileMeta",t)}function ki(t,e){return c("space.writeFile",t,e)}function _i(t){return c("space.deleteFile",t)}function Ei(t){return c("space.fileExists",t)}var ae={};Q(ae,{cleanDatabases:()=>Ri,getBaseURI:()=>Di,getConfig:()=>zi,getMode:()=>Fi,getURLPrefix:()=>Mi,getVersion:()=>Ii,invokeCommand:()=>Ai,invokeFunction:()=>Pi,listCommands:()=>Si,listSyscalls:()=>Ti,reloadPlugs:()=>Ci,wipeClient:()=>Oi});function Pi(t,...e){return c("system.invokeFunction",t,...e)}function Ai(t,e){return c("system.invokeCommand",t,e)}function Si(){return c("system.listCommands")}function Ti(){return c("system.listSyscalls")}function Ci(){return c("system.reloadPlugs")}function Fi(){return c("system.getMode")}function Mi(){return c("system.getURLPrefix")}function Di(){return c("system.getBaseURI")}function Ii(){return c("system.getVersion")}function zi(t,e=void 0){return c("system.getConfig",t,e)}function Oi(t=!1){return c("system.wipeClient",t)}function Ri(){return c("system.cleanDatabases")}var F={};Q(F,{del:()=>Ni,get:()=>ji,set:()=>Li});function Li(t,e){return c("clientStore.set",t,e)}function ji(t){return c("clientStore.get",t)}function Ni(t){return c("clientStore.delete",t)}var po=new Uint8Array(16);var ce={};Q(ce,{dispatchEvent:()=>Vi,listEvents:()=>qi});function Vi(t,e,n){return new Promise((r,i)=>{let s=-1;n&&(s=setTimeout(()=>{console.log("Timeout!"),i("timeout")},n)),c("event.dispatch",t,e).then(o=>{s!==-1&&clearTimeout(s),r(o)}).catch(i)})}function qi(){return c("event.listEvents")}var ze='var vl=Object.defineProperty;var fi=P=>{throw TypeError(P)};var pl=(P,D,F)=>D in P?vl(P,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):P[D]=F;var ge=(P,D,F)=>pl(P,typeof D!="symbol"?D+"":D,F),Kn=(P,D,F)=>D.has(P)||fi("Cannot "+F);var u=(P,D,F)=>(Kn(P,D,"read from private field"),F?F.call(P):D.get(P)),T=(P,D,F)=>D.has(P)?fi("Cannot add the same private member more than once"):D instanceof WeakSet?D.add(P):D.set(P,F),y=(P,D,F,ke)=>(Kn(P,D,"write to private field"),ke?ke.call(P,F):D.set(P,F),F),N=(P,D,F)=>(Kn(P,D,"access private method"),F);(function(){"use strict";var Et,xt,Tt,St,Wt,Ue,kt,Ve,be,At,B,Yn,Wn,Gn,Qn,ai,fe,Vn,Ee,st,Q,xe,$,pe,Pe,lt,He,Mt,Dt,Pt,Ce,an,O,_l,gl,ml,Xn,cn,dn,Zn,li,_e,Te,ee,ot,Gt,Qt,un,oi;var D=Array.isArray,F=Array.prototype.indexOf,ke=Array.prototype.includes,Jt=Array.from,ui=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,ci=Object.getOwnPropertyDescriptors,di=Object.prototype,hi=Array.prototype,Jn=Object.getPrototypeOf,$n=Object.isExtensible;const It=()=>{};function vi(e){return e()}function hn(e){for(var t=0;t<e.length;t++)e[t]()}function er(){var e,t,n=new Promise((r,i)=>{e=r,t=i});return{promise:n,resolve:e,reject:t}}const q=2,ct=4,Rt=8,tr=1<<24,Ie=16,ae=32,Be=64,vn=128,re=512,L=1024,z=2048,ue=4096,X=8192,ce=16384,Ke=32768,pn=1<<25,Ye=65536,nr=1<<17,pi=1<<18,dt=1<<19,rr=1<<20,Ae=1<<25,We=65536,_n=1<<21,gn=1<<22,Re=1<<23,ht=Symbol("$state"),Me=new class extends Error{constructor(){super(...arguments);ge(this,"name","StaleReactionError");ge(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};function ir(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function _i(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function gi(e,t,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function mi(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function wi(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function yi(e){throw new Error("https://svelte.dev/e/effect_orphan")}function bi(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Ei(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function xi(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Ti(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Si(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const ki=1,Ai=2,Mi=16,Di=1,Pi=2,V=Symbol(),Ci="http://www.w3.org/1999/xhtml",Ii="http://www.w3.org/2000/svg",Ri="http://www.w3.org/1998/Math/MathML";function Ni(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function sr(e){return e===this.v}function Fi(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function lr(e){return!Fi(e,this.v)}let Nt=!1,wl=!1;function Oi(){Nt=!0}let M=null;function vt(e){M=e}function or(e){return qi().get(e)}function pt(e,t=!1,n){M={p:M,i:!1,c:null,e:null,s:e,x:null,r:S,l:Nt&&!t?{s:null,u:null,$:[]}:null}}function _t(e){var t=M,n=t.e;if(n!==null){t.e=null;for(var r of n)Rr(r)}return t.i=!0,M=t.p,{}}function Ft(){return!Nt||M!==null&&M.l===null}function qi(e){return M===null&&ir(),M.c??(M.c=new Map(Li(M)||void 0))}function Li(e){let t=e.p;for(;t!==null;){const n=t.c;if(n!==null)return n;t=t.p}return null}let Ge=[];function fr(){var e=Ge;Ge=[],hn(e)}function Qe(e){if(Ge.length===0&&!qt){var t=Ge;queueMicrotask(()=>{t===Ge&&fr()})}Ge.push(e)}function ji(){for(;Ge.length>0;)fr()}function ar(e){var t=S;if(t===null)return b.f|=Re,e;if((t.f&Ke)===0&&(t.f&ct)===0)throw e;Ne(e,t)}function Ne(e,t){for(;t!==null;){if((t.f&vn)!==0){if((t.f&Ke)===0)throw e;try{t.b.error(e);return}catch(n){e=n}}t=t.parent}throw e}const Ui=-7169;function I(e,t){e.f=e.f&Ui|t}function mn(e){(e.f&re)!==0||e.deps===null?I(e,L):I(e,ue)}function ur(e){if(e!==null)for(const t of e)(t.f&q)===0||(t.f&We)===0||(t.f^=We,ur(t.deps))}function cr(e,t,n){(e.f&z)!==0?t.add(e):(e.f&ue)!==0&&n.add(e),ur(e.deps),I(e,L)}const Ot=new Set;let m=null,H=null,wn=null,qt=!1,yn=!1,gt=null,$t=null;var dr=0;let Vi=1;const fn=class fn{constructor(){T(this,B);ge(this,"id",Vi++);ge(this,"current",new Map);ge(this,"previous",new Map);T(this,Et,new Set);T(this,xt,new Set);T(this,Tt,0);T(this,St,0);T(this,Wt,null);T(this,Ue,[]);T(this,kt,new Set);T(this,Ve,new Set);T(this,be,new Map);ge(this,"is_fork",!1);T(this,At,!1)}skip_effect(t){u(this,be).has(t)||u(this,be).set(t,{d:[],m:[]})}unskip_effect(t){var n=u(this,be).get(t);if(n){u(this,be).delete(t);for(var r of n.d)I(r,z),this.schedule(r);for(r of n.m)I(r,ue),this.schedule(r)}}capture(t,n){n!==V&&!this.previous.has(t)&&this.previous.set(t,n),(t.f&Re)===0&&(this.current.set(t,t.v),H==null||H.set(t,t.v))}activate(){m=this}deactivate(){m=null,H=null}flush(){try{if(yn=!0,m=this,!N(this,B,Yn).call(this)){for(const t of u(this,kt))u(this,Ve).delete(t),I(t,z),this.schedule(t);for(const t of u(this,Ve))I(t,ue),this.schedule(t)}N(this,B,Wn).call(this)}finally{dr=0,wn=null,gt=null,$t=null,yn=!1,m=null,H=null,Fe.clear()}}discard(){for(const t of u(this,xt))t(this);u(this,xt).clear()}increment(t){y(this,Tt,u(this,Tt)+1),t&&y(this,St,u(this,St)+1)}decrement(t,n){y(this,Tt,u(this,Tt)-1),t&&y(this,St,u(this,St)-1),!(u(this,At)||n)&&(y(this,At,!0),Qe(()=>{y(this,At,!1),this.flush()}))}oncommit(t){u(this,Et).add(t)}ondiscard(t){u(this,xt).add(t)}settled(){return(u(this,Wt)??y(this,Wt,er())).promise}static ensure(){if(m===null){const t=m=new fn;yn||(Ot.add(m),qt||Qe(()=>{m===t&&t.flush()}))}return m}apply(){}schedule(t){var i;if(wn=t,(i=t.b)!=null&&i.is_pending&&(t.f&(ct|Rt|tr))!==0&&(t.f&Ke)===0){t.b.defer_effect(t);return}for(var n=t;n.parent!==null;){n=n.parent;var r=n.f;if(gt!==null&&n===S&&(b===null||(b.f&q)===0))return;if((r&(Be|ae))!==0){if((r&L)===0)return;n.f^=L}}u(this,Ue).push(n)}};Et=new WeakMap,xt=new WeakMap,Tt=new WeakMap,St=new WeakMap,Wt=new WeakMap,Ue=new WeakMap,kt=new WeakMap,Ve=new WeakMap,be=new WeakMap,At=new WeakMap,B=new WeakSet,Yn=function(){return this.is_fork||u(this,St)>0},Wn=function(){var l,o;dr++>1e3&&zi();const t=u(this,Ue);y(this,Ue,[]),this.apply();var n=gt=[],r=[],i=$t=[];for(const a of t)N(this,B,Gn).call(this,a,n,r);if(m=null,i.length>0){var s=fn.ensure();for(const a of i)s.schedule(a)}if(gt=null,$t=null,N(this,B,Yn).call(this)){N(this,B,Qn).call(this,r),N(this,B,Qn).call(this,n);for(const[a,c]of u(this,be))_r(a,c)}else{u(this,kt).clear(),u(this,Ve).clear();for(const a of u(this,Et))a(this);u(this,Et).clear(),hr(r),hr(n),u(this,Tt)===0&&N(this,B,ai).call(this),(l=u(this,Wt))==null||l.resolve()}var f=m;f!==null&&(Ot.add(f),N(o=f,B,Wn).call(o))},Gn=function(t,n,r){t.f^=L;for(var i=t.first;i!==null;){var s=i.f,f=(s&(ae|Be))!==0,l=f&&(s&L)!==0,o=l||(s&X)!==0||u(this,be).has(i);if(!o&&i.fn!==null){f?i.f^=L:(s&ct)!==0?n.push(i):Vt(i)&&((s&Ie)!==0&&u(this,Ve).add(i),yt(i));var a=i.first;if(a!==null){i=a;continue}}for(;i!==null;){var c=i.next;if(c!==null){i=c;break}i=i.parent}}},Qn=function(t){for(var n=0;n<t.length;n+=1)cr(t[n],u(this,kt),u(this,Ve))},ai=function(){var i;if(Ot.size>1){this.previous.clear();var t=m,n=H,r=!0;for(const s of Ot){if(s===this){r=!1;continue}const f=[];for(const[o,a]of this.current){if(s.current.has(o))if(r&&a!==s.current.get(o))s.current.set(o,a);else continue;f.push(o)}if(f.length===0)continue;const l=[...s.current.keys()].filter(o=>!this.current.has(o));if(l.length>0){s.activate();const o=new Set,a=new Map;for(const c of f)vr(c,l,o,a);if(u(s,Ue).length>0){s.apply();for(const c of u(s,Ue))N(i=s,B,Gn).call(i,c,[],[])}s.deactivate()}}m=t,H=n}u(this,be).clear(),Ot.delete(this)};let Xe=fn;function Hi(e){var t=qt;qt=!0;try{for(var n;;){if(ji(),m===null)return n;m.flush()}}finally{qt=t}}function zi(){try{bi()}catch(e){Ne(e,wn)}}let de=null;function hr(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if((r.f&(ce|X))===0&&Vt(r)&&(de=new Set,yt(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Or(r),(de==null?void 0:de.size)>0)){Fe.clear();for(const i of de){if((i.f&(ce|X))!==0)continue;const s=[i];let f=i.parent;for(;f!==null;)de.has(f)&&(de.delete(f),s.push(f)),f=f.parent;for(let l=s.length-1;l>=0;l--){const o=s[l];(o.f&(ce|X))===0&&yt(o)}}de.clear()}}de=null}}function vr(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const i of e.reactions){const s=i.f;(s&q)!==0?vr(i,t,n,r):(s&(gn|Ie))!==0&&(s&z)===0&&pr(i,t,r)&&(I(i,z),bn(i))}}function pr(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const i of e.deps){if(ke.call(t,i))return!0;if((i.f&q)!==0&&pr(i,t,n))return n.set(i,!0),!0}return n.set(e,!1),!1}function bn(e){m.schedule(e)}function _r(e,t){if(!((e.f&ae)!==0&&(e.f&L)!==0)){(e.f&z)!==0?t.d.push(e):(e.f&ue)!==0&&t.m.push(e),I(e,L);for(var n=e.first;n!==null;)_r(n,t),n=n.next}}function Bi(e){let t=0,n=Ze(0),r;return()=>{Sn()&&(E(n),kn(()=>(t===0&&(r=zt(()=>e(()=>Lt(n)))),t+=1,()=>{Qe(()=>{t-=1,t===0&&(r==null||r(),r=void 0,Lt(n))})})))}}var Ki=Ye|dt;function Yi(e,t,n,r){new Wi(e,t,n,r)}class Wi{constructor(t,n,r,i){T(this,O);ge(this,"parent");ge(this,"is_pending",!1);ge(this,"transform_error");T(this,fe);T(this,Vn,null);T(this,Ee);T(this,st);T(this,Q);T(this,xe,null);T(this,$,null);T(this,pe,null);T(this,Pe,null);T(this,lt,0);T(this,He,0);T(this,Mt,!1);T(this,Dt,new Set);T(this,Pt,new Set);T(this,Ce,null);T(this,an,Bi(()=>(y(this,Ce,Ze(u(this,lt))),()=>{y(this,Ce,null)})));var s;y(this,fe,t),y(this,Ee,n),y(this,st,f=>{var l=S;l.b=this,l.f|=vn,r(f)}),this.parent=S.b,this.transform_error=i??((s=this.parent)==null?void 0:s.transform_error)??(f=>f),y(this,Q,rn(()=>{N(this,O,Xn).call(this)},Ki))}defer_effect(t){cr(t,u(this,Dt),u(this,Pt))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!u(this,Ee).pending}update_pending_count(t,n){N(this,O,Zn).call(this,t,n),y(this,lt,u(this,lt)+t),!(!u(this,Ce)||u(this,Mt))&&(y(this,Mt,!0),Qe(()=>{y(this,Mt,!1),u(this,Ce)&&mt(u(this,Ce),u(this,lt))}))}get_effect_pending(){return u(this,an).call(this),E(u(this,Ce))}error(t){var n=u(this,Ee).onerror;let r=u(this,Ee).failed;if(!n&&!r)throw t;u(this,xe)&&(W(u(this,xe)),y(this,xe,null)),u(this,$)&&(W(u(this,$)),y(this,$,null)),u(this,pe)&&(W(u(this,pe)),y(this,pe,null));var i=!1,s=!1;const f=()=>{if(i){Ni();return}i=!0,s&&Si(),u(this,pe)!==null&&$e(u(this,pe),()=>{y(this,pe,null)}),N(this,O,dn).call(this,()=>{N(this,O,Xn).call(this)})},l=o=>{try{s=!0,n==null||n(o,f),s=!1}catch(a){Ne(a,u(this,Q)&&u(this,Q).parent)}r&&y(this,pe,N(this,O,dn).call(this,()=>{try{return ie(()=>{var a=S;a.b=this,a.f|=vn,r(u(this,fe),()=>o,()=>f)})}catch(a){return Ne(a,u(this,Q).parent),null}}))};Qe(()=>{var o;try{o=this.transform_error(t)}catch(a){Ne(a,u(this,Q)&&u(this,Q).parent);return}o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(l,a=>Ne(a,u(this,Q)&&u(this,Q).parent)):l(o)})}}fe=new WeakMap,Vn=new WeakMap,Ee=new WeakMap,st=new WeakMap,Q=new WeakMap,xe=new WeakMap,$=new WeakMap,pe=new WeakMap,Pe=new WeakMap,lt=new WeakMap,He=new WeakMap,Mt=new WeakMap,Dt=new WeakMap,Pt=new WeakMap,Ce=new WeakMap,an=new WeakMap,O=new WeakSet,_l=function(){try{y(this,xe,ie(()=>u(this,st).call(this,u(this,fe))))}catch(t){this.error(t)}},gl=function(t){const n=u(this,Ee).failed;n&&y(this,pe,ie(()=>{n(u(this,fe),()=>t,()=>()=>{})}))},ml=function(){const t=u(this,Ee).pending;if(t){this.is_pending=!0,y(this,$,ie(()=>t(u(this,fe))));var n=m;Qe(()=>{var r=y(this,Pe,document.createDocumentFragment()),i=Oe();r.append(i),y(this,xe,N(this,O,dn).call(this,()=>ie(()=>u(this,st).call(this,i)))),u(this,He)===0&&(u(this,fe).before(r),y(this,Pe,null),$e(u(this,$),()=>{y(this,$,null)}),N(this,O,cn).call(this,n))})}},Xn=function(){var t=m;try{if(this.is_pending=this.has_pending_snippet(),y(this,He,0),y(this,lt,0),y(this,xe,ie(()=>{u(this,st).call(this,u(this,fe))})),u(this,He)>0){var n=y(this,Pe,document.createDocumentFragment());Dn(u(this,xe),n);const r=u(this,Ee).pending;y(this,$,ie(()=>r(u(this,fe))))}else N(this,O,cn).call(this,t)}catch(r){this.error(r)}},cn=function(t){this.is_pending=!1;for(const n of u(this,Dt))I(n,z),t.schedule(n);for(const n of u(this,Pt))I(n,ue),t.schedule(n);u(this,Dt).clear(),u(this,Pt).clear()},dn=function(t){var n=S,r=b,i=M;ye(u(this,Q)),se(u(this,Q)),vt(u(this,Q).ctx);try{return Xe.ensure(),t()}catch(s){return ar(s),null}finally{ye(n),se(r),vt(i)}},Zn=function(t,n){var r;if(!this.has_pending_snippet()){this.parent&&N(r=this.parent,O,Zn).call(r,t,n);return}y(this,He,u(this,He)+t),u(this,He)===0&&(N(this,O,cn).call(this,n),u(this,$)&&$e(u(this,$),()=>{y(this,$,null)}),u(this,Pe)&&(u(this,fe).before(u(this,Pe)),y(this,Pe,null)))};function Gi(e,t,n,r){const i=Ft()?tn:wr;var s=e.filter(v=>!v.settled);if(n.length===0&&s.length===0){r(t.map(i));return}var f=S,l=Qi(),o=s.length===1?s[0].promise:s.length>1?Promise.all(s.map(v=>v.promise)):null;function a(v){l();try{r(v)}catch(p){(f.f&ce)===0&&Ne(p,f)}en()}if(n.length===0){o.then(()=>a(t.map(i)));return}var c=gr();function h(){Promise.all(n.map(v=>Xi(v))).then(v=>a([...t.map(i),...v])).catch(v=>Ne(v,f)).finally(()=>c())}o?o.then(()=>{l(),h(),en()}):h()}function Qi(){var e=S,t=b,n=M,r=m;return function(s=!0){ye(e),se(t),vt(n),s&&(e.f&ce)===0&&(r==null||r.activate(),r==null||r.apply())}}function en(e=!0){ye(null),se(null),vt(null),e&&(m==null||m.deactivate())}function gr(){var e=S.b,t=m,n=e.is_rendered();return e.update_pending_count(1,t),t.increment(n),(r=!1)=>{e.update_pending_count(-1,t),t.decrement(n,r)}}function tn(e){var t=q|z,n=b!==null&&(b.f&q)!==0?b:null;return S!==null&&(S.f|=dt),{ctx:M,deps:null,effects:null,equals:sr,f:t,fn:e,reactions:null,rv:0,v:V,wv:0,parent:n??S,ac:null}}function Xi(e,t,n){let r=S;r===null&&_i();var i=void 0,s=Ze(V),f=!b,l=new Map;return us(()=>{var p;var o=S,a=er();i=a.promise;try{Promise.resolve(e()).then(a.resolve,a.reject).finally(en)}catch(d){a.reject(d),en()}var c=m;if(f){if((o.f&Ke)!==0)var h=gr();if(r.b.is_rendered())(p=l.get(c))==null||p.reject(Me),l.delete(c);else{for(const d of l.values())d.reject(Me);l.clear()}l.set(c,a)}const v=(d,_=void 0)=>{if(h){var x=_===Me;h(x)}if(!(_===Me||(o.f&ce)!==0)){if(c.activate(),_)s.f|=Re,mt(s,_);else{(s.f&Re)!==0&&(s.f^=Re),mt(s,d);for(const[w,A]of l){if(l.delete(w),w===c)break;A.reject(Me)}}c.deactivate()}};a.promise.then(v,d=>v(null,d||"unknown"))}),Ir(()=>{for(const o of l.values())o.reject(Me)}),new Promise(o=>{function a(c){function h(){c===i?o(s):a(i)}c.then(h,h)}a(i)})}function mr(e){const t=tn(e);return Ur(t),t}function wr(e){const t=tn(e);return t.equals=lr,t}function Zi(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)W(t[n])}}function Ji(e){for(var t=e.parent;t!==null;){if((t.f&q)===0)return(t.f&ce)===0?t:null;t=t.parent}return null}function En(e){var t,n=S;ye(Ji(e));try{e.f&=~We,Zi(e),t=Kr(e)}finally{ye(n)}return t}function yr(e){var t=En(e);if(!e.equals(t)&&(e.wv=zr(),(!(m!=null&&m.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){I(e,L);return}et||(H!==null?(Sn()||m!=null&&m.is_fork)&&H.set(e,t):mn(e))}function $i(e){var t,n;if(e.effects!==null)for(const r of e.effects)(r.teardown||r.ac)&&((t=r.teardown)==null||t.call(r),(n=r.ac)==null||n.abort(Me),r.teardown=It,r.ac=null,Ht(r,0),An(r))}function br(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&yt(t)}let xn=new Set;const Fe=new Map;let Er=!1;function Ze(e,t){var n={f:0,v:e,reactions:null,equals:sr,rv:0,wv:0};return n}function Z(e,t){const n=Ze(e);return Ur(n),n}function es(e,t=!1,n=!0){var i;const r=Ze(e);return t||(r.equals=lr),Nt&&n&&M!==null&&M.l!==null&&((i=M.l).s??(i.s=[])).push(r),r}function j(e,t,n=!1){b!==null&&(!ve||(b.f&nr)!==0)&&Ft()&&(b.f&(q|Ie|gn|nr))!==0&&(le===null||!ke.call(le,e))&&Ti();let r=n?Je(t):t;return mt(e,r,$t)}function mt(e,t,n=null){if(!e.equals(t)){var r=e.v;et?Fe.set(e,t):Fe.set(e,r),e.v=t;var i=Xe.ensure();if(i.capture(e,r),(e.f&q)!==0){const s=e;(e.f&z)!==0&&En(s),mn(s)}e.wv=zr(),Tr(e,z,n),Ft()&&S!==null&&(S.f&L)!==0&&(S.f&(ae|Be))===0&&(oe===null?ds([e]):oe.push(e)),!i.is_fork&&xn.size>0&&!Er&&ts()}return t}function ts(){Er=!1;for(const e of xn)(e.f&L)!==0&&I(e,ue),Vt(e)&&yt(e);xn.clear()}function xr(e,t=1){var n=E(e),r=t===1?n++:n--;return j(e,n),r}function Lt(e){j(e,e.v+1)}function Tr(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ft(),s=r.length,f=0;f<s;f++){var l=r[f],o=l.f;if(!(!i&&l===S)){var a=(o&z)===0;if(a&&I(l,t),(o&q)!==0){var c=l;H==null||H.delete(c),(o&We)===0&&(o&re&&(l.f|=We),Tr(c,ue,n))}else if(a){var h=l;(o&Ie)!==0&&de!==null&&de.add(h),n!==null?n.push(h):bn(h)}}}}function Je(e){if(typeof e!="object"||e===null||ht in e)return e;const t=Jn(e);if(t!==di&&t!==hi)return e;var n=new Map,r=D(e),i=Z(0),s=nt,f=l=>{if(nt===s)return l();var o=b,a=nt;se(null),Hr(s);var c=l();return se(o),Hr(a),c};return r&&n.set("length",Z(e.length)),new Proxy(e,{defineProperty(l,o,a){(!("value"in a)||a.configurable===!1||a.enumerable===!1||a.writable===!1)&&Ei();var c=n.get(o);return c===void 0?f(()=>{var h=Z(a.value);return n.set(o,h),h}):j(c,a.value,!0),!0},deleteProperty(l,o){var a=n.get(o);if(a===void 0){if(o in l){const c=f(()=>Z(V));n.set(o,c),Lt(i)}}else j(a,V),Lt(i);return!0},get(l,o,a){var p;if(o===ht)return e;var c=n.get(o),h=o in l;if(c===void 0&&(!h||(p=Ct(l,o))!=null&&p.writable)&&(c=f(()=>{var d=Je(h?l[o]:V),_=Z(d);return _}),n.set(o,c)),c!==void 0){var v=E(c);return v===V?void 0:v}return Reflect.get(l,o,a)},getOwnPropertyDescriptor(l,o){var a=Reflect.getOwnPropertyDescriptor(l,o);if(a&&"value"in a){var c=n.get(o);c&&(a.value=E(c))}else if(a===void 0){var h=n.get(o),v=h==null?void 0:h.v;if(h!==void 0&&v!==V)return{enumerable:!0,configurable:!0,value:v,writable:!0}}return a},has(l,o){var v;if(o===ht)return!0;var a=n.get(o),c=a!==void 0&&a.v!==V||Reflect.has(l,o);if(a!==void 0||S!==null&&(!c||(v=Ct(l,o))!=null&&v.writable)){a===void 0&&(a=f(()=>{var p=c?Je(l[o]):V,d=Z(p);return d}),n.set(o,a));var h=E(a);if(h===V)return!1}return c},set(l,o,a,c){var U;var h=n.get(o),v=o in l;if(r&&o==="length")for(var p=a;p<h.v;p+=1){var d=n.get(p+"");d!==void 0?j(d,V):p in l&&(d=f(()=>Z(V)),n.set(p+"",d))}if(h===void 0)(!v||(U=Ct(l,o))!=null&&U.writable)&&(h=f(()=>Z(void 0)),j(h,Je(a)),n.set(o,h));else{v=h.v!==V;var _=f(()=>Je(a));j(h,_)}var x=Reflect.getOwnPropertyDescriptor(l,o);if(x!=null&&x.set&&x.set.call(c,a),!v){if(r&&typeof o=="string"){var w=n.get("length"),A=Number(o);Number.isInteger(A)&&A>=w.v&&j(w,A+1)}Lt(i)}return!0},ownKeys(l){E(i);var o=Reflect.ownKeys(l).filter(h=>{var v=n.get(h);return v===void 0||v.v!==V});for(var[a,c]of n)c.v!==V&&!(a in l)&&o.push(a);return o},setPrototypeOf(){xi()}})}var Tn,Sr,kr,Ar;function ns(){if(Tn===void 0){Tn=window,Sr=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;kr=Ct(t,"firstChild").get,Ar=Ct(t,"nextSibling").get,$n(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),$n(n)&&(n.__t=void 0)}}function Oe(e=""){return document.createTextNode(e)}function qe(e){return kr.call(e)}function jt(e){return Ar.call(e)}function K(e,t){return qe(e)}function me(e,t=!1){{var n=qe(e);return n instanceof Comment&&n.data===""?jt(n):n}}function he(e,t=1,n=!1){let r=e;for(;t--;)r=jt(r);return r}function rs(e){e.textContent=""}function Mr(){return!1}function Dr(e,t,n){return document.createElementNS(t??Ci,e,void 0)}let Pr=!1;function is(){Pr||(Pr=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const n of e.target.elements)(t=n.__on_r)==null||t.call(n)})},{capture:!0}))}function nn(e){var t=b,n=S;se(null),ye(null);try{return e()}finally{se(t),ye(n)}}function ss(e,t,n,r=n){e.addEventListener(t,()=>nn(n));const i=e.__on_r;i?e.__on_r=()=>{i(),r(!0)}:e.__on_r=()=>r(!0),is()}function Cr(e){S===null&&(b===null&&yi(),wi()),et&&mi()}function ls(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function we(e,t){var n=S;n!==null&&(n.f&X)!==0&&(e|=X);var r={ctx:M,deps:null,nodes:null,f:e|z|re,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null},i=r;if((e&ct)!==0)gt!==null?gt.push(r):Xe.ensure().schedule(r);else if(t!==null){try{yt(r)}catch(f){throw W(r),f}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&dt)===0&&(i=i.first,(e&Ie)!==0&&(e&Ye)!==0&&i!==null&&(i.f|=Ye))}if(i!==null&&(i.parent=n,n!==null&&ls(i,n),b!==null&&(b.f&q)!==0&&(e&Be)===0)){var s=b;(s.effects??(s.effects=[])).push(i)}return r}function Sn(){return b!==null&&!ve}function Ir(e){const t=we(Rt,null);return I(t,L),t.teardown=e,t}function wt(e){Cr();var t=S.f,n=!b&&(t&ae)!==0&&(t&Ke)===0;if(n){var r=M;(r.e??(r.e=[])).push(e)}else return Rr(e)}function Rr(e){return we(ct|rr,e)}function os(e){return Cr(),we(Rt|rr,e)}function fs(e){Xe.ensure();const t=we(Be|dt,e);return(n={})=>new Promise(r=>{n.outro?$e(t,()=>{W(t),r(void 0)}):(W(t),r(void 0))})}function as(e){return we(ct,e)}function us(e){return we(gn|dt,e)}function kn(e,t=0){return we(Rt|t,e)}function Ut(e,t=[],n=[],r=[]){Gi(r,t,n,i=>{we(Rt,()=>e(...i.map(E)))})}function rn(e,t=0){var n=we(Ie|t,e);return n}function ie(e){return we(ae|dt,e)}function Nr(e){var t=e.teardown;if(t!==null){const n=et,r=b;jr(!0),se(null);try{t.call(null)}finally{jr(n),se(r)}}}function An(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const i=n.ac;i!==null&&nn(()=>{i.abort(Me)});var r=n.next;(n.f&Be)!==0?n.parent=null:W(n,t),n=r}}function cs(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&ae)===0&&W(t),t=n}}function W(e,t=!0){var n=!1;(t||(e.f&pi)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Fr(e.nodes.start,e.nodes.end),n=!0),I(e,pn),An(e,t&&!n),Ht(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(const s of r)s.stop();Nr(e),e.f^=pn,e.f|=ce;var i=e.parent;i!==null&&i.first!==null&&Or(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Fr(e,t){for(;e!==null;){var n=e===t?null:jt(e);e.remove(),e=n}}function Or(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function $e(e,t,n=!0){var r=[];qr(e,r,!0);var i=()=>{n&&W(e),t&&t()},s=r.length;if(s>0){var f=()=>--s||i();for(var l of r)l.out(f)}else i()}function qr(e,t,n){if((e.f&X)===0){e.f^=X;var r=e.nodes&&e.nodes.t;if(r!==null)for(const l of r)(l.is_global||n)&&t.push(l);for(var i=e.first;i!==null;){var s=i.next,f=(i.f&Ye)!==0||(i.f&ae)!==0&&(e.f&Ie)!==0;qr(i,t,f?n:!1),i=s}}}function Mn(e){Lr(e,!0)}function Lr(e,t){if((e.f&X)!==0){e.f^=X,(e.f&L)===0&&(I(e,z),Xe.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&Ye)!==0||(n.f&ae)!==0;Lr(n,i?t:!1),n=r}var s=e.nodes&&e.nodes.t;if(s!==null)for(const f of s)(f.is_global||t)&&f.in()}}function Dn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:jt(n);t.append(n),n=i}}let sn=!1,et=!1;function jr(e){et=e}let b=null,ve=!1;function se(e){b=e}let S=null;function ye(e){S=e}let le=null;function Ur(e){b!==null&&(le===null?le=[e]:le.push(e))}let G=null,J=0,oe=null;function ds(e){oe=e}let Vr=1,tt=0,nt=tt;function Hr(e){nt=e}function zr(){return++Vr}function Vt(e){var t=e.f;if((t&z)!==0)return!0;if(t&q&&(e.f&=~We),(t&ue)!==0){for(var n=e.deps,r=n.length,i=0;i<r;i++){var s=n[i];if(Vt(s)&&yr(s),s.wv>e.wv)return!0}(t&re)!==0&&H===null&&I(e,L)}return!1}function Br(e,t,n=!0){var r=e.reactions;if(r!==null&&!(le!==null&&ke.call(le,e)))for(var i=0;i<r.length;i++){var s=r[i];(s.f&q)!==0?Br(s,t,!1):t===s&&(n?I(s,z):(s.f&L)!==0&&I(s,ue),bn(s))}}function Kr(e){var _;var t=G,n=J,r=oe,i=b,s=le,f=M,l=ve,o=nt,a=e.f;G=null,J=0,oe=null,b=(a&(ae|Be))===0?e:null,le=null,vt(e.ctx),ve=!1,nt=++tt,e.ac!==null&&(nn(()=>{e.ac.abort(Me)}),e.ac=null);try{e.f|=_n;var c=e.fn,h=c();e.f|=Ke;var v=e.deps,p=m==null?void 0:m.is_fork;if(G!==null){var d;if(p||Ht(e,J),v!==null&&J>0)for(v.length=J+G.length,d=0;d<G.length;d++)v[J+d]=G[d];else e.deps=v=G;if(Sn()&&(e.f&re)!==0)for(d=J;d<v.length;d++)((_=v[d]).reactions??(_.reactions=[])).push(e)}else!p&&v!==null&&J<v.length&&(Ht(e,J),v.length=J);if(Ft()&&oe!==null&&!ve&&v!==null&&(e.f&(q|ue|z))===0)for(d=0;d<oe.length;d++)Br(oe[d],e);if(i!==null&&i!==e){if(tt++,i.deps!==null)for(let x=0;x<n;x+=1)i.deps[x].rv=tt;if(t!==null)for(const x of t)x.rv=tt;oe!==null&&(r===null?r=oe:r.push(...oe))}return(e.f&Re)!==0&&(e.f^=Re),h}catch(x){return ar(x)}finally{e.f^=_n,G=t,J=n,oe=r,b=i,le=s,vt(f),ve=l,nt=o}}function hs(e,t){let n=t.reactions;if(n!==null){var r=F.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&(t.f&q)!==0&&(G===null||!ke.call(G,t))){var s=t;(s.f&re)!==0&&(s.f^=re,s.f&=~We),mn(s),$i(s),Ht(s,0)}}function Ht(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)hs(e,n[r])}function yt(e){var t=e.f;if((t&ce)===0){I(e,L);var n=S,r=sn;S=e,sn=!0;try{(t&(Ie|tr))!==0?cs(e):An(e),Nr(e);var i=Kr(e);e.teardown=typeof i=="function"?i:null,e.wv=Vr;var s}finally{sn=r,S=n}}}async function Yr(){await Promise.resolve(),Hi()}function E(e){var t=e.f,n=(t&q)!==0;if(b!==null&&!ve){var r=S!==null&&(S.f&ce)!==0;if(!r&&(le===null||!ke.call(le,e))){var i=b.deps;if((b.f&_n)!==0)e.rv<tt&&(e.rv=tt,G===null&&i!==null&&i[J]===e?J++:G===null?G=[e]:G.push(e));else{(b.deps??(b.deps=[])).push(e);var s=e.reactions;s===null?e.reactions=[b]:ke.call(s,b)||s.push(b)}}}if(et&&Fe.has(e))return Fe.get(e);if(n){var f=e;if(et){var l=f.v;return((f.f&L)===0&&f.reactions!==null||Gr(f))&&(l=En(f)),Fe.set(f,l),l}var o=(f.f&re)===0&&!ve&&b!==null&&(sn||(b.f&re)!==0),a=(f.f&Ke)===0;Vt(f)&&(o&&(f.f|=re),yr(f)),o&&!a&&(br(f),Wr(f))}if(H!=null&&H.has(e))return H.get(e);if((e.f&Re)!==0)throw e.v;return e.v}function Wr(e){if(e.f|=re,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&q)!==0&&(t.f&re)===0&&(br(t),Wr(t))}function Gr(e){if(e.v===V)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(Fe.has(t)||(t.f&q)!==0&&Gr(t))return!0;return!1}function zt(e){var t=ve;try{return ve=!0,e()}finally{ve=t}}function vs(e){if(!(typeof e!="object"||!e||e instanceof EventTarget)){if(ht in e)Pn(e);else if(!Array.isArray(e))for(let t in e){const n=e[t];typeof n=="object"&&n&&ht in n&&Pn(n)}}}function Pn(e,t=new Set){if(typeof e=="object"&&e!==null&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let r in e)try{Pn(e[r],t)}catch{}const n=Jn(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const r=ci(n);for(let i in r){const s=r[i].get;if(s)try{s.call(e)}catch{}}}}}const ps=["touchstart","touchmove"];function _s(e){return ps.includes(e)}const rt=Symbol("events"),Qr=new Set,Cn=new Set;function gs(e,t,n,r={}){function i(s){if(r.capture||Rn.call(t,s),!s.cancelBubble)return nn(()=>n==null?void 0:n.call(this,s))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?Qe(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Xr(e,t,n,r,i){var s={capture:r,passive:i},f=gs(e,t,n,s);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Ir(()=>{t.removeEventListener(e,f,s)})}function Bt(e,t,n){(t[rt]??(t[rt]={}))[e]=n}function In(e){for(var t=0;t<e.length;t++)Qr.add(e[t]);for(var n of Cn)n(e)}let Zr=null;function Rn(e){var x,w;var t=this,n=t.ownerDocument,r=e.type,i=((x=e.composedPath)==null?void 0:x.call(e))||[],s=i[0]||e.target;Zr=e;var f=0,l=Zr===e&&e[rt];if(l){var o=i.indexOf(l);if(o!==-1&&(t===document||t===window)){e[rt]=t;return}var a=i.indexOf(t);if(a===-1)return;o<=a&&(f=o)}if(s=i[f]||e.target,s!==t){ui(e,"currentTarget",{configurable:!0,get(){return s||n}});var c=b,h=S;se(null),ye(null);try{for(var v,p=[];s!==null;){var d=s.assignedSlot||s.parentNode||s.host||null;try{var _=(w=s[rt])==null?void 0:w[r];_!=null&&(!s.disabled||e.target===s)&&_.call(s,e)}catch(A){v?p.push(A):v=A}if(e.cancelBubble||d===t||d===null)break;s=d}if(v){for(let A of p)queueMicrotask(()=>{throw A});throw v}}finally{e[rt]=t,delete e.currentTarget,se(c),ye(h)}}}const Nn=((li=globalThis==null?void 0:globalThis.window)==null?void 0:li.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function ms(e){return(Nn==null?void 0:Nn.createHTML(e))??e}function ws(e){var t=Dr("template");return t.innerHTML=ms(e.replaceAll("<!>","<!---->")),t.content}function bt(e,t){var n=S;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function Y(e,t){var n=(t&Di)!==0,r=(t&Pi)!==0,i,s=!e.startsWith("<!>");return()=>{i===void 0&&(i=ws(s?e:"<!>"+e),n||(i=qe(i)));var f=r||Sr?document.importNode(i,!0):i.cloneNode(!0);if(n){var l=qe(f),o=f.lastChild;bt(l,o)}else bt(f,f);return f}}function ys(e=""){{var t=Oe(e+"");return bt(t,t),t}}function Le(){var e=document.createDocumentFragment(),t=document.createComment(""),n=Oe();return e.append(t,n),bt(t,n),e}function C(e,t){e!==null&&e.before(t)}function Fn(e,t){var n=t==null?"":typeof t=="object"?`${t}`:t;n!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=n,e.nodeValue=`${n}`)}function bs(e,t){return Es(e,t)}const ln=new Map;function Es(e,{target:t,anchor:n,props:r={},events:i,context:s,intro:f=!0,transformError:l}){ns();var o=void 0,a=fs(()=>{var c=n??t.appendChild(Oe());Yi(c,{pending:()=>{}},p=>{pt({});var d=M;s&&(d.c=s),i&&(r.$$events=i),o=e(p,r)||{},_t()},l);var h=new Set,v=p=>{for(var d=0;d<p.length;d++){var _=p[d];if(!h.has(_)){h.add(_);var x=_s(_);for(const U of[t,document]){var w=ln.get(U);w===void 0&&(w=new Map,ln.set(U,w));var A=w.get(_);A===void 0?(U.addEventListener(_,Rn,{passive:x}),w.set(_,1)):w.set(_,A+1)}}}};return v(Jt(Qr)),Cn.add(v),()=>{var x;for(var p of h)for(const w of[t,document]){var d=ln.get(w),_=d.get(p);--_==0?(w.removeEventListener(p,Rn),d.delete(p),d.size===0&&ln.delete(w)):d.set(p,_)}Cn.delete(v),c!==n&&((x=c.parentNode)==null||x.removeChild(c))}});return xs.set(o,a),o}let xs=new WeakMap;class Jr{constructor(t,n=!0){ge(this,"anchor");T(this,_e,new Map);T(this,Te,new Map);T(this,ee,new Map);T(this,ot,new Set);T(this,Gt,!0);T(this,Qt,t=>{if(u(this,_e).has(t)){var n=u(this,_e).get(t),r=u(this,Te).get(n);if(r)Mn(r),u(this,ot).delete(n);else{var i=u(this,ee).get(n);i&&(u(this,Te).set(n,i.effect),u(this,ee).delete(n),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[s,f]of u(this,_e)){if(u(this,_e).delete(s),s===t)break;const l=u(this,ee).get(f);l&&(W(l.effect),u(this,ee).delete(f))}for(const[s,f]of u(this,Te)){if(s===n||u(this,ot).has(s))continue;const l=()=>{if(Array.from(u(this,_e).values()).includes(s)){var a=document.createDocumentFragment();Dn(f,a),a.append(Oe()),u(this,ee).set(s,{effect:f,fragment:a})}else W(f);u(this,ot).delete(s),u(this,Te).delete(s)};u(this,Gt)||!r?(u(this,ot).add(s),$e(f,l,!1)):l()}}});T(this,un,t=>{u(this,_e).delete(t);const n=Array.from(u(this,_e).values());for(const[r,i]of u(this,ee))n.includes(r)||(W(i.effect),u(this,ee).delete(r))});this.anchor=t,y(this,Gt,n)}ensure(t,n){var r=m,i=Mr();if(n&&!u(this,Te).has(t)&&!u(this,ee).has(t))if(i){var s=document.createDocumentFragment(),f=Oe();s.append(f),u(this,ee).set(t,{effect:ie(()=>n(f)),fragment:s})}else u(this,Te).set(t,ie(()=>n(this.anchor)));if(u(this,_e).set(r,t),i){for(const[l,o]of u(this,Te))l===t?r.unskip_effect(o):r.skip_effect(o);for(const[l,o]of u(this,ee))l===t?r.unskip_effect(o.effect):r.skip_effect(o.effect);r.oncommit(u(this,Qt)),r.ondiscard(u(this,un))}else u(this,Qt).call(this,r)}}_e=new WeakMap,Te=new WeakMap,ee=new WeakMap,ot=new WeakMap,Gt=new WeakMap,Qt=new WeakMap,un=new WeakMap;function De(e,t,n=!1){var r=new Jr(e),i=n?Ye:0;function s(f,l){r.ensure(f,l)}rn(()=>{var f=!1;t((l,o=0)=>{f=!0,s(o,l)}),f||s(-1,null)},i)}function Ts(e,t){return t}function Ss(e,t,n){for(var r=[],i=t.length,s,f=t.length,l=0;l<i;l++){let h=t[l];$e(h,()=>{if(s){if(s.pending.delete(h),s.done.add(h),s.pending.size===0){var v=e.outrogroups;On(e,Jt(s.done)),v.delete(s),v.size===0&&(e.outrogroups=null)}}else f-=1},!1)}if(f===0){var o=r.length===0&&n!==null;if(o){var a=n,c=a.parentNode;rs(c),c.append(a),e.items.clear()}On(e,t,!o)}else s={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(s)}function On(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(const f of e.pending.values())for(const l of f)r.add(e.items.get(l).e)}for(var i=0;i<t.length;i++){var s=t[i];if(r!=null&&r.has(s)){s.f|=Ae;const f=document.createDocumentFragment();Dn(s,f)}else W(t[i],n)}}var $r;function ks(e,t,n,r,i,s=null){var f=e,l=new Map,o=null,a=wr(()=>{var w=n();return D(w)?w:w==null?[]:Jt(w)}),c,h=new Map,v=!0;function p(w){(x.effect.f&ce)===0&&(x.pending.delete(w),x.fallback=o,As(x,c,f,t,r),o!==null&&(c.length===0?(o.f&Ae)===0?Mn(o):(o.f^=Ae,Yt(o,null,f)):$e(o,()=>{o=null})))}function d(w){x.pending.delete(w)}var _=rn(()=>{c=E(a);for(var w=c.length,A=new Set,U=m,ze=Mr(),te=0;te<w;te+=1){var ft=c[te],g=r(ft,te),R=v?null:l.get(g);R?(R.v&&mt(R.v,ft),R.i&&mt(R.i,te),ze&&U.unskip_effect(R.e)):(R=Ms(l,v?f:$r??($r=Oe()),ft,g,te,i,t,n),v||(R.e.f|=Ae),l.set(g,R)),A.add(g)}if(w===0&&s&&!o&&(v?o=ie(()=>s(f)):(o=ie(()=>s($r??($r=Oe()))),o.f|=Ae)),w>A.size&&gi(),!v)if(h.set(U,A),ze){for(const[ne,Hn]of l)A.has(ne)||U.skip_effect(Hn.e);U.oncommit(p),U.ondiscard(d)}else p(U);E(a)}),x={effect:_,items:l,pending:h,outrogroups:null,fallback:o};v=!1}function Kt(e){for(;e!==null&&(e.f&ae)===0;)e=e.next;return e}function As(e,t,n,r,i){var R;var s=t.length,f=e.items,l=Kt(e.effect.first),o,a=null,c=[],h=[],v,p,d,_;for(_=0;_<s;_+=1){if(v=t[_],p=i(v,_),d=f.get(p).e,e.outrogroups!==null)for(const ne of e.outrogroups)ne.pending.delete(d),ne.done.delete(d);if((d.f&Ae)!==0)if(d.f^=Ae,d===l)Yt(d,null,n);else{var x=a?a.next:l;d===e.effect.last&&(e.effect.last=d.prev),d.prev&&(d.prev.next=d.next),d.next&&(d.next.prev=d.prev),je(e,a,d),je(e,d,x),Yt(d,x,n),a=d,c=[],h=[],l=Kt(a.next);continue}if((d.f&X)!==0&&Mn(d),d!==l){if(o!==void 0&&o.has(d)){if(c.length<h.length){var w=h[0],A;a=w.prev;var U=c[0],ze=c[c.length-1];for(A=0;A<c.length;A+=1)Yt(c[A],w,n);for(A=0;A<h.length;A+=1)o.delete(h[A]);je(e,U.prev,ze.next),je(e,a,U),je(e,ze,w),l=w,a=ze,_-=1,c=[],h=[]}else o.delete(d),Yt(d,l,n),je(e,d.prev,d.next),je(e,d,a===null?e.effect.first:a.next),je(e,a,d),a=d;continue}for(c=[],h=[];l!==null&&l!==d;)(o??(o=new Set)).add(l),h.push(l),l=Kt(l.next);if(l===null)continue}(d.f&Ae)===0&&c.push(d),a=d,l=Kt(d.next)}if(e.outrogroups!==null){for(const ne of e.outrogroups)ne.pending.size===0&&(On(e,Jt(ne.done)),(R=e.outrogroups)==null||R.delete(ne));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||o!==void 0){var te=[];if(o!==void 0)for(d of o)(d.f&X)===0&&te.push(d);for(;l!==null;)(l.f&X)===0&&l!==e.fallback&&te.push(l),l=Kt(l.next);var ft=te.length;if(ft>0){var g=null;Ss(e,te,g)}}}function Ms(e,t,n,r,i,s,f,l){var o=(f&ki)!==0?(f&Mi)===0?es(n,!1,!1):Ze(n):null,a=(f&Ai)!==0?Ze(i):null;return{v:o,i:a,e:ie(()=>(s(t,o??n,a??i,l),()=>{e.delete(r)}))}}function Yt(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,s=t&&(t.f&Ae)===0?t.nodes.start:n;r!==null;){var f=jt(r);if(s.before(r),r===i)return;r=f}}function je(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function on(e,t,n=!1,r=!1,i=!1,s=!1){var f=e,l="";if(n)var o=e;Ut(()=>{var a=S;if(l!==(l=t()??"")){if(n){a.nodes=null,o.innerHTML=l,l!==""&&bt(qe(o),o.lastChild);return}if(a.nodes!==null&&(Fr(a.nodes.start,a.nodes.end),a.nodes=null),l!==""){var c=r?Ii:i?Ri:void 0,h=Dr(r?"svg":i?"math":"template",c);h.innerHTML=l;var v=r||i?h:h.content;if(bt(qe(v),v.lastChild),r||i)for(;qe(v);)f.before(qe(v));else f.before(v)}}})}function it(e,t,...n){var r=new Jr(e);rn(()=>{const i=t()??null;r.ensure(i,i&&(s=>i(s,...n)))},Ye)}const ei=[...` \n\\r\\f\xA0\\v\\uFEFF`];function Ds(e,t,n){var r=""+e;if(n){for(var i of Object.keys(n))if(n[i])r=r?r+" "+i:i;else if(r.length)for(var s=i.length,f=0;(f=r.indexOf(i,f))>=0;){var l=f+s;(f===0||ei.includes(r[f-1]))&&(l===r.length||ei.includes(r[l]))?r=(f===0?"":r.substring(0,f))+r.substring(l+1):f=l}}return r===""?null:r}function ti(e,t=!1){var n=t?" !important;":";",r="";for(var i of Object.keys(e)){var s=e[i];s!=null&&s!==""&&(r+=" "+i+": "+s+n)}return r}function Ps(e,t){if(t){var n="",r,i;return Array.isArray(t)?(r=t[0],i=t[1]):r=t,r&&(n+=ti(r)),i&&(n+=ti(i,!0)),n=n.trim(),n===""?null:n}return String(e)}function Cs(e,t,n,r,i,s){var f=e.__className;if(f!==n||f===void 0){var l=Ds(n,r,s);l==null?e.removeAttribute("class"):e.className=l,e.__className=n}else if(s&&i!==s)for(var o in s){var a=!!s[o];(i==null||a!==!!i[o])&&e.classList.toggle(o,a)}return s}function qn(e,t={},n,r){for(var i in n){var s=n[i];t[i]!==s&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,s,r))}}function Is(e,t,n,r){var i=e.__style;if(i!==t){var s=Ps(t,r);s==null?e.removeAttribute("style"):e.style.cssText=s,e.__style=t}else r&&(Array.isArray(r)?(qn(e,n==null?void 0:n[0],r[0]),qn(e,n==null?void 0:n[1],r[1],"important")):qn(e,n,r));return r}function Rs(e,t,n=t){var r=new WeakSet;ss(e,"input",async i=>{var s=i?e.defaultValue:e.value;if(s=Ln(e)?jn(s):s,n(s),m!==null&&r.add(m),await Yr(),s!==(s=t())){var f=e.selectionStart,l=e.selectionEnd,o=e.value.length;if(e.value=s??"",l!==null){var a=e.value.length;f===l&&l===o&&a>o?(e.selectionStart=a,e.selectionEnd=a):(e.selectionStart=f,e.selectionEnd=Math.min(l,a))}}}),zt(t)==null&&e.value&&(n(Ln(e)?jn(e.value):e.value),m!==null&&r.add(m)),kn(()=>{var i=t();if(e===document.activeElement){var s=m;if(r.has(s))return}Ln(e)&&i===jn(e.value)||e.type==="date"&&!i&&!e.value||i!==e.value&&(e.value=i??"")})}function Ln(e){var t=e.type;return t==="number"||t==="range"}function jn(e){return e===""?null:+e}function ni(e,t){return e===t||(e==null?void 0:e[ht])===t}function Ns(e={},t,n,r){var i=M.r,s=S;return as(()=>{var f,l;return kn(()=>{f=l,l=[],zt(()=>{e!==n(...l)&&(t(e,...l),f&&ni(n(...f),e)&&t(null,...f))})}),()=>{let o=s;for(;o!==i&&o.parent!==null&&o.parent.f&pn;)o=o.parent;const a=()=>{l&&ni(n(...l),e)&&t(null,...l)},c=o.teardown;o.teardown=()=>{a(),c==null||c()}}}),e}function Fs(e=!1){const t=M,n=t.l.u;if(!n)return;let r=()=>vs(t.s);if(e){let i=0,s={};const f=tn(()=>{let l=!1;const o=t.s;for(const a in o)o[a]!==s[a]&&(s[a]=o[a],l=!0);return l&&i++,i});r=()=>E(f)}n.b.length&&os(()=>{ri(t,r),hn(n.b)}),wt(()=>{const i=zt(()=>n.m.map(vi));return()=>{for(const s of i)typeof s=="function"&&s()}}),n.a.length&&wt(()=>{ri(t,r),hn(n.a)})}function ri(e,t){if(e.l.s)for(const n of e.l.s)E(n);t()}function Os(e){M===null&&ir(),Nt&&M.l!==null?qs(M).m.push(e):wt(()=>{const t=zt(e);if(typeof t=="function")return t})}function qs(e){var t=e.l;return t.u??(t.u={a:[],b:[],m:[]})}const Ls="5";typeof window<"u"&&((oi=window.__svelte??(window.__svelte={})).v??(oi.v=new Set)).add(Ls);var js=Y(\'<span class="silversearch-title svelte-utv8gj"><!></span>\'),Us=Y(\'<span class="silversearch-info svelte-utv8gj"><!></span>\'),Vs=Y(\'<div class="sb-name svelte-utv8gj"><!> <!></div>\'),Hs=Y(\'<div><!> <div class="sb-description svelte-utv8gj"><!></div></div>\');function zs(e,t){var n=Hs();let r;var i=K(n);{var s=o=>{var a=Vs(),c=K(a);{var h=d=>{var _=js(),x=K(_);it(x,()=>t.title),C(d,_)};De(c,d=>{t.title&&d(h)})}var v=he(c,2);{var p=d=>{var _=Us(),x=K(_);it(x,()=>t.info),C(d,_)};De(v,d=>{t.info&&d(p)})}C(o,a)};De(i,o=>{(t.title||t.info)&&o(s)})}var f=he(i,2),l=K(f);it(l,()=>t.description),Ut(()=>r=Cs(n,1,"sb-option",null,r,{"silversearch-selected":t.selected})),Bt("click",n,function(...o){var a;(a=t.onclick)==null||a.apply(this,o)}),Bt("mousemove",n,function(...o){var a;(a=t.onmousemove)==null||a.apply(this,o)}),C(e,n)}In(["click","mousemove"]),Oi();var Bs=Y(\'<p class="silversearch-apology svelte-l7tsl3">Silversearch found <code>0</code> results for your query</p>\');function Ks(e){var t=Bs();C(e,t)}var Ys=Y(\'<div class="container svelte-1e54ghr"><div class="bar svelte-1e54ghr"></div></div>\');function Ws(e,t){var n=Ys(),r=K(n);let i;Ut(()=>i=Is(r,"",i,{width:t.progress===null?"30%":`${t.progress}%`,animation:t.progress===null?"slide 1s linear infinite":"none"})),C(e,n)}var Gs=Y(\'<p class="svelte-qgaxc8">Indexed <code> </code> out of <code> </code> documents</p>\'),Qs=Y(\'<p class="svelte-qgaxc8">Loading ...</p>\'),Xs=Y(\'<div class="silversearch-apology svelte-qgaxc8"><!> <!></div>\');function Zs(e,t){pt(t,!0);let n=Z(null),r=mr(()=>E(n)?E(n).done/E(n).all*100:null);Os(()=>{const a=setInterval(async()=>{const c=await syscall("clientStore.get","silversearch-progress");c&&j(n,c,!0)},50);return()=>clearInterval(a)});var i=Xs(),s=K(i);Ws(s,{get progress(){return E(r)}});var f=he(s,2);{var l=a=>{var c=Gs(),h=he(K(c)),v=K(h),p=he(h,2),d=K(p);Ut(()=>{Fn(v,E(n).done),Fn(d,E(n).all)}),C(a,c)},o=a=>{var c=Qs();C(a,c)};De(f,a=>{E(n)!==null?a(l):a(o,-1)})}C(e,i),_t()}var Js=Y(`<div class="silversearch-help svelte-rar4cx"><p class="svelte-rar4cx">Add the following to your query to refine the search:</p> <ul class="svelte-rar4cx"><li>Use <code>path:"Library"</code> to restrict your results\n to paths which include "Library"</li> <li>Use <code>ext:pdf,jpg</code> or <code>ext:png</code>, or\n a plain <code>.png</code> to restrict your search to certain filetypes</li> <li>Use <code>"exact expressions"</code> in quotes to further filter\n the results returned by the query</li> <li>Use <code>-apple -pie</code> to exclude notes containing the words\n "apple" and "pie"</li></ul></div>`);function $s(e){var t=Js();C(e,t)}let k=Je({text:"",buffer:"",historyIndex:-1,history:[]});var el=Y(\'<dialog class="sb-modal-box svelte-1pjmr73"><div class="sb-header"><label for="mini-editor">Search</label> <input id="mini-editor" class="sb-input svelte-1pjmr73" placeholder="Search with Silversearch" autocomplete="off"/></div> <div class="sb-help-text"><!></div> <div class="sb-result-list" style="max-height: 80vh;"><!> <!></div></dialog>\');function ii(e,t){pt(t,!0);let n;wt(()=>{n.showModal()});function r(){syscall("editor.hidePanel","modal")}let i=Z(Je([])),s=Z(!1),f=Z(0);wt(()=>{k.historyIndex>=0&&(k.history[k.historyIndex]=k.text)}),wt(()=>{k.text?o():(j(i,[],!0),j(s,!1))});let l=null;async function o(){j(s,!0),l&&(l.reject(),l=null),l=Promise.withResolvers();try{j(i,await Promise.race([t.search(k.text),l.promise]),!0),l=null,j(f,0),h(),j(s,!1)}catch{}}async function a(g,R){E(i).length!==0&&(k.text&&k.history.unshift(k.text),k.history=k.history.filter(ne=>ne),k.history.length>50&&k.history.pop(),syscall("clientStore.set","silversearch-history",[...k.history]),await t.open(E(i)[E(f)],g,R),await syscall("editor.hidePanel","modal"))}function c(g){if(g.key==="Enter"){a(g.ctrlKey,g.altKey);return}if(g.ctrlKey){const R=k.historyIndex;if(R===-1&&(k.buffer=k.text),g.key==="ArrowUp")k.historyIndex++;else if(g.key==="ArrowDown")k.historyIndex--;else return;k.historyIndex=Math.max(-1,Math.min(k.historyIndex,k.history.length-1)),R!=k.historyIndex&&k.historyIndex>=0?k.text=k.history[k.historyIndex]:k.historyIndex===-1&&(k.text=k.buffer)}else{if(g.key==="ArrowUp")xr(f,-1);else if(g.key==="ArrowDown")xr(f);else return;j(f,Math.max(0,Math.min(E(f),E(i).length-1)),!0)}g.preventDefault(),h()}async function h(){await Yr();const g=document.querySelector(".silversearch-selected");g&&g.scrollIntoView({block:"nearest"})}var v=el();Xr("click",Tn,r);var p=K(v),d=he(K(p),2),_=he(p,2),x=K(_);it(x,()=>t.helpText);var w=he(_,2),A=K(w);ks(A,17,()=>E(i),Ts,(g,R,ne)=>{{const Hn=at=>{var Se=Le(),Xt=me(Se);{var zn=ut=>{var Zt=Le(),Bn=me(Zt);it(Bn,()=>t.elementTitle,()=>E(R)),C(ut,Zt)};De(Xt,ut=>{t.elementTitle&&ut(zn)})}C(at,Se)},cl=at=>{var Se=Le(),Xt=me(Se);it(Xt,()=>t.elementDescription,()=>E(R)),C(at,Se)},dl=at=>{var Se=Le(),Xt=me(Se);{var zn=ut=>{var Zt=Le(),Bn=me(Zt);it(Bn,()=>t.elementInfo,()=>E(R)),C(ut,Zt)};De(Xt,ut=>{t.elementInfo&&ut(zn)})}C(at,Se)};let hl=mr(()=>ne===E(f));zs(g,{get selected(){return E(hl)},onclick:({ctrlKey:at,altKey:Se})=>a(at,Se),onmousemove:()=>j(f,ne,!0),title:Hn,description:cl,info:dl})}});var U=he(A,2);{var ze=g=>{Ks(g)},te=g=>{$s(g)},ft=g=>{Zs(g,{})};De(U,g=>{!E(i).length&&!E(s)&&k.text?g(ze):!E(i).length&&!E(s)?g(te,1):!E(i).length&&E(s)&&g(ft,2)})}Ns(v,g=>n=g,()=>n),Xr("cancel",v,g=>{g.preventDefault(),syscall("editor.hidePanel","modal")}),Bt("click",p,g=>g.stopPropagation()),Bt("keydown",p,c),Rs(d,()=>k.text,g=>k.text=g),C(e,v),_t()}In(["click","keydown"]);function tl(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,"\\\\$&")}const si=/(<br>|<|>|"|')/g;function Un(e,t){const n="silversearch-highlight";if(!t.length)return e;try{return e.split(si).map(r=>r.match(si)?r:r.replace(new RegExp(`(${t.map(i=>tl(i.match)).join("|")})`,"giu"),`<span class="${n}">$1</span>`)).join("")}catch(r){return console.error("[Silversearch] Error in highlightText()",r),e}}var nl=Y("Press <code>Ctrl-Enter</code> to open in new Tab. Use <code>Tab</code> to switch scope.",1);function rl(e,t){pt(t,!0);let n=[],r=null;async function i(f){let l=await syscall("silversearch.search",f,{singleFilePath:t.currentPath,silent:!0});return n=l[0].matches,r=l[0].name,l[0].excerpts}async function s(f,l,o){r&&await syscall("editor.navigate",`${r}@${f.offset}`,!1,l)}ii(e,{search:i,open:s,helpText:o=>{var a=nl();C(o,a)},elementDescription:(o,a=It)=>{var c=Le(),h=me(c);on(h,()=>Un(a().excerpt,n)),C(o,c)},$$slots:{helpText:!0,elementDescription:!0}}),_t()}function il(e,t){for(const n of e)if(n.type==="range"&&n.from<=t&&t<=n.to)return n.tail;return""}var sl=Y("Use <code>Tab</code> to switch scope.",1),ll=Y("Press <code>Ctrl-Enter</code> to open in new Tab and <code>Alt-Enter</code> to insert a link. <!>",1);function ol(e,t){pt(t,!1);const n=or("isDocumentEditor");async function r(f,l,o){var h,v;if(o)return await i(f);const a=((v=(h=f.matches)==null?void 0:h[0])==null?void 0:v.offset)??0;let c=`@${a}`;f.navigationMap&&(c=il(f.navigationMap,a)),await syscall("editor.navigate",`${f.name}${c}`,!1,l)}async function i(f){const l=`[[${f.name}]]`;await syscall("editor.insertAtCursor",l),await syscall("editor.hidePanel","modal")}async function s(f){return syscall("silversearch.search",f,{silent:!0})}Fs(),ii(e,{search:s,open:r,helpText:c=>{var h=ll(),v=he(me(h),5);{var p=d=>{var _=sl();C(d,_)};De(v,d=>{n||d(p)})}C(c,h)},elementTitle:(c,h=It)=>{var v=Le(),p=me(v);on(p,()=>Un(h().name,h().matchesName)),C(c,v)},elementDescription:(c,h=It)=>{var v=Le(),p=me(v);on(p,()=>Un(h().excerpts[0].excerpt,h().matches)),C(c,v)},elementInfo:(c,h=It)=>{var v=ys();Ut(()=>Fn(v,`${h().matches.length??""} Matches`)),C(c,v)},$$slots:{helpText:!0,elementTitle:!0,elementDescription:!0,elementInfo:!0}}),_t()}var fl=Y("<!> <div><!></div>",1);function al(e,t){pt(t,!0),syscall("clientStore.get","silversearch-history").then(h=>{k.history=h||[]});const n=or("isDocumentEditor");k.text=t.defaultQuery;let r=Z(!0);function i(h){h.stopPropagation(),h.key==="Tab"&&(n||(j(r,!E(r)),h.preventDefault()))}var s=fl(),f=me(s);on(f,()=>t.customStyles);var l=he(f,2),o=K(l);{var a=h=>{ol(h,{})},c=h=>{rl(h,{get currentPath(){return t.currentPath}})};De(o,h=>{E(r)?h(a):h(c,-1)})}Bt("keydown",l,i),C(e,s),_t()}In(["keydown"]);async function ul(){const e=syscall("editor.getCurrentPath"),t=syscall("editor.getCurrentEditor"),n=syscall("editor.getUiOption","customStyles");await Promise.race([new Promise(r=>setTimeout(r,75)),new Promise(r=>{const i=document.querySelector("link#stylesheet");i&&(i.onload=r)})]),bs(al,{target:document.querySelector("#container"),props:{defaultQuery:globalThis.DEFAULT_QUERY??"",currentPath:await e,customStyles:await n},context:new Map([["isDocumentEditor",await t!=="page"]])})}ul()})();\n';var Tt=`<style>html,body{background:none!important;--silversearch-progress-bar-color: var(--ui-accent-text-color)}*{font-family:var(--ui-font)}code{font-family:monospace}.silversearch-highlight{background-color:color-mix(in srgb,var(--editor-highlight-background-color),50% transparent)}.sb-description.svelte-utv8gj{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-clamp:3;overflow:hidden}.sb-name.svelte-utv8gj{display:flex;white-space:nowrap;align-items:baseline}.silversearch-info.svelte-utv8gj{font-size:.8rem;margin-left:1ch;color:var(--modal-description-color)}.silversearch-title.svelte-utv8gj{text-overflow:ellipsis;overflow:hidden}.silversearch-selected{background-color:var(--editor-selection-background-color)}.silversearch-apology.svelte-l7tsl3{text-align:center;padding:5px}.container.svelte-1e54ghr{background:var(--progress-background-color);position:relative;width:300px;height:8px;margin:1rem;border-radius:4px;overflow:hidden}.bar.svelte-1e54ghr{background:var(--silversearch-progress-bar-color);position:absolute;height:100%;left:0;border-radius:4px;transition:width .3s ease}@keyframes slide{0%{left:-30%}to{left:100%}}.silversearch-apology.svelte-qgaxc8{display:flex;flex-direction:column;align-items:center;padding:1em}.silversearch-apology.svelte-qgaxc8 p:where(.svelte-qgaxc8){margin:0}.silversearch-help.svelte-rar4cx{padding:8px;line-height:1.5;color:var(--modal-help-color)}.silversearch-help.svelte-rar4cx p:where(.svelte-rar4cx){margin:0}.silversearch-help.svelte-rar4cx ul:where(.svelte-rar4cx){margin:0;list-style-position:inside;padding-left:15px}dialog.svelte-1pjmr73{outline:none}#mini-editor.svelte-1pjmr73{caret-color:var(--editor-caret-color);outline:none;border:none;padding:2px 0 0 3px;line-height:1.4;width:100%;background:none;font-family:var(--ui-font);font-size:1em;color:inherit}</style>
|
|
<link id="stylesheet" rel="stylesheet" href=".client/main.css"/>
|
|
<div id="container"></div>`;var Yi="ENTRIES",It="KEYS",zt="VALUES";var Y=class{constructor(e,n){let r=e._tree,i=Array.from(r.keys());this.set=e,this._type=n,this._path=i.length>0?[{node:r,keys:i}]:[]}next(){let e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return{done:!0,value:void 0};let{node:e,keys:n}=B(this._path);if(B(n)==="")return{done:!1,value:this.result()};let r=e.get(B(n));return this._path.push({node:r,keys:Array.from(r.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;let e=B(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:e})=>B(e)).filter(e=>e!=="").join("")}value(){return B(this._path).node.get("")}result(){switch(this._type){case zt:return this.value();case It:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}},B=t=>t[t.length-1],es=(t,e,n)=>{let r=new Map;if(e===void 0)return r;let i=e.length+1,s=i+n,o=new Uint8Array(s*i).fill(n+1);for(let u=0;u<i;++u)o[u]=u;for(let u=1;u<s;++u)o[u*i]=u;return Ot(t,e,n,r,o,1,i,""),r},Ot=(t,e,n,r,i,s,o,u)=>{let a=s*o;e:for(let l of t.keys())if(l===""){let f=i[a-1];f<=n&&r.set(u,[t.get(l),f])}else{let f=s;for(let p=0;p<l.length;++p,++f){let h=l[p],d=o*f,g=d-o,v=i[d],m=Math.max(0,f-n-1),y=Math.min(o-1,f+n);for(let x=m;x<y;++x){let w=h!==e[x],k=i[g+x]+ +w,E=i[g+x+1]+1,T=i[d+x]+1,M=i[d+x+1]=Math.min(k,E,T);M<v&&(v=M)}if(v>n)continue e}Ot(t.get(l),e,n,r,i,f,o,u+l)}},ee=class t{constructor(e=new Map,n=""){this._size=void 0,this._tree=e,this._prefix=n}atPrefix(e){if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");let[n,r]=he(this._tree,e.slice(this._prefix.length));if(n===void 0){let[i,s]=Be(r);for(let o of i.keys())if(o!==""&&o.startsWith(s)){let u=new Map;return u.set(o.slice(s.length),i.get(o)),new t(u,e)}}return new t(n,e)}clear(){this._size=void 0,this._tree.clear()}delete(e){return this._size=void 0,ts(this._tree,e)}entries(){return new Y(this,Yi)}forEach(e){for(let[n,r]of this)e(n,r,this)}fuzzyGet(e,n){return es(this._tree,e,n)}get(e){let n=Ne(this._tree,e);return n!==void 0?n.get(""):void 0}has(e){let n=Ne(this._tree,e);return n!==void 0&&n.has("")}keys(){return new Y(this,It)}set(e,n){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,Oe(this._tree,e).set("",n),this}get size(){if(this._size)return this._size;this._size=0;let e=this.entries();for(;!e.next().done;)this._size+=1;return this._size}update(e,n){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;let r=Oe(this._tree,e);return r.set("",n(r.get(""))),this}fetch(e,n){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;let r=Oe(this._tree,e),i=r.get("");return i===void 0&&r.set("",i=n()),i}values(){return new Y(this,zt)}[Symbol.iterator](){return this.entries()}static from(e){let n=new t;for(let[r,i]of e)n.set(r,i);return n}static fromObject(e){return t.from(Object.entries(e))}},he=(t,e,n=[])=>{if(e.length===0||t==null)return[t,n];for(let r of t.keys())if(r!==""&&e.startsWith(r))return n.push([t,r]),he(t.get(r),e.slice(r.length),n);return n.push([t,e]),he(void 0,"",n)},Ne=(t,e)=>{if(e.length===0||t==null)return t;for(let n of t.keys())if(n!==""&&e.startsWith(n))return Ne(t.get(n),e.slice(n.length))},Oe=(t,e)=>{let n=e.length;e:for(let r=0;t&&r<n;){for(let s of t.keys())if(s!==""&&e[r]===s[0]){let o=Math.min(n-r,s.length),u=1;for(;u<o&&e[r+u]===s[u];)++u;let a=t.get(s);if(u===s.length)t=a;else{let l=new Map;l.set(s.slice(u),a),t.set(e.slice(r,r+u),l),t.delete(s),t=l}r+=u;continue e}let i=new Map;return t.set(e.slice(r),i),i}return t},ts=(t,e)=>{let[n,r]=he(t,e);if(n!==void 0){if(n.delete(""),n.size===0)Rt(r);else if(n.size===1){let[i,s]=n.entries().next().value;Lt(r,i,s)}}},Rt=t=>{if(t.length===0)return;let[e,n]=Be(t);if(e.delete(n),e.size===0)Rt(t.slice(0,-1));else if(e.size===1){let[r,i]=e.entries().next().value;r!==""&&Lt(t.slice(0,-1),r,i)}},Lt=(t,e,n)=>{if(t.length===0)return;let[r,i]=Be(t);r.set(i+e,n),r.delete(i)},Be=t=>t[t.length-1],Ue="or",jt="and",ns="and_not",U=class t{constructor(e){if(e?.fields==null)throw new Error('MiniSearch: option "fields" must be provided');let n=e.autoVacuum==null||e.autoVacuum===!0?je:e.autoVacuum;this._options={...Le,...e,autoVacuum:n,searchOptions:{...Ct,...e.searchOptions||{}},autoSuggestOptions:{...us,...e.autoSuggestOptions||{}}},this._index=new ee,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=We,this.addFields(this._options.fields)}add(e){let{extractField:n,stringifyField:r,tokenize:i,processTerm:s,fields:o,idField:u}=this._options,a=n(e,u);if(a==null)throw new Error(`MiniSearch: document does not have ID field "${u}"`);if(this._idToShortId.has(a))throw new Error(`MiniSearch: duplicate ID ${a}`);let l=this.addDocumentId(a);this.saveStoredFields(l,e);for(let f of o){let p=n(e,f);if(p==null)continue;let h=i(r(p,f),f),d=this._fieldIds[f],g=new Set(h).size;this.addFieldLength(l,d,this._documentCount-1,g);for(let v of h){let m=s(v,f);if(Array.isArray(m))for(let y of m)this.addTerm(d,l,y);else m&&this.addTerm(d,l,m)}}}addAll(e){for(let n of e)this.add(n)}addAllAsync(e,n={}){let{chunkSize:r=10}=n,i={chunk:[],promise:Promise.resolve()},{chunk:s,promise:o}=e.reduce(({chunk:u,promise:a},l,f)=>(u.push(l),(f+1)%r===0?{chunk:[],promise:a.then(()=>new Promise(p=>setTimeout(p,0))).then(()=>this.addAll(u))}:{chunk:u,promise:a}),i);return o.then(()=>this.addAll(s))}remove(e){let{tokenize:n,processTerm:r,extractField:i,stringifyField:s,fields:o,idField:u}=this._options,a=i(e,u);if(a==null)throw new Error(`MiniSearch: document does not have ID field "${u}"`);let l=this._idToShortId.get(a);if(l==null)throw new Error(`MiniSearch: cannot remove document with ID ${a}: it is not in the index`);for(let f of o){let p=i(e,f);if(p==null)continue;let h=n(s(p,f),f),d=this._fieldIds[f],g=new Set(h).size;this.removeFieldLength(l,d,this._documentCount,g);for(let v of h){let m=r(v,f);if(Array.isArray(m))for(let y of m)this.removeTerm(d,l,y);else m&&this.removeTerm(d,l,m)}}this._storedFields.delete(l),this._documentIds.delete(l),this._idToShortId.delete(a),this._fieldLength.delete(l),this._documentCount-=1}removeAll(e){if(e)for(let n of e)this.remove(n);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new ee,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}}discard(e){let n=this._idToShortId.get(e);if(n==null)throw new Error(`MiniSearch: cannot discard document with ID ${e}: it is not in the index`);this._idToShortId.delete(e),this._documentIds.delete(n),this._storedFields.delete(n),(this._fieldLength.get(n)||[]).forEach((r,i)=>{this.removeFieldLength(n,i,this._documentCount,r)}),this._fieldLength.delete(n),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;let{minDirtFactor:e,minDirtCount:n,batchSize:r,batchWait:i}=this._options.autoVacuum;this.conditionalVacuum({batchSize:r,batchWait:i},{minDirtCount:n,minDirtFactor:e})}discardAll(e){let n=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(let r of e)this.discard(r)}finally{this._options.autoVacuum=n}this.maybeAutoVacuum()}replace(e){let{idField:n,extractField:r}=this._options,i=r(e,n);this.discard(i),this.add(e)}vacuum(e={}){return this.conditionalVacuum(e)}conditionalVacuum(e,n){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&n,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{let r=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=We,this.performVacuuming(e,r)}),this._enqueuedVacuum)):this.vacuumConditionsMet(n)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)}async performVacuuming(e,n){let r=this._dirtCount;if(this.vacuumConditionsMet(n)){let i=e.batchSize||$e.batchSize,s=e.batchWait||$e.batchWait,o=1;for(let[u,a]of this._index){for(let[l,f]of a)for(let[p]of f)this._documentIds.has(p)||(f.size<=1?a.delete(l):f.delete(p));this._index.get(u).size===0&&this._index.delete(u),o%i===0&&await new Promise(l=>setTimeout(l,s)),o+=1}this._dirtCount-=r}await null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null}vacuumConditionsMet(e){if(e==null)return!0;let{minDirtCount:n,minDirtFactor:r}=e;return n=n||je.minDirtCount,r=r||je.minDirtFactor,this.dirtCount>=n&&this.dirtFactor>=r}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}has(e){return this._idToShortId.has(e)}getStoredFields(e){let n=this._idToShortId.get(e);if(n!=null)return this._storedFields.get(n)}search(e,n={}){let{searchOptions:r}=this._options,i={...r,...n},s=this.executeQuery(e,n),o=[];for(let[u,{score:a,terms:l,match:f}]of s){let p=l.length||1,h={id:this._documentIds.get(u),score:a*p,terms:Object.keys(f),queryTerms:l,match:f};Object.assign(h,this._storedFields.get(u)),(i.filter==null||i.filter(h))&&o.push(h)}return e===t.wildcard&&i.boostDocument==null||o.sort(Mt),o}autoSuggest(e,n={}){n={...this._options.autoSuggestOptions,...n};let r=new Map;for(let{score:s,terms:o}of this.search(e,n)){let u=o.join(" "),a=r.get(u);a!=null?(a.score+=s,a.count+=1):r.set(u,{score:s,terms:o,count:1})}let i=[];for(let[s,{score:o,terms:u,count:a}]of r)i.push({suggestion:s,terms:u,score:o/a});return i.sort(Mt),i}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(e,n){if(n==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),n)}static async loadJSONAsync(e,n){if(n==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(e),n)}static getDefault(e){if(Le.hasOwnProperty(e))return Re(Le,e);throw new Error(`MiniSearch: unknown option "${e}"`)}static loadJS(e,n){let{index:r,documentIds:i,fieldLength:s,storedFields:o,serializationVersion:u}=e,a=this.instantiateMiniSearch(e,n);a._documentIds=fe(i),a._fieldLength=fe(s),a._storedFields=fe(o);for(let[l,f]of a._documentIds)a._idToShortId.set(f,l);for(let[l,f]of r){let p=new Map;for(let h of Object.keys(f)){let d=f[h];u===1&&(d=d.ds),p.set(parseInt(h,10),fe(d))}a._index.set(l,p)}return a}static async loadJSAsync(e,n){let{index:r,documentIds:i,fieldLength:s,storedFields:o,serializationVersion:u}=e,a=this.instantiateMiniSearch(e,n);a._documentIds=await pe(i),a._fieldLength=await pe(s),a._storedFields=await pe(o);for(let[f,p]of a._documentIds)a._idToShortId.set(p,f);let l=0;for(let[f,p]of r){let h=new Map;for(let d of Object.keys(p)){let g=p[d];u===1&&(g=g.ds),h.set(parseInt(d,10),await pe(g))}++l%1e3===0&&await Nt(0),a._index.set(f,h)}return a}static instantiateMiniSearch(e,n){let{documentCount:r,nextId:i,fieldIds:s,averageFieldLength:o,dirtCount:u,serializationVersion:a}=e;if(a!==1&&a!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");let l=new t(n);return l._documentCount=r,l._nextId=i,l._idToShortId=new Map,l._fieldIds=s,l._avgFieldLength=o,l._dirtCount=u||0,l._index=new ee,l}executeQuery(e,n={}){if(e===t.wildcard)return this.executeWildcardQuery(n);if(typeof e!="string"){let h={...n,...e,queries:void 0},d=e.queries.map(g=>this.executeQuery(g,h));return this.combineResults(d,h.combineWith)}let{tokenize:r,processTerm:i,searchOptions:s}=this._options,o={tokenize:r,processTerm:i,...s,...n},{tokenize:u,processTerm:a}=o,p=u(e).flatMap(h=>a(h)).filter(h=>!!h).map(os(o)).map(h=>this.executeQuerySpec(h,o));return this.combineResults(p,o.combineWith)}executeQuerySpec(e,n){let r={...this._options.searchOptions,...n},i=(r.fields||this._options.fields).reduce((v,m)=>({...v,[m]:Re(r.boost,m)||1}),{}),{boostDocument:s,weights:o,maxFuzzy:u,bm25:a}=r,{fuzzy:l,prefix:f}={...Ct.weights,...o},p=this._index.get(e.term),h=this.termResults(e.term,e.term,1,e.termBoost,p,i,s,a),d,g;if(e.prefix&&(d=this._index.atPrefix(e.term)),e.fuzzy){let v=e.fuzzy===!0?.2:e.fuzzy,m=v<1?Math.min(u,Math.round(e.term.length*v)):v;m&&(g=this._index.fuzzyGet(e.term,m))}if(d)for(let[v,m]of d){let y=v.length-e.term.length;if(!y)continue;g?.delete(v);let x=f*v.length/(v.length+.3*y);this.termResults(e.term,v,x,e.termBoost,m,i,s,a,h)}if(g)for(let v of g.keys()){let[m,y]=g.get(v);if(!y)continue;let x=l*v.length/(v.length+y);this.termResults(e.term,v,x,e.termBoost,m,i,s,a,h)}return h}executeWildcardQuery(e){let n=new Map,r={...this._options.searchOptions,...e};for(let[i,s]of this._documentIds){let o=r.boostDocument?r.boostDocument(s,"",this._storedFields.get(i)):1;n.set(i,{score:o,terms:[],match:{}})}return n}combineResults(e,n=Ue){if(e.length===0)return new Map;let r=n.toLowerCase(),i=rs[r];if(!i)throw new Error(`Invalid combination operator: ${n}`);return e.reduce(i)||new Map}toJSON(){let e=[];for(let[n,r]of this._index){let i={};for(let[s,o]of r)i[s]=Object.fromEntries(o);e.push([n,i])}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:e,serializationVersion:2}}termResults(e,n,r,i,s,o,u,a,l=new Map){if(s==null)return l;for(let f of Object.keys(o)){let p=o[f],h=this._fieldIds[f],d=s.get(h);if(d==null)continue;let g=d.size,v=this._avgFieldLength[h];for(let m of d.keys()){if(!this._documentIds.has(m)){this.removeTerm(h,m,n),g-=1;continue}let y=u?u(this._documentIds.get(m),n,this._storedFields.get(m)):1;if(!y)continue;let x=d.get(m),w=this._fieldLength.get(m)[h],k=ss(x,g,this._documentCount,w,v,a),E=r*i*p*y*k,T=l.get(m);if(T){T.score+=E,ls(T.terms,e);let M=Re(T.match,n);M?M.push(f):T.match[n]=[f]}else l.set(m,{score:E,terms:[e],match:{[n]:[f]}})}}return l}addTerm(e,n,r){let i=this._index.fetch(r,Dt),s=i.get(e);if(s==null)s=new Map,s.set(n,1),i.set(e,s);else{let o=s.get(n);s.set(n,(o||0)+1)}}removeTerm(e,n,r){if(!this._index.has(r)){this.warnDocumentChanged(n,e,r);return}let i=this._index.fetch(r,Dt),s=i.get(e);s==null||s.get(n)==null?this.warnDocumentChanged(n,e,r):s.get(n)<=1?s.size<=1?i.delete(e):s.delete(n):s.set(n,s.get(n)-1),this._index.get(r).size===0&&this._index.delete(r)}warnDocumentChanged(e,n,r){for(let i of Object.keys(this._fieldIds))if(this._fieldIds[i]===n){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(e)} has changed before removal: term "${r}" was not present in field "${i}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(e){let n=this._nextId;return this._idToShortId.set(e,n),this._documentIds.set(n,e),this._documentCount+=1,this._nextId+=1,n}addFields(e){for(let n=0;n<e.length;n++)this._fieldIds[e[n]]=n}addFieldLength(e,n,r,i){let s=this._fieldLength.get(e);s==null&&this._fieldLength.set(e,s=[]),s[n]=i;let u=(this._avgFieldLength[n]||0)*r+i;this._avgFieldLength[n]=u/(r+1)}removeFieldLength(e,n,r,i){if(r===1){this._avgFieldLength[n]=0;return}let s=this._avgFieldLength[n]*r-i;this._avgFieldLength[n]=s/(r-1)}saveStoredFields(e,n){let{storeFields:r,extractField:i}=this._options;if(r==null||r.length===0)return;let s=this._storedFields.get(e);s==null&&this._storedFields.set(e,s={});for(let o of r){let u=i(n,o);u!==void 0&&(s[o]=u)}}};U.wildcard=Symbol("*");var Re=(t,e)=>Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0,rs={[Ue]:(t,e)=>{for(let n of e.keys()){let r=t.get(n);if(r==null)t.set(n,e.get(n));else{let{score:i,terms:s,match:o}=e.get(n);r.score=r.score+i,r.match=Object.assign(r.match,o),Ft(r.terms,s)}}return t},[jt]:(t,e)=>{let n=new Map;for(let r of e.keys()){let i=t.get(r);if(i==null)continue;let{score:s,terms:o,match:u}=e.get(r);Ft(i.terms,o),n.set(r,{score:i.score+s,terms:i.terms,match:Object.assign(i.match,u)})}return n},[ns]:(t,e)=>{for(let n of e.keys())t.delete(n);return t}},is={k:1.2,b:.7,d:.5},ss=(t,e,n,r,i,s)=>{let{k:o,b:u,d:a}=s;return Math.log(1+(n-e+.5)/(e+.5))*(a+t*(o+1)/(t+o*(1-u+u*r/i)))},os=t=>(e,n,r)=>{let i=typeof t.fuzzy=="function"?t.fuzzy(e,n,r):t.fuzzy||!1,s=typeof t.prefix=="function"?t.prefix(e,n,r):t.prefix===!0,o=typeof t.boostTerm=="function"?t.boostTerm(e,n,r):1;return{term:e,fuzzy:i,prefix:s,termBoost:o}},Le={idField:"id",extractField:(t,e)=>t[e],stringifyField:(t,e)=>t.toString(),tokenize:t=>t.split(as),processTerm:t=>t.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(t,e)=>{typeof console?.[t]=="function"&&console[t](e)},autoVacuum:!0},Ct={combineWith:Ue,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:is},us={combineWith:jt,prefix:(t,e,n)=>e===n.length-1},$e={batchSize:1e3,batchWait:10},We={minDirtFactor:.1,minDirtCount:20},je={...$e,...We},ls=(t,e)=>{t.includes(e)||t.push(e)},Ft=(t,e)=>{for(let n of e)t.includes(n)||t.push(n)},Mt=({score:t},{score:e})=>e-t,Dt=()=>new Map,fe=t=>{let e=new Map;for(let n of Object.keys(t))e.set(parseInt(n,10),t[n]);return e},pe=async t=>{let e=new Map,n=0;for(let r of Object.keys(t))e.set(parseInt(r,10),t[r]),++n%1e3===0&&await Nt(0);return e},Nt=t=>new Promise(e=>setTimeout(e,t)),as=/[\n\r\p{Z}\p{P}]+/u;var Ve;function qe(t){return{lang:t?.lang??Ve?.lang,message:t?.message,abortEarly:t?.abortEarly??Ve?.abortEarly,abortPipeEarly:t?.abortPipeEarly??Ve?.abortPipeEarly}}var cs;function fs(t){return cs?.get(t)}var ps;function hs(t){return ps?.get(t)}var ds;function ms(t,e){return ds?.get(t)?.get(e)}function de(t){let e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function _(t,e,n,r,i){let s=i&&"input"in i?i.input:n.value,o=i?.expected??t.expects??null,u=i?.received??de(s),a={kind:t.kind,type:t.type,input:s,expected:o,received:u,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${u}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=t.kind==="schema",f=i?.message??t.message??ms(t.reference,a.lang)??(l?hs(a.lang):null)??r.message??fs(a.lang);f!==void 0&&(a.message=typeof f=="function"?f(a):f),l&&(n.typed=!1),n.issues?n.issues.push(a):n.issues=[a]}function P(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},qe())}}}function ys(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function Ge(t,e){let n=[...new Set(t)];return n.length>1?`(${n.join(` ${e} `)})`:n[0]??"never"}function Wt(t){if(t.path){let e="";for(let n of t.path)if(typeof n.key=="string"||typeof n.key=="number")e?e+=`.${n.key}`:e+=n.key;else return null;return e}return null}var me=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function te(t){return{kind:"transformation",type:"args",reference:te,async:!1,schema:t,"~run"(e,n){let r=e.value;return e.value=(...i)=>{let s=this.schema["~run"]({value:i},n);if(s.issues)throw new me(s.issues);return r(...s.value)},e}}}function Ke(t){return{kind:"validation",type:"non_empty",reference:Ke,async:!1,expects:"!0",message:t,"~run"(e,n){return e.typed&&e.value.length===0&&_(this,"length",e,n,{received:"0"}),e}}}function ye(t){return{kind:"transformation",type:"returns",reference:ye,async:!1,schema:t,"~run"(e,n){let r=e.value;return e.value=(...i)=>{let s=this.schema["~run"]({value:r(...i)},n);if(s.issues)throw new me(s.issues);return s.value},e}}}function He(t){return{kind:"transformation",type:"returns",reference:He,async:!1,schema:t,"~run"(e,n){let r=e.value;return e.value=async(...i)=>{let s=await this.schema["~run"]({value:await r(...i)},n);if(s.issues)throw new me(s.issues);return s.value},e}}}function Bt(t,e,n){return typeof t.fallback=="function"?t.fallback(e,n):t.fallback}function Ut(t){let e={};for(let n of t)if(n.path){let r=Wt(n);r?(e.nested||(e.nested={}),e.nested[r]?e.nested[r].push(n.message):e.nested[r]=[n.message]):e.other?e.other.push(n.message):e.other=[n.message]}else e.root?e.root.push(n.message):e.root=[n.message];return e}function ve(t,e,n){return typeof t.default=="function"?t.default(e,n):t.default}function R(t,e){return{kind:"schema",type:"array",reference:R,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return P(this)},"~run"(n,r){let i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let s=0;s<i.length;s++){let o=i[s],u=this.item["~run"]({value:o},r);if(u.issues){let a={type:"array",origin:"value",input:i,key:s,value:o};for(let l of u.issues)l.path?l.path.unshift(a):l.path=[a],n.issues?.push(l);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else _(this,"type",n,r);return n}}}function z(t){return{kind:"schema",type:"boolean",reference:z,expects:"boolean",async:!1,message:t,get"~standard"(){return P(this)},"~run"(e,n){return typeof e.value=="boolean"?e.typed=!0:_(this,"type",e,n),e}}}function Xe(t,e){let n=[];for(let r in t)(`${+r}`!==r||typeof t[r]!="string"||!Object.is(t[t[r]],+r))&&n.push(t[r]);return{kind:"schema",type:"enum",reference:Xe,expects:Ge(n.map(de),"|"),async:!1,enum:t,options:n,message:e,get"~standard"(){return P(this)},"~run"(r,i){return this.options.includes(r.value)?r.typed=!0:_(this,"type",r,i),r}}}function ne(t){return{kind:"schema",type:"function",reference:ne,expects:"Function",async:!1,message:t,get"~standard"(){return P(this)},"~run"(e,n){return typeof e.value=="function"?e.typed=!0:_(this,"type",e,n),e}}}function Je(t){return{kind:"schema",type:"lazy",reference:Je,expects:"unknown",async:!1,getter:t,get"~standard"(){return P(this)},"~run"(e,n){return this.getter(e.value)["~run"](e,n)}}}function Qe(t,e){return{kind:"schema",type:"literal",reference:Qe,expects:de(t),async:!1,literal:t,message:e,get"~standard"(){return P(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:_(this,"type",n,r),n}}}function Ze(t){return{kind:"schema",type:"null",reference:Ze,expects:"null",async:!1,message:t,get"~standard"(){return P(this)},"~run"(e,n){return e.value===null?e.typed=!0:_(this,"type",e,n),e}}}function I(t){return{kind:"schema",type:"number",reference:I,expects:"number",async:!1,message:t,get"~standard"(){return P(this)},"~run"(e,n){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:_(this,"type",e,n),e}}}function Ye(t,e){return{kind:"schema",type:"object",reference:Ye,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return P(this)},"~run"(n,r){let i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(let s in this.entries){let o=this.entries[s];if(s in i||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let u=s in i?i[s]:ve(o),a=o["~run"]({value:u},r);if(a.issues){let l={type:"object",origin:"value",input:i,key:s,value:u};for(let f of a.issues)f.path?f.path.unshift(l):f.path=[l],n.issues?.push(f);if(n.issues||(n.issues=a.issues),r.abortEarly){n.typed=!1;break}}a.typed||(n.typed=!1),n.value[s]=a.value}else if(o.fallback!==void 0)n.value[s]=Bt(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(_(this,"key",n,r,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]}),r.abortEarly))break}}else _(this,"type",n,r);return n}}}function b(t,e){return{kind:"schema",type:"optional",reference:b,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return P(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=ve(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function re(t,e){return{kind:"schema",type:"picklist",reference:re,expects:Ge(t.map(de),"|"),async:!1,options:t,message:e,get"~standard"(){return P(this)},"~run"(n,r){return this.options.includes(n.value)?n.typed=!0:_(this,"type",n,r),n}}}function V(t,e,n){return{kind:"schema",type:"record",reference:V,expects:"Object",async:!1,key:t,value:e,message:n,get"~standard"(){return P(this)},"~run"(r,i){let s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(let o in s)if(ys(s,o)){let u=s[o],a=this.key["~run"]({value:o},i);if(a.issues){let f={type:"object",origin:"key",input:s,key:o,value:u};for(let p of a.issues)p.path=[f],r.issues?.push(p);if(r.issues||(r.issues=a.issues),i.abortEarly){r.typed=!1;break}}let l=this.value["~run"]({value:u},i);if(l.issues){let f={type:"object",origin:"value",input:s,key:o,value:u};for(let p of l.issues)p.path?p.path.unshift(f):p.path=[f],r.issues?.push(p);if(r.issues||(r.issues=l.issues),i.abortEarly){r.typed=!1;break}}(!a.typed||!l.typed)&&(r.typed=!1),a.typed&&(r.value[a.value]=l.value)}}else _(this,"type",r,i);return r}}}function j(t,e){return{kind:"schema",type:"strict_object",reference:j,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return P(this)},"~run"(n,r){let i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(let s in this.entries){let o=this.entries[s];if(s in i||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let u=s in i?i[s]:ve(o),a=o["~run"]({value:u},r);if(a.issues){let l={type:"object",origin:"value",input:i,key:s,value:u};for(let f of a.issues)f.path?f.path.unshift(l):f.path=[l],n.issues?.push(f);if(n.issues||(n.issues=a.issues),r.abortEarly){n.typed=!1;break}}a.typed||(n.typed=!1),n.value[s]=a.value}else if(o.fallback!==void 0)n.value[s]=Bt(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(_(this,"key",n,r,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly){for(let s in i)if(!(s in this.entries)){_(this,"key",n,r,{input:s,expected:"never",path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]});break}}}else _(this,"type",n,r);return n}}}function A(t){return{kind:"schema",type:"string",reference:A,expects:"string",async:!1,message:t,get"~standard"(){return P(this)},"~run"(e,n){return typeof e.value=="string"?e.typed=!0:_(this,"type",e,n),e}}}function ie(t,e){return{kind:"schema",type:"tuple",reference:ie,expects:"Array",async:!1,items:t,message:e,get"~standard"(){return P(this)},"~run"(n,r){let i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let s=0;s<this.items.length;s++){let o=i[s],u=this.items[s]["~run"]({value:o},r);if(u.issues){let a={type:"array",origin:"value",input:i,key:s,value:o};for(let l of u.issues)l.path?l.path.unshift(a):l.path=[a],n.issues?.push(l);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else _(this,"type",n,r);return n}}}function et(t,e){return{kind:"schema",type:"undefinedable",reference:et,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return P(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=ve(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function $t(t){let e;if(t)for(let n of t)e?e.push(...n.issues):e=n.issues;return e}function tt(t,e){return{kind:"schema",type:"union",reference:tt,expects:Ge(t.map(n=>n.expects),"|"),async:!1,options:t,message:e,get"~standard"(){return P(this)},"~run"(n,r){let i,s,o;for(let u of this.options){let a=u["~run"]({value:n.value},r);if(a.typed)if(a.issues)s?s.push(a):s=[a];else{i=a;break}else o?o.push(a):o=[a]}if(i)return i;if(s){if(s.length===1)return s[0];_(this,"type",n,r,{issues:$t(s)}),n.typed=!0}else{if(o?.length===1)return o[0];_(this,"type",n,r,{issues:$t(o)})}return n}}}function nt(t){return{kind:"schema",type:"void",reference:nt,expects:"void",async:!1,message:t,get"~standard"(){return P(this)},"~run"(e,n){return e.value===void 0?e.typed=!0:_(this,"type",e,n),e}}}function rt(t,e,n){let r=t["~run"]({value:e},qe(n));if(r.issues)throw new me(r.issues);return r.value}function q(...t){return{...t[0],pipe:t,get"~standard"(){return P(this)},"~run"(e,n){for(let r of t)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!n.abortEarly&&!n.abortPipeEarly)&&(e=r["~run"](e,n))}return e}}}function G(t,e,n){let r=t["~run"]({value:e},qe(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}function Vt(t){let e="";for(let n of t){e&&(e+=`
|
|
`),e+=`\xD7 ${n.message}`;let r=Wt(n);r&&(e+=`
|
|
\u2192 at ${r}`)}return e}var qt=100,ge=300,xe=(i=>(i.Disabled="disabled",i.Day="day",i.Week="week",i.Month="month",i))(xe||{}),vs='/[|\\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]/'.slice(1,-1),Gt=new RegExp(`${vs}+`,"u"),Kt=/[|\[\]\(\)<>\{\} \t\n\r]/u;var Ht=!1,se=null,oe=Je(()=>tt([A(),I(),z(),Ze(),V(A(),oe),R(oe)])),Xt=j({content:b(I(),1),basename:b(I(),10),displayName:b(I(),10),directory:b(I(),7),aliases:b(I(),1),tags:b(I(),1)}),Jt=j({weights:b(Xt,rt(Xt,{})),weightCustomProperties:b(V(A(),I()),{}),recencyBoost:b(Xe(xe),"disabled"),downrankedFoldersFilters:b(R(A()),[]),ignoreDiacritics:b(z(),!0),ignoreArabicDiacritics:b(z(),!1),tokenizeUrls:b(z(),!0),splitCamelCase:b(z(),!0),fuzziness:b(re(["0","1","2"]),"1"),renderLineReturnInExcerpts:b(z(),!0),ignore:b(R(A()),[]),tokenizers:b(V(q(A(),Ke()),V(A(),oe)),{})});async function N(){if(se)return se;let t=await ae.getConfig("silversearch",{}),e=G(Jt,t);if(e.success)se=e.output;else{if(!Ht){let n=Object.entries(Ut(e.issues).nested??{}).map(([r,i])=>i?`${i.join(" & ")} in "${r}"`:"").filter(r=>r).join("; ");await C.flashNotification(`Silersearch - There was an error in your CONFIG: ${n}`),Ht=!0}se=rt(Jt,{})}return se}var gs=["\\u30FC","\\u309A","\\u3099"],xs=gs.join("|"),Qt=new RegExp(`(?!${xs})\\p{Diacritic}`,"gu");function Zt(t){return t.replace(/(\*|_)+(.+?)(\*|_)+/g,(e,n,r)=>r)}function st(t){return/[a-z][A-Z]/.test(t)?t.replace(/([a-z](?=[A-Z]))/g,"$1 ").split(" ").filter(n=>n):[]}function ot(t){return t.includes("-")?t.split("-").filter(e=>e):[]}function $(t,e=!1){if(t==null)return"";if(e){t=t.replace(/([^\u0621-\u063A\u0641-\u064A\u0660-\u0669a-zA-Z 0-9])/g,"").replace(/(آ|إ|أ)/g,"\u0627").replace(/(ة)/g,"\u0647").replace(/(ئ|ؤ)/g,"\u0621").replace(/(ى)/g,"\u064A");for(let n=0;n<10;n++)t.replace(String.fromCharCode(1632+n),String.fromCharCode(48+n))}return t=t.replaceAll("`","[__silversearch__backtick__]"),t=t.replaceAll("^","[__silversearch__caret__]"),t=t.normalize("NFD").replace(Qt,"").normalize("NFC"),t=t.replaceAll("[__silversearch__backtick__]","`"),t=t.replaceAll("[__silversearch__caret__]","^"),t}function Yt(t){return t.replace(new RegExp(`(?!\\^|\`)${Qt.source}`,"gu"),"")}function ut(t){let e=[],n=-1,r=0;for(;++r<100;){let i=ws(t,n,ge);if(!i.length)break;n=i.at(-1).offset,e.push(i)}return e}function ws(t,e,n){let r=t.find(i=>i.offset>e);return r?t.filter(i=>i.offset>e&&i.offset<=r.offset+n):[]}var bs=/\r\n?|\n/g,ks=/\0/g;function lt(t){let e=t;return e=e.replace(bs,`
|
|
`),e=e.replace(ks,"\uFFFD"),e}var at=(t,e)=>{let n=0,r=0,i=0;for(;n<t.length&&r<e.length;)t[n]===e[r]&&(i+=1,n+=1),r+=1;return t.slice(0,i)};var tn=t=>t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),_s=({link:t,startSyntax:e,endSyntax:n,links:r})=>{if(t.startsWith(e)){if(t.endsWith(n))return!1;if(t.includes(n)){let o=t.replace(/.?http/g,"http").substring(0,t.lastIndexOf(n)).replace(new RegExp(`\\${n}$`,"g"),"");return!r.some(u=>u.href===o)}}return!0},Es=t=>{let e=/mailto:([^\s[;]+)/g;return t.map(n=>n.href.match(e)||n.href.includes("@")?{...n,href:n.href.startsWith("mailto")?n.href:`mailto:${n.href}`,type:"email"}:n)},en=t=>t.startsWith("http")||t.startsWith("/")||t.includes("@"),ct=({line:t,url:e,lineLinks:n=[]})=>{var r;let i=((r=t?.match(new RegExp(tn(e),"g")))===null||r===void 0?void 0:r.length)||0,s=n?.reduce((o,u)=>o+(u.href.includes(e)?1:0)+(u.format==="[]()"&&u.text.includes(e)?1:0),0);return i>0&&s<i},Ps=({line:t,links:e,link:n})=>{var r,i;let s="",o=(((r=n?.match(/https:\/\/.*/g))===null||r===void 0?void 0:r[0])||"").replace("https://","");for(let u of e){let a=at(o,u.href);a.length>s.length&&(s=a)}if(s.length>0){let u=((i=t?.match(new RegExp(tn(s),"g")))===null||i===void 0?void 0:i.length)||0,a=e?.reduce((l,f)=>l+(f.href.includes(s)?1:0)+(f.format==="[]()"&&f.text.includes(s)?1:0),0);return u>0&&a<u}return!0},ft=t=>{var e,n,r,i;let s=lt(t).split(`
|
|
`),o=/.?\[([^\]]*)\]\(([^\][]*)\)/g,u=/<[^>]*>/g,a=/.?\(([^)]*)\)/g,l=/.?https?:\/\/[^\s[;]+/g,f=[];for(let p of s){let h=p.match(o)||[],d=p.match(u)||[],g=p.match(a)||[],v=p.match(l)||[],m=[];for(let y of h)if(!y.startsWith("!")){let x=y?.replace(/^.?\[/g,"[")||"",w=x.indexOf("["),k=x.indexOf("]",w+1),E=x;if(w!==-1&&k!==-1&&x[k+1]==="("){let Bn=k+1,Se=0,Te=-1;for(let le=Bn;le<x.length;le+=1){let _t=x[le];if(_t==="(")Se+=1;else if(_t===")"&&(Se-=1,Se===0)){Te=le;break}}Te!==-1&&(E=x.slice(0,Te+1))}let T=/\[([^\]]*)\]/,M=(((e=E?.match(T))===null||e===void 0?void 0:e[1])||"").trim(),Wn=(((r=(n=E?.replace(T,""))===null||n===void 0?void 0:n.match(/\(([^\][]*)\)$/))===null||r===void 0?void 0:r[1])||"").trim(),kt={text:M,href:Wn,line:p,raw:E,type:"link",format:"[]()"};f.push(kt),m.push(kt)}for(let y of d){let x=(((i=y.match(/<([^>]*)>/))===null||i===void 0?void 0:i[1])||"").trim();if(en(x)){let w=x;if(ct({line:p,url:w,lineLinks:m})){let k={text:x,href:w,line:p,raw:y,type:"link",format:"<>"};f.push(k),m.push(k)}}}for(let y of g){let x=y.replace(/^.?\(/g,"("),w=x.match(/\(([^)]*)\)/),k=(w?.[1]||"").trim();if(!y.startsWith("]")&&en(k)){let E=k;if(ct({line:p,url:E,lineLinks:m})){let T={text:k,href:E,line:p,raw:x,type:"link",format:"()"};f.push(T),m.push(T)}}}for(let y of v)if([{start:"[",end:"]"},{start:"<",end:">"},{start:"(",end:")"}].every(w=>_s({link:y,startSyntax:w.start,endSyntax:w.end,links:m}))&&Ps({line:p,links:m,link:y})){let w=y.replace(/^.?http/g,"http"),k=w;if(ct({line:p,url:k,lineLinks:m})){let E={text:w,href:k,line:p,raw:w,type:"link",format:"raw"};f.push(E),m.push(E)}}}return Es(f)};var As=j({init:q(ne(),te(ie([oe])),He(nt())),isTokenizable:q(ne(),te(ie([A()])),ye(z())),tokenize:q(ne(),te(ie([A()])),ye(R(A())))}),we=class t{constructor(e){this.implementation=e}static async loadFromPath(e,n){let r;try{let s=await D.readDocument(e),o=new Blob([s],{type:"text/javascript"}),u=URL.createObjectURL(o);r=await import(u),URL.revokeObjectURL(u)}catch{return console.warn(`[Silversearch] Failed to load tokenizer at ${e}. Maybe the path is wrong?`),null}let i=G(As,r);if(i.success){let s=new t(i.output);return await s.implementation.init(n),s}else return console.warn(`[Silversearch] Failed to load tokenizer at ${e}.
|
|
${Vt(i.issues)}`),null}tryTokenization(e){try{if(this.implementation.isTokenizable(e))return this.implementation.tokenize(e)}catch(n){console.warn(`[Silversearch] Tokenizer failed with error ${n}. Ignoring!`)}return null}};function nn(t,e){try{let n=sn(t,e.tokenizers),r=[];return e.tokenizeUrls&&(r=ft(t).map(o=>o.href)),[...on(t).flatMap(o=>[o,...ot(o),...st(o)]),...n,...r]}catch(n){return console.error("[Silversearch] Error tokenizing text, skipping document",n),[]}}function rn(t,e){let n=ft(t).map(i=>i.href);t=n.reduce((i,s)=>i.replace(s,""),t);let r=[...on(t),...n];return{combineWith:"OR",queries:[{combineWith:"AND",queries:r},{combineWith:"AND",queries:sn(t,e.tokenizers)},{combineWith:"AND",queries:r.flatMap(ot)},{combineWith:"AND",queries:r.flatMap(st)}]}}function sn(t,e){return Ss(t,e)??t.split(Kt).filter(Boolean)}function on(t){return t.split(Gt).filter(Boolean)}function Ss(t,e){let n=e.flatMap(r=>r.tryTokenization(t)??[]);return n.length===0?null:n}function un(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ts(t){if(!t.length)return/^$/g;t.sort((n,r)=>r.length-n.length);let e=`(${t.map(n=>`\\b${un(n)}\\b|${un(n)}`).join("|")})`;return new RegExp(`${e}`,"gui")}function ln(t,e){if(t=an(t),e.renderLineReturnInExcerpts){let n=new RegExp(/(?:\r\n|\r|\n)/g);t=t.split(n).filter(r=>r).join(`
|
|
`),t=t.replaceAll(`
|
|
`,"<br>")}return t.trim()}async function pt(t,e,n){let r=await N();e=e.map(an);let i=Ts(e),s=t;r.ignoreDiacritics&&(t=$(t,r.ignoreArabicDiacritics));let o=new Date().getTime(),u=null,a=[],l=0;for(;(u=i.exec(t))!==null&&!(++l>=100||new Date().getTime()-o>50);){let f=u.index,p=f+u[0].length,h=s.substring(f,p).trim();h&&u.index>=0&&a.push({match:h,offset:u.index})}if(n&&(n.query.text.length>1||n.getExactTerms().length>0)){let f=t.indexOf(n.getBestStringForExcerpt());f>-1&&a.find(p=>p.offset===f)&&a.unshift({offset:f,match:n.getBestStringForExcerpt()})}return a.map(f=>({...f,match:ln(f.match,{renderLineReturnInExcerpts:r.renderLineReturnInExcerpts})}))}async function ht(t,e){let n=await N();try{let r=Math.max(0,e-qt),i=Math.min(t.length,e+ge);if(t=(r>0?"\u2026":"")+t.slice(r,i).trim()+(i<t.length-1?"\u2026":""),n.renderLineReturnInExcerpts){let s=t.lastIndexOf(`
|
|
`,e-r);s>0&&(t=t.slice(s+1))}return{excerpt:ln(t,{renderLineReturnInExcerpts:n.renderLineReturnInExcerpts}),offset:e}}catch(r){return console.error("[Silversearch] Error while creating excerpt",r),{excerpt:"",offset:0}}}function an(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Cs(t){return t!==""?t.split(".").pop().toLowerCase():"md"}function O(t){return Fs({path:t})}function K(t){return Cs(t)==="md"}function Fs(t){let e=t.path;return K(t.path)&&(e=e.slice(0,-3)),t.details?.type==="linecolumn"?(e+=`@L${t.details.line}`,t.details.column!==1&&(e+=`C${t.details.column}`)):t.details?.type==="position"?e+=`@${t.details.pos}`:t.details?.type==="header"&&(e+=`#${t.details.header}`),e}function cn(t){return t.split("/").slice(0,-1).join("/")}function fn(t){return t.split("/").pop()}var Ms=j({content:A(),cacheMode:et(re(["persistent","session"]),"session"),navigationMap:b(R(Ye({type:Qe("range"),from:I(),to:I(),tail:A()})))});async function pn(t,e){if(K(t))try{return{content:await D.readPage(O(t)),cacheMode:"session"}}catch{return null}else{let n;try{n=e??await D.getDocumentMeta(O(t))}catch{return null}let r;try{r=await ce.dispatchEvent("silversearch:index",{meta:n})}catch{return console.warn("[silversearch] Eventhandler threw error. Discarding it."),null}if(r.length===0)return null;r.length>1&&console.warn(`[silversearch] We got multiple responses while indexing ${n.name}. Can't handle that.`);let i=G(Ms,r[0]);return i.success?i.output:(console.warn("[silversearch] Eventhandler didn't return well-formed result. Discarding it."),null)}}var _n=Et(bn()),kn=4,J=class t{constructor(e,n){this.minisearch=new U(t.getOptions(e,n)),this.entryCache=new Map,this.tokenizers=n,this.ignore=(0,_n.default)().add(e.ignore)}static async create(e){let n=(await Promise.all(Object.entries(e.tokenizers).map(async([r,i])=>await we.loadFromPath(r,i)))).filter(r=>r!==null);return new t(e,n)}static async loadFromCache(e){if(await F.get("silversearch-cache-lock"))return await C.flashNotification("Silversearch - Last cache failed, resetting index"),t.deleteCache(),null;let n=await F.get("silversearch-cache");if(!n||n.version!==kn||typeof n.minisearch!="string"||typeof n.entries!="object")return console.log("[Silversearch] Couldn't find cache or cache version mismatched"),t.deleteCache(),null;let r=await this.create(e);return r.minisearch=await U.loadJSONAsync(n.minisearch,t.getOptions(e,r.tokenizers)),r.entryCache=new Map(n.entries),r}static async deleteCache(){await F.del("silversearch-cache"),await F.del("silversearch-cache-lock")}async writeToCache(){clearTimeout(this.cacheWritingTimer),await F.set("silversearch-cache-lock",!0),this.cacheWritingTimer=setTimeout(async()=>{await F.set("silversearch-cache",{version:kn,minisearch:JSON.stringify(this.minisearch),entries:Array.from(this.entryCache.entries()).filter(e=>e[1].cacheMode==="persistent")}),await F.set("silversearch-cache-lock",!1)},250)}async reindex(e=!1){e||await C.flashNotification("Silversearch - Reindexing, this can cause performance problems"),this.minisearch.removeAll();let n=(await D.listFiles()).map(r=>r.name).filter(this.isIndexedPath);console.log(`[Silversearch] Indexing ${n.length} pages`),e||await C.showProgress(0,"index"),await this.indexByPaths(n,(r,i)=>{e||C.showProgress(Math.round(r/i*100),"index"),F.set("silversearch-progress",{done:r,all:i})}),F.del("silversearch-progress"),e||(await C.showProgress(),await C.flashNotification("Silversearch - Full reindex done!"))}async indexByPath(e){await this.indexByPaths([e])}async indexByPaths(e,n){let r=0;for(let i of e)try{if(this.entryCache.delete(i),this.ignore.ignores(i))console.log(`[Silversearch] Ignoring ${O(i)}`),this.minisearch.discard(i);else{console.log(`[Silversearch] Indexing ${O(i)}`);let s=await this.getCacheEntry(i);if(!s)throw null;this.minisearch.has(s.path)?this.minisearch.replace(s):this.minisearch.add(s)}n&&n(++r,e.length)}catch{console.warn(`[Silversearch] Failed to index ${O(i)}. Skipping!`)}await this.writeToCache()}async deleteByPath(e){await this.deleteByPaths([e])}async deleteByPaths(e){for(let n of e)try{this.entryCache.delete(n),this.minisearch.discard(n)}catch{console.error("[Silversearch] Something went wrong. Failed to delete page")}await this.writeToCache()}async search(e,n){let r=await N();if(e.isEmpty())return[];let i={0:0,1:.1,2:.2}[r.fuzziness],s=rn(e.segmentsToStr(),{tokenizers:this.tokenizers}),o=this.minisearch.search(s,{prefix:p=>p.length>=n.prefixLength,fuzzy:p=>p.length<=3?0:p.length<=5?i/2:i,boost:{basename:r.weights.basename,aliases:r.weights.aliases,displayName:r.weights.displayName,directory:r.weights.directory,tags:r.weights.tags,unmarkedTags:r.weights.tags},tokenize:p=>[p],boostDocument(p,h,d){if(!d?.lastModified||r.recencyBoost==="disabled")return 1;let g=d?.lastModified,m=(new Date().getTime()-g)/(24*3600*1e3),y={day:-3,week:-.3,month:-.1};return 1+Math.exp(y[r.recencyBoost]*(m/1e3))}});if(e.query.ext?.length&&(o=o.filter(p=>{let h=p.id.includes(".")?"."+p.id.split(".").pop():".md";return e.query.ext?.some(d=>h.startsWith(d.startsWith(".")?d:"."+d))})),e.query.path&&(o=o.filter(p=>e.query.path?.some(h=>p.id.toLowerCase().includes(h.toLowerCase())))),e.query.exclude.path&&(o=o.filter(p=>!e.query.exclude.path?.some(h=>p.id.toLowerCase().includes(h.toLowerCase())))),!o.length)return[];if(n.singleFilePath)return o.filter(p=>p.id===n.singleFilePath);let u=await this.getCacheEntries(o.map(p=>p.id)),a=e.getTags();for(let p of o){let h=p.id,d=O(h);r.downrankedFoldersFilters.length>0&&(r.downrankedFoldersFilters.some(m=>d===m||d.startsWith(m+"/"))||d.split("/").some(m=>r.downrankedFoldersFilters.includes(m)))&&(p.score/=10);let g=u.find(v=>v.path===h);if(g)for(let[v,m]of Object.entries(r.weightCustomProperties)){let y=g.metadata[v];y&&p.terms.some(x=>y.includes(x))&&(p.score*=m)}for(let v of a)(g?.tags??[]).includes(v)&&(p.score*=100)}o=o.sort((p,h)=>h.score-p.score).slice(0,50);let l=e.getExactTerms();l.length&&(o=o.filter(p=>{let h=u.find(v=>v.path===p.id),d=h?.name.toLowerCase()??"",g=(h?.cleanedContent??"").toLowerCase();return l.every(v=>g.includes(v)||$(d,r.ignoreArabicDiacritics).includes(v))}));let f=e.query.exclude.text;return f.length&&(o=o.filter(p=>{let h=(u.find(d=>d.path===p.id)?.content??"").toLowerCase();return f.every(d=>!h.includes(d))})),o}async getSuggestions(e,n){let r=await this.search(e,{prefixLength:1,singleFilePath:n?.singleFilePath}),i=await this.getCacheEntries(r.map(o=>o.id));return(await Promise.all(r.map(async o=>{let u=i.find(d=>d.path===o.id);if(!u)return console.warn(`[Silversearch] Note "${o.name}" disappeared. Skipping`),null;let a=[...o.terms,...e.getExactTerms(),...e.getTags()],l=await pt(u.content,a,e),f=await pt(u.name,a),p;if(n?.singleFilePath){let d=ut(l),g=e.getExactTerms();g.length&&(d=d.filter(m=>g.every(y=>m.some(x=>x.match.includes(y)))));let v=d.map(m=>m[0].offset);p=await Promise.all(v.map(m=>ht(u?.content??"",m)))}else{let d=ut(l),g=0;d.length&&(g=d.reduce((m,y)=>y.length>m.length?y:m)[0].offset),p=[await ht(u.content,g)]}return{score:o.score,foundWords:a,matches:l,matchesName:f,excerpts:p,name:u.name,basename:u.basename,content:u.content,navigationMap:u.navigationMap}}))).filter(o=>o!==null)}async getCacheEntries(e){return(await Promise.all(e.map(r=>this.getCacheEntry(r)))).filter(r=>!!r)}async getCacheEntry(e){let n,r=this.entryCache.get(e);if(r)return r;try{let u=O(e);n=K(e)?await D.getPageMeta(u):await D.getDocumentMeta(u)}catch{return console.log("[Silversearch] Couldn't find the specified file:",e),null}let i=await t.pathToIndexableEntry(e,n);if(!i)return null;let s=Object.fromEntries(Object.entries(n).filter(([u,a])=>!["ref","tag","tags","itags","name","created","lastModified","perm","lastOpened","pageDecoration","aliases","extension","size","contentType"].includes(u))),o={...i.entry,...i.info,cleanedContent:Zt($(i.entry.content)),metadata:s,tags:n.tags?.map(u=>"#"+u)??[]};return this.entryCache.set(e,o),o}static async pathToIndexableEntry(e,n){let r=O(e),i;try{i=n??(K(e)?await D.getPageMeta(r):await D.getDocumentMeta(r))}catch{return null}let s=await pn(e,i);if(!s)return null;let o=Yt(s.content),u={path:e,name:r,content:o,basename:fn(r),directory:cn(r),aliases:i.aliases??[],displayName:i.displayName??"",unmarkedTags:i.tags??[],lastModified:new Date(i.lastModified).getTime()},{content:a,...l}=s;return{entry:u,info:l}}isIndexedPath(e){return!e.endsWith(".plug.js")}static getOptions(e,n){return{tokenize:r=>nn(r,{tokenizers:n,tokenizeUrls:e.tokenizeUrls}),processTerm:r=>(e.ignoreDiacritics?$(r,e.ignoreArabicDiacritics):r).toLowerCase(),idField:"path",fields:["content","basename","directory","aliases","displayName","unmarkedTags"],storeFields:["lastModified"]}}};var Sn=Et(An()),wt=["ext","path"],Pe=class{#e;constructor(e="",n){n.ignoreDiacritics&&(e=$(e,n.ignoreArabicDiacritics));let r=(0,Sn.parse)(e.toLowerCase(),{tokenize:!0,keywords:wt});r.text=r.text??[],r.exclude=r.exclude??{text:[]},r.exclude.text=r.exclude.text??[],Array.isArray(r.exclude.text)||(r.exclude.text=[r.exclude.text]),r.exclude.text=r.exclude.text.filter(s=>s.length);for(let s of wt){let o=r[s];o&&(r[s]=Array.isArray(o)?o:[o]);let u=r.exclude[s];u&&(r.exclude[s]=Array.isArray(u)?u:[u])}this.query=r;let i=this.query.text.filter(s=>s.startsWith(".")).map(s=>s.slice(1));this.query.ext=[...new Set([...i,...this.query.ext??[]])],this.query.text=this.query.text.filter(s=>!s.startsWith(".")),this.#e=e.match(/"([^"]+)"/g)?.map(s=>s.replace(/"/g,""))??[]}isEmpty(){for(let e of wt)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()))]}getBestStringForExcerpt(){return this.#e.length?this.#e.sort((e,n)=>n.length-e.length)[0]??"":this.segmentsToStr()}};var Tn="1.2.5";var S=null,W=[],Ae=null;function bt(t=!0,e=!1){return Ae||(Ae=Zs(t,e).then(()=>{Ae=null})),Ae}async function Zs(t,e){if(S)return;let n=await N();S=await J.loadFromCache(n),!S&&t?(S=await J.create(n),await S.reindex(e)):S&&W.length&&(await S.indexByPaths(W.filter(r=>r.action==="index").map(r=>r.path)),await S.deleteByPaths(W.filter(r=>r.action==="delete").map(r=>r.path))),W=[]}async function Cn(t=""){await C.showPanel("modal",1,Tt,t?`globalThis.DEFAULT_QUERY = ${JSON.stringify(t)};`+ze:ze)}async function Fn(){await c("silversearch.openSearch")}async function Mn(){await bt(!1)}async function Dn({name:t}){let e=`${t}.md`;S?await S.indexByPath(e):W.push({action:"index",path:e})}async function In(t){let e=t;S?await S.indexByPath(e):W.push({action:"index",path:e})}async function zn(t){S?await S.deleteByPath(t):W.push({action:"delete",path:t})}async function On(t,e){await bt(!0,e.silent??!1);let n=await N(),r=new Pe(t,{ignoreDiacritics:n.ignoreDiacritics,ignoreArabicDiacritics:n.ignoreArabicDiacritics});return S.getSuggestions(r,{singleFilePath:e.singleFilePath})}async function Rn(t=!1){await J.deleteCache(),S=null,await bt(!0,t)}async function Ln(){await C.flashNotification(`Silversearch - Version ${Tn}`)}async function jn(){await C.flashNotification("Silversearch - Cleared History"),F.set("silversearch-history",[])}var Nn={startSearch:Fn,getVersion:Ln,clearHistory:jn,openSearch:Cn,reindex:Rn,init:Mn,indexPage:Dn,indexDocument:In,deleted:zn,search:On},$n={name:"silversearch",functions:{startSearch:{path:"./silversearch.ts:startSearch",command:{name:"Silversearch: Search",key:"Ctrl-s",mac:"Cmd-s"}},getVersion:{path:"./silversearch.ts:showVersion",command:{name:"Silversearch: Version"}},clearHistory:{path:"./silversearch.ts:clearHistory",command:{name:"Silversearch: Clear History"}},openSearch:{path:"./silversearch.ts:openSearch",syscall:"silversearch.openSearch"},reindex:{path:"./silversearch.ts:reindex",syscall:"silversearch.reindex",command:{name:"Silversearch: Reindex"}},init:{path:"./silversearch.ts:init",events:["editor:init"]},indexPage:{path:"./silversearch.ts:indexPage",events:["page:index"]},indexDocument:{path:"./silversearch.ts:indexDocument",events:["document:index"]},deleted:{path:"./silversearch.ts:deleted",events:["file:deleted"]},search:{path:"./silversearch.ts:search",syscall:"silversearch.search"}},assets:{}},ol={manifest:$n,functionMapping:Nn};St(Nn,$n,self.postMessage);export{ol as plug};
|
|
/*! Bundled license information:
|
|
|
|
search-query-parser/lib/search-query-parser.js:
|
|
(*!
|
|
* search-query-parser.js
|
|
* Copyright(c) 2014-2019
|
|
* MIT Licensed
|
|
*)
|
|
*/
|
|
//# sourceMappingURL=silversearch.plug.js.map
|