@cloudflare/ai-search-snippet 0.0.31 → 0.0.33

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.
@@ -1,7 +1,7 @@
1
- var P = Object.defineProperty;
2
- var O = (n, i, e) => i in n ? P(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var a = (n, i, e) => O(n, typeof i != "symbol" ? i + "" : i, e);
4
- const u = [
1
+ var U = Object.defineProperty;
2
+ var _ = (n, i, e) => i in n ? U(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var a = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
4
+ const g = [
5
5
  "Searching...",
6
6
  "Digging through results...",
7
7
  "Scanning the knowledge base...",
@@ -26,10 +26,17 @@ function h(n) {
26
26
  const i = document.createElement("div");
27
27
  return i.textContent = n, i.innerHTML;
28
28
  }
29
+ function q(n) {
30
+ try {
31
+ return decodeURI(n);
32
+ } catch {
33
+ return n;
34
+ }
35
+ }
29
36
  function E(n) {
30
37
  return new DOMParser().parseFromString(n, "text/html").documentElement.textContent || "";
31
38
  }
32
- function _(n) {
39
+ function O(n) {
33
40
  const i = new Date(n), t = (/* @__PURE__ */ new Date()).getTime() - i.getTime();
34
41
  if (t < 6e4)
35
42
  return "Just now";
@@ -48,7 +55,7 @@ function _(n) {
48
55
  minute: "2-digit"
49
56
  });
50
57
  }
51
- function q(n) {
58
+ function B(n) {
52
59
  return new Date(n).toLocaleDateString(void 0, {
53
60
  month: "short",
54
61
  day: "numeric"
@@ -79,34 +86,34 @@ function v(n, i) {
79
86
  function x(n) {
80
87
  if (!n)
81
88
  throw new Error("API URL is required");
82
- return new V(n);
89
+ return new K(n);
83
90
  }
84
91
  function w(n) {
85
92
  return n !== null && typeof n == "object" && !Array.isArray(n);
86
93
  }
87
- function B(...n) {
94
+ function R(...n) {
88
95
  const i = {};
89
96
  for (const e of n)
90
97
  if (e)
91
98
  for (const [t, s] of Object.entries(e)) {
92
99
  const r = i[t];
93
- w(r) && w(s) ? i[t] = B(r, s) : i[t] = s;
100
+ w(r) && w(s) ? i[t] = R(r, s) : i[t] = s;
94
101
  }
95
102
  return i;
96
103
  }
97
- function U(n, i) {
104
+ function D(n, i) {
98
105
  if (!w(i))
99
106
  return n;
100
107
  const e = new URLSearchParams();
101
- for (const [l, g] of Object.entries(i))
102
- g != null && e.append(l, String(g));
108
+ for (const [l, p] of Object.entries(i))
109
+ p != null && e.append(l, String(p));
103
110
  const t = e.toString();
104
111
  if (!t)
105
112
  return n;
106
113
  const s = n.indexOf("#"), r = s === -1 ? n : n.slice(0, s), o = s === -1 ? "" : n.slice(s), c = r.includes("?") ? "&" : "?";
107
114
  return `${r}${c}${t}${o}`;
108
115
  }
109
- function D(n) {
116
+ function j(n) {
110
117
  if (!w(n))
111
118
  return {};
112
119
  const i = {};
@@ -114,22 +121,22 @@ function D(n) {
114
121
  t != null && (i[e] = String(t));
115
122
  return i;
116
123
  }
117
- function j(n) {
124
+ function V(n) {
118
125
  return w(n) ? n : void 0;
119
126
  }
120
- class V {
127
+ class K {
121
128
  constructor(i) {
122
129
  a(this, "activeRequests", /* @__PURE__ */ new Map());
123
130
  a(this, "baseUrl");
124
131
  this.baseUrl = i.replace(/\/$/, "");
125
132
  }
126
133
  request(i, e, t, s) {
127
- const r = e === "search" ? "snippet-search" : "snippet-chat-completions", o = U(`${this.baseUrl}/${e}`, s?.queryParams);
134
+ const r = e === "search" ? "snippet-search" : "snippet-chat-completions", o = D(`${this.baseUrl}/${e}`, s?.queryParams);
128
135
  return fetch(o, {
129
136
  method: "POST",
130
- body: JSON.stringify(B(j(s?.body), i)),
137
+ body: JSON.stringify(R(V(s?.body), i)),
131
138
  headers: {
132
- ...D(s?.headers),
139
+ ...j(s?.headers),
133
140
  "Content-Type": "application/json",
134
141
  "cf-ai-search-source": r
135
142
  },
@@ -147,10 +154,10 @@ class V {
147
154
  {
148
155
  messages: [{ role: "user", content: i }],
149
156
  stream: !1,
150
- max_results: e.maxResults ?? 30,
151
157
  ai_search_options: {
152
158
  retrieval: {
153
- metadata_only: !0
159
+ metadata_only: !0,
160
+ max_num_results: e.maxResults ?? 30
154
161
  }
155
162
  }
156
163
  },
@@ -189,7 +196,7 @@ class V {
189
196
  messages: [{ role: "user", content: i }],
190
197
  stream: !0,
191
198
  ...e.maxResults !== void 0 && {
192
- max_results: e.maxResults
199
+ max_num_results: e.maxResults
193
200
  }
194
201
  },
195
202
  "ai-search",
@@ -201,13 +208,13 @@ class V {
201
208
  if (!o.body)
202
209
  throw new Error("Response body is empty");
203
210
  let c = "";
204
- const l = o.body.getReader(), g = new TextDecoder();
211
+ const l = o.body.getReader(), p = new TextDecoder();
205
212
  for (; ; ) {
206
- const { done: p, value: S } = await l.read();
207
- if (p)
213
+ const { done: u, value: S } = await l.read();
214
+ if (u)
208
215
  break;
209
- const N = g.decode(S, { stream: !0 });
210
- c += N;
216
+ const P = p.decode(S, { stream: !0 });
217
+ c += P;
211
218
  }
212
219
  yield {
213
220
  type: "result",
@@ -215,7 +222,7 @@ class V {
215
222
  title: "",
216
223
  description: c.replaceAll("data: ", "").trim().split(`
217
224
 
218
- `).map((p) => JSON.parse(p)).map((p) => p.response).join(""),
225
+ `).map((u) => JSON.parse(u)).map((u) => u.response).join(""),
219
226
  url: "",
220
227
  metadata: {}
221
228
  };
@@ -275,10 +282,10 @@ class V {
275
282
  return `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
276
283
  }
277
284
  }
278
- const K = `<svg width="32" height="10" viewBox="0 0 412 186" xmlns="http://www.w3.org/2000/svg" aria-label="Cloudflare" role="img">
285
+ const G = `<svg width="32" height="10" viewBox="0 0 412 186" xmlns="http://www.w3.org/2000/svg" aria-label="Cloudflare" role="img">
279
286
  <path fill="#f38020" d="m280.8395,183.31456c11,-26 -4,-38 -19,-38l-148,-2c-4,0 -4,-6 1,-7l150,-2c17,-1 37,-15 43,-33c0,0 10,-21 9,-24a97,97 0 0 0 -187,-11c-38,-25 -78,9 -69,46c-48,3 -65,46 -60,72c0,1 1,2 3,2l274,0c1,0 3,-1 3,-3z"/>
280
287
  <path fill="#faae40" d="m330.8395,81.31456c-4,0 -6,-1 -7,1l-5,21c-5,16 3,30 20,31l32,2c4,0 4,6 -1,7l-33,1c-36,4 -46,39 -46,39c0,2 0,3 2,3l113,0l3,-2a81,81 0 0 0 -78,-103"/>
281
- </svg>`, G = "https://workers.cloudflare.com/product/ai-search", k = `Powered by <a href="${G}" target="_blank" rel="noopener noreferrer">Cloudflare AI Search ${K}</a>`, R = `
288
+ </svg>`, F = "https://workers.cloudflare.com/product/ai-search", k = `Powered by <a href="${F}" target="_blank" rel="noopener noreferrer">Cloudflare AI Search ${G}</a>`, H = `
282
289
  /* Chat container */
283
290
  .chat-container {
284
291
  display: flex;
@@ -1030,17 +1037,17 @@ const K = `<svg width="32" height="10" viewBox="0 0 412 186" xmlns="http://www.w
1030
1037
  text-align: center;
1031
1038
  }
1032
1039
  `;
1033
- function F(n) {
1040
+ function Y(n) {
1034
1041
  let i = n;
1035
- i = Y(i), i = i.replace(/```([\s\S]*?)```/g, (o, c) => `<pre><code>${c.trim()}</code></pre>`);
1042
+ i = J(i), i = i.replace(/```([\s\S]*?)```/g, (o, c) => `<pre><code>${c.trim()}</code></pre>`);
1036
1043
  const e = i.split(`
1037
1044
  `), t = [];
1038
1045
  let s = !1, r = "";
1039
1046
  for (let o = 0; o < e.length; o++) {
1040
1047
  const c = e[o], l = c.match(/^(#{1,6})\s+(.+)$/);
1041
1048
  if (l) {
1042
- const p = l[1].length, S = l[2];
1043
- t.push(`<h${p}>${f(S)}</h${p}>`);
1049
+ const u = l[1].length, S = l[2];
1050
+ t.push(`<h${u}>${f(S)}</h${u}>`);
1044
1051
  continue;
1045
1052
  }
1046
1053
  if (c.match(/^---+$/)) {
@@ -1048,13 +1055,13 @@ function F(n) {
1048
1055
  continue;
1049
1056
  }
1050
1057
  if (c.match(/^>\s+/)) {
1051
- const p = c.replace(/^>\s+/, "");
1052
- t.push(`<blockquote>${f(p)}</blockquote>`);
1058
+ const u = c.replace(/^>\s+/, "");
1059
+ t.push(`<blockquote>${f(u)}</blockquote>`);
1053
1060
  continue;
1054
1061
  }
1055
- const g = c.match(/^[-*]\s+(.+)$/);
1056
- if (g) {
1057
- (!s || r !== "ul") && (s && t.push(`</${r}>`), t.push("<ul>"), s = !0, r = "ul"), t.push(`<li>${f(g[1])}</li>`);
1062
+ const p = c.match(/^[-*]\s+(.+)$/);
1063
+ if (p) {
1064
+ (!s || r !== "ul") && (s && t.push(`</${r}>`), t.push("<ul>"), s = !0, r = "ul"), t.push(`<li>${f(p[1])}</li>`);
1058
1065
  continue;
1059
1066
  }
1060
1067
  const b = c.match(/^\d+\.\s+(.+)$/);
@@ -1078,7 +1085,7 @@ function f(n) {
1078
1085
  '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
1079
1086
  ), i;
1080
1087
  }
1081
- function Y(n) {
1088
+ function J(n) {
1082
1089
  const i = {
1083
1090
  "&": "&amp;",
1084
1091
  "<": "&lt;",
@@ -1088,7 +1095,7 @@ function Y(n) {
1088
1095
  };
1089
1096
  return n.replace(/[&<>"']/g, (e) => i[e] || e);
1090
1097
  }
1091
- class H {
1098
+ class N {
1092
1099
  constructor(i, e, t) {
1093
1100
  a(this, "container");
1094
1101
  a(this, "client");
@@ -1259,11 +1266,11 @@ class H {
1259
1266
  <div class="chat-message-avatar">${s}</div>
1260
1267
  <div class="chat-message-content">
1261
1268
  <div class="chat-message-bubble">
1262
- ${i.content ? `<div class="chat-message-text">${F(i.content)}</div>` : ""}
1263
- ${e ? `<div class="chat-streaming"><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="loading-text">${u[this.loadingMessageIndex]}</span></div>` : ""}
1269
+ ${i.content ? `<div class="chat-message-text">${Y(i.content)}</div>` : ""}
1270
+ ${e ? `<div class="chat-streaming"><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="loading-text">${g[this.loadingMessageIndex]}</span></div>` : ""}
1264
1271
  </div>
1265
1272
  <div class="chat-message-metadata">
1266
- <span class="chat-message-time">${_(i.timestamp)}</span>
1273
+ <span class="chat-message-time">${O(i.timestamp)}</span>
1267
1274
  </div>
1268
1275
  </div>
1269
1276
  </div>
@@ -1284,8 +1291,8 @@ class H {
1284
1291
  this.isStreaming = i, this.inputElement && (this.inputElement.disabled = i), this.sendButton && (this.sendButton.disabled = i, this.sendButton.innerHTML = i ? '<div class="loading"></div>' : "<span>Send</span>"), i ? this.startLoadingMessages() : this.clearLoadingMessages();
1285
1292
  }
1286
1293
  startLoadingMessages() {
1287
- this.loadingMessageIndex = Math.floor(Math.random() * u.length), this.loadingMessageInterval = setInterval(() => {
1288
- this.loadingMessageIndex = (this.loadingMessageIndex + 1) % u.length, this.isStreaming && this.renderMessages(!0);
1294
+ this.loadingMessageIndex = Math.floor(Math.random() * g.length), this.loadingMessageInterval = setInterval(() => {
1295
+ this.loadingMessageIndex = (this.loadingMessageIndex + 1) % g.length, this.isStreaming && this.renderMessages(!0);
1289
1296
  }, 2500);
1290
1297
  }
1291
1298
  clearLoadingMessages() {
@@ -1317,7 +1324,7 @@ class H {
1317
1324
  }
1318
1325
  }
1319
1326
  const L = "chat-bubble-snippet";
1320
- class J extends HTMLElement {
1327
+ class W extends HTMLElement {
1321
1328
  constructor() {
1322
1329
  super();
1323
1330
  a(this, "shadow");
@@ -1368,7 +1375,7 @@ class J extends HTMLElement {
1368
1375
  render() {
1369
1376
  const e = document.createElement("style");
1370
1377
  e.textContent = `${C}
1371
- ${R}
1378
+ ${H}
1372
1379
  ${this.getBubbleStyles()}`, this.container = document.createElement("div"), this.container.className = "chat-bubble-widget", this.container.innerHTML = this.getBaseHTML(), this.shadow.innerHTML = "", this.shadow.appendChild(e), this.shadow.appendChild(this.container), this.attachEventListeners();
1373
1380
  }
1374
1381
  getBubbleStyles() {
@@ -1588,7 +1595,7 @@ ${this.getBubbleStyles()}`, this.container = document.createElement("div"), this
1588
1595
  return;
1589
1596
  }
1590
1597
  const t = this.getProps();
1591
- this.chatView = new H(e, this.client, t);
1598
+ this.chatView = new N(e, this.client, t);
1592
1599
  }
1593
1600
  updateTheme(e) {
1594
1601
  (e === "light" || e === "dark" ? e : null) === null && this.hasAttribute("theme") && this.getAttribute("theme") !== "auto" && this.removeAttribute("theme");
@@ -1607,9 +1614,9 @@ ${this.getBubbleStyles()}`, this.container = document.createElement("div"), this
1607
1614
  return this.chatView?.getMessages() || [];
1608
1615
  }
1609
1616
  }
1610
- customElements.get(L) || customElements.define(L, J);
1617
+ customElements.get(L) || customElements.define(L, W);
1611
1618
  const I = "chat-page-snippet", z = "chat-page-sessions";
1612
- class W extends HTMLElement {
1619
+ class X extends HTMLElement {
1613
1620
  constructor() {
1614
1621
  super();
1615
1622
  a(this, "shadow");
@@ -1662,7 +1669,7 @@ class W extends HTMLElement {
1662
1669
  render() {
1663
1670
  const e = document.createElement("style");
1664
1671
  e.textContent = `${C}
1665
- ${R}
1672
+ ${H}
1666
1673
  ${this.getPageStyles()}`, this.container = document.createElement("div"), this.container.className = "chat-page-container", this.container.innerHTML = this.getBaseHTML(), this.shadow.innerHTML = "", this.shadow.appendChild(e), this.shadow.appendChild(this.container), this.attachEventListeners();
1667
1674
  }
1668
1675
  getPageStyles() {
@@ -2006,7 +2013,7 @@ ${this.getPageStyles()}`, this.container = document.createElement("div"), this.c
2006
2013
  }
2007
2014
  if (!e) return;
2008
2015
  const t = this.getProps();
2009
- if (this.chatView = new H(e, this.client, t), this.sessions.length === 0)
2016
+ if (this.chatView = new N(e, this.client, t), this.sessions.length === 0)
2010
2017
  this.createNewChat();
2011
2018
  else {
2012
2019
  const s = this.sessions[0];
@@ -2147,8 +2154,8 @@ ${this.getPageStyles()}`, this.container = document.createElement("div"), this.c
2147
2154
  return this.sessions.find((e) => e.id === this.currentSessionId) || null;
2148
2155
  }
2149
2156
  }
2150
- customElements.get(I) || customElements.define(I, W);
2151
- const X = `
2157
+ customElements.get(I) || customElements.define(I, X);
2158
+ const Z = `
2152
2159
  /* Search view states */
2153
2160
  .search-view {
2154
2161
  transition: var(--search-snippet-transition-slow);
@@ -2518,8 +2525,8 @@ a.search-result-item:focus-visible {
2518
2525
  border-radius: 2px;
2519
2526
  font-weight: var(--search-snippet-font-weight-medium);
2520
2527
  }
2521
- `, A = "search-bar-snippet", Z = 10, Q = 100;
2522
- class ee extends HTMLElement {
2528
+ `, A = "search-bar-snippet", Q = 10, ee = 100;
2529
+ class te extends HTMLElement {
2523
2530
  constructor() {
2524
2531
  super();
2525
2532
  a(this, "shadow");
@@ -2610,7 +2617,7 @@ class ee extends HTMLElement {
2610
2617
  );
2611
2618
  const s = document.createElement("style");
2612
2619
  s.textContent = `${C}
2613
- ${X}`, this.container = document.createElement("div"), this.container.className = "container", this.container.innerHTML = `
2620
+ ${Z}`, this.container = document.createElement("div"), this.container.className = "container", this.container.innerHTML = `
2614
2621
  <div class="search-view">
2615
2622
  <div class="search-input-wrapper">
2616
2623
  <svg xmlns="http://www.w3.org/2000/svg" class="search-icon" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>
@@ -2659,9 +2666,9 @@ ${X}`, this.container = document.createElement("div"), this.container.className
2659
2666
  try {
2660
2667
  const t = await this.client.search(e, {
2661
2668
  signal: this.currentSearchController.signal,
2662
- maxResults: Q,
2669
+ maxResults: ee,
2663
2670
  request: this.getRequestOptions()
2664
- }), s = this.getProps(), r = t.slice(0, s.maxResults || Z);
2671
+ }), s = this.getProps(), r = t.slice(0, s.maxResults || Q);
2665
2672
  this.displayResults(r, e, t.length);
2666
2673
  } catch (t) {
2667
2674
  if (t.name === "AbortError")
@@ -2677,7 +2684,7 @@ ${X}`, this.container = document.createElement("div"), this.container.className
2677
2684
  this.showNoResultsState(t);
2678
2685
  return;
2679
2686
  }
2680
- const r = this.getProps(), o = r.hideBranding ? "" : `<div class="powered-by-inline">${k}</div>`, c = s > e.length, l = c ? `Showing ${e.length} of ${s} results` : `Found ${s} result${s === 1 ? "" : "s"}`, g = r.seeMore && c ? `<div class="search-footer">
2687
+ const r = this.getProps(), o = r.hideBranding ? "" : `<div class="powered-by-inline">${k}</div>`, c = s > e.length, l = c ? `Showing ${e.length} of ${s} results` : `Found ${s} result${s === 1 ? "" : "s"}`, p = r.seeMore && c ? `<div class="search-footer">
2681
2688
  <a href="${h(r.seeMore + encodeURIComponent(t))}" class="search-see-more">
2682
2689
  <span>See more results</span>
2683
2690
  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
@@ -2690,16 +2697,16 @@ ${X}`, this.container = document.createElement("div"), this.container.className
2690
2697
  ${o}
2691
2698
  </div>
2692
2699
  <div class="search-results">
2693
- ${e.map((p) => this.renderResult(p)).join("")}
2700
+ ${e.map((u) => this.renderResult(u)).join("")}
2694
2701
  </div>
2695
- ${g}
2702
+ ${p}
2696
2703
  `;
2697
2704
  this.resultsContainer.innerHTML = b, this.attachResultHandlers();
2698
2705
  }
2699
2706
  renderResult(e) {
2700
- const t = this.getProps(), s = t.hideThumbnails ? "" : this.renderResultImage(e.image, e.title), r = e.url ? h(e.url) : "#", o = t.showDate && e.timestamp !== void 0 ? `<div class="search-result-date">${h(q(e.timestamp))}</div>` : "", c = t.showUrl && e.url || o ? `<div class="search-result-metadata">
2701
- ${t.showUrl && e.url ? `<span class="search-result-url">${h(e.url)}</span>` : '<span class="search-result-url search-result-url-empty"></span>'}
2702
- ${o}
2707
+ const t = this.getProps(), s = t.hideThumbnails ? "" : this.renderResultImage(e.image, e.title), r = e.url ? h(e.url) : "#", o = e.url ? h(q(e.url)) : "", c = t.showDate && e.timestamp !== void 0 ? `<div class="search-result-date">${h(B(e.timestamp))}</div>` : "", l = t.showUrl && e.url || c ? `<div class="search-result-metadata">
2708
+ ${t.showUrl && e.url ? `<span class="search-result-url">${o}</span>` : '<span class="search-result-url search-result-url-empty"></span>'}
2709
+ ${c}
2703
2710
  </div>` : "";
2704
2711
  return `
2705
2712
  <a href="${r}" class="search-result-item" data-result-id="${h(e.url || "")}">
@@ -2707,7 +2714,7 @@ ${X}`, this.container = document.createElement("div"), this.container.className
2707
2714
  <div class="search-result-content">
2708
2715
  <div class="search-result-title">${h(e.title || "")}</div>
2709
2716
  <div class="search-result-snippet">${h(e.description || "")}</div>
2710
- ${c}
2717
+ ${l}
2711
2718
  </div>
2712
2719
  </a>
2713
2720
  `;
@@ -2752,18 +2759,18 @@ ${X}`, this.container = document.createElement("div"), this.container.className
2752
2759
  });
2753
2760
  }
2754
2761
  showLoadingState() {
2755
- this.resultsContainer && (this.clearLoadingInterval(), this.loadingMessageIndex = Math.floor(Math.random() * u.length), this.resultsContainer.innerHTML = `
2762
+ this.resultsContainer && (this.clearLoadingInterval(), this.loadingMessageIndex = Math.floor(Math.random() * g.length), this.resultsContainer.innerHTML = `
2756
2763
  <div class="search-loading">
2757
2764
  <div class="loading" aria-label="Loading"></div>
2758
- <div class="loading-text loading-text-animate">${u[this.loadingMessageIndex]}</div>
2765
+ <div class="loading-text loading-text-animate">${g[this.loadingMessageIndex]}</div>
2759
2766
  </div>
2760
2767
  `, this.startLoadingInterval());
2761
2768
  }
2762
2769
  startLoadingInterval() {
2763
2770
  this.loadingMessageInterval = setInterval(() => {
2764
- this.loadingMessageIndex = (this.loadingMessageIndex + 1) % u.length;
2771
+ this.loadingMessageIndex = (this.loadingMessageIndex + 1) % g.length;
2765
2772
  const e = this.resultsContainer?.querySelector(".loading-text");
2766
- e && (e.classList.remove("loading-text-animate"), e.offsetWidth, e.textContent = u[this.loadingMessageIndex], e.classList.add("loading-text-animate"));
2773
+ e && (e.classList.remove("loading-text-animate"), e.offsetWidth, e.textContent = g[this.loadingMessageIndex], e.classList.add("loading-text-animate"));
2767
2774
  }, 2500);
2768
2775
  }
2769
2776
  clearLoadingInterval() {
@@ -2819,8 +2826,8 @@ ${X}`, this.container = document.createElement("div"), this.container.className
2819
2826
  await this.performSearch(e);
2820
2827
  }
2821
2828
  }
2822
- customElements.get(A) || customElements.define(A, ee);
2823
- const te = `
2829
+ customElements.get(A) || customElements.define(A, te);
2830
+ const se = `
2824
2831
  /* Modal backdrop */
2825
2832
  .modal-backdrop {
2826
2833
  position: fixed;
@@ -3257,8 +3264,8 @@ a.modal-result-item:focus-visible {
3257
3264
  .modal-container.open {
3258
3265
  animation: modal-slide-in var(--search-snippet-transition) ease-out;
3259
3266
  }
3260
- `, T = "search-modal-snippet", se = 10, ie = 100;
3261
- class re extends HTMLElement {
3267
+ `, T = "search-modal-snippet", ie = 10, re = 100;
3268
+ class ae extends HTMLElement {
3262
3269
  constructor() {
3263
3270
  super();
3264
3271
  a(this, "shadow");
@@ -3360,7 +3367,7 @@ class re extends HTMLElement {
3360
3367
  );
3361
3368
  const s = document.createElement("style");
3362
3369
  s.textContent = `${C}
3363
- ${te}`;
3370
+ ${se}`;
3364
3371
  const r = e.hideBranding ? "" : `<div class="powered-by-inline">${k}</div>`, o = document.createElement("div");
3365
3372
  o.innerHTML = `
3366
3373
  <div class="modal-backdrop" role="presentation"></div>
@@ -3474,10 +3481,10 @@ ${te}`;
3474
3481
  try {
3475
3482
  const t = await this.client.search(e, {
3476
3483
  signal: this.currentSearchController.signal,
3477
- maxResults: ie,
3484
+ maxResults: re,
3478
3485
  request: this.getRequestOptions()
3479
3486
  }), s = this.getProps();
3480
- this.results = t.slice(0, s.maxResults || se), this.activeIndex = this.results.length > 0 ? 0 : -1, this.displayResults(this.results, e, t.length);
3487
+ this.results = t.slice(0, s.maxResults || ie), this.activeIndex = this.results.length > 0 ? 0 : -1, this.displayResults(this.results, e, t.length);
3481
3488
  } catch (t) {
3482
3489
  if (t.name === "AbortError")
3483
3490
  return;
@@ -3492,16 +3499,16 @@ ${te}`;
3492
3499
  this.showNoResultsState(t);
3493
3500
  return;
3494
3501
  }
3495
- const r = this.getProps(), o = e.map((b, p) => this.renderResult(b, p)).join(""), c = s > e.length, l = c ? `Showing ${e.length} of ${s} results` : `${s} result${s === 1 ? "" : "s"}`, g = r.seeMore && c ? `<a href="${h(r.seeMore + encodeURIComponent(t))}" class="modal-see-more">
3502
+ const r = this.getProps(), o = e.map((b, u) => this.renderResult(b, u)).join(""), c = s > e.length, l = c ? `Showing ${e.length} of ${s} results` : `${s} result${s === 1 ? "" : "s"}`, p = r.seeMore && c ? `<a href="${h(r.seeMore + encodeURIComponent(t))}" class="modal-see-more">
3496
3503
  <span>See more results</span>
3497
3504
  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
3498
3505
  </a>` : "";
3499
- this.resultsContainer.innerHTML = o + g, this.footerCount && (this.footerCount.textContent = l), this.inputElement && this.inputElement.setAttribute("aria-expanded", "true"), this.attachResultHandlers(), this.updateActiveResult();
3506
+ this.resultsContainer.innerHTML = o + p, this.footerCount && (this.footerCount.textContent = l), this.inputElement && this.inputElement.setAttribute("aria-expanded", "true"), this.attachResultHandlers(), this.updateActiveResult();
3500
3507
  }
3501
3508
  renderResult(e, t) {
3502
- const s = this.getProps(), r = s.hideThumbnails ? "" : this.renderResultImage(e.image, e.title), o = e.url ? h(e.url) : "#", c = s.showDate && e.timestamp !== void 0 ? `<div class="modal-result-date">${h(q(e.timestamp))}</div>` : "", l = s.showUrl && e.url || c ? `<div class="modal-result-metadata">
3503
- ${s.showUrl && e.url ? `<span class="modal-result-url">${h(e.url)}</span>` : '<span class="modal-result-url modal-result-url-empty"></span>'}
3504
- ${c}
3509
+ const s = this.getProps(), r = s.hideThumbnails ? "" : this.renderResultImage(e.image, e.title), o = e.url ? h(e.url) : "#", c = e.url ? h(q(e.url)) : "", l = s.showDate && e.timestamp !== void 0 ? `<div class="modal-result-date">${h(B(e.timestamp))}</div>` : "", p = s.showUrl && e.url || l ? `<div class="modal-result-metadata">
3510
+ ${s.showUrl && e.url ? `<span class="modal-result-url">${c}</span>` : '<span class="modal-result-url modal-result-url-empty"></span>'}
3511
+ ${l}
3505
3512
  </div>` : "";
3506
3513
  return `
3507
3514
  <a
@@ -3518,7 +3525,7 @@ ${te}`;
3518
3525
  <div class="modal-result-content">
3519
3526
  <div class="modal-result-title">${h(e.title || "")}</div>
3520
3527
  ${e.description ? `<div class="modal-result-description">${h(e.description)}</div>` : ""}
3521
- ${l}
3528
+ ${p}
3522
3529
  </div>
3523
3530
  </a>
3524
3531
  `;
@@ -3579,18 +3586,18 @@ ${te}`;
3579
3586
  this.clearLoadingInterval(), this.resultsContainer && (this.resultsContainer.innerHTML = this.renderEmptyState(), this.footerCount && (this.footerCount.textContent = ""), this.inputElement && this.inputElement.setAttribute("aria-expanded", "false"));
3580
3587
  }
3581
3588
  showLoadingState() {
3582
- this.resultsContainer && (this.clearLoadingInterval(), this.loadingMessageIndex = Math.floor(Math.random() * u.length), this.resultsContainer.innerHTML = `
3589
+ this.resultsContainer && (this.clearLoadingInterval(), this.loadingMessageIndex = Math.floor(Math.random() * g.length), this.resultsContainer.innerHTML = `
3583
3590
  <div class="modal-loading">
3584
3591
  <div class="loading" aria-label="Loading"></div>
3585
- <div class="loading-text loading-text-animate">${u[this.loadingMessageIndex]}</div>
3592
+ <div class="loading-text loading-text-animate">${g[this.loadingMessageIndex]}</div>
3586
3593
  </div>
3587
- `, this.footerCount && (this.footerCount.textContent = u[this.loadingMessageIndex]), this.startLoadingInterval());
3594
+ `, this.footerCount && (this.footerCount.textContent = g[this.loadingMessageIndex]), this.startLoadingInterval());
3588
3595
  }
3589
3596
  startLoadingInterval() {
3590
3597
  this.loadingMessageInterval = setInterval(() => {
3591
- this.loadingMessageIndex = (this.loadingMessageIndex + 1) % u.length;
3598
+ this.loadingMessageIndex = (this.loadingMessageIndex + 1) % g.length;
3592
3599
  const e = this.resultsContainer?.querySelector(".loading-text");
3593
- e && (e.classList.remove("loading-text-animate"), e.offsetWidth, e.textContent = u[this.loadingMessageIndex], e.classList.add("loading-text-animate")), this.footerCount && (this.footerCount.textContent = u[this.loadingMessageIndex]);
3600
+ e && (e.classList.remove("loading-text-animate"), e.offsetWidth, e.textContent = g[this.loadingMessageIndex], e.classList.add("loading-text-animate")), this.footerCount && (this.footerCount.textContent = g[this.loadingMessageIndex]);
3594
3601
  }, 2500);
3595
3602
  }
3596
3603
  clearLoadingInterval() {
@@ -3681,13 +3688,13 @@ ${te}`;
3681
3688
  return this.isOpen;
3682
3689
  }
3683
3690
  }
3684
- customElements.get(T) || customElements.define(T, re);
3691
+ customElements.get(T) || customElements.define(T, ae);
3685
3692
  export {
3686
- V as AISearchClient,
3687
- J as ChatBubbleSnippet,
3688
- W as ChatPageSnippet,
3689
- ee as SearchBarSnippet,
3690
- re as SearchModalSnippet,
3691
- ee as default
3693
+ K as AISearchClient,
3694
+ W as ChatBubbleSnippet,
3695
+ X as ChatPageSnippet,
3696
+ te as SearchBarSnippet,
3697
+ ae as SearchModalSnippet,
3698
+ te as default
3692
3699
  };
3693
3700
  //# sourceMappingURL=search-snippet.es.js.map