@burdenoff/website-sdk 2026.829.5 → 2026.829.7

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,4 +1,4 @@
1
- export { D as DEFAULT_EXPLORE_EXAMPLE_PROMPTS, E as ExploreChatError, a as ExploreChatErrorKind, b as ExploreChatPhase, F as FALLBACK_EXPLORE_LIMITS, U as UseExploreChatOptions, c as UseExploreChatResult, d as classifyExploreError, u as useExploreChat } from '../use-explore-chat-B-E7jN1H.mjs';
1
+ export { D as DEFAULT_EXPLORE_EXAMPLE_PROMPTS, E as ExploreChatError, a as ExploreChatErrorKind, b as ExploreChatPhase, F as FALLBACK_EXPLORE_LIMITS, U as UseExploreChatOptions, c as UseExploreChatResult, d as classifyExploreError, u as useExploreChat } from '../use-explore-chat-BzXCz2UM.mjs';
2
2
 
3
3
  interface UseSpeechInputOptions {
4
4
  /** Receives settled text as it is recognised. Append it to the draft. */
@@ -1,4 +1,4 @@
1
- export { D as DEFAULT_EXPLORE_EXAMPLE_PROMPTS, E as ExploreChatError, a as ExploreChatErrorKind, b as ExploreChatPhase, F as FALLBACK_EXPLORE_LIMITS, U as UseExploreChatOptions, c as UseExploreChatResult, d as classifyExploreError, u as useExploreChat } from '../use-explore-chat-B-E7jN1H.js';
1
+ export { D as DEFAULT_EXPLORE_EXAMPLE_PROMPTS, E as ExploreChatError, a as ExploreChatErrorKind, b as ExploreChatPhase, F as FALLBACK_EXPLORE_LIMITS, U as UseExploreChatOptions, c as UseExploreChatResult, d as classifyExploreError, u as useExploreChat } from '../use-explore-chat-BzXCz2UM.js';
2
2
 
3
3
  interface UseSpeechInputOptions {
4
4
  /** Receives settled text as it is recognised. Append it to the draft. */
@@ -254,6 +254,12 @@ var EXPLORE_MESSAGE_FIELDS = (
254
254
  }
255
255
  followUps
256
256
  answered
257
+ attachments {
258
+ name
259
+ mimeType
260
+ size
261
+ textExtracted
262
+ }
257
263
  errorCode
258
264
  createdAt
259
265
  completedAt
@@ -339,6 +345,16 @@ var CREATE_EXPLORE_SHARE_LINK_MUTATION = (
339
345
  }
340
346
  `
341
347
  );
348
+ var EXPLORE_SHARED_CONVERSATION_QUERY = (
349
+ /* GraphQL */
350
+ `
351
+ query ExploreSharedConversation($shareToken: String!) {
352
+ exploreSharedConversation(shareToken: $shareToken) {
353
+ ${EXPLORE_MESSAGE_FIELDS}
354
+ }
355
+ }
356
+ `
357
+ );
342
358
 
343
359
  // src/data/products.ts
344
360
  var ECOSYSTEM_PRODUCTS = [
@@ -789,6 +805,14 @@ function readPersisted(key) {
789
805
  return null;
790
806
  }
791
807
  }
808
+ function readShareToken() {
809
+ if (typeof window === "undefined") return null;
810
+ try {
811
+ return new URL(window.location.href).searchParams.get("c");
812
+ } catch {
813
+ return null;
814
+ }
815
+ }
792
816
  function visibleText(message) {
793
817
  return message.content || message.partialContent || "";
794
818
  }
@@ -827,10 +851,18 @@ function useExploreChat(options = {}) {
827
851
  const pollGenerationRef = react.useRef(0);
828
852
  const pollTimerRef = react.useRef(null);
829
853
  const conversationTokenRef = react.useRef(null);
854
+ const shareTokenRef = react.useRef(void 0);
855
+ if (shareTokenRef.current === void 0) {
856
+ shareTokenRef.current = readShareToken();
857
+ }
858
+ const isSharedView = shareTokenRef.current !== null;
830
859
  const catalogRef = react.useRef(fallbackCatalog);
831
860
  const turnCountRef = react.useRef(0);
832
861
  const focusProductRef = react.useRef(null);
833
862
  const lastSentTextRef = react.useRef(null);
863
+ const lastSentAttachmentsRef = react.useRef(
864
+ []
865
+ );
834
866
  const inFlightRef = react.useRef(false);
835
867
  catalogRef.current = catalog;
836
868
  const clearPollTimer = react.useCallback(() => {
@@ -855,6 +887,43 @@ function useExploreChat(options = {}) {
855
887
  };
856
888
  }, []);
857
889
  react.useEffect(() => {
890
+ const shareToken = shareTokenRef.current;
891
+ if (!shareToken) return;
892
+ let cancelled = false;
893
+ setHydrated(true);
894
+ void client.query(
895
+ EXPLORE_SHARED_CONVERSATION_QUERY,
896
+ { shareToken },
897
+ { cache: false }
898
+ ).then((res) => {
899
+ if (cancelled || !mountedRef.current) return;
900
+ const shared = res?.data?.exploreSharedConversation;
901
+ if (shared && shared.length > 0) {
902
+ setMessages(shared);
903
+ return;
904
+ }
905
+ setError({
906
+ kind: "unknown",
907
+ code: "SHARE_NOT_FOUND",
908
+ message: "That shared conversation could not be found. The link may have expired.",
909
+ // Nothing to retry: a bad token will stay bad.
910
+ retryable: false
911
+ });
912
+ }).catch(() => {
913
+ if (cancelled || !mountedRef.current) return;
914
+ setError({
915
+ kind: "unknown",
916
+ code: "SHARE_NOT_FOUND",
917
+ message: "That shared conversation could not be loaded.",
918
+ retryable: true
919
+ });
920
+ });
921
+ return () => {
922
+ cancelled = true;
923
+ };
924
+ }, [client]);
925
+ react.useEffect(() => {
926
+ if (shareTokenRef.current !== null) return;
858
927
  if (!persist) {
859
928
  setHydrated(true);
860
929
  return;
@@ -1022,7 +1091,7 @@ function useExploreChat(options = {}) {
1022
1091
  [client, pollIntervalMs, pollTimeoutMs]
1023
1092
  );
1024
1093
  const submit = react.useCallback(
1025
- async (text, optimisticId, captchaAttempt) => {
1094
+ async (text, optimisticId, captchaAttempt, attachments) => {
1026
1095
  const activeCatalog = catalogRef.current;
1027
1096
  let recaptchaToken;
1028
1097
  if (activeCatalog.captchaRequired && activeCatalog.recaptchaSiteKey) {
@@ -1040,7 +1109,8 @@ function useExploreChat(options = {}) {
1040
1109
  ...focusProductRef.current || productSlug ? { productSlug: focusProductRef.current ?? productSlug } : {},
1041
1110
  ...recaptchaToken ? { recaptchaToken } : {},
1042
1111
  ...locale ? { locale } : {},
1043
- ...pageUrl ? { pageUrl } : {}
1112
+ ...pageUrl ? { pageUrl } : {},
1113
+ ...attachments.length > 0 ? { attachments: [...attachments] } : {}
1044
1114
  };
1045
1115
  const res = await client.mutate(
1046
1116
  SEND_EXPLORE_MESSAGE_MUTATION,
@@ -1054,7 +1124,7 @@ function useExploreChat(options = {}) {
1054
1124
  const code = typeof first?.extensions?.code === "string" ? first.extensions.code : void 0;
1055
1125
  const classified = classifyExploreError(code, first?.message);
1056
1126
  if (classified.kind === "captcha" && captchaAttempt === 0) {
1057
- await submit(text, optimisticId, 1);
1127
+ await submit(text, optimisticId, 1, attachments);
1058
1128
  return;
1059
1129
  }
1060
1130
  inFlightRef.current = false;
@@ -1091,7 +1161,7 @@ function useExploreChat(options = {}) {
1091
1161
  [client, locale, pageUrl, productSlug, startPolling]
1092
1162
  );
1093
1163
  const send = react.useCallback(
1094
- async (message) => {
1164
+ async (message, attachments = []) => {
1095
1165
  const text = message.trim();
1096
1166
  if (!text) return;
1097
1167
  if (inFlightRef.current) return;
@@ -1121,6 +1191,7 @@ function useExploreChat(options = {}) {
1121
1191
  }
1122
1192
  inFlightRef.current = true;
1123
1193
  lastSentTextRef.current = text;
1194
+ lastSentAttachmentsRef.current = attachments;
1124
1195
  setError(null);
1125
1196
  setPhase("sending");
1126
1197
  cancelPolling();
@@ -1143,7 +1214,7 @@ function useExploreChat(options = {}) {
1143
1214
  setTurnCount(turnCountRef.current);
1144
1215
  onSend?.(text);
1145
1216
  try {
1146
- await submit(text, optimistic.id, 0);
1217
+ await submit(text, optimistic.id, 0, attachments);
1147
1218
  } catch (err) {
1148
1219
  if (!mountedRef.current) return;
1149
1220
  console.error("[WebSDK] Explore send failed", err);
@@ -1192,7 +1263,7 @@ function useExploreChat(options = {}) {
1192
1263
  });
1193
1264
  turnCountRef.current = Math.max(0, turnCountRef.current - 1);
1194
1265
  setTurnCount(turnCountRef.current);
1195
- void send(text);
1266
+ void send(text, lastSentAttachmentsRef.current);
1196
1267
  }, [cancelPolling, send]);
1197
1268
  const reset = react.useCallback(() => {
1198
1269
  setArchive(
@@ -1206,6 +1277,7 @@ function useExploreChat(options = {}) {
1206
1277
  inFlightRef.current = false;
1207
1278
  conversationTokenRef.current = null;
1208
1279
  lastSentTextRef.current = null;
1280
+ lastSentAttachmentsRef.current = [];
1209
1281
  turnCountRef.current = 0;
1210
1282
  setTurnCount(0);
1211
1283
  setMessages([]);
@@ -1314,7 +1386,8 @@ function useExploreChat(options = {}) {
1314
1386
  deleteConversation,
1315
1387
  clearHistory,
1316
1388
  recordClick,
1317
- createShareLink
1389
+ createShareLink,
1390
+ isSharedView
1318
1391
  };
1319
1392
  }
1320
1393
  var optimisticCounter = 0;