PageSourceSearch

https://kindredly.ai/js/search.bgrouteCf9ywAsQ.js

js kindredly.ai collected 2026-10-02 01:14:39 UTC 12,936 bytes, 3 lines download raw bytes

1var Y=Object.defineProperty;var G=(e,t,s)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var M=(e,t,s)=>G(e,typeof t!="symbol"?t+"":t,s);import{k as K,m as W,n as q,o as B,p as x,q as $,s as A,t as X,h as z,u as Q,v as j,w as v}from"./remoteActionApprovalC_byoH4M.js";import{C as J,I as T,b as H}from"./ItemServiceDYS7Z6Pr.js";import{a as Z}from"./tourGateGu4icdk6.js";import{f as C,bG as tt,a7 as et,O as st,e as F}from"./chunkReloadRecoveryrjuMb-b8.js";import{U as it}from"./OperationQueueKzEpmh-u.js";import{M as nt}from"./memoryPressureCXUVStEA.js";import{b as rt,g as ot}from"./usageBDNfLijZ.js";import{a as at,i as ct}from"./urlGuardsBFjEFH91.js";import{d as lt,a as ut,c as ht,m as dt}from"./search-provider.utilsBiOzVtNa.js";import{b as pt,p as mt,c as yt,t as ft,a as wt,s as gt,l as Mt,i as vt,d as bt,e as St,C as _t,f as It,g as kt,h as Et}from"./freshSignInv8N2vL5e.js";import{g as At}from"./item-name.utilsBH3paGZr.js";import"./classificationEvalProgramStatusBazwXda2.js";import"./ActivityUtilsDiYdCK40.js";import"./constantsDW26WJ6H.js";import"./url.utils3SlYVg-c.js";import"./reason-code.utilswudkndKE.js";import"./reason-metadataDPJV5z5v.js";import"./socialMediaSitesDTleWHW6.js";import"./regexCcuTG5WM.js";import"./appUsageDisplayBY7OQki1.js";import"./deviceAppIdsBqiQQIm5.js";import"./sentryUtilsC8JjCXHs.js";import"./classificationRulesDUyL5GMw.js";import"./content.typesyje91KzF.js";import"./browserTabsCpW6SD42.js";import"./settingsMenuCatalogBT0bsy85.js";import"./searchTargets.pureDLBWinh3.js";import"./SearchHistoryStoreBNg-02Jq.js";import"./urlDuplicateMatchingB9T_GhRn.js";import"./item.typesx7Q7rrX9.js";import"./siteBlockModeCGmJVg0R.js";import"./alwaysAllowedBZhbIqQn.js";import"./familyClockv2WXhBE2.js";import"./deviceAppPolicyG0TWkbSX.js";import"./familyDowntimeDMv_mvJ9.js";import"./google-ai-modeaEFJUNOw.js";import"./dexie2jmnBxhj.js";import"./statusFacetsB0tsuUpJ.js";import"./browseFacets8dSOpUAG.js";import"./v4CtRu48qb.js";import"./restrictionPresetsAJUpiAxw.js";import"./deviceAppInventoryMergevnYbxNmN.js";import"./usageIdentityCn48n3s8.js";import"./usageInterventionModeBjzyP5YP.js";import"./TextEmbeddingServiceD7QjSnH7.js";import"./analysis-utilsDkY9KbJt.js";import"./textEmbeddingUtilsBRNkRshv.js";import"./queryEmbeddingl6fVc4SQ.js";import"./usageRuleStateD0i2H3LO.js";import"./noteAttachmentDId5R_kp.js";import"./file_utilsBvAXo0vA.js";import"./extraction.pure.utilsDQPW8yIh.js";import"./api-typesD1zIcSfT.js";import"./feedback.utilscwcZGi10.js";import"./feedDiscoveryCsjZq3pR.js";import"./itemImageSourcesCubmTdva.js";import"./rolloutCapsBJsLLLO7.js";import"./vue-runtimeBHGad_ZB.js";import"./cjs-helpersC4iS2aBk.js";import"./bootstrap-vue-nextDXY4qsO1.js";import"./searchContentKindsBGoDYC-k.js";const D=12,Ct=2e4,Lt=new Set(["videoPlaying","audioPlaying"]);function L(e){return(e==null?void 0:e.startTime)??(e==null?void 0:e.endTime)??0}function U(e){return(e==null?void 0:e.endTime)??(e==null?void 0:e.startTime)??0}function Tt(e){try{return new URL(e).hostname.toLowerCase().replace(/^www\./,"")}catch{return""}}function Dt(e,t){var n;const s=t.get(e);if(s!==void 0)return s;const i=/^https?:\/\//i.test(e)&&!at(e)&&!ct(e)&&((n=lt(e))==null?void 0:n.pageState)!=="results";return t.set(e,i),i}function Ot(e,t){return!e||e===t||/^https?:\/\//i.test(e)?"":e}function V(e,t={}){var p,y;const s=t.sinceMs??0,i=t.maxPages??Ct;if(!e||e.length===0)return[];const n=K(e),r=new Map,a=new Map;for(const u of n){const h=u==null?void 0:u.url;if(!h||u.type==="query"||W(u)||U(u)<s||!Dt(h,r))continue;const o=q(h);if(!o)continue;const l=a.get(o);l?l.push(u):a.set(o,[u])}const c=[];for(const[u,h]of a){h.sort((d,f)=>L(d)-L(f));let o="",l="",g=-1/0,w=1/0,b=0,k=-1/0,E=0,R=0;for(const d of h){o=B(o,d);const f=L(d),_=U(d);_>=g&&(g=_,l=d.url||l),f<w&&(w=f),f-k>$&&b++,_>k&&(k=_),d.type==="active"?E+=x(d):Lt.has(d.type)&&(R+=x(d))}const S=[],P=new Set;for(let d=h.length-1;d>=0&&S.length<D;d--)for(const f of((y=(p=h[d])==null?void 0:p.contentInfo)==null?void 0:y.keywords)||[]){if(S.length>=D)break;typeof f!="string"||P.has(f)||(P.add(f),S.push(f))}c.push({key:u,url:l,title:Ot(o,l),host:Tt(l),keywords:S,firstVisitMs:w,lastVisitMs:g,visitCount:Math.max(1,b),timeSpentMs:E>0?E:R})}return c.sort((u,h)=>h.lastVisitMs-u.lastVisitMs),c.length>i?c.slice(0,i):c}function Rt(e,t){const s=t.lastVisitMs>=e.lastVisitMs?t:e,i=s===e?t:e,n=[],r=new Set;for(const c of[...s.keywords,...i.keywords]){if(n.length>=D)break;r.has(c)||(r.add(c),n.push(c))}const a=s.title&&(!i.title||s.title.length>=i.title.length)?s.title:i.title;return{key:s.key,url:s.url,title:a,host:s.host||i.host,keywords:n,firstVisitMs:Math.min(e.firstVisitMs,t.firstVisitMs),lastVisitMs:s.lastVisitMs,visitCount:e.visitCount+t.visitCount,timeSpentMs:e.timeSpentMs+t.timeSpentMs}}const Pt={title:1.9,keywords:1.3,url:1},xt=20;function Ht(e){try{const t=new URL(e.url);let s=t.pathname;try{s=decodeURIComponent(s)}catch{}return`${t.hostname.replace(/^www\./,"")}${s==="/"?"":s}`.toLowerCase()}catch{return(e.url||"").toLowerCase()}}function Ut(e){const t={url:Ht(e)};return e.title&&(t.title=e.title.toLowerCase()),e.keywords.length>0&&(t.keywords=e.keywords.join(" · ").toLowerCase()),t}function N(e){const t=new Array(e.length),s=new Array(e.length),i=new Map;for(let n=0;n<e.length;n++){const r=Ut(e[n]);t[n]=r,s[n]=`${r.title||""}
2${r.keywords||""}
3${r.url||""}`,i.set(e[n].key,n)}return{pages:e,fields:t,haystacks:s,byKey:i}}function Vt(e,t){return N(t.map(s=>{const i=e.byKey.get(s.key);return i===void 0?s:Rt(e.pages[i],s)}))}function Ft(e,t){const s=[];return e.title&&t.some(i=>e.title.includes(i))&&s.push("title"),e.keywords&&t.some(i=>e.keywords.includes(i))&&s.push("keywords"),e.url&&t.some(i=>e.url.includes(i))&&s.push("address"),s}function Nt(e,t,s={}){const i=Math.max(1,s.limit??xt),n=s.nowMs??Date.now(),r=s.overlay||null,a=pt(mt(t||""));if(a.tokenCount===0)return{hits:[],total:0};const c=a.terms.filter((o,l)=>!a.isPhrase[l]),p=[],y=(o,l)=>{const g=o.haystacks[l];for(const b of c)if(!g.includes(b))return;const w=gt(o.fields[l],a,Pt);w.matchedTokenCount<a.tokenCount||p.push({page:o.pages[l],fields:o.fields[l],scored:w})};for(let o=0;o<e.pages.length;o++)r&&r.byKey.has(e.pages[o].key)||y(e,o);if(r)for(let o=0;o<r.pages.length;o++)y(r,o);if(p.length===0)return{hits:[],total:0};const u=yt(ft(p.map(o=>o.scored),a.terms.length),p.length),h=p.map(o=>({candidate:o,score:wt({scored:o.scored,query:a,idfWeights:u,signals:{visitCount:o.page.visitCount,lastVisitMs:o.page.lastVisitMs,nowMs:n}}).score}));return h.sort((o,l)=>l.score-o.score||l.candidate.page.lastVisitMs-o.candidate.page.lastVisitMs),{hits:h.slice(0,i).map(({candidate:o,score:l})=>({page:o.page,score:l,matchedIn:Ft(o.fields,c)}
3)),total:h.length}}const Yt=30,Gt=3e4,I=class I{constructor(){M(this,"built",null);M(this,"live",null);M(this,"building",null);try{J.instance.addSignoutCallback(()=>this.clear())}catch(t){C("HistorySearchService: could not register the sign-out callback",t)}typeof window<"u"&&typeof window.addEventListener=="function"&&window.addEventListener(nt,()=>this.clear())}static get instance(){return this._staticInstance||(this._staticInstance=new I),this._staticInstance}clear(){this.built=null,this.live=null}resolveWindowDays(t,s){var n;const i=typeof s=="number"&&Number.isFinite(s)?s:tt(void 0,(n=t==null?void 0:t.options)==null?void 0:n.historyRetentionDays);return Math.max(1,Math.min(Yt,Math.floor(i)))}isRecording(t){const s=t==null?void 0:t.options;return Z({userOptions:s,userType:(t==null?void 0:t.type)||null,restrictionsPaused:et(s==null?void 0:s.accessControlSettings,Date.now())})}needsRebuild(t,s,i){return!t||t.userId!==s||t.windowDays!==i||t.revision!==A()?!0:Date.now()-t.builtAtMs>X}async build(t,s,i){const n=Date.now(),r=rt(s).getTime(),a=A(),c=await z.getOwnHistoryForSearch(r,{force:i});if(!c)throw new Error("HistorySearchService: no signed-in person to search history for");const p=V(c.remoteEntries,{sinceMs:r}),y={userId:c.userId,revision:a,windowDays:s,windowStartMs:r,builtAtMs:Date.now(),index:N(p),entryCount:c.remoteEntries.length,buildMs:Date.now()-n};return this.setLiveOverlay(y,c.liveMonitor),y}setLiveOverlay(t,s){const i=s?ot(s):[],n=V(i,{sinceMs:t.windowStartMs});this.live={userId:t.userId,builtAtMs:t.builtAtMs,readAtMs:Date.now(),monitorId:(s==null?void 0:s.monitorId)||null,overlay:Vt(t.index,n)}}async liveOverlayFor(t,s){var n;const i=this.live;if(i&&i.builtAtMs===t.builtAtMs&&Date.now()-i.readAtMs<Gt)return i.overlay;try{const r=await Q.getActivityMonitorFromStorage(s);this.setLiveOverlay(t,r||null)}catch(r){return C("HistorySearchService: could not read today’s log",r),i&&i.builtAtMs===t.builtAtMs?i.overlay:null}return((n=this.live)==null?void 0:n.overlay)||null}async ensureIndex(t,s){if(this.building){const r=await this.building.catch(()=>null);if(r&&r.userId===t&&r.windowDays===s)return r}const i=this.built;if(!this.needsRebuild(i,t,s))return i;const n=!!i&&i.revision!==A();return this.building=this.build(t,s,n).then(r=>(this.built=r,r)).catch(r=>{throw this.built=null,this.live=null,r}).finally(()=>{this.building=null}),this.building}async search(t={}){var u;const s=await it.instance.getCurrentUser();if(!s||((u=s.options)==null?void 0:u.historySearchEnabled)!==!0||await st())return this.clear(),{state:"off",windowDays:0,hits:[],total:0};const i=this.resolveWindowDays(s,t.keptDays),n=this.isRecording(s)?"ready":"not-recording";if(t.warmOnly===!0)return this.built&&!this.needsRebuild(this.built,s._id,i)?{state:n,windowDays:i,hits:[],total:0,builtAtMs:this.built.builtAtMs}:(this.ensureIndex(s._id,i).catch(o=>{C("HistorySearchService: warm-up build failed",o)}),{state:"loading",windowDays:i,hits:[],total:0});const r=await this.ensureIndex(s._id,i),a=(t.query||"").trim(),c=await this.liveOverlayFor(r,s),{hits:p,total:y}=a?Nt(r.index,a,{limit:t.limit,overlay:c}):{hits:[],total:0};return{state:n,windowDays:i,hits:p,total:y,builtAtMs:r.builtAtMs,diagnostics:{buildMs:r.buildMs,entryCount:r.entryCount,pageCount:r.index.pages.length}}}};M(I,"_staticInstance",null);let O=I;function Kt(e){var s;const t=((s=e==null?void 0:e.details)==null?void 0:s.url)??(e==null?void 0:e.url);return typeof t=="string"&&t.length>0?t:null}async function Wt(){var i;const e=new Map,t=await H.instance.getItemIdsByKinds(ht());if(!t.length)return e;const s=await H.instance.getItemsByIdsLocal(t);for(const n of s){if((i=n==null?void 0:n.details)!=null&&i.archived)continue;const r=Kt(n);if(!r)continue;const a=dt(r);if(!(!a||e.has(a.id)))try{e.set(a.id,new URL(r).origin)}catch{e.set(a.id,a.homepageUrl)}}return e}async function qt(){if(!await T.instance.isLibraryIndexHydrated())return{providers:[],indexHydrated:!1};const t=await Wt(),s=await T.instance.getDataIndex(),i=[];for(const n of ut()){const r=t.get(n.id);if(r){i.push({id:n.id,role:n.role,displayName:n.displayName,iconName:n.iconName,origin:r,marked:!0});continue}(await s.urlDetailsStore.getMatches(j(n.homepageUrl))).length&&i.push({id:n.id,role:n.role,displayName:n.displayName,iconName:n.iconName,origin:n.homepageUrl,marked:!1})}return{providers:i,indexHydrated:!0}}const m=[];m.push({path:"/search/lookupProviders",handler:async(e,t,s)=>await qt()});m.push({path:"/search/status",handler:async(e,t,s)=>(await T.instance.getDataIndexStatus()).statusInfo()});m.push({path:"/search/diagnostics",handler:async(e,t,s)=>{const i=await At(),n=i?await i.getLibraryStats():null,r=await Mt();return{libraryStats:n,summary:St(r),shadowEnabled:await bt(),corpusEngineEnabled:await vt(),recentSearches:[...r].reverse()}}});m.push({path:"/search/setCorpusEngineEnabled",handler:async(e,t,s)=>(await F(_t,(t==null?void 0:t.enabled)===!0),It(),{enabled:(t==null?void 0:t.enabled)===!0})});m.push({path:"/search/setShadowEnabled",handler:async(e,t,s)=>(await F(kt,(t==null?void 0:t.enabled)===!0),Et(),{enabled:(t==null?void 0:t.enabled)===!0})});m.push({path:"/search/main",handler:async(e,t,s)=>await v.instance.searchMain(t)});m.push({path:"/search/terms",handler:async(e,t,s)=>await v.instance.searchTerms(t)});m.push({path:"/search/autocomplete",handler:async(e,t,s)=>await v.instance.runSearchAuto(t.query)});m.push({path:"/search/browser-address-autocomplete",handler:async(e,t,s)=>await v.instance.runBrowserAddressAutocomplete(t.query,{limit:t.limit})});m.push({path:"/search/history",handler:async(e,t,s)=>{const i=await O.instance.search({query:t==null?void 0:t.query,keptDays:t==null?void 0:t.keptDays,limit:t==null?void 0:t.limit,warmOnly:t==null?void 0:t.warmOnly});return{state:i.state,windowDays:i.windowDays,total:i.total,builtAtMs:i.builtAtMs,diagnostics:i.diagnostics,pages:i.hits.map(n=>({url:n.page.url,title:n.page.title,host:n.page.host,lastVisitMs:n.page.lastVisitMs,visitCount:n.page.visitCount,timeSpentMs:n.page.timeSpentMs,matchedIn:n.matchedIn}))}}});m.push({path:"/search/embedded",handler:async(e,t,s)=>await v.instance.searchEmbedded(e,t,s)});export{m as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.