PageSourceSearch

https://hub.synerise.com/assets/search-modal-B_8meJhc.js

js synerise.com collected 2026-10-03 21:59:08 UTC 12,554 bytes, 1 lines download raw bytes

1import{r as l,j as t}from"./vendor-react-zCUKWWlL.js";import{u as V}from"./vendor-router-KQ4maDu4.js";import{u as Z,i as F,T as X,M as J}from"./index-BpqCaQqm.js";import{g as Y}from"./api-category-lookup-DaPgYtyE.js";import{c as W}from"./search-filters-BY-2Izyw.js";import{S as z,X as ee,Z as te,A as k,a as ae,M as se,F as re,C as ne}from"./vendor-icons-CJu8WWjG.js";import"./vendor-query-BsMfdZUb.js";import"./vendor-radix-D4bT2nfC.js";import"./vendor-prism-B3rGufK0.js";import"./vendor-motion-CTJOECYG.js";import"./categories-map-D2EKkFhr.js";function f(r,n){if(!n.trim()||!r)return r;const o=n.trim().split(/\s+/).filter(Boolean).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),g=new RegExp(`(${o})`,"gi"),c=r.split(g);return c.length===1?r:c.map((u,x)=>x%2===1?t.jsx("mark",{className:"text-brand-text bg-transparent",children:u},x):u)}const M=[{value:"all",label:"All"},{value:"docs",label:"Product Guides"},{value:"api",label:"API"},{value:"resources",label:"Resources"},{value:"glossary",label:"Glossary"},{value:"use-cases",label:"Use Cases"},{value:"developer-guides",label:"Developer Guides & SDKs"},{value:"changelog",label:"Changelog"},{value:"roadmap",label:"Roadmap"}],oe=new Set(["docs","resources","glossary","use-cases","developer-guides"]),le={api:()=>!1,changelog:()=>!1,roadmap:()=>!1,docs:r=>{const n=(r.category||"").toLowerCase(),s=(r.section||"").toLowerCase();return n==="docs"||s.startsWith("docs")},resources:r=>{const n=(r.category||"").toLowerCase(),s=(r.section||"").toLowerCase();return n==="integrations"||s.startsWith("integrations")||n==="first steps"||s.startsWith("first-steps")||n==="ai 7 days"||s.startsWith("ai-7-days")||n==="loyalty"||s.startsWith("loyalty")},glossary:r=>{const n=(r.category||"").toLowerCase(),s=(r.section||"").toLowerCase(),p=(r.slug||"").toLowerCase();return n==="glossary"||s.includes("glossary")||p.includes("glossary")},"use-cases":r=>{const n=(r.category||"").toLowerCase(),s=(r.section||"").toLowerCase();return n==="use cases"||s.startsWith("use-cases")},"developer-guides":r=>{const n=(r.category||"").toLowerCase(),s=(r.section||"").toLowerCase();return n==="developers"||s.startsWith("developers")}};function ce(r,n,s,p,o){if(o.size===0)return{articles:r,endpoints:n,changelog:s,roadmap:p};const g=o.has("api"),c=o.has("changelog"),u=o.has("roadmap"),x=[...o].filter(m=>oe.has(m));let b;return x.length===0?b=[]:b=r.filter(m=>x.some(y=>le[y](m))),{articles:b,endpoints:g?n:[],changelog:c?s:[],roadmap:u?p:[]}}const ie=["How do I track custom events in Synerise?","Give me an overview of Synerise API authentication.","How to create a customer profile?","What are catalogs and how to use them?"];function we({open:r,onClose:n}){const[s,p]=l.useState(""),[o,g]=l.useState(W),[c,u]=l.useState([]),[x,b]=l.useState(!1),[m,y]=l.useState(-1),[,v]=V(),{initialQuery:L,setInitialQuery:G}=Z(),N=l.useRef(null),I=l.useRef(null),w=l.useRef(null);l.useEffect(()=>{if(r){const e=L||"",a=W();p(e),g(a),u([]),y(-1),L&&(G(""),w.current!==null&&clearTimeout(w.current),w.current=setTimeout(()=>S(e,a),200)),setTimeout(()=>{N.current&&(N.current.focus(),N.current.setSelectionRange(e.length,e.length))},100)}},[r]),l.useEffect(()=>{y(-1)},[c]);const S=l.useCallback(async(e,a)=>{if(!e.trim()){u([]);return}b(!0);try{const h=a.size>0?`&filters=${encodeURIComponent([...a].join(","))}`:"",i=await fetch(`/api/search?q=${encodeURIComponent(e)}${h}`);if(i.ok){const j=await i.json(),{articles:Q,endpoints:_,changelog:q,roadmap:B}=ce((j.articles||[]).filter(d=>!F(d.slug)),j.endpoints||[],(j.changelog||[]).filter(d=>!F(d.url)),j.roadmap||[],a),U=[...Q.map(d=>({type:"article",data:d})),..._.map(d=>({type:"endpoint",data:d})),...q.map(d=>({type:"changelog",data:d})),...B.map(d=>({type:"roadmap",data:d}))];U.sort((d,O)=>(O.data.score||0)-(d.data.score||0)),u(U)}}catch{}b(!1)},[]),H=e=>{p(e),w.current!==null&&clearTimeout(w.current),w.current=setTimeout(()=>S(e,o),400)},K=e=>{let a;e==="all"?a=new Set:(a=new Set(o),a.has(e)?a.delete(e):a.add(e)),g(a),s.trim()&&S(s,a)},R=l.useCallback(e=>{v(`/${e}`),n()},[v,n]),E=l.useCallback(e=>{const a=Y(e.tag)??"all",h=e.operationId?`#tag/${encodeURIComponent(e.tag)}/operation/${e.operationId}`:`#tag/${encodeURIComponent(e.tag)}`,i=`/api-reference/${a}${h}`;window.location.pathname.endsWith(`/api-reference/${a}`)?(window.history.pushState({},"",i),window.dispatchEvent(new HashChangeEvent("hashchange"))):v(i),n()},[v,n]),T=l.useCallback(()=>{const e=new URLSearchParams;s.trim()&&e.set("q",s.trim()),o.size>0&&e.set("filter",[...o].join(","));const a=e.toString();v(a?`/search?${a}`:"/search"),n()},[s,o,v,n]),C=l.useCallback(e=>{window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate")),n()},[n]),A=l.useCallback(e=>{e.type==="article"?R(e.data.slug):e.type==="endpoint"?E(e.data):C(e.data.url)},[R,E,C]);l.useEffect(()=>{const e=a=>{if((a.metaKey||a.ctrlKey)&&a.key==="k"){a.preventDefault(),r&&n();return}if(a.key==="Escape"&&r){n();return}if(r){if(a.key==="Enter"){m>=0&&m<c.length?(a.preventDefault(),A(c[m])):s.trim()&&(a.preventDefault(),T());return}c.length!==0&&(a.key==="ArrowDown"?(a.preventDefault(),y(h=>{const i=h<c.length-1?h+1:0;return P(i),i})):a.key==="ArrowUp"&&(a.preventDefault(),y(h=>{const i=h>0?h-1:c.length-1;return P(i),i})))}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,n,c,m,A,s,T]);const P=e=>{requestAnimationFrame(()=>{const a=I.current;if(!a)return;const i=a.querySelectorAll("[data-result-item]")[e];i&&i.scrollIntoView({block:"nearest"})})};if(!r)return null;const D=c.length>0,$=s.trim().length>0;return t.jsxs("div",{className:"fixed inset-0 z-[100] flex items-start justify-center pt-4 sm:pt-[15vh] max-h-[100dvh]",children:[t.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:n}),t.jsxs("div",{className:"relative w-full max-w-2xl mx-4 max-h-[calc(100dvh-2rem)] sm:max-h-[calc(100dvh-30vh)] bg-card border border-border rounded-xl shadow-2xl overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[t.jsx(z,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"}),t.jsx("input",{ref:N,value:s,onChange:e=>H(e.target.value),placeholder:o.size===0?"Search articles and API endpoints...":o.size===1&&o.has("api")?"Search API endpoints...":`Search ${[...o].map(e=>M.find(a=>
1a.value===e)?.label).filter(Boolean).join(", ")}...`,className:"flex-1 bg-transparent text-foreground text-sm placeholder:text-muted-foreground focus:outline-none"}),s&&t.jsx("button",{onClick:()=>{p(""),u([])},className:"p-1 rounded hover:bg-accent",children:t.jsx(ee,{className:"h-4 w-4 text-muted-foreground"})}),t.jsx("kbd",{className:"hidden sm:inline-flex px-1.5 py-0.5 rounded border border-border text-[10px] text-muted-foreground font-mono",children:"ESC"})]}),t.jsx("div",{className:"flex flex-wrap items-center gap-1 px-4 py-2 border-b border-border flex-shrink-0",children:M.map(e=>{const a=e.value==="all"?o.size===0:o.has(e.value);return t.jsx(X,{active:a,"aria-pressed":a,onClick:()=>K(e.value),className:a?"search-category-pill flex-shrink-0 dark:border dark:border-brand/40 dark:bg-background dark:text-brand dark:hover:bg-accent dark:hover:text-brand":"search-category-pill flex-shrink-0 dark:border dark:border-border dark:bg-muted dark:text-foreground dark:hover:border-brand/40 dark:hover:bg-accent dark:hover:text-brand",children:e.label},e.value)})}),t.jsxs("div",{ref:I,className:"min-h-0 flex-1 overflow-y-auto",children:[x&&t.jsx("div",{className:"px-4 py-8 text-center text-muted-foreground text-sm",children:"Searching..."}),!x&&$&&!D&&t.jsxs("div",{className:"px-4 py-8 text-center text-muted-foreground text-sm",children:['No results found for "',s,'"']}),!x&&D&&t.jsx("div",{className:"py-2",children:c.map((e,a)=>e.type==="endpoint"?t.jsxs("button",{"data-result-item":!0,onClick:()=>E(e.data),className:`w-full flex items-center gap-3 px-4 py-2.5 transition-colors text-left ${a===m?"bg-accent":"hover:bg-accent"}`,children:[t.jsx(te,{className:"h-4 w-4 text-brand-text flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`inline-block px-1.5 py-0 rounded text-[10px] font-medium leading-4 ${J[e.data.method]||"text-muted-foreground bg-muted"}`,children:e.data.method}),t.jsx("span",{className:"text-xs text-foreground font-medium truncate",children:f(e.data.summary||e.data.path,s)})]}),t.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5 truncate",children:[f(e.data.path,s)," · ",e.data.tag]})]}),t.jsx(k,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"})]},`ep-${a}`):e.type==="changelog"?t.jsxs("button",{"data-result-item":!0,onClick:()=>C(e.data.url),className:`w-full flex items-center gap-3 px-4 py-2.5 transition-colors text-left ${a===m?"bg-accent":"hover:bg-accent"}`,children:[t.jsx(ae,{className:"h-4 w-4 text-emerald-500 flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-block px-1.5 py-0 rounded text-[10px] font-medium leading-4 text-emerald-600 dark:text-emerald-400 bg-emerald-500/10",children:"Changelog"}),t.jsx("span",{className:"text-xs text-foreground font-medium truncate",children:f(e.data.title,s)})]}),e.data.snippet&&t.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 line-clamp-2 leading-relaxed",children:f(e.data.snippet,s)}),t.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 truncate",children:[e.data.module,e.data.type].filter(Boolean).join(" · ")})]}),t.jsx(k,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"})]},`cl-${e.data.key}`):e.type==="roadmap"?t.jsxs("button",{"data-result-item":!0,onClick:()=>C(e.data.url),className:`w-full flex items-center gap-3 px-4 py-2.5 transition-colors text-left ${a===m?"bg-accent":"hover:bg-accent"}`,children:[t.jsx(se,{className:"h-4 w-4 text-violet-500 flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-block px-1.5 py-0 rounded text-[10px] font-medium leading-4 text-violet-600 dark:text-violet-400 bg-violet-500/10",children:"Roadmap"}),t.jsx("span",{className:"text-xs text-foreground font-medium truncate",children:f(e.data.title,s)})]}),e.data.snippet&&t.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 line-clamp-2 leading-relaxed",children:f(e.data.snippet,s)}),t.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 truncate",children:[e.data.module,e.data.status].filter(
1Boolean).join(" · ")})]}),t.jsx(k,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"})]},`rm-${e.data.key}`):t.jsxs("button",{"data-result-item":!0,onClick:()=>R(e.data.slug),className:`w-full flex items-center gap-3 px-4 py-2.5 transition-colors text-left ${a===m?"bg-accent":"hover:bg-accent"}`,children:[t.jsx(re,{className:"h-4 w-4 text-brand-text flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-xs text-foreground font-medium truncate block",children:f(e.data.title,s)}),e.data.snippet&&t.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 line-clamp-2 leading-relaxed",children:f(e.data.snippet,s)}),e.data.category&&t.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 truncate",children:e.data.category})]}),t.jsx(k,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"})]},`art-${e.data.id}`))}),$&&!x&&t.jsx("div",{className:"border-t border-border px-4 py-2 flex items-center justify-end",children:t.jsxs("button",{onClick:T,className:"inline-flex items-center gap-1 text-xs text-brand-text hover:underline font-medium",children:["View all results",t.jsx(k,{className:"h-3 w-3"})]})}),!$&&!x&&t.jsxs("div",{className:"py-2",children:[t.jsx("div",{className:"px-4 py-2",children:t.jsx("span",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Suggested"})}),ie.map(e=>t.jsxs("button",{onClick:()=>{p(e),S(e,o)},className:"w-full flex items-center gap-3 px-4 py-2.5 hover:bg-accent transition-colors text-left group",children:[t.jsx(z,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"flex-1 text-sm text-foreground",children:e}),t.jsx(ne,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]},e))]})]})]})]})}export{we as SearchModal};

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.