@mixpeek/react-searchkit 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +224 -0
- package/dist/AIAnswer.d.ts +9 -0
- package/dist/IntentCTA.d.ts +8 -0
- package/dist/PoweredBy.d.ts +9 -0
- package/dist/ResultCard.d.ts +11 -0
- package/dist/SearchButton.d.ts +9 -0
- package/dist/SearchInput.d.ts +11 -0
- package/dist/SearchKit.d.ts +35 -0
- package/dist/SearchModal.d.ts +28 -0
- package/dist/SearchResults.d.ts +14 -0
- package/dist/ShareLink.d.ts +7 -0
- package/dist/ZeroResults.d.ts +7 -0
- package/dist/api/client.d.ts +44 -0
- package/dist/filters/FacetFilter.d.ts +10 -0
- package/dist/filters/FilterPanel.d.ts +12 -0
- package/dist/filters/RangeFilter.d.ts +11 -0
- package/dist/filters/SmartFilter.d.ts +10 -0
- package/dist/filters/index.d.ts +4 -0
- package/dist/hooks/useFilters.d.ts +10 -0
- package/dist/hooks/useKeyboardShortcut.d.ts +12 -0
- package/dist/hooks/useRecentSearches.d.ts +7 -0
- package/dist/hooks/useSearch.d.ts +22 -0
- package/dist/index.d.ts +39 -0
- package/dist/searchkit.cjs.js +3 -0
- package/dist/searchkit.esm.js +1771 -0
- package/dist/searchkit.umd.js +3 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +250 -0
- package/package.json +71 -0
- package/scripts/bootstrap.mjs +149 -0
- package/scripts/index.mjs +364 -0
|
@@ -0,0 +1,1771 @@
|
|
|
1
|
+
import { jsxs as l, jsx as e, Fragment as me } from "react/jsx-runtime";
|
|
2
|
+
import le, { useMemo as J, useRef as z, useEffect as j, useState as C, useCallback as y, createContext as xe, useContext as ge } from "react";
|
|
3
|
+
import { createPortal as ye } from "react-dom";
|
|
4
|
+
function ve() {
|
|
5
|
+
return typeof navigator > "u" ? "Ctrl K" : navigator.platform.toUpperCase().indexOf("MAC") >= 0 ? "⌘K" : "Ctrl K";
|
|
6
|
+
}
|
|
7
|
+
const be = ({
|
|
8
|
+
onClick: t,
|
|
9
|
+
placeholder: r,
|
|
10
|
+
keyboardShortcut: n
|
|
11
|
+
}) => {
|
|
12
|
+
const i = J(() => ve(), []);
|
|
13
|
+
return /* @__PURE__ */ l(
|
|
14
|
+
"button",
|
|
15
|
+
{
|
|
16
|
+
className: "mixpeek-search-button",
|
|
17
|
+
onClick: t,
|
|
18
|
+
type: "button",
|
|
19
|
+
"aria-label": "Open search",
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ l(
|
|
22
|
+
"svg",
|
|
23
|
+
{
|
|
24
|
+
className: "mixpeek-search-button-icon",
|
|
25
|
+
width: "16",
|
|
26
|
+
height: "16",
|
|
27
|
+
viewBox: "0 0 24 24",
|
|
28
|
+
fill: "none",
|
|
29
|
+
stroke: "currentColor",
|
|
30
|
+
strokeWidth: "2",
|
|
31
|
+
strokeLinecap: "round",
|
|
32
|
+
strokeLinejoin: "round",
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ e("circle", { cx: "11", cy: "11", r: "8" }),
|
|
35
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-search-button-text", children: r }),
|
|
40
|
+
n && /* @__PURE__ */ e("kbd", { className: "mixpeek-search-button-kbd", children: i })
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}, Ne = ({
|
|
45
|
+
value: t,
|
|
46
|
+
onChange: r,
|
|
47
|
+
placeholder: n,
|
|
48
|
+
isLoading: i,
|
|
49
|
+
onClear: s
|
|
50
|
+
}) => {
|
|
51
|
+
const a = z(null);
|
|
52
|
+
return j(() => {
|
|
53
|
+
const c = setTimeout(() => {
|
|
54
|
+
var h;
|
|
55
|
+
(h = a.current) == null || h.focus();
|
|
56
|
+
}, 50);
|
|
57
|
+
return () => clearTimeout(c);
|
|
58
|
+
}, []), /* @__PURE__ */ l("div", { className: "mixpeek-search-input-wrapper", children: [
|
|
59
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-search-input-icon", children: /* @__PURE__ */ l(
|
|
60
|
+
"svg",
|
|
61
|
+
{
|
|
62
|
+
width: "20",
|
|
63
|
+
height: "20",
|
|
64
|
+
viewBox: "0 0 24 24",
|
|
65
|
+
fill: "none",
|
|
66
|
+
stroke: "currentColor",
|
|
67
|
+
strokeWidth: "2",
|
|
68
|
+
strokeLinecap: "round",
|
|
69
|
+
strokeLinejoin: "round",
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ e("circle", { cx: "11", cy: "11", r: "8" }),
|
|
72
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
) }),
|
|
76
|
+
/* @__PURE__ */ e(
|
|
77
|
+
"input",
|
|
78
|
+
{
|
|
79
|
+
ref: a,
|
|
80
|
+
type: "text",
|
|
81
|
+
className: "mixpeek-search-input",
|
|
82
|
+
value: t,
|
|
83
|
+
onChange: (c) => r(c.target.value),
|
|
84
|
+
placeholder: n,
|
|
85
|
+
autoComplete: "off",
|
|
86
|
+
autoCorrect: "off",
|
|
87
|
+
autoCapitalize: "off",
|
|
88
|
+
spellCheck: !1,
|
|
89
|
+
role: "combobox",
|
|
90
|
+
"aria-expanded": "true",
|
|
91
|
+
"aria-haspopup": "listbox",
|
|
92
|
+
"aria-label": "Search"
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
i && /* @__PURE__ */ e("div", { className: "mixpeek-search-spinner", "aria-label": "Loading", children: /* @__PURE__ */ e(
|
|
96
|
+
"svg",
|
|
97
|
+
{
|
|
98
|
+
width: "18",
|
|
99
|
+
height: "18",
|
|
100
|
+
viewBox: "0 0 24 24",
|
|
101
|
+
fill: "none",
|
|
102
|
+
stroke: "currentColor",
|
|
103
|
+
strokeWidth: "2",
|
|
104
|
+
children: /* @__PURE__ */ e("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" })
|
|
105
|
+
}
|
|
106
|
+
) }),
|
|
107
|
+
t && !i && /* @__PURE__ */ e(
|
|
108
|
+
"button",
|
|
109
|
+
{
|
|
110
|
+
className: "mixpeek-search-clear",
|
|
111
|
+
onClick: s,
|
|
112
|
+
"aria-label": "Clear search",
|
|
113
|
+
type: "button",
|
|
114
|
+
children: /* @__PURE__ */ l(
|
|
115
|
+
"svg",
|
|
116
|
+
{
|
|
117
|
+
width: "16",
|
|
118
|
+
height: "16",
|
|
119
|
+
viewBox: "0 0 24 24",
|
|
120
|
+
fill: "none",
|
|
121
|
+
stroke: "currentColor",
|
|
122
|
+
strokeWidth: "2",
|
|
123
|
+
strokeLinecap: "round",
|
|
124
|
+
strokeLinejoin: "round",
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
127
|
+
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
] });
|
|
134
|
+
}, we = ({ data: t, onCitationClick: r }) => t.answer ? /* @__PURE__ */ l("div", { className: "mixpeek-ai-answer", role: "region", "aria-label": "AI Answer", children: [
|
|
135
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-ai-answer-header", children: [
|
|
136
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-ai-answer-icon", children: /* @__PURE__ */ l(
|
|
137
|
+
"svg",
|
|
138
|
+
{
|
|
139
|
+
width: "16",
|
|
140
|
+
height: "16",
|
|
141
|
+
viewBox: "0 0 24 24",
|
|
142
|
+
fill: "none",
|
|
143
|
+
stroke: "currentColor",
|
|
144
|
+
strokeWidth: "2",
|
|
145
|
+
strokeLinecap: "round",
|
|
146
|
+
strokeLinejoin: "round",
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ e("path", { d: "M12 2L2 7l10 5 10-5-10-5z" }),
|
|
149
|
+
/* @__PURE__ */ e("path", { d: "M2 17l10 5 10-5" }),
|
|
150
|
+
/* @__PURE__ */ e("path", { d: "M2 12l10 5 10-5" })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
) }),
|
|
154
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-ai-answer-label", children: "AI Answer" }),
|
|
155
|
+
t.isStreaming && /* @__PURE__ */ e("span", { className: "mixpeek-ai-answer-streaming", children: "Generating..." })
|
|
156
|
+
] }),
|
|
157
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-ai-answer-text", children: t.answer }),
|
|
158
|
+
t.citations && t.citations.length > 0 && /* @__PURE__ */ l("div", { className: "mixpeek-ai-answer-citations", children: [
|
|
159
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-ai-answer-citations-label", children: "Sources:" }),
|
|
160
|
+
t.citations.map((n, i) => /* @__PURE__ */ l(
|
|
161
|
+
"button",
|
|
162
|
+
{
|
|
163
|
+
className: "mixpeek-ai-answer-citation",
|
|
164
|
+
onClick: () => r == null ? void 0 : r(n.resultIndex),
|
|
165
|
+
type: "button",
|
|
166
|
+
title: n.text,
|
|
167
|
+
children: [
|
|
168
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-citation-index", children: n.resultIndex + 1 }),
|
|
169
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-citation-text", children: n.text })
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
i
|
|
173
|
+
))
|
|
174
|
+
] })
|
|
175
|
+
] }) : null;
|
|
176
|
+
function pe(t, r) {
|
|
177
|
+
if (!r.trim() || !t) return t;
|
|
178
|
+
const n = r.trim().split(/\s+/).filter((a) => a.length > 2).map((a) => a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
179
|
+
if (n.length === 0) return t;
|
|
180
|
+
const i = new RegExp(`(${n.join("|")})`, "gi");
|
|
181
|
+
return t.split(i).map(
|
|
182
|
+
(a, c) => i.test(a) ? /* @__PURE__ */ e("mark", { className: "mixpeek-highlight", children: a }, c) : a
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
function _e(t) {
|
|
186
|
+
if (t.title) return t.title;
|
|
187
|
+
if (t.page_url)
|
|
188
|
+
try {
|
|
189
|
+
const r = new URL(t.page_url);
|
|
190
|
+
return r.pathname === "/" ? r.hostname : r.pathname.split("/").pop() || r.hostname;
|
|
191
|
+
} catch {
|
|
192
|
+
return t.page_url;
|
|
193
|
+
}
|
|
194
|
+
return t.content ? t.content.slice(0, 80) : "Untitled";
|
|
195
|
+
}
|
|
196
|
+
function Se(t) {
|
|
197
|
+
if (t.content) return t.content;
|
|
198
|
+
for (const r of ["description", "snippet", "summary", "text", "body"])
|
|
199
|
+
if (typeof t[r] == "string" && t[r])
|
|
200
|
+
return t[r];
|
|
201
|
+
return "";
|
|
202
|
+
}
|
|
203
|
+
function Ce(t) {
|
|
204
|
+
return t >= 0 && t <= 1 ? `${Math.round(t * 100)}%` : t.toFixed(1);
|
|
205
|
+
}
|
|
206
|
+
function Le(t) {
|
|
207
|
+
return typeof t == "string" ? t : typeof t == "number" || typeof t == "boolean" ? String(t) : t == null ? "" : JSON.stringify(t);
|
|
208
|
+
}
|
|
209
|
+
const $e = /* @__PURE__ */ new Set([
|
|
210
|
+
"id",
|
|
211
|
+
"title",
|
|
212
|
+
"content",
|
|
213
|
+
"page_url",
|
|
214
|
+
"image_url",
|
|
215
|
+
"score",
|
|
216
|
+
"document_id",
|
|
217
|
+
"collection_id",
|
|
218
|
+
"namespace_id"
|
|
219
|
+
]), Me = ({
|
|
220
|
+
result: t,
|
|
221
|
+
index: r,
|
|
222
|
+
query: n,
|
|
223
|
+
onResultClick: i
|
|
224
|
+
}) => {
|
|
225
|
+
const [s, a] = C(!1), [c, h] = C(!1), o = _e(t), m = Se(t), d = m.length > 200 ? m.slice(0, 200) + "..." : m, p = t.document_id || t.id || null, v = J(() => {
|
|
226
|
+
const k = [];
|
|
227
|
+
for (const [x, b] of Object.entries(t)) {
|
|
228
|
+
if ($e.has(x) || x.startsWith("_") || x.startsWith("__") || b == null) continue;
|
|
229
|
+
const w = Le(b);
|
|
230
|
+
w && k.push([x, w]);
|
|
231
|
+
}
|
|
232
|
+
return k;
|
|
233
|
+
}, [t]), L = y(
|
|
234
|
+
(k) => {
|
|
235
|
+
i == null || i(t, r), t.page_url && i && k.preventDefault();
|
|
236
|
+
},
|
|
237
|
+
[t, r, i]
|
|
238
|
+
), _ = y(
|
|
239
|
+
(k) => {
|
|
240
|
+
(k.key === "Enter" || k.key === " ") && (k.preventDefault(), i == null || i(t, r), t.page_url && !i && window.open(t.page_url, "_blank", "noopener,noreferrer"));
|
|
241
|
+
},
|
|
242
|
+
[t, r, i]
|
|
243
|
+
), D = y(
|
|
244
|
+
(k) => {
|
|
245
|
+
k.stopPropagation(), k.preventDefault();
|
|
246
|
+
const x = `${o}${t.page_url ? `
|
|
247
|
+
` + t.page_url : ""}`;
|
|
248
|
+
navigator.clipboard.writeText(x).then(() => {
|
|
249
|
+
a(!0), setTimeout(() => a(!1), 2e3);
|
|
250
|
+
}).catch(() => {
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
[o, t.page_url]
|
|
254
|
+
), T = y(
|
|
255
|
+
(k) => {
|
|
256
|
+
k.stopPropagation(), k.preventDefault(), h((x) => !x);
|
|
257
|
+
},
|
|
258
|
+
[]
|
|
259
|
+
), B = t.page_url ? "a" : "div", A = t.page_url ? { href: t.page_url, target: "_blank", rel: "noopener noreferrer" } : {};
|
|
260
|
+
return /* @__PURE__ */ l(
|
|
261
|
+
B,
|
|
262
|
+
{
|
|
263
|
+
className: "mixpeek-result-card",
|
|
264
|
+
onClick: L,
|
|
265
|
+
onKeyDown: _,
|
|
266
|
+
tabIndex: 0,
|
|
267
|
+
...A,
|
|
268
|
+
role: "option",
|
|
269
|
+
"aria-selected": !1,
|
|
270
|
+
"data-index": r,
|
|
271
|
+
children: [
|
|
272
|
+
t.image_url && /* @__PURE__ */ e("div", { className: "mixpeek-result-thumbnail", children: /* @__PURE__ */ e(
|
|
273
|
+
"img",
|
|
274
|
+
{
|
|
275
|
+
src: t.image_url,
|
|
276
|
+
alt: "",
|
|
277
|
+
loading: "lazy",
|
|
278
|
+
onError: (k) => {
|
|
279
|
+
k.target.style.display = "none";
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
) }),
|
|
283
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-result-body", children: [
|
|
284
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-result-header", children: [
|
|
285
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-result-title", children: pe(o, n) }),
|
|
286
|
+
typeof t.score == "number" && /* @__PURE__ */ e("span", { className: "mixpeek-result-score", children: Ce(t.score) })
|
|
287
|
+
] }),
|
|
288
|
+
t.page_url && /* @__PURE__ */ e("div", { className: "mixpeek-result-url", children: t.page_url }),
|
|
289
|
+
d && /* @__PURE__ */ e("div", { className: "mixpeek-result-content", children: pe(d, n) }),
|
|
290
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-result-footer", children: [
|
|
291
|
+
p && /* @__PURE__ */ e("span", { className: "mixpeek-result-ref", title: p, children: p }),
|
|
292
|
+
v.length > 0 && /* @__PURE__ */ l(
|
|
293
|
+
"button",
|
|
294
|
+
{
|
|
295
|
+
className: "mixpeek-meta-toggle",
|
|
296
|
+
onClick: T,
|
|
297
|
+
type: "button",
|
|
298
|
+
"aria-expanded": c,
|
|
299
|
+
"aria-label": c ? "Hide details" : "Show details",
|
|
300
|
+
children: [
|
|
301
|
+
/* @__PURE__ */ e(
|
|
302
|
+
"svg",
|
|
303
|
+
{
|
|
304
|
+
className: `mixpeek-meta-chevron ${c ? "mixpeek-meta-chevron-open" : ""}`,
|
|
305
|
+
width: "12",
|
|
306
|
+
height: "12",
|
|
307
|
+
viewBox: "0 0 24 24",
|
|
308
|
+
fill: "none",
|
|
309
|
+
stroke: "currentColor",
|
|
310
|
+
strokeWidth: "2",
|
|
311
|
+
strokeLinecap: "round",
|
|
312
|
+
strokeLinejoin: "round",
|
|
313
|
+
children: /* @__PURE__ */ e("polyline", { points: "9 18 15 12 9 6" })
|
|
314
|
+
}
|
|
315
|
+
),
|
|
316
|
+
"Details"
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
)
|
|
320
|
+
] }),
|
|
321
|
+
c && v.length > 0 && /* @__PURE__ */ e("div", { className: "mixpeek-result-metadata", children: v.map(([k, x]) => /* @__PURE__ */ l("div", { className: "mixpeek-meta-row", children: [
|
|
322
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-meta-key", children: k }),
|
|
323
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-meta-value", children: x })
|
|
324
|
+
] }, k)) })
|
|
325
|
+
] }),
|
|
326
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-result-actions", children: /* @__PURE__ */ e(
|
|
327
|
+
"button",
|
|
328
|
+
{
|
|
329
|
+
className: "mixpeek-result-copy",
|
|
330
|
+
onClick: D,
|
|
331
|
+
"aria-label": "Copy link",
|
|
332
|
+
title: "Copy link",
|
|
333
|
+
type: "button",
|
|
334
|
+
children: s ? /* @__PURE__ */ e(
|
|
335
|
+
"svg",
|
|
336
|
+
{
|
|
337
|
+
width: "14",
|
|
338
|
+
height: "14",
|
|
339
|
+
viewBox: "0 0 24 24",
|
|
340
|
+
fill: "none",
|
|
341
|
+
stroke: "currentColor",
|
|
342
|
+
strokeWidth: "2",
|
|
343
|
+
strokeLinecap: "round",
|
|
344
|
+
strokeLinejoin: "round",
|
|
345
|
+
children: /* @__PURE__ */ e("polyline", { points: "20 6 9 17 4 12" })
|
|
346
|
+
}
|
|
347
|
+
) : /* @__PURE__ */ l(
|
|
348
|
+
"svg",
|
|
349
|
+
{
|
|
350
|
+
width: "14",
|
|
351
|
+
height: "14",
|
|
352
|
+
viewBox: "0 0 24 24",
|
|
353
|
+
fill: "none",
|
|
354
|
+
stroke: "currentColor",
|
|
355
|
+
strokeWidth: "2",
|
|
356
|
+
strokeLinecap: "round",
|
|
357
|
+
strokeLinejoin: "round",
|
|
358
|
+
children: [
|
|
359
|
+
/* @__PURE__ */ e("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
360
|
+
/* @__PURE__ */ e("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
) })
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
}, Te = {
|
|
370
|
+
feature_search: "Search",
|
|
371
|
+
attribute_filter: "Filter",
|
|
372
|
+
sort_attribute: "Sort",
|
|
373
|
+
llm_filter: "LLM Filter",
|
|
374
|
+
rerank: "Rerank",
|
|
375
|
+
llm_enrich: "Enrich",
|
|
376
|
+
mmr: "Diversify",
|
|
377
|
+
group_by: "Group",
|
|
378
|
+
limit: "Limit",
|
|
379
|
+
json_transform: "Transform",
|
|
380
|
+
agent_search: "Agent",
|
|
381
|
+
rag_prepare: "RAG",
|
|
382
|
+
reduce: "Reduce"
|
|
383
|
+
};
|
|
384
|
+
function ae(t) {
|
|
385
|
+
return Te[t] || t.replace(/_/g, " ").replace(/\b\w/g, (r) => r.toUpperCase());
|
|
386
|
+
}
|
|
387
|
+
function Ae(t) {
|
|
388
|
+
return t < 1e3 ? `${Math.round(t)}ms` : `${(t / 1e3).toFixed(1)}s`;
|
|
389
|
+
}
|
|
390
|
+
const Ee = ({
|
|
391
|
+
stages: t,
|
|
392
|
+
isStreaming: r
|
|
393
|
+
}) => t.length === 0 ? null : /* @__PURE__ */ l("div", { className: "mixpeek-pipeline", role: "status", "aria-label": "Pipeline progress", children: [
|
|
394
|
+
t.map((n, i) => {
|
|
395
|
+
var s;
|
|
396
|
+
return /* @__PURE__ */ l(le.Fragment, { children: [
|
|
397
|
+
i > 0 && /* @__PURE__ */ e("div", { className: "mixpeek-pipeline-connector" }),
|
|
398
|
+
/* @__PURE__ */ l(
|
|
399
|
+
"div",
|
|
400
|
+
{
|
|
401
|
+
className: "mixpeek-pipeline-stage",
|
|
402
|
+
"data-status": n.status,
|
|
403
|
+
title: (s = n.statistics) != null && s.duration_ms ? `${ae(n.name)}: ${n.documents.length} results in ${Ae(n.statistics.duration_ms)}` : ae(n.name),
|
|
404
|
+
children: [
|
|
405
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-pipeline-dot", children: [
|
|
406
|
+
n.status === "complete" && /* @__PURE__ */ e("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("polyline", { points: "20 6 9 17 4 12" }) }),
|
|
407
|
+
n.status === "error" && /* @__PURE__ */ l("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
408
|
+
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
409
|
+
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
410
|
+
] })
|
|
411
|
+
] }),
|
|
412
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-pipeline-label", children: ae(n.name) }),
|
|
413
|
+
n.status === "complete" && /* @__PURE__ */ e("span", { className: "mixpeek-pipeline-count", children: n.documents.length })
|
|
414
|
+
]
|
|
415
|
+
}
|
|
416
|
+
)
|
|
417
|
+
] }, n.index);
|
|
418
|
+
}),
|
|
419
|
+
r && /* @__PURE__ */ e("div", { className: "mixpeek-pipeline-connector mixpeek-pipeline-connector-active" })
|
|
420
|
+
] }), je = ({
|
|
421
|
+
results: t,
|
|
422
|
+
stages: r,
|
|
423
|
+
isStreaming: n,
|
|
424
|
+
query: i,
|
|
425
|
+
isLoading: s,
|
|
426
|
+
onResultClick: a,
|
|
427
|
+
renderResult: c
|
|
428
|
+
}) => {
|
|
429
|
+
const h = z(null), o = y((d) => {
|
|
430
|
+
if (!h.current) return;
|
|
431
|
+
const p = h.current.querySelectorAll(".mixpeek-result-card");
|
|
432
|
+
p[d] && p[d].scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
433
|
+
}, []);
|
|
434
|
+
le.useImperativeHandle(
|
|
435
|
+
le.createRef(),
|
|
436
|
+
() => ({ scrollToResult: o }),
|
|
437
|
+
[o]
|
|
438
|
+
);
|
|
439
|
+
const m = r.length > 0;
|
|
440
|
+
return s && t.length === 0 && r.length === 0 ? /* @__PURE__ */ e("div", { className: "mixpeek-results-loading", children: /* @__PURE__ */ e("div", { className: "mixpeek-results-skeleton", children: Array.from({ length: 3 }).map((d, p) => /* @__PURE__ */ l("div", { className: "mixpeek-skeleton-card", children: [
|
|
441
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-skeleton-line mixpeek-skeleton-title" }),
|
|
442
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-skeleton-line mixpeek-skeleton-url" }),
|
|
443
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-skeleton-line mixpeek-skeleton-content" }),
|
|
444
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-skeleton-line mixpeek-skeleton-content-short" })
|
|
445
|
+
] }, p)) }) }) : t.length === 0 && !m ? null : /* @__PURE__ */ l("div", { ref: h, children: [
|
|
446
|
+
m && /* @__PURE__ */ e(Ee, { stages: r, isStreaming: n }),
|
|
447
|
+
t.length > 0 && /* @__PURE__ */ e(
|
|
448
|
+
"div",
|
|
449
|
+
{
|
|
450
|
+
className: "mixpeek-results-list",
|
|
451
|
+
role: "listbox",
|
|
452
|
+
"aria-label": "Search results",
|
|
453
|
+
children: t.map((d, p) => c ? /* @__PURE__ */ e("div", { className: "mixpeek-result-custom", role: "option", children: c(d, p) }, d.id || p) : /* @__PURE__ */ e(
|
|
454
|
+
Me,
|
|
455
|
+
{
|
|
456
|
+
result: d,
|
|
457
|
+
index: p,
|
|
458
|
+
query: i,
|
|
459
|
+
onResultClick: a
|
|
460
|
+
},
|
|
461
|
+
d.id || p
|
|
462
|
+
))
|
|
463
|
+
}
|
|
464
|
+
),
|
|
465
|
+
n && t.length === 0 && /* @__PURE__ */ e("div", { className: "mixpeek-results-loading", children: /* @__PURE__ */ e("div", { className: "mixpeek-results-skeleton", children: Array.from({ length: 2 }).map((d, p) => /* @__PURE__ */ l("div", { className: "mixpeek-skeleton-card", children: [
|
|
466
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-skeleton-line mixpeek-skeleton-title" }),
|
|
467
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-skeleton-line mixpeek-skeleton-content" }),
|
|
468
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-skeleton-line mixpeek-skeleton-content-short" })
|
|
469
|
+
] }, p)) }) })
|
|
470
|
+
] });
|
|
471
|
+
}, Ke = ({ query: t }) => /* @__PURE__ */ l("div", { className: "mixpeek-zero-results", role: "status", children: [
|
|
472
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-zero-results-icon", children: /* @__PURE__ */ l(
|
|
473
|
+
"svg",
|
|
474
|
+
{
|
|
475
|
+
width: "48",
|
|
476
|
+
height: "48",
|
|
477
|
+
viewBox: "0 0 24 24",
|
|
478
|
+
fill: "none",
|
|
479
|
+
stroke: "currentColor",
|
|
480
|
+
strokeWidth: "1.5",
|
|
481
|
+
strokeLinecap: "round",
|
|
482
|
+
strokeLinejoin: "round",
|
|
483
|
+
children: [
|
|
484
|
+
/* @__PURE__ */ e("circle", { cx: "11", cy: "11", r: "8" }),
|
|
485
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }),
|
|
486
|
+
/* @__PURE__ */ e("line", { x1: "8", y1: "11", x2: "14", y2: "11" })
|
|
487
|
+
]
|
|
488
|
+
}
|
|
489
|
+
) }),
|
|
490
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-zero-results-title", children: "No results found" }),
|
|
491
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-zero-results-text", children: [
|
|
492
|
+
"No results for “",
|
|
493
|
+
/* @__PURE__ */ e("strong", { children: t }),
|
|
494
|
+
"”. Try different keywords or check for typos."
|
|
495
|
+
] })
|
|
496
|
+
] }), Re = ({ theme: t }) => /* @__PURE__ */ l(
|
|
497
|
+
"a",
|
|
498
|
+
{
|
|
499
|
+
className: `mixpeek-powered-by${t ? ` mixpeek-powered-by--${t}` : ""}`,
|
|
500
|
+
href: "https://mxp.co/searchkit",
|
|
501
|
+
target: "_blank",
|
|
502
|
+
rel: "noopener noreferrer",
|
|
503
|
+
"aria-label": "Search powered by Mixpeek",
|
|
504
|
+
children: [
|
|
505
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-powered-by__text", children: "Search by" }),
|
|
506
|
+
/* @__PURE__ */ l(
|
|
507
|
+
"svg",
|
|
508
|
+
{
|
|
509
|
+
className: "mixpeek-powered-by__logo",
|
|
510
|
+
width: "14",
|
|
511
|
+
height: "14",
|
|
512
|
+
viewBox: "0 0 32 32",
|
|
513
|
+
fill: "none",
|
|
514
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
515
|
+
"aria-hidden": "true",
|
|
516
|
+
children: [
|
|
517
|
+
/* @__PURE__ */ e("rect", { width: "32", height: "32", rx: "6", fill: "currentColor", fillOpacity: "0.15" }),
|
|
518
|
+
/* @__PURE__ */ e(
|
|
519
|
+
"path",
|
|
520
|
+
{
|
|
521
|
+
d: "M8 22V10l5 6 5-6v12",
|
|
522
|
+
stroke: "currentColor",
|
|
523
|
+
strokeWidth: "2.5",
|
|
524
|
+
strokeLinecap: "round",
|
|
525
|
+
strokeLinejoin: "round"
|
|
526
|
+
}
|
|
527
|
+
),
|
|
528
|
+
/* @__PURE__ */ e(
|
|
529
|
+
"path",
|
|
530
|
+
{
|
|
531
|
+
d: "M22 10v12",
|
|
532
|
+
stroke: "currentColor",
|
|
533
|
+
strokeWidth: "2.5",
|
|
534
|
+
strokeLinecap: "round"
|
|
535
|
+
}
|
|
536
|
+
)
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
),
|
|
540
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-powered-by__wordmark", children: "Mixpeek" })
|
|
541
|
+
]
|
|
542
|
+
}
|
|
543
|
+
), De = ({ query: t }) => {
|
|
544
|
+
const [r, n] = C(!1), i = y(() => {
|
|
545
|
+
if (!t.trim()) return;
|
|
546
|
+
const s = new URL(window.location.href);
|
|
547
|
+
s.searchParams.set("mixpeek_q", t), navigator.clipboard.writeText(s.toString()).then(() => {
|
|
548
|
+
n(!0), setTimeout(() => n(!1), 2500);
|
|
549
|
+
});
|
|
550
|
+
}, [t]);
|
|
551
|
+
return t.trim() ? /* @__PURE__ */ e(
|
|
552
|
+
"button",
|
|
553
|
+
{
|
|
554
|
+
className: "mixpeek-share-link",
|
|
555
|
+
onClick: i,
|
|
556
|
+
type: "button",
|
|
557
|
+
"aria-label": "Copy shareable link",
|
|
558
|
+
title: "Copy shareable search link",
|
|
559
|
+
children: r ? /* @__PURE__ */ l(me, { children: [
|
|
560
|
+
/* @__PURE__ */ e(
|
|
561
|
+
"svg",
|
|
562
|
+
{
|
|
563
|
+
width: "14",
|
|
564
|
+
height: "14",
|
|
565
|
+
viewBox: "0 0 24 24",
|
|
566
|
+
fill: "none",
|
|
567
|
+
stroke: "currentColor",
|
|
568
|
+
strokeWidth: "2",
|
|
569
|
+
strokeLinecap: "round",
|
|
570
|
+
strokeLinejoin: "round",
|
|
571
|
+
children: /* @__PURE__ */ e("polyline", { points: "20 6 9 17 4 12" })
|
|
572
|
+
}
|
|
573
|
+
),
|
|
574
|
+
/* @__PURE__ */ e("span", { children: "Copied!" })
|
|
575
|
+
] }) : /* @__PURE__ */ l(me, { children: [
|
|
576
|
+
/* @__PURE__ */ l(
|
|
577
|
+
"svg",
|
|
578
|
+
{
|
|
579
|
+
width: "14",
|
|
580
|
+
height: "14",
|
|
581
|
+
viewBox: "0 0 24 24",
|
|
582
|
+
fill: "none",
|
|
583
|
+
stroke: "currentColor",
|
|
584
|
+
strokeWidth: "2",
|
|
585
|
+
strokeLinecap: "round",
|
|
586
|
+
strokeLinejoin: "round",
|
|
587
|
+
children: [
|
|
588
|
+
/* @__PURE__ */ e("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
589
|
+
/* @__PURE__ */ e("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
590
|
+
]
|
|
591
|
+
}
|
|
592
|
+
),
|
|
593
|
+
/* @__PURE__ */ e("span", { children: "Share" })
|
|
594
|
+
] })
|
|
595
|
+
}
|
|
596
|
+
) : null;
|
|
597
|
+
}, Be = ({ config: t }) => /* @__PURE__ */ l("div", { className: "mixpeek-intent-cta", role: "banner", children: [
|
|
598
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-intent-cta-message", children: t.message }),
|
|
599
|
+
/* @__PURE__ */ e(
|
|
600
|
+
"a",
|
|
601
|
+
{
|
|
602
|
+
className: "mixpeek-intent-cta-button",
|
|
603
|
+
href: t.buttonUrl,
|
|
604
|
+
target: "_blank",
|
|
605
|
+
rel: "noopener noreferrer",
|
|
606
|
+
children: t.buttonText
|
|
607
|
+
}
|
|
608
|
+
)
|
|
609
|
+
] }), Ie = ({
|
|
610
|
+
isOpen: t,
|
|
611
|
+
onClose: r,
|
|
612
|
+
query: n,
|
|
613
|
+
onQueryChange: i,
|
|
614
|
+
results: s,
|
|
615
|
+
stages: a,
|
|
616
|
+
isStreaming: c,
|
|
617
|
+
isLoading: h,
|
|
618
|
+
error: o,
|
|
619
|
+
aiAnswer: m,
|
|
620
|
+
metadata: d,
|
|
621
|
+
placeholder: p,
|
|
622
|
+
showPoweredBy: v,
|
|
623
|
+
enableShareLinks: L,
|
|
624
|
+
enableAIAnswer: _,
|
|
625
|
+
recentSearches: D,
|
|
626
|
+
onClearRecent: T,
|
|
627
|
+
onResultClick: B,
|
|
628
|
+
renderResult: A,
|
|
629
|
+
ctaConfig: k,
|
|
630
|
+
theme: x = "light"
|
|
631
|
+
}) => {
|
|
632
|
+
const b = z(null), w = z(null);
|
|
633
|
+
j(() => {
|
|
634
|
+
if (!t) return;
|
|
635
|
+
const g = (f) => {
|
|
636
|
+
if (f.key === "Escape") {
|
|
637
|
+
f.preventDefault(), r();
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
if (f.key === "Tab" && b.current) {
|
|
641
|
+
const K = b.current.querySelectorAll(
|
|
642
|
+
'input, button, a[href], [tabindex]:not([tabindex="-1"])'
|
|
643
|
+
);
|
|
644
|
+
if (K.length === 0) return;
|
|
645
|
+
const H = K[0], q = K[K.length - 1];
|
|
646
|
+
f.shiftKey && document.activeElement === H ? (f.preventDefault(), q.focus()) : !f.shiftKey && document.activeElement === q && (f.preventDefault(), H.focus());
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
return document.addEventListener("keydown", g), () => document.removeEventListener("keydown", g);
|
|
650
|
+
}, [t, r]), j(() => {
|
|
651
|
+
if (t) {
|
|
652
|
+
const g = document.body.style.overflow;
|
|
653
|
+
return document.body.style.overflow = "hidden", () => {
|
|
654
|
+
document.body.style.overflow = g;
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
}, [t]);
|
|
658
|
+
const O = y(
|
|
659
|
+
(g) => {
|
|
660
|
+
g.target === w.current && r();
|
|
661
|
+
},
|
|
662
|
+
[r]
|
|
663
|
+
), U = y(() => {
|
|
664
|
+
i("");
|
|
665
|
+
}, [i]), S = y(
|
|
666
|
+
(g) => {
|
|
667
|
+
i(g);
|
|
668
|
+
},
|
|
669
|
+
[i]
|
|
670
|
+
), I = y(
|
|
671
|
+
(g) => {
|
|
672
|
+
var K;
|
|
673
|
+
const f = (K = b.current) == null ? void 0 : K.querySelector(
|
|
674
|
+
`[data-index="${g}"]`
|
|
675
|
+
);
|
|
676
|
+
f && (f.scrollIntoView({ behavior: "smooth", block: "nearest" }), f.classList.add("mixpeek-result-highlighted"), setTimeout(() => {
|
|
677
|
+
f.classList.remove("mixpeek-result-highlighted");
|
|
678
|
+
}, 1500));
|
|
679
|
+
},
|
|
680
|
+
[]
|
|
681
|
+
), $ = !n && D.length > 0, W = !n && D.length === 0, F = n.trim() && !h && !c && s.length === 0 && !o, E = s.length > 0 || a.length > 0, N = _ && m && m.answer, u = k || (d == null ? void 0 : d.cta);
|
|
682
|
+
if (!t) return null;
|
|
683
|
+
const R = /* @__PURE__ */ e(
|
|
684
|
+
"div",
|
|
685
|
+
{
|
|
686
|
+
ref: w,
|
|
687
|
+
className: `mixpeek-search mixpeek-theme-${x} mixpeek-modal-backdrop`,
|
|
688
|
+
onClick: O,
|
|
689
|
+
role: "dialog",
|
|
690
|
+
"aria-modal": "true",
|
|
691
|
+
"aria-label": "Search",
|
|
692
|
+
children: /* @__PURE__ */ l("div", { ref: b, className: "mixpeek-modal", children: [
|
|
693
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-modal-header", children: /* @__PURE__ */ e(
|
|
694
|
+
Ne,
|
|
695
|
+
{
|
|
696
|
+
value: n,
|
|
697
|
+
onChange: i,
|
|
698
|
+
placeholder: p,
|
|
699
|
+
isLoading: h,
|
|
700
|
+
onClear: U
|
|
701
|
+
}
|
|
702
|
+
) }),
|
|
703
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-modal-body", children: [
|
|
704
|
+
o && /* @__PURE__ */ l("div", { className: "mixpeek-error", role: "alert", children: [
|
|
705
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-error-icon", children: /* @__PURE__ */ l(
|
|
706
|
+
"svg",
|
|
707
|
+
{
|
|
708
|
+
width: "16",
|
|
709
|
+
height: "16",
|
|
710
|
+
viewBox: "0 0 24 24",
|
|
711
|
+
fill: "none",
|
|
712
|
+
stroke: "currentColor",
|
|
713
|
+
strokeWidth: "2",
|
|
714
|
+
strokeLinecap: "round",
|
|
715
|
+
strokeLinejoin: "round",
|
|
716
|
+
children: [
|
|
717
|
+
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
|
|
718
|
+
/* @__PURE__ */ e("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
719
|
+
/* @__PURE__ */ e("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
720
|
+
]
|
|
721
|
+
}
|
|
722
|
+
) }),
|
|
723
|
+
/* @__PURE__ */ e("span", { children: o })
|
|
724
|
+
] }),
|
|
725
|
+
W && /* @__PURE__ */ l("div", { className: "mixpeek-empty-state", children: [
|
|
726
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-empty-state-icon", children: /* @__PURE__ */ l(
|
|
727
|
+
"svg",
|
|
728
|
+
{
|
|
729
|
+
width: "32",
|
|
730
|
+
height: "32",
|
|
731
|
+
viewBox: "0 0 24 24",
|
|
732
|
+
fill: "none",
|
|
733
|
+
stroke: "currentColor",
|
|
734
|
+
strokeWidth: "1.5",
|
|
735
|
+
strokeLinecap: "round",
|
|
736
|
+
strokeLinejoin: "round",
|
|
737
|
+
children: [
|
|
738
|
+
/* @__PURE__ */ e("circle", { cx: "11", cy: "11", r: "8" }),
|
|
739
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
|
|
740
|
+
]
|
|
741
|
+
}
|
|
742
|
+
) }),
|
|
743
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-empty-state-text", children: [
|
|
744
|
+
"Type to search or press",
|
|
745
|
+
" ",
|
|
746
|
+
/* @__PURE__ */ e("kbd", { className: "mixpeek-empty-state-kbd", children: "Esc" }),
|
|
747
|
+
" to close"
|
|
748
|
+
] })
|
|
749
|
+
] }),
|
|
750
|
+
$ && /* @__PURE__ */ l("div", { className: "mixpeek-recent-searches", children: [
|
|
751
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-recent-header", children: [
|
|
752
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-recent-title", children: "Recent searches" }),
|
|
753
|
+
/* @__PURE__ */ e(
|
|
754
|
+
"button",
|
|
755
|
+
{
|
|
756
|
+
className: "mixpeek-recent-clear",
|
|
757
|
+
onClick: T,
|
|
758
|
+
type: "button",
|
|
759
|
+
children: "Clear"
|
|
760
|
+
}
|
|
761
|
+
)
|
|
762
|
+
] }),
|
|
763
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-recent-list", children: D.map((g, f) => /* @__PURE__ */ l(
|
|
764
|
+
"button",
|
|
765
|
+
{
|
|
766
|
+
className: "mixpeek-recent-item",
|
|
767
|
+
onClick: () => S(g),
|
|
768
|
+
type: "button",
|
|
769
|
+
children: [
|
|
770
|
+
/* @__PURE__ */ l(
|
|
771
|
+
"svg",
|
|
772
|
+
{
|
|
773
|
+
width: "14",
|
|
774
|
+
height: "14",
|
|
775
|
+
viewBox: "0 0 24 24",
|
|
776
|
+
fill: "none",
|
|
777
|
+
stroke: "currentColor",
|
|
778
|
+
strokeWidth: "2",
|
|
779
|
+
strokeLinecap: "round",
|
|
780
|
+
strokeLinejoin: "round",
|
|
781
|
+
children: [
|
|
782
|
+
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
|
|
783
|
+
/* @__PURE__ */ e("polyline", { points: "12 6 12 12 16 14" })
|
|
784
|
+
]
|
|
785
|
+
}
|
|
786
|
+
),
|
|
787
|
+
/* @__PURE__ */ e("span", { children: g })
|
|
788
|
+
]
|
|
789
|
+
},
|
|
790
|
+
f
|
|
791
|
+
)) })
|
|
792
|
+
] }),
|
|
793
|
+
N && /* @__PURE__ */ e(we, { data: m, onCitationClick: I }),
|
|
794
|
+
E && /* @__PURE__ */ e(
|
|
795
|
+
je,
|
|
796
|
+
{
|
|
797
|
+
results: s,
|
|
798
|
+
stages: a,
|
|
799
|
+
isStreaming: c,
|
|
800
|
+
query: n,
|
|
801
|
+
isLoading: h,
|
|
802
|
+
onResultClick: B,
|
|
803
|
+
renderResult: A
|
|
804
|
+
}
|
|
805
|
+
),
|
|
806
|
+
F && /* @__PURE__ */ e(Ke, { query: n }),
|
|
807
|
+
u && /* @__PURE__ */ e(Be, { config: u })
|
|
808
|
+
] }),
|
|
809
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-modal-footer", children: [
|
|
810
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-modal-footer-left", children: L && /* @__PURE__ */ e(De, { query: n }) }),
|
|
811
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-modal-footer-right", children: [
|
|
812
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-modal-footer-hints", children: [
|
|
813
|
+
/* @__PURE__ */ e("kbd", { className: "mixpeek-kbd-hint", children: "Esc" }),
|
|
814
|
+
/* @__PURE__ */ e("span", { children: "to close" })
|
|
815
|
+
] }),
|
|
816
|
+
v && /* @__PURE__ */ e(Re, {})
|
|
817
|
+
] })
|
|
818
|
+
] })
|
|
819
|
+
] })
|
|
820
|
+
}
|
|
821
|
+
);
|
|
822
|
+
return ye(R, document.body);
|
|
823
|
+
}, We = "https://api.mixpeek.com";
|
|
824
|
+
class Fe {
|
|
825
|
+
constructor(r) {
|
|
826
|
+
this.abortController = null, this.projectKey = r.projectKey, this.baseUrl = (r.baseUrl || We).replace(/\/+$/, ""), this.retrieverSlug = r.retrieverSlug, this.bearerToken = r.bearerToken;
|
|
827
|
+
}
|
|
828
|
+
isApiKey() {
|
|
829
|
+
return this.projectKey.startsWith("ret_sk_");
|
|
830
|
+
}
|
|
831
|
+
getHeaders() {
|
|
832
|
+
const r = {
|
|
833
|
+
"Content-Type": "application/json"
|
|
834
|
+
};
|
|
835
|
+
return this.bearerToken ? r.Authorization = `Bearer ${this.bearerToken}` : this.isApiKey() && (r["X-Public-API-Key"] = this.projectKey), r;
|
|
836
|
+
}
|
|
837
|
+
getEndpoint() {
|
|
838
|
+
return this.bearerToken ? `${this.baseUrl}/v1/retrievers/${encodeURIComponent(this.projectKey)}/execute` : this.isApiKey() ? this.retrieverSlug ? `${this.baseUrl}/v1/public/retrievers/${encodeURIComponent(this.retrieverSlug)}/execute` : `${this.baseUrl}/v1/public/retrievers/execute` : `${this.baseUrl}/v1/public/retrievers/${encodeURIComponent(this.projectKey)}/execute`;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Cancel any in-flight search request.
|
|
842
|
+
*/
|
|
843
|
+
cancel() {
|
|
844
|
+
this.abortController && (this.abortController.abort(), this.abortController = null);
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Execute a search query against the configured retriever.
|
|
848
|
+
*/
|
|
849
|
+
async search(r) {
|
|
850
|
+
this.cancel(), this.abortController = new AbortController();
|
|
851
|
+
const n = {
|
|
852
|
+
inputs: { query: r.query, ...r.inputs },
|
|
853
|
+
settings: { limit: r.limit || 10 }
|
|
854
|
+
};
|
|
855
|
+
r.stream && (n.stream = !0);
|
|
856
|
+
const i = await fetch(this.getEndpoint(), {
|
|
857
|
+
method: "POST",
|
|
858
|
+
headers: this.getHeaders(),
|
|
859
|
+
body: JSON.stringify(n),
|
|
860
|
+
signal: this.abortController.signal
|
|
861
|
+
});
|
|
862
|
+
if (!i.ok) {
|
|
863
|
+
const c = await i.text();
|
|
864
|
+
let h = `Search request failed (${i.status})`;
|
|
865
|
+
try {
|
|
866
|
+
const o = JSON.parse(c);
|
|
867
|
+
o.detail && (h = typeof o.detail == "string" ? o.detail : JSON.stringify(o.detail));
|
|
868
|
+
} catch {
|
|
869
|
+
}
|
|
870
|
+
throw new Error(h);
|
|
871
|
+
}
|
|
872
|
+
const s = await i.json();
|
|
873
|
+
return {
|
|
874
|
+
results: s.results || s.documents || [],
|
|
875
|
+
ai_answer: s.ai_answer || null,
|
|
876
|
+
metadata: s.metadata || null
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Execute a streaming search query. Yields StageEvent objects as the pipeline executes.
|
|
881
|
+
*/
|
|
882
|
+
async *searchStream(r) {
|
|
883
|
+
this.cancel(), this.abortController = new AbortController();
|
|
884
|
+
const n = {
|
|
885
|
+
inputs: { query: r.query, ...r.inputs },
|
|
886
|
+
settings: { limit: r.limit || 10 },
|
|
887
|
+
stream: !0
|
|
888
|
+
}, i = await fetch(this.getEndpoint(), {
|
|
889
|
+
method: "POST",
|
|
890
|
+
headers: {
|
|
891
|
+
...this.getHeaders(),
|
|
892
|
+
Accept: "text/event-stream"
|
|
893
|
+
},
|
|
894
|
+
body: JSON.stringify(n),
|
|
895
|
+
signal: this.abortController.signal
|
|
896
|
+
});
|
|
897
|
+
if (!i.ok)
|
|
898
|
+
throw new Error(`Search request failed (${i.status})`);
|
|
899
|
+
if (!i.body)
|
|
900
|
+
throw new Error("Streaming not supported");
|
|
901
|
+
const s = i.body.getReader(), a = new TextDecoder();
|
|
902
|
+
let c = "";
|
|
903
|
+
try {
|
|
904
|
+
for (; ; ) {
|
|
905
|
+
const { done: h, value: o } = await s.read();
|
|
906
|
+
if (h) break;
|
|
907
|
+
c += a.decode(o, { stream: !0 });
|
|
908
|
+
const m = c.split(`
|
|
909
|
+
`);
|
|
910
|
+
c = m.pop() || "";
|
|
911
|
+
for (const d of m) {
|
|
912
|
+
const p = d.trim();
|
|
913
|
+
if (!p || !p.startsWith("data: ")) continue;
|
|
914
|
+
const v = p.slice(6);
|
|
915
|
+
if (v === "[DONE]") return;
|
|
916
|
+
try {
|
|
917
|
+
const L = JSON.parse(v);
|
|
918
|
+
L.event_type && (yield L);
|
|
919
|
+
} catch {
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
} finally {
|
|
924
|
+
s.releaseLock();
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
const Z = /* @__PURE__ */ new Map(), Oe = 5 * 60 * 1e3;
|
|
929
|
+
function Ue(t, r, n, i) {
|
|
930
|
+
const s = i && Object.keys(i).length > 0 ? `:${JSON.stringify(i)}` : "";
|
|
931
|
+
return `${t}:${r}:${n}${s}`;
|
|
932
|
+
}
|
|
933
|
+
function Pe() {
|
|
934
|
+
const t = Date.now();
|
|
935
|
+
for (const [r, n] of Z.entries())
|
|
936
|
+
t - n.timestamp > Oe && Z.delete(r);
|
|
937
|
+
}
|
|
938
|
+
function ze(t) {
|
|
939
|
+
const { config: r, filterInputs: n, onSearch: i, onSearchExecuted: s, onZeroResults: a, transformResults: c } = t, [h, o] = C([]), [m, d] = C([]), [p, v] = C(!1), [L, _] = C(!1), [D, T] = C(null), [B, A] = C(null), [k, x] = C(null), b = z(null), w = z(null);
|
|
940
|
+
j(() => (b.current = new Fe({
|
|
941
|
+
projectKey: r.projectKey,
|
|
942
|
+
baseUrl: r.apiBaseUrl,
|
|
943
|
+
retrieverSlug: r.retrieverSlug,
|
|
944
|
+
bearerToken: r.bearerToken
|
|
945
|
+
}), () => {
|
|
946
|
+
var S;
|
|
947
|
+
(S = b.current) == null || S.cancel();
|
|
948
|
+
}), [r.projectKey, r.apiBaseUrl, r.retrieverSlug, r.bearerToken]);
|
|
949
|
+
const O = y(
|
|
950
|
+
async (S) => {
|
|
951
|
+
const I = b.current;
|
|
952
|
+
if (!I) return;
|
|
953
|
+
const $ = S.trim();
|
|
954
|
+
if (!$) {
|
|
955
|
+
o([]), d([]), T(null), A(null), x(null), v(!1), _(!1);
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
const W = Ue(r.projectKey, $, r.maxResults, n);
|
|
959
|
+
Pe();
|
|
960
|
+
const F = Z.get(W);
|
|
961
|
+
if (F) {
|
|
962
|
+
const E = c ? c(F.results) : F.results;
|
|
963
|
+
o(E), A(F.aiAnswer), x(F.metadata), d([]), T(null), v(!1), _(!1);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
v(!0), _(!0), T(null), d([]), o([]), A(null);
|
|
967
|
+
try {
|
|
968
|
+
i == null || i($);
|
|
969
|
+
let E = [];
|
|
970
|
+
for await (const u of I.searchStream({ query: $, limit: r.maxResults, inputs: n }))
|
|
971
|
+
switch (u.event_type) {
|
|
972
|
+
case "stage_start":
|
|
973
|
+
d((R) => {
|
|
974
|
+
const g = [...R];
|
|
975
|
+
return g[u.stage_index] = {
|
|
976
|
+
name: u.stage_name || `Stage ${u.stage_index}`,
|
|
977
|
+
index: u.stage_index,
|
|
978
|
+
status: "running",
|
|
979
|
+
documents: []
|
|
980
|
+
}, g;
|
|
981
|
+
});
|
|
982
|
+
break;
|
|
983
|
+
case "stage_complete":
|
|
984
|
+
d((R) => {
|
|
985
|
+
const g = [...R], f = g[u.stage_index];
|
|
986
|
+
return g[u.stage_index] = {
|
|
987
|
+
name: (f == null ? void 0 : f.name) || u.stage_name || `Stage ${u.stage_index}`,
|
|
988
|
+
index: u.stage_index,
|
|
989
|
+
status: "complete",
|
|
990
|
+
documents: u.documents || [],
|
|
991
|
+
statistics: u.statistics
|
|
992
|
+
}, g;
|
|
993
|
+
}), u.documents && o(
|
|
994
|
+
c ? c(u.documents) : u.documents
|
|
995
|
+
);
|
|
996
|
+
break;
|
|
997
|
+
case "stage_error":
|
|
998
|
+
d((R) => {
|
|
999
|
+
const g = [...R], f = g[u.stage_index];
|
|
1000
|
+
return g[u.stage_index] = {
|
|
1001
|
+
name: (f == null ? void 0 : f.name) || u.stage_name || `Stage ${u.stage_index}`,
|
|
1002
|
+
index: u.stage_index,
|
|
1003
|
+
status: "error",
|
|
1004
|
+
documents: (f == null ? void 0 : f.documents) || [],
|
|
1005
|
+
error: u.error
|
|
1006
|
+
}, g;
|
|
1007
|
+
});
|
|
1008
|
+
break;
|
|
1009
|
+
case "execution_complete":
|
|
1010
|
+
E = u.documents || [];
|
|
1011
|
+
break;
|
|
1012
|
+
case "execution_error":
|
|
1013
|
+
T(u.error || "Execution failed"), _(!1), v(!1);
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
const N = c ? c(E) : E;
|
|
1017
|
+
o(N), _(!1), v(!1), T(null), Z.set(W, {
|
|
1018
|
+
results: E,
|
|
1019
|
+
aiAnswer: null,
|
|
1020
|
+
metadata: null,
|
|
1021
|
+
timestamp: Date.now()
|
|
1022
|
+
}), s == null || s($), N.length === 0 && (a == null || a($));
|
|
1023
|
+
} catch (E) {
|
|
1024
|
+
if (E instanceof Error && E.name === "AbortError")
|
|
1025
|
+
return;
|
|
1026
|
+
_(!1), d([]);
|
|
1027
|
+
try {
|
|
1028
|
+
const N = await I.search({
|
|
1029
|
+
query: $,
|
|
1030
|
+
limit: r.maxResults,
|
|
1031
|
+
inputs: n
|
|
1032
|
+
}), u = N.results || [], R = c ? c(u) : u;
|
|
1033
|
+
o(R), A(N.ai_answer || null), x(N.metadata || null), T(null), Z.set(W, {
|
|
1034
|
+
results: u,
|
|
1035
|
+
aiAnswer: N.ai_answer || null,
|
|
1036
|
+
metadata: N.metadata || null,
|
|
1037
|
+
timestamp: Date.now()
|
|
1038
|
+
}), s == null || s($), R.length === 0 && (a == null || a($));
|
|
1039
|
+
} catch (N) {
|
|
1040
|
+
if (N instanceof Error && N.name === "AbortError")
|
|
1041
|
+
return;
|
|
1042
|
+
const u = N instanceof Error ? N.message : "Search failed";
|
|
1043
|
+
T(u), o([]), A(null);
|
|
1044
|
+
}
|
|
1045
|
+
} finally {
|
|
1046
|
+
v(!1), _(!1);
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
[r.projectKey, r.maxResults, r.apiBaseUrl, n, i, s, a, c]
|
|
1050
|
+
), U = y(
|
|
1051
|
+
async (S) => {
|
|
1052
|
+
var I;
|
|
1053
|
+
return w.current && clearTimeout(w.current), (I = b.current) == null || I.cancel(), new Promise(($) => {
|
|
1054
|
+
w.current = setTimeout(async () => {
|
|
1055
|
+
await O(S), $();
|
|
1056
|
+
}, 300);
|
|
1057
|
+
});
|
|
1058
|
+
},
|
|
1059
|
+
[O]
|
|
1060
|
+
);
|
|
1061
|
+
return j(() => () => {
|
|
1062
|
+
w.current && clearTimeout(w.current);
|
|
1063
|
+
}, []), { results: h, stages: m, isLoading: p, isStreaming: L, error: D, aiAnswer: B, metadata: k, search: U };
|
|
1064
|
+
}
|
|
1065
|
+
function qe(t) {
|
|
1066
|
+
const [r, n] = C(
|
|
1067
|
+
t || {}
|
|
1068
|
+
), i = y((o, m) => {
|
|
1069
|
+
n((d) => {
|
|
1070
|
+
if (m == null || m === "" || Array.isArray(m) && m.length === 0) {
|
|
1071
|
+
const p = { ...d };
|
|
1072
|
+
return delete p[o], p;
|
|
1073
|
+
}
|
|
1074
|
+
return { ...d, [o]: m };
|
|
1075
|
+
});
|
|
1076
|
+
}, []), s = y((o) => {
|
|
1077
|
+
n((m) => {
|
|
1078
|
+
const d = { ...m };
|
|
1079
|
+
return delete d[o], d;
|
|
1080
|
+
});
|
|
1081
|
+
}, []), a = y(() => {
|
|
1082
|
+
n({});
|
|
1083
|
+
}, []), c = J(
|
|
1084
|
+
() => Object.keys(r).length > 0,
|
|
1085
|
+
[r]
|
|
1086
|
+
), h = y(
|
|
1087
|
+
(o) => r[o],
|
|
1088
|
+
[r]
|
|
1089
|
+
);
|
|
1090
|
+
return {
|
|
1091
|
+
filterInputs: r,
|
|
1092
|
+
setFilter: i,
|
|
1093
|
+
removeFilter: s,
|
|
1094
|
+
clearFilters: a,
|
|
1095
|
+
hasActiveFilters: c,
|
|
1096
|
+
getFilter: h
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
function Je(t) {
|
|
1100
|
+
const { enabled: r, onTrigger: n } = t, i = y(
|
|
1101
|
+
(s) => {
|
|
1102
|
+
if (!r) return;
|
|
1103
|
+
(navigator.platform.toUpperCase().indexOf("MAC") >= 0 ? s.metaKey : s.ctrlKey) && s.key === "k" && (s.preventDefault(), s.stopPropagation(), n());
|
|
1104
|
+
},
|
|
1105
|
+
[r, n]
|
|
1106
|
+
);
|
|
1107
|
+
j(() => {
|
|
1108
|
+
if (r)
|
|
1109
|
+
return document.addEventListener("keydown", i), () => {
|
|
1110
|
+
document.removeEventListener("keydown", i);
|
|
1111
|
+
};
|
|
1112
|
+
}, [r, i]);
|
|
1113
|
+
}
|
|
1114
|
+
const fe = "mixpeek_recent_searches", He = 10;
|
|
1115
|
+
function Ge() {
|
|
1116
|
+
try {
|
|
1117
|
+
const t = localStorage.getItem(fe);
|
|
1118
|
+
if (!t) return [];
|
|
1119
|
+
const r = JSON.parse(t);
|
|
1120
|
+
return Array.isArray(r) ? r.filter(
|
|
1121
|
+
(n) => typeof n == "object" && n !== null && "query" in n && "timestamp" in n && typeof n.query == "string" && typeof n.timestamp == "number"
|
|
1122
|
+
) : [];
|
|
1123
|
+
} catch {
|
|
1124
|
+
return [];
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
function he(t) {
|
|
1128
|
+
try {
|
|
1129
|
+
localStorage.setItem(fe, JSON.stringify(t));
|
|
1130
|
+
} catch {
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
function Ve() {
|
|
1134
|
+
const [t, r] = C([]);
|
|
1135
|
+
j(() => {
|
|
1136
|
+
r(Ge());
|
|
1137
|
+
}, []);
|
|
1138
|
+
const n = y((s) => {
|
|
1139
|
+
const a = s.trim();
|
|
1140
|
+
a && r((c) => {
|
|
1141
|
+
const h = c.filter(
|
|
1142
|
+
(m) => m.query.toLowerCase() !== a.toLowerCase()
|
|
1143
|
+
), o = [
|
|
1144
|
+
{ query: a, timestamp: Date.now() },
|
|
1145
|
+
...h
|
|
1146
|
+
].slice(0, He);
|
|
1147
|
+
return he(o), o;
|
|
1148
|
+
});
|
|
1149
|
+
}, []), i = y(() => {
|
|
1150
|
+
r([]), he([]);
|
|
1151
|
+
}, []);
|
|
1152
|
+
return {
|
|
1153
|
+
recentSearches: t.map((s) => s.query),
|
|
1154
|
+
addSearch: n,
|
|
1155
|
+
clearRecentSearches: i
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
const oe = xe(null);
|
|
1159
|
+
function Xe() {
|
|
1160
|
+
const t = ge(oe);
|
|
1161
|
+
if (!t)
|
|
1162
|
+
throw new Error(
|
|
1163
|
+
"useSearchKit must be used within a SearchKit component"
|
|
1164
|
+
);
|
|
1165
|
+
return t;
|
|
1166
|
+
}
|
|
1167
|
+
const it = Xe, ke = ({
|
|
1168
|
+
projectKey: t,
|
|
1169
|
+
placeholder: r = "Search...",
|
|
1170
|
+
maxResults: n = 10,
|
|
1171
|
+
theme: i = "auto",
|
|
1172
|
+
accentColor: s = "#6366f1",
|
|
1173
|
+
position: a = "modal",
|
|
1174
|
+
keyboardShortcut: c = !0,
|
|
1175
|
+
showPoweredBy: h = !0,
|
|
1176
|
+
enableShareLinks: o = !1,
|
|
1177
|
+
enableAIAnswer: m = !1,
|
|
1178
|
+
onSearch: d,
|
|
1179
|
+
onResultClick: p,
|
|
1180
|
+
onZeroResults: v,
|
|
1181
|
+
transformResults: L,
|
|
1182
|
+
renderResult: _,
|
|
1183
|
+
retrieverSlug: D,
|
|
1184
|
+
bearerToken: T,
|
|
1185
|
+
apiBaseUrl: B = "https://api.mixpeek.com",
|
|
1186
|
+
className: A,
|
|
1187
|
+
defaultOpen: k = !1,
|
|
1188
|
+
ctaConfig: x,
|
|
1189
|
+
defaultFilters: b,
|
|
1190
|
+
onFilterChange: w
|
|
1191
|
+
}) => {
|
|
1192
|
+
const [O, U] = C(k), [S, I] = C(""), $ = J(
|
|
1193
|
+
() => ({
|
|
1194
|
+
projectKey: t,
|
|
1195
|
+
retrieverSlug: D,
|
|
1196
|
+
bearerToken: T,
|
|
1197
|
+
apiBaseUrl: B,
|
|
1198
|
+
maxResults: n,
|
|
1199
|
+
theme: i,
|
|
1200
|
+
accentColor: s,
|
|
1201
|
+
placeholder: r,
|
|
1202
|
+
showPoweredBy: h,
|
|
1203
|
+
enableShareLinks: o,
|
|
1204
|
+
enableAIAnswer: m,
|
|
1205
|
+
position: a
|
|
1206
|
+
}),
|
|
1207
|
+
[
|
|
1208
|
+
t,
|
|
1209
|
+
D,
|
|
1210
|
+
T,
|
|
1211
|
+
B,
|
|
1212
|
+
n,
|
|
1213
|
+
i,
|
|
1214
|
+
s,
|
|
1215
|
+
r,
|
|
1216
|
+
h,
|
|
1217
|
+
o,
|
|
1218
|
+
m,
|
|
1219
|
+
a
|
|
1220
|
+
]
|
|
1221
|
+
), { recentSearches: W, addSearch: F, clearRecentSearches: E } = Ve(), { filterInputs: N, setFilter: u, removeFilter: R, clearFilters: g, hasActiveFilters: f } = qe(b), { results: K, stages: H, isLoading: q, isStreaming: ee, error: G, aiAnswer: V, metadata: te, search: X } = ze({
|
|
1222
|
+
config: $,
|
|
1223
|
+
filterInputs: N,
|
|
1224
|
+
onSearch: d,
|
|
1225
|
+
onSearchExecuted: F,
|
|
1226
|
+
onZeroResults: v,
|
|
1227
|
+
transformResults: L
|
|
1228
|
+
});
|
|
1229
|
+
j(() => {
|
|
1230
|
+
S.trim() && X(S);
|
|
1231
|
+
}, [N]), j(() => {
|
|
1232
|
+
w == null || w(N);
|
|
1233
|
+
}, [N]);
|
|
1234
|
+
const re = y(() => U(!0), []), ne = y(() => U(!1), []), ie = y(() => U((M) => !M), []);
|
|
1235
|
+
Je({
|
|
1236
|
+
enabled: c,
|
|
1237
|
+
onTrigger: ie
|
|
1238
|
+
});
|
|
1239
|
+
const Y = y(
|
|
1240
|
+
(M) => {
|
|
1241
|
+
I(M), M.trim() && X(M);
|
|
1242
|
+
},
|
|
1243
|
+
[X]
|
|
1244
|
+
);
|
|
1245
|
+
j(() => {
|
|
1246
|
+
if (typeof window > "u") return;
|
|
1247
|
+
const P = new URLSearchParams(window.location.search).get("mixpeek_q");
|
|
1248
|
+
P && (I(P), U(!0), X(P));
|
|
1249
|
+
}, []);
|
|
1250
|
+
const Q = J(() => i === "auto" ? typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : i, [i]), ce = J(
|
|
1251
|
+
() => ({
|
|
1252
|
+
"--mixpeek-accent": s,
|
|
1253
|
+
"--mixpeek-accent-rgb": Ye(s)
|
|
1254
|
+
}),
|
|
1255
|
+
[s]
|
|
1256
|
+
), de = J(
|
|
1257
|
+
() => ({
|
|
1258
|
+
query: S,
|
|
1259
|
+
setQuery: Y,
|
|
1260
|
+
results: K,
|
|
1261
|
+
stages: H,
|
|
1262
|
+
isLoading: q,
|
|
1263
|
+
isStreaming: ee,
|
|
1264
|
+
error: G,
|
|
1265
|
+
aiAnswer: V,
|
|
1266
|
+
metadata: te,
|
|
1267
|
+
isOpen: O,
|
|
1268
|
+
open: re,
|
|
1269
|
+
close: ne,
|
|
1270
|
+
toggle: ie,
|
|
1271
|
+
search: X,
|
|
1272
|
+
recentSearches: W,
|
|
1273
|
+
clearRecentSearches: E,
|
|
1274
|
+
config: $,
|
|
1275
|
+
filterInputs: N,
|
|
1276
|
+
setFilter: u,
|
|
1277
|
+
removeFilter: R,
|
|
1278
|
+
clearFilters: g,
|
|
1279
|
+
hasActiveFilters: f
|
|
1280
|
+
}),
|
|
1281
|
+
[
|
|
1282
|
+
S,
|
|
1283
|
+
Y,
|
|
1284
|
+
K,
|
|
1285
|
+
H,
|
|
1286
|
+
q,
|
|
1287
|
+
ee,
|
|
1288
|
+
G,
|
|
1289
|
+
V,
|
|
1290
|
+
te,
|
|
1291
|
+
O,
|
|
1292
|
+
re,
|
|
1293
|
+
ne,
|
|
1294
|
+
ie,
|
|
1295
|
+
X,
|
|
1296
|
+
W,
|
|
1297
|
+
E,
|
|
1298
|
+
$,
|
|
1299
|
+
N,
|
|
1300
|
+
u,
|
|
1301
|
+
R,
|
|
1302
|
+
g,
|
|
1303
|
+
f
|
|
1304
|
+
]
|
|
1305
|
+
);
|
|
1306
|
+
return a === "inline" ? /* @__PURE__ */ e(oe.Provider, { value: de, children: /* @__PURE__ */ e(
|
|
1307
|
+
"div",
|
|
1308
|
+
{
|
|
1309
|
+
className: `mixpeek-search mixpeek-theme-${Q} mixpeek-inline ${A || ""}`,
|
|
1310
|
+
style: ce,
|
|
1311
|
+
"data-theme": Q,
|
|
1312
|
+
children: /* @__PURE__ */ l("div", { className: "mixpeek-inline-container", children: [
|
|
1313
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-modal-header", children: /* @__PURE__ */ l("div", { className: "mixpeek-search-input-wrapper", children: [
|
|
1314
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-search-input-icon", children: /* @__PURE__ */ l(
|
|
1315
|
+
"svg",
|
|
1316
|
+
{
|
|
1317
|
+
width: "20",
|
|
1318
|
+
height: "20",
|
|
1319
|
+
viewBox: "0 0 24 24",
|
|
1320
|
+
fill: "none",
|
|
1321
|
+
stroke: "currentColor",
|
|
1322
|
+
strokeWidth: "2",
|
|
1323
|
+
strokeLinecap: "round",
|
|
1324
|
+
strokeLinejoin: "round",
|
|
1325
|
+
children: [
|
|
1326
|
+
/* @__PURE__ */ e("circle", { cx: "11", cy: "11", r: "8" }),
|
|
1327
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
|
|
1328
|
+
]
|
|
1329
|
+
}
|
|
1330
|
+
) }),
|
|
1331
|
+
/* @__PURE__ */ e(
|
|
1332
|
+
"input",
|
|
1333
|
+
{
|
|
1334
|
+
type: "text",
|
|
1335
|
+
className: "mixpeek-search-input",
|
|
1336
|
+
value: S,
|
|
1337
|
+
onChange: (M) => Y(M.target.value),
|
|
1338
|
+
placeholder: r,
|
|
1339
|
+
autoComplete: "off",
|
|
1340
|
+
autoCorrect: "off",
|
|
1341
|
+
autoCapitalize: "off",
|
|
1342
|
+
spellCheck: !1,
|
|
1343
|
+
"aria-label": "Search"
|
|
1344
|
+
}
|
|
1345
|
+
),
|
|
1346
|
+
S && /* @__PURE__ */ e(
|
|
1347
|
+
"button",
|
|
1348
|
+
{
|
|
1349
|
+
className: "mixpeek-search-clear",
|
|
1350
|
+
onClick: () => Y(""),
|
|
1351
|
+
"aria-label": "Clear search",
|
|
1352
|
+
type: "button",
|
|
1353
|
+
children: /* @__PURE__ */ l(
|
|
1354
|
+
"svg",
|
|
1355
|
+
{
|
|
1356
|
+
width: "16",
|
|
1357
|
+
height: "16",
|
|
1358
|
+
viewBox: "0 0 24 24",
|
|
1359
|
+
fill: "none",
|
|
1360
|
+
stroke: "currentColor",
|
|
1361
|
+
strokeWidth: "2",
|
|
1362
|
+
strokeLinecap: "round",
|
|
1363
|
+
strokeLinejoin: "round",
|
|
1364
|
+
children: [
|
|
1365
|
+
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1366
|
+
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1367
|
+
]
|
|
1368
|
+
}
|
|
1369
|
+
)
|
|
1370
|
+
}
|
|
1371
|
+
)
|
|
1372
|
+
] }) }),
|
|
1373
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-modal-body", children: [
|
|
1374
|
+
G && /* @__PURE__ */ e("div", { className: "mixpeek-error", role: "alert", children: G }),
|
|
1375
|
+
m && V && V.answer && /* @__PURE__ */ e("div", { className: "mixpeek-ai-answer", children: /* @__PURE__ */ e("div", { className: "mixpeek-ai-answer-text", children: V.answer }) }),
|
|
1376
|
+
K.length > 0 && /* @__PURE__ */ e("div", { className: "mixpeek-results-list", role: "listbox", children: K.map(
|
|
1377
|
+
(M, P) => _ ? /* @__PURE__ */ e("div", { role: "option", children: _(M, P) }, M.id || P) : /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
|
|
1378
|
+
"a",
|
|
1379
|
+
{
|
|
1380
|
+
className: "mixpeek-result-card",
|
|
1381
|
+
href: M.page_url,
|
|
1382
|
+
target: "_blank",
|
|
1383
|
+
rel: "noopener noreferrer",
|
|
1384
|
+
onClick: () => p == null ? void 0 : p(M, P),
|
|
1385
|
+
role: "option",
|
|
1386
|
+
children: /* @__PURE__ */ l("div", { className: "mixpeek-result-body", children: [
|
|
1387
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-result-title", children: M.title || "Untitled" }),
|
|
1388
|
+
M.content && /* @__PURE__ */ e("div", { className: "mixpeek-result-content", children: M.content.slice(0, 200) })
|
|
1389
|
+
] })
|
|
1390
|
+
}
|
|
1391
|
+
) }, M.id || P)
|
|
1392
|
+
) }),
|
|
1393
|
+
S.trim() && !q && K.length === 0 && !G && /* @__PURE__ */ l("div", { className: "mixpeek-zero-results", children: [
|
|
1394
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-zero-results-title", children: "No results found" }),
|
|
1395
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-zero-results-text", children: [
|
|
1396
|
+
"No results for “",
|
|
1397
|
+
S,
|
|
1398
|
+
"”"
|
|
1399
|
+
] })
|
|
1400
|
+
] })
|
|
1401
|
+
] }),
|
|
1402
|
+
h && /* @__PURE__ */ l("div", { className: "mixpeek-modal-footer", children: [
|
|
1403
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-modal-footer-left" }),
|
|
1404
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-modal-footer-right", children: /* @__PURE__ */ l(
|
|
1405
|
+
"a",
|
|
1406
|
+
{
|
|
1407
|
+
className: "mixpeek-powered-by",
|
|
1408
|
+
href: "https://mxp.co/searchkit",
|
|
1409
|
+
target: "_blank",
|
|
1410
|
+
rel: "noopener noreferrer",
|
|
1411
|
+
children: [
|
|
1412
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-powered-by-text", children: "Search by" }),
|
|
1413
|
+
/* @__PURE__ */ e("strong", { children: "Mixpeek" })
|
|
1414
|
+
]
|
|
1415
|
+
}
|
|
1416
|
+
) })
|
|
1417
|
+
] })
|
|
1418
|
+
] })
|
|
1419
|
+
}
|
|
1420
|
+
) }) : /* @__PURE__ */ e(oe.Provider, { value: de, children: /* @__PURE__ */ l(
|
|
1421
|
+
"div",
|
|
1422
|
+
{
|
|
1423
|
+
className: `mixpeek-search mixpeek-theme-${Q} ${A || ""}`,
|
|
1424
|
+
style: ce,
|
|
1425
|
+
"data-theme": Q,
|
|
1426
|
+
children: [
|
|
1427
|
+
/* @__PURE__ */ e(
|
|
1428
|
+
be,
|
|
1429
|
+
{
|
|
1430
|
+
onClick: re,
|
|
1431
|
+
placeholder: r,
|
|
1432
|
+
keyboardShortcut: c
|
|
1433
|
+
}
|
|
1434
|
+
),
|
|
1435
|
+
/* @__PURE__ */ e(
|
|
1436
|
+
Ie,
|
|
1437
|
+
{
|
|
1438
|
+
isOpen: O,
|
|
1439
|
+
onClose: ne,
|
|
1440
|
+
query: S,
|
|
1441
|
+
onQueryChange: Y,
|
|
1442
|
+
results: K,
|
|
1443
|
+
stages: H,
|
|
1444
|
+
isStreaming: ee,
|
|
1445
|
+
isLoading: q,
|
|
1446
|
+
error: G,
|
|
1447
|
+
aiAnswer: V,
|
|
1448
|
+
metadata: te,
|
|
1449
|
+
placeholder: r,
|
|
1450
|
+
showPoweredBy: h,
|
|
1451
|
+
enableShareLinks: o,
|
|
1452
|
+
enableAIAnswer: m,
|
|
1453
|
+
recentSearches: W,
|
|
1454
|
+
onClearRecent: E,
|
|
1455
|
+
onResultClick: p,
|
|
1456
|
+
renderResult: _,
|
|
1457
|
+
ctaConfig: x,
|
|
1458
|
+
theme: Q
|
|
1459
|
+
}
|
|
1460
|
+
)
|
|
1461
|
+
]
|
|
1462
|
+
}
|
|
1463
|
+
) });
|
|
1464
|
+
};
|
|
1465
|
+
function Ye(t) {
|
|
1466
|
+
const r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
|
|
1467
|
+
return r ? `${parseInt(r[1], 16)}, ${parseInt(r[2], 16)}, ${parseInt(r[3], 16)}` : "99, 102, 241";
|
|
1468
|
+
}
|
|
1469
|
+
const at = ke, Qe = ({
|
|
1470
|
+
config: t,
|
|
1471
|
+
value: r,
|
|
1472
|
+
onChange: n
|
|
1473
|
+
}) => {
|
|
1474
|
+
const { field: i, options: s, multiple: a } = t, c = (o) => a && Array.isArray(r) ? r.includes(o) : r === o, h = (o) => {
|
|
1475
|
+
if (a) {
|
|
1476
|
+
const m = Array.isArray(r) ? r : [];
|
|
1477
|
+
m.includes(o) ? n(i, m.filter((d) => d !== o)) : n(i, [...m, o]);
|
|
1478
|
+
} else
|
|
1479
|
+
n(i, r === o ? null : o);
|
|
1480
|
+
};
|
|
1481
|
+
return /* @__PURE__ */ e("div", { className: "mixpeek-facet-filter", children: s.map((o) => /* @__PURE__ */ l(
|
|
1482
|
+
"label",
|
|
1483
|
+
{
|
|
1484
|
+
className: `mixpeek-facet-filter__option${c(o.value) ? " mixpeek-facet-filter__option--active" : ""}`,
|
|
1485
|
+
children: [
|
|
1486
|
+
/* @__PURE__ */ e(
|
|
1487
|
+
"input",
|
|
1488
|
+
{
|
|
1489
|
+
type: "checkbox",
|
|
1490
|
+
className: "mixpeek-facet-filter__checkbox",
|
|
1491
|
+
checked: c(o.value),
|
|
1492
|
+
onChange: () => h(o.value)
|
|
1493
|
+
}
|
|
1494
|
+
),
|
|
1495
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-facet-filter__label", children: o.label }),
|
|
1496
|
+
o.count !== void 0 && /* @__PURE__ */ e("span", { className: "mixpeek-facet-filter__count", children: o.count })
|
|
1497
|
+
]
|
|
1498
|
+
},
|
|
1499
|
+
o.value
|
|
1500
|
+
)) });
|
|
1501
|
+
}, Ze = ({
|
|
1502
|
+
config: t,
|
|
1503
|
+
minValue: r,
|
|
1504
|
+
maxValue: n,
|
|
1505
|
+
onChange: i
|
|
1506
|
+
}) => {
|
|
1507
|
+
const { field: s, min: a, max: c, step: h = 1, unit: o = "" } = t, [m, d] = C(r ?? a), [p, v] = C(n ?? c), L = z(null);
|
|
1508
|
+
j(() => {
|
|
1509
|
+
d(r ?? a);
|
|
1510
|
+
}, [r, a]), j(() => {
|
|
1511
|
+
v(n ?? c);
|
|
1512
|
+
}, [n, c]);
|
|
1513
|
+
const _ = y(
|
|
1514
|
+
(x, b) => {
|
|
1515
|
+
L.current && clearTimeout(L.current), L.current = setTimeout(() => {
|
|
1516
|
+
i(`min_${s}`, x > a ? x : null), i(`max_${s}`, b < c ? b : null);
|
|
1517
|
+
}, 300);
|
|
1518
|
+
},
|
|
1519
|
+
[s, a, c, i]
|
|
1520
|
+
);
|
|
1521
|
+
j(() => () => {
|
|
1522
|
+
L.current && clearTimeout(L.current);
|
|
1523
|
+
}, []);
|
|
1524
|
+
const D = (x) => {
|
|
1525
|
+
const b = Number(x.target.value), w = Math.min(b, p - h);
|
|
1526
|
+
d(w), _(w, p);
|
|
1527
|
+
}, T = (x) => {
|
|
1528
|
+
const b = Number(x.target.value), w = Math.max(b, m + h);
|
|
1529
|
+
v(w), _(m, w);
|
|
1530
|
+
}, B = (x) => `${o}${x}`, A = (m - a) / (c - a) * 100, k = (p - a) / (c - a) * 100;
|
|
1531
|
+
return /* @__PURE__ */ l("div", { className: "mixpeek-range-filter", children: [
|
|
1532
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-range-filter__values", children: [
|
|
1533
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-range-filter__value", children: B(m) }),
|
|
1534
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-range-filter__separator", children: "–" }),
|
|
1535
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-range-filter__value", children: B(p) })
|
|
1536
|
+
] }),
|
|
1537
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-range-filter__track", children: [
|
|
1538
|
+
/* @__PURE__ */ e(
|
|
1539
|
+
"div",
|
|
1540
|
+
{
|
|
1541
|
+
className: "mixpeek-range-filter__fill",
|
|
1542
|
+
style: { left: `${A}%`, width: `${k - A}%` }
|
|
1543
|
+
}
|
|
1544
|
+
),
|
|
1545
|
+
/* @__PURE__ */ e(
|
|
1546
|
+
"input",
|
|
1547
|
+
{
|
|
1548
|
+
type: "range",
|
|
1549
|
+
className: "mixpeek-range-filter__input mixpeek-range-filter__input--min",
|
|
1550
|
+
min: a,
|
|
1551
|
+
max: c,
|
|
1552
|
+
step: h,
|
|
1553
|
+
value: m,
|
|
1554
|
+
onChange: D,
|
|
1555
|
+
"aria-label": `Minimum ${t.label}`
|
|
1556
|
+
}
|
|
1557
|
+
),
|
|
1558
|
+
/* @__PURE__ */ e(
|
|
1559
|
+
"input",
|
|
1560
|
+
{
|
|
1561
|
+
type: "range",
|
|
1562
|
+
className: "mixpeek-range-filter__input mixpeek-range-filter__input--max",
|
|
1563
|
+
min: a,
|
|
1564
|
+
max: c,
|
|
1565
|
+
step: h,
|
|
1566
|
+
value: p,
|
|
1567
|
+
onChange: T,
|
|
1568
|
+
"aria-label": `Maximum ${t.label}`
|
|
1569
|
+
}
|
|
1570
|
+
)
|
|
1571
|
+
] })
|
|
1572
|
+
] });
|
|
1573
|
+
}, et = ({
|
|
1574
|
+
config: t,
|
|
1575
|
+
value: r,
|
|
1576
|
+
onChange: n
|
|
1577
|
+
}) => {
|
|
1578
|
+
const [i, s] = C(r || ""), a = z(null);
|
|
1579
|
+
return j(() => {
|
|
1580
|
+
s(r || "");
|
|
1581
|
+
}, [r]), j(() => () => {
|
|
1582
|
+
a.current && clearTimeout(a.current);
|
|
1583
|
+
}, []), /* @__PURE__ */ l("div", { className: "mixpeek-smart-filter", children: [
|
|
1584
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-smart-filter__header", children: [
|
|
1585
|
+
/* @__PURE__ */ e(
|
|
1586
|
+
"svg",
|
|
1587
|
+
{
|
|
1588
|
+
className: "mixpeek-smart-filter__icon",
|
|
1589
|
+
width: "14",
|
|
1590
|
+
height: "14",
|
|
1591
|
+
viewBox: "0 0 24 24",
|
|
1592
|
+
fill: "none",
|
|
1593
|
+
stroke: "currentColor",
|
|
1594
|
+
strokeWidth: "2",
|
|
1595
|
+
strokeLinecap: "round",
|
|
1596
|
+
strokeLinejoin: "round",
|
|
1597
|
+
"aria-hidden": "true",
|
|
1598
|
+
children: /* @__PURE__ */ e("path", { d: "M12 2L9 9l-7 1 5 5-1.5 7L12 18l6.5 4L17 15l5-5-7-1z" })
|
|
1599
|
+
}
|
|
1600
|
+
),
|
|
1601
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-smart-filter__label", children: "AI Filter" })
|
|
1602
|
+
] }),
|
|
1603
|
+
/* @__PURE__ */ e(
|
|
1604
|
+
"input",
|
|
1605
|
+
{
|
|
1606
|
+
type: "text",
|
|
1607
|
+
className: "mixpeek-smart-filter__input",
|
|
1608
|
+
value: i,
|
|
1609
|
+
onChange: (h) => {
|
|
1610
|
+
const o = h.target.value;
|
|
1611
|
+
s(o), a.current && clearTimeout(a.current), a.current = setTimeout(() => {
|
|
1612
|
+
n("smart_filter", o || null);
|
|
1613
|
+
}, 500);
|
|
1614
|
+
},
|
|
1615
|
+
placeholder: t.placeholder || "Describe what you're looking for...",
|
|
1616
|
+
"aria-label": "Smart filter"
|
|
1617
|
+
}
|
|
1618
|
+
),
|
|
1619
|
+
/* @__PURE__ */ e("p", { className: "mixpeek-smart-filter__hint", children: "AI will interpret your description to filter results" })
|
|
1620
|
+
] });
|
|
1621
|
+
}, se = ({
|
|
1622
|
+
label: t,
|
|
1623
|
+
defaultOpen: r = !0,
|
|
1624
|
+
children: n
|
|
1625
|
+
}) => {
|
|
1626
|
+
const [i, s] = C(r);
|
|
1627
|
+
return /* @__PURE__ */ l("div", { className: "mixpeek-filter-section", children: [
|
|
1628
|
+
/* @__PURE__ */ l(
|
|
1629
|
+
"button",
|
|
1630
|
+
{
|
|
1631
|
+
className: "mixpeek-filter-section__header",
|
|
1632
|
+
onClick: () => s((a) => !a),
|
|
1633
|
+
type: "button",
|
|
1634
|
+
"aria-expanded": i,
|
|
1635
|
+
children: [
|
|
1636
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-filter-section__label", children: t }),
|
|
1637
|
+
/* @__PURE__ */ e(
|
|
1638
|
+
"svg",
|
|
1639
|
+
{
|
|
1640
|
+
className: `mixpeek-filter-section__chevron${i ? " mixpeek-filter-section__chevron--open" : ""}`,
|
|
1641
|
+
width: "12",
|
|
1642
|
+
height: "12",
|
|
1643
|
+
viewBox: "0 0 24 24",
|
|
1644
|
+
fill: "none",
|
|
1645
|
+
stroke: "currentColor",
|
|
1646
|
+
strokeWidth: "2",
|
|
1647
|
+
strokeLinecap: "round",
|
|
1648
|
+
strokeLinejoin: "round",
|
|
1649
|
+
"aria-hidden": "true",
|
|
1650
|
+
children: /* @__PURE__ */ e("polyline", { points: "9 18 15 12 9 6" })
|
|
1651
|
+
}
|
|
1652
|
+
)
|
|
1653
|
+
]
|
|
1654
|
+
}
|
|
1655
|
+
),
|
|
1656
|
+
i && /* @__PURE__ */ e("div", { className: "mixpeek-filter-section__body", children: n })
|
|
1657
|
+
] });
|
|
1658
|
+
}, st = ({
|
|
1659
|
+
config: t,
|
|
1660
|
+
filterInputs: r,
|
|
1661
|
+
onFilterChange: n,
|
|
1662
|
+
onClearAll: i,
|
|
1663
|
+
hasActiveFilters: s
|
|
1664
|
+
}) => /* @__PURE__ */ l("div", { className: "mixpeek-filter-panel", children: [
|
|
1665
|
+
/* @__PURE__ */ l("div", { className: "mixpeek-filter-panel__header", children: [
|
|
1666
|
+
/* @__PURE__ */ e("span", { className: "mixpeek-filter-panel__title", children: t.title || "Filters" }),
|
|
1667
|
+
s && i && /* @__PURE__ */ e(
|
|
1668
|
+
"button",
|
|
1669
|
+
{
|
|
1670
|
+
className: "mixpeek-filter-panel__clear",
|
|
1671
|
+
onClick: i,
|
|
1672
|
+
type: "button",
|
|
1673
|
+
children: "Clear all"
|
|
1674
|
+
}
|
|
1675
|
+
)
|
|
1676
|
+
] }),
|
|
1677
|
+
/* @__PURE__ */ e("div", { className: "mixpeek-filter-panel__body", children: t.filters.map((a, c) => {
|
|
1678
|
+
switch (a.type) {
|
|
1679
|
+
case "facet":
|
|
1680
|
+
return /* @__PURE__ */ e(se, { label: a.label, children: /* @__PURE__ */ e(
|
|
1681
|
+
Qe,
|
|
1682
|
+
{
|
|
1683
|
+
config: a,
|
|
1684
|
+
value: r[a.field],
|
|
1685
|
+
onChange: n
|
|
1686
|
+
}
|
|
1687
|
+
) }, a.field);
|
|
1688
|
+
case "range":
|
|
1689
|
+
return /* @__PURE__ */ e(se, { label: a.label, children: /* @__PURE__ */ e(
|
|
1690
|
+
Ze,
|
|
1691
|
+
{
|
|
1692
|
+
config: a,
|
|
1693
|
+
minValue: r[`min_${a.field}`],
|
|
1694
|
+
maxValue: r[`max_${a.field}`],
|
|
1695
|
+
onChange: n
|
|
1696
|
+
}
|
|
1697
|
+
) }, a.field);
|
|
1698
|
+
case "smart":
|
|
1699
|
+
return /* @__PURE__ */ e(
|
|
1700
|
+
se,
|
|
1701
|
+
{
|
|
1702
|
+
label: a.label || "Smart Filter",
|
|
1703
|
+
children: /* @__PURE__ */ e(
|
|
1704
|
+
et,
|
|
1705
|
+
{
|
|
1706
|
+
config: a,
|
|
1707
|
+
value: r.smart_filter,
|
|
1708
|
+
onChange: n
|
|
1709
|
+
}
|
|
1710
|
+
)
|
|
1711
|
+
},
|
|
1712
|
+
`smart-${c}`
|
|
1713
|
+
);
|
|
1714
|
+
default:
|
|
1715
|
+
return null;
|
|
1716
|
+
}
|
|
1717
|
+
}) })
|
|
1718
|
+
] });
|
|
1719
|
+
function ue() {
|
|
1720
|
+
if (typeof document > "u" || typeof window > "u") return;
|
|
1721
|
+
const t = document.querySelectorAll("script[data-project-key]");
|
|
1722
|
+
if (t.length === 0) return;
|
|
1723
|
+
const r = window, n = r.React, i = r.ReactDOM;
|
|
1724
|
+
if (!n || !i) {
|
|
1725
|
+
console.warn(
|
|
1726
|
+
"[@mixpeek/react-searchkit] Auto-init requires React and ReactDOM as globals. Include React before the SearchKit script, or use the npm package instead."
|
|
1727
|
+
);
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
t.forEach((s) => {
|
|
1731
|
+
var v;
|
|
1732
|
+
const a = s.getAttribute("data-project-key");
|
|
1733
|
+
if (!a) return;
|
|
1734
|
+
const c = s.getAttribute("data-theme") || "auto", h = s.getAttribute("data-placeholder") || void 0, o = s.getAttribute("data-container") || "mixpeek-search", m = s.getAttribute("data-accent-color") || void 0;
|
|
1735
|
+
let d = document.getElementById(o);
|
|
1736
|
+
d || (d = document.createElement("div"), d.id = o, (v = s.parentNode) == null || v.insertBefore(d, s));
|
|
1737
|
+
const p = {
|
|
1738
|
+
projectKey: a,
|
|
1739
|
+
theme: c
|
|
1740
|
+
};
|
|
1741
|
+
h && (p.placeholder = h), m && (p.accentColor = m), i.createRoot && i.createRoot(d).render(
|
|
1742
|
+
n.createElement(ke, p)
|
|
1743
|
+
);
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", ue) : setTimeout(ue, 0));
|
|
1747
|
+
export {
|
|
1748
|
+
we as AIAnswer,
|
|
1749
|
+
Qe as FacetFilter,
|
|
1750
|
+
st as FilterPanel,
|
|
1751
|
+
Be as IntentCTA,
|
|
1752
|
+
Fe as MixpeekClient,
|
|
1753
|
+
at as MixpeekSearch,
|
|
1754
|
+
Re as PoweredBy,
|
|
1755
|
+
Ze as RangeFilter,
|
|
1756
|
+
Me as ResultCard,
|
|
1757
|
+
be as SearchButton,
|
|
1758
|
+
Ne as SearchInput,
|
|
1759
|
+
ke as SearchKit,
|
|
1760
|
+
Ie as SearchModal,
|
|
1761
|
+
je as SearchResults,
|
|
1762
|
+
De as ShareLink,
|
|
1763
|
+
et as SmartFilter,
|
|
1764
|
+
Ke as ZeroResults,
|
|
1765
|
+
qe as useFilters,
|
|
1766
|
+
Je as useKeyboardShortcut,
|
|
1767
|
+
it as useMixpeekSearch,
|
|
1768
|
+
Ve as useRecentSearches,
|
|
1769
|
+
ze as useSearch,
|
|
1770
|
+
Xe as useSearchKit
|
|
1771
|
+
};
|