"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[546],{60546:(t,e,n)=>{n.d(e,{searchDocs:()=>l});var i=n(82263),r=n(84e3);async function l(t,e){let n=(0,r.r)(t),l=[],{index:h="default",client:o,params:u={},tag:s}=e;if("crawler"===h){let e=await o.search({...u,term:t,where:{category:s?{eq:s.slice(0,1).toUpperCase()+s.slice(1)}:void 0,...u.where},limit:10});if(!e)return l;for(let t of e.hits){let e=t.document;l.push({id:t.id,type:"page",content:e.title,contentWithHighlights:n.highlight(e.title),url:e.path},{id:"page"+t.id,type:"text",content:e.content,contentWithHighlights:n.highlight(e.content),url:e.path})}return l}let c={...u,term:t,where:(0,i.B)({tag:s,...u.where}),groupBy:{properties:["page_id"],maxResult:7,...u.groupBy}},g=await o.search(c);if(!g||!g.groups)return l;for(let t of g.groups){let e=!1;for(let i of t.result){let t=i.document;e||(l.push({id:t.page_id,type:"page",content:t.title,contentWithHighlights:n.highlight(t.title),url:t.url}),e=!0),l.push({id:t.id,content:t.content,contentWithHighlights:n.highlight(t.content),type:t.content===t.section?"heading":"text",url:t.section_id?`${t.url}#${t.section_id}`:t.url})}}return l}n(65156)},82263:(t,e,n)=>{n.d(e,{B:()=>function t(e,n=!1){for(let i of Object.keys(e))void 0===e[i]&&delete e[i],n&&"object"==typeof e[i]&&null!==e[i]?t(e[i],n):n&&Array.isArray(e[i])&&e[i].forEach(e=>t(e,n));return e}})},84e3:(t,e,n)=>{function i(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(t){let e="string"==typeof t?function(t){let e=t.trim();if(0===e.length)return null;let n=Array.from(new Set(e.split(/\s+/).map(t=>t.trim()).filter(Boolean)));if(0===n.length)return null;let r=n.map(i).join("|");return RegExp(`(${r})`,"gi")}(t):t;return{highlight(t){if(!e)return[{type:"text",content:t}];let n=[],i=0;for(let r of t.matchAll(e))i<r.index&&n.push({type:"text",content:t.substring(i,r.index)}),n.push({type:"text",content:r[0],styles:{highlight:!0}}),i=r.index+r[0].length;return i<t.length&&n.push({type:"text",content:t.substring(i)}),n}}}n.d(e,{r:()=>r})}}]);