//{"name":"search","version":"1.3.476","created":"2025-05-19T08:30:04.560Z"}
import{moduleManager as e}from"./napi.js";import{stringUtils as s}from"./libs.js";import t,{nls as r,nlsRaw as a}from"./i18n.js";const i=globalThis.process?.env?.NODE_ENV,n=i&&!i.toLowerCase().startsWith("prod"),o=()=>{};let c=!1;if(n){function w(e){if(!(e in globalThis)){let s;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(void 0!==s)return s;!function(e){if(n){const s=new Error(`rune_outside_svelte\nThe \`${e}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files\nhttps://svelte.dev/e/rune_outside_svelte`);throw s.name="Svelte error",s}throw new Error("https://svelte.dev/e/rune_outside_svelte")}(e)},set:e=>{s=e}})}}w("$state"),w("$effect"),w("$derived"),w("$inspect"),w("$props"),w("$bindable")}function h(e,s,t){if(null==e)return s(void 0),t&&t(void 0),o;const r=function(e){var s=c;try{return c=!0,e()}finally{c=s}}((()=>e.subscribe(s,t)));return r.unsubscribe?()=>r.unsubscribe():r}const l=[];function u(e,s=o){let t=null;const r=new Set;function a(s){if(i=s,((a=e)!=a?i==i:a!==i||null!==a&&"object"==typeof a||"function"==typeof a)&&(e=s,t)){const s=!l.length;for(const t of r)t[1](),l.push(t,e);if(s){for(let e=0;e<l.length;e+=2)l[e][0](l[e+1]);l.length=0}}var a,i}function i(s){a(s(e))}return{set:a,update:i,subscribe:function(n,c=o){const h=[n,c];return r.add(h),1===r.size&&(t=s(a,i)||o),n(e),()=>{r.delete(h),0===r.size&&t&&(t(),t=null)}}}}function d(e,s,t){const r=!Array.isArray(e),a=r?[e]:e;if(!a.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const i=s.length<2;return n=(e,t)=>{let n=!1;const c=[];let l=0,u=o;const d=()=>{if(l)return;u();const a=s(r?c[0]:c,e,t);i?e(a):u="function"==typeof a?a:o},g=a.map(((e,s)=>h(e,(e=>{c[s]=e,l&=~(1<<s),n&&d()}),(()=>{l|=1<<s}))));return n=!0,d(),function(){!function(e){for(var s=0;s<e.length;s++)e[s]()}(g),u(),n=!1}},{subscribe:u(t,n).subscribe};var n}const g=["core","debug","i18n","kin","libs","napi","napiAdapter","napiExtensions","plugins","svelteComponents","svelteInternal","system"];class b{#e;#s;constructor(e){this.#e=[],this.#s=this.#t(e)}buildSearchStrings(){const e=this.#s.map((e=>e.searchStrings?"function"==typeof e.searchStrings?e.searchStrings():e.searchStrings:this.#r(e.name,e.view)));return Promise.allSettled(e).then((e=>(this.#e.length=0,e.map(((e,s)=>this.#a(this.#s[s].route,[],e.value)))))).then((e=>Promise.allSettled(e))).then((()=>this.#e))}getSearchStrings(){return this.#e}#t(e){return e.filter((e=>!g.includes(e))).map((e=>{if("string"==typeof e)return{name:e,route:"#"+e};{const s=e.route||e.name;return{...e,route:(s.startsWith("#")?"":"#")+s}}}))}#r(s,t){const r=t?t+"SearchStrings":"searchStrings";return e.importModule(s,r,{silent:!0}).then((e=>"function"==typeof e?e():e)).catch((e=>{console.warn(`loading search strings of ${s}${t?`[${t}]`:""} failed; REASON:`,e)}))}async#a(e,s,t){if(!t)return;await this.#i({route:e,title:t.title,parents:s,desc:t.desc,secondaries:t.secondaries,keywords:t.keywords,icon:t.icon,isPage:!0});const r=t.title?[...s,{title:t.title,icon:t.icon}]:s,a=this.#n([t.loaded,t.loading],[!1,!0]);if(await this.#o({route:e,items:t.items,parents:r,loaded:a}),t.pages){const s=t.pages.map((s=>this.#a(e+"/"+s.subroute,r,{...s,loaded:this.#n([a,s.loaded,s.loading],[!1,!1,!0]),loading:null})));await Promise.allSettled(s)}}async#i(e){if(!e.title)return;if(await this.#c(e.cond))return;const{isPage:s}=e,t=s?1e6-1e4*e.parents.length:100,r=[{stringId:e.title,score:t}];let a;e.desc&&(a="function"==typeof e.desc?await e.desc():e.desc,r.push({stringId:a,score:50})),e.secondaries?.forEach((e=>{"string"==typeof e||Array.isArray(e)?r.push({stringId:e}):r.push({stringId:e.stringId,score:Math.max(Math.min(e.score,10),0)})})),e.keywords?.forEach((e=>{r.push("string"==typeof e||Array.isArray(e)?{stringId:e}:e)})),e.parents?.forEach((e=>r.push({stringId:e.title,score:s?1e3:100}))),this.#e.push({title:e.title,parents:e.parents,desc:a,isPage:e.isPage,icon:e.icon,route:e.route,postroute:e.postroute,loaded:this.#n([e.loaded,e.loading],[!1,!0]),elemId:e.elemId,strings:r})}async#o(e){if(!e.items?.length)return;const s=e.items.reduce(((s,t)=>{if(!t)return s;const r=this.#n([t.loaded,t.loading,e.loaded,e.loading],[!1,!0,!1,!0]),a=t.title||t.desc,i=t.parents?.map((e=>"string"==typeof e?{title:e}:e))||[],n=[...e.parents,...i];let o,c=e.route;return"string"==typeof t.route?c=t.route:"function"==typeof t.route&&(c=t.route(e.route)),(e.postroute||t.postroute)&&(o=()=>{e.postroute?.(),t.postroute?.()}),s.push(this.#i({title:a,parents:n,desc:t.title?t.desc:null,secondaries:t.secondaries,keywords:t.keywords,route:c,postroute:o,loaded:r,elemId:t.elemId,cond:t.cond})),t.items?.length&&s.push(this.#o({route:c,items:t.items,parents:[...n,{title:a}],postroute:o,loaded:r})),s}),[]);await Promise.allSettled(s)}async#c(e){return"boolean"==typeof e?!e:"function"==typeof e&&!await e()}#n(e,s=[]){const t=[],r=[];if(e.forEach(((e,a)=>{e&&(t.push(e),r.push(s[a]))})),0!==t.length)return 1!==t.length||r[0]?d(t,(e=>e.every(((e,s)=>r[s]?!e:e)))):t[0]}}var p,m={};var f=function(){if(p)return m;p=1,m.remove=function(e){return e.replace(/[^\u0000-\u007e]/g,(function(e){return s[e]||e}))};for(var e=[{base:" ",chars:" "},{base:"0",chars:"߀"},{base:"A",chars:"ⒶＡÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",chars:"Ꜳ"},{base:"AE",chars:"ÆǼǢ"},{base:"AO",chars:"Ꜵ"},{base:"AU",chars:"Ꜷ"},{base:"AV",chars:"ꜸꜺ"},{base:"AY",chars:"Ꜽ"},{base:"B",chars:"ⒷＢḂḄḆɃƁ"},{base:"C",chars:"ⒸＣꜾḈĆCĈĊČÇƇȻ"},{base:"D",chars:"ⒹＤḊĎḌḐḒḎĐƊƉᴅꝹ"},{base:"Dh",chars:"Ð"},{base:"DZ",chars:"ǱǄ"},{base:"Dz",chars:"ǲǅ"},{base:"E",chars:"ɛⒺＥÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎᴇ"},{base:"F",chars:"ꝼⒻＦḞƑꝻ"},{base:"G",chars:"ⒼＧǴĜḠĞĠǦĢǤƓꞠꝽꝾɢ"},{base:"H",chars:"ⒽＨĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",chars:"ⒾＩÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",chars:"ⒿＪĴɈȷ"},{base:"K",chars:"ⓀＫḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",chars:"ⓁＬĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",chars:"Ǉ"},{base:"Lj",chars:"ǈ"},{base:"M",chars:"ⓂＭḾṀṂⱮƜϻ"},{base:"N",chars:"ꞤȠⓃＮǸŃÑṄŇṆŅṊṈƝꞐᴎ"},{base:"NJ",chars:"Ǌ"},{base:"Nj",chars:"ǋ"},{base:"O",chars:"ⓄＯÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OE",chars:"Œ"},{base:"OI",chars:"Ƣ"},{base:"OO",chars:"Ꝏ"},{base:"OU",chars:"Ȣ"},{base:"P",chars:"ⓅＰṔṖƤⱣꝐꝒꝔ"},{base:"Q",chars:"ⓆＱꝖꝘɊ"},{base:"R",chars:"ⓇＲŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",chars:"ⓈＳẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",chars:"ⓉＴṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"Th",chars:"Þ"},{base:"TZ",chars:"Ꜩ"},{base:"U",chars:"ⓊＵÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",chars:"ⓋＶṼṾƲꝞɅ"},{base:"VY",chars:"Ꝡ"},{base:"W",chars:"ⓌＷẀẂŴẆẄẈⱲ"},{base:"X",chars:"ⓍＸẊẌ"},{base:"Y",chars:"ⓎＹỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",chars:"ⓏＺŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",chars:"ⓐａẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ"},{base:"aa",chars:"ꜳ"},{base:"ae",chars:"æǽǣ"},{base:"ao",chars:"ꜵ"},{base:"au",chars:"ꜷ"},{base:"av",chars:"ꜹꜻ"},{base:"ay",chars:"ꜽ"},{base:"b",chars:"ⓑｂḃḅḇƀƃɓƂ"},{base:"c",chars:"ｃⓒćĉċčçḉƈȼꜿↄ"},{base:"d",chars:"ⓓｄḋďḍḑḓḏđƌɖɗƋᏧԁꞪ"},{base:"dh",chars:"ð"},{base:"dz",chars:"ǳǆ"},{base:"e",chars:"ⓔｅèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇǝ"},{base:"f",chars:"ⓕｆḟƒ"},{base:"ff",chars:"ﬀ"},{base:"fi",chars:"ﬁ"},{base:"fl",chars:"ﬂ"},{base:"ffi",chars:"ﬃ"},{base:"ffl",chars:"ﬄ"},{base:"g",chars:"ⓖｇǵĝḡğġǧģǥɠꞡꝿᵹ"},{base:"h",chars:"ⓗｈĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",chars:"ƕ"},{base:"i",chars:"ⓘｉìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",chars:"ⓙｊĵǰɉ"},{base:"k",chars:"ⓚｋḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",chars:"ⓛｌŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇɭ"},{base:"lj",chars:"ǉ"},{base:"m",chars:"ⓜｍḿṁṃɱɯ"},{base:"n",chars:"ⓝｎǹńñṅňṇņṋṉƞɲŉꞑꞥлԉ"},{base:"nj",chars:"ǌ"},{base:"o",chars:"ⓞｏòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿꝋꝍɵɔᴑ"},{base:"oe",chars:"œ"},{base:"oi",chars:"ƣ"},{base:"oo",chars:"ꝏ"},{base:"ou",chars:"ȣ"},{base:"p",chars:"ⓟｐṕṗƥᵽꝑꝓꝕρ"},{base:"q",chars:"ⓠｑɋꝗꝙ"},{base:"r",chars:"ⓡｒŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",chars:"ⓢｓśṥŝṡšṧṣṩșşȿꞩꞅẛʂ"},{base:"ss",chars:"ß"},{base:"t",chars:"ⓣｔṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"th",chars:"þ"},{base:"tz",chars:"ꜩ"},{base:"u",chars:"ⓤｕùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",chars:"ⓥｖṽṿʋꝟʌ"},{base:"vy",chars:"ꝡ"},{base:"w",chars:"ⓦｗẁẃŵẇẅẘẉⱳ"},{base:"x",chars:"ⓧｘẋẍ"},{base:"y",chars:"ⓨｙỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",chars:"ⓩｚźẑżžẓẕƶȥɀⱬꝣ"}],s={},t=0;t<e.length;t+=1)for(var r=e[t].chars,a=0;a<r.length;a+=1)s[r[a]]=e[t].base;return m.replacementList=e,m.diacriticsMap=s,m}();const S={ar:2,bn:2,"zh-CN":1,"zh-TW":1,fa:2,he:2,hi:2,ja:1,ko:1,th:2,"ur-PK":2,vi:2};function y(){return S[t.locale()]||3}class v{static SPLIT_STR_REGEX=/[\s,;.?!|&+<>]+/;static STRICT_SIMILARITY=1;static TOLERANT_SIMILARITY=.6;#e;#h;constructor(e={}){this.#h=e.contentElem,this.updateSearchStrings(e.searchStrings)}static sanitize(e){if("string"!=typeof e)return"";const t=s.stripHtml(e);return f.remove(t).replace(/[\!@#\$\^\&%\*\(\)\+\=\-\[\]\\\/\{\}\|\:<>\?,\._'"`]/g,"").replace(/\s+/g," ").trim()}static getMinQueryLength(){return y()}updateSearchStrings(e){this.#e=e?.map((e=>(e.stringChunks=e.strings.reduce(((e,s)=>(this.#l(s,e),this.#l(s,e,{english:!0}),e)),{}),e)))}async getResults(e,s){const t=s?.minSimilarity||v.STRICT_SIMILARITY,r=s?.getQuerySuggestions,a=s?.maxQuerySuqestions||3;if(e=v.sanitize(e).toLowerCase(),!this.#e?.length||!e||e.length<y())return;const i=this.#u(e,{sanitized:!0}),n=r?[]:void 0,o=this.#e.map((e=>this.#d(e,i,t,n))),c=(await Promise.allSettled(o)).filter((e=>e.value)).map((e=>e.value)).sort(((e,s)=>s.score-e.score)),h=this.#g(n)?.slice(0,a);return{results:c,querySuggestions:h}}async goToResult(e){"function"==typeof e.route?await e.route():/^https?:\/\//.test(e.route)?window.location.href=e.route:e.route&&(window.location.hash=e.route),setTimeout((async()=>{const s=this.#b(e);e.postroute&&await e.postroute(),s||this.#p(e)}))}async#d(e,s,t,r){const a=[],i=r&&[];let n=0;if(s.forEach(((s,o)=>{const c=r&&Math.min(o,i.length);a[o]=0;for(const r in e.stringChunks){const h=e.stringChunks[r],l=r.includes(s)?1:this.#m(s,r);if(l>=t){++a[o];const e=i?.[c];i&&(!e||e.similarity<l)&&(i[c]={match:r,similarity:l}),n+=(h||1)*l}}})),i?.length===s.length){const e=i.map((e=>e.match)).sort(((e,s)=>e.localeCompare(s))).join(" "),s=i.reduce(((e,s,t)=>(e.match+=(t?" ":"")+s.match,e.similarity+=s.similarity,e)),{match:"",similarity:0});(!r[e]||s.similarity>r[e].similarity||s.similarity===r[e].similarity&&n>r[e].score)&&(r[e]={...s,score:n})}if(a.every((e=>e))){const s=this.#f(e.title).replace(/:$/,""),t=e.parents?.map((e=>this.#f(e.title)));return{title:s,parents:t,desc:e.desc&&this.#f(e.desc),icon:e.parents[0]?.icon||e.icon,route:e.route,postroute:e.postroute,loaded:e.loaded,elemId:e.elemId,isPage:e.isPage,score:n}}}#b(e){if(!e.loaded)return!1;let s;return s=e.loaded.subscribe((t=>{t&&(this.#p(e),s?.())})),!0}#p(e){return new Promise((s=>{setTimeout((()=>{let t;e.elemId&&(t=document.body.querySelector("#"+e.elemId+"__container"),t||(t=document.body.querySelector("#"+e.elemId))),document.body.querySelectorAll(".search-highlight").forEach((e=>{e.classList.remove("search-highlight")})),t?(t.classList.add("search-highlight"),t.scrollIntoView({block:"center"}),setTimeout((()=>{t.classList.remove("search-highlight")}),5e3)):this.#h?.scrollTo(0,0),s()}),200)}))}#f(e,s){const t=s?.english?this.#S.bind(this):r;let a;return a=Array.isArray(e)?t.apply(null,e):t(e),a=a?.replace(/{.*?}/g,"")||e,s?.sanitize?v.sanitize(a):a.replace(/\s+/g," ")}#S(e){return a(e,"en")?.replace(/\$t\((.+?)\)/g,((e,s)=>this.#S(s)))}#u(e,s={}){return"string"!=typeof e?[]:e.split(v.SPLIT_STR_REGEX).reduce(((e,t)=>(t&&e.push(s.sanitized?t:v.sanitize(t)),e)),[])}#m(e,s){e=e.toLowerCase(),s=s.toLowerCase();const t=Math.min(e.length,s.length),r=Math.max(e.length,s.length);let a=0;for(let i=0;i<t;i++)e[i].toLowerCase()===s[i].toLowerCase()?a++:e[i+1]!==s[i]&&e[i-1]!==s[i]||(a+=.25);return a/r}#l(e,s,r={}){if("en"===t.locale()&&r.english)return[];const a=this.#f(e.stringId,{sanitize:!0,english:r.english}),i=this.#u(a.toLowerCase());for(const t of i)s[t]=s[t]||0,s[t]+=(e.score||0)/i.length/(r.english?2:1)}#g(e){if(!e)return;return Object.values(e).filter((e=>e.match.length>=y())).sort(((e,s)=>e.similarity===s.similarity?s.score-e.score:s.similarity-e.similarity)).map((e=>e.match))}}export{v as SearchEngine,b as SearchStringsBuilder};const I={name:"search",version:"1.3.476",created:"2025-05-19T08:30:04.560Z"};export{I as metadata};
