@burdenoff/website-sdk 2026.1031.3 → 2026.1101.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.
Files changed (274) hide show
  1. package/README.md +42 -8
  2. package/dist/analytics/index.js +19 -69
  3. package/dist/analytics/index.js.map +1 -1
  4. package/dist/analytics/index.mjs +3 -69
  5. package/dist/analytics/index.mjs.map +1 -1
  6. package/dist/avatar-live/index.js +1 -0
  7. package/dist/avatar-live/index.js.map +1 -1
  8. package/dist/avatar-live/index.mjs +1 -0
  9. package/dist/avatar-live/index.mjs.map +1 -1
  10. package/dist/avatar-live-view/index.js +10 -30
  11. package/dist/avatar-live-view/index.js.map +1 -1
  12. package/dist/avatar-live-view/index.mjs +4 -24
  13. package/dist/avatar-live-view/index.mjs.map +1 -1
  14. package/dist/chunk-23H4JUL4.js +41 -0
  15. package/dist/chunk-23H4JUL4.js.map +1 -0
  16. package/dist/chunk-34RX5P75.mjs +25 -0
  17. package/dist/chunk-34RX5P75.mjs.map +1 -0
  18. package/dist/chunk-3LFFY7AZ.js +184 -0
  19. package/dist/chunk-3LFFY7AZ.js.map +1 -0
  20. package/dist/chunk-3X26GE4S.js +2794 -0
  21. package/dist/chunk-3X26GE4S.js.map +1 -0
  22. package/dist/chunk-45GCA4GG.js +85 -0
  23. package/dist/chunk-45GCA4GG.js.map +1 -0
  24. package/dist/chunk-4SAGVLHN.js +876 -0
  25. package/dist/chunk-4SAGVLHN.js.map +1 -0
  26. package/dist/chunk-4U6YAII5.js +218 -0
  27. package/dist/chunk-4U6YAII5.js.map +1 -0
  28. package/dist/chunk-5GMTBOO6.js +21 -0
  29. package/dist/chunk-5GMTBOO6.js.map +1 -0
  30. package/dist/chunk-5JRJ57CL.mjs +329 -0
  31. package/dist/chunk-5JRJ57CL.mjs.map +1 -0
  32. package/dist/chunk-6C2DKIC7.js +4 -0
  33. package/dist/chunk-6C2DKIC7.js.map +1 -0
  34. package/dist/chunk-6IBFBWC5.mjs +17 -0
  35. package/dist/chunk-6IBFBWC5.mjs.map +1 -0
  36. package/dist/chunk-6KY2ZRVI.js +116 -0
  37. package/dist/chunk-6KY2ZRVI.js.map +1 -0
  38. package/dist/chunk-6VJT3SM4.mjs +182 -0
  39. package/dist/chunk-6VJT3SM4.mjs.map +1 -0
  40. package/dist/chunk-6YZUFMK2.mjs +40 -0
  41. package/dist/chunk-6YZUFMK2.mjs.map +1 -0
  42. package/dist/chunk-7A6R7CGG.js +47 -0
  43. package/dist/chunk-7A6R7CGG.js.map +1 -0
  44. package/dist/chunk-7PWL4V2R.js +4 -0
  45. package/dist/chunk-7PWL4V2R.js.map +1 -0
  46. package/dist/chunk-AA33WDYS.js +161 -0
  47. package/dist/chunk-AA33WDYS.js.map +1 -0
  48. package/dist/chunk-AHRGFXV2.js +525 -0
  49. package/dist/chunk-AHRGFXV2.js.map +1 -0
  50. package/dist/chunk-B63XLDZH.mjs +109 -0
  51. package/dist/chunk-B63XLDZH.mjs.map +1 -0
  52. package/dist/chunk-BX2USEWF.mjs +35 -0
  53. package/dist/chunk-BX2USEWF.mjs.map +1 -0
  54. package/dist/chunk-BYSZT35R.js +150 -0
  55. package/dist/chunk-BYSZT35R.js.map +1 -0
  56. package/dist/chunk-C6OJIHNO.js +12 -0
  57. package/dist/chunk-C6OJIHNO.js.map +1 -0
  58. package/dist/chunk-COOELBX7.mjs +63 -0
  59. package/dist/chunk-COOELBX7.mjs.map +1 -0
  60. package/dist/chunk-D2TW7MNC.mjs +2771 -0
  61. package/dist/chunk-D2TW7MNC.mjs.map +1 -0
  62. package/dist/chunk-D5KEZ6V6.mjs +3 -0
  63. package/dist/chunk-D5KEZ6V6.mjs.map +1 -0
  64. package/dist/chunk-E3GUGJMY.js +46 -0
  65. package/dist/chunk-E3GUGJMY.js.map +1 -0
  66. package/dist/chunk-EBZ2HGJ2.mjs +52 -0
  67. package/dist/chunk-EBZ2HGJ2.mjs.map +1 -0
  68. package/dist/chunk-EDLTUOIA.mjs +210 -0
  69. package/dist/chunk-EDLTUOIA.mjs.map +1 -0
  70. package/dist/chunk-EJQSOT4X.js +4 -0
  71. package/dist/chunk-EJQSOT4X.js.map +1 -0
  72. package/dist/chunk-EUPFS6MZ.mjs +2019 -0
  73. package/dist/chunk-EUPFS6MZ.mjs.map +1 -0
  74. package/dist/chunk-F3XWDC3B.js +77 -0
  75. package/dist/chunk-F3XWDC3B.js.map +1 -0
  76. package/dist/chunk-FFADMVIK.mjs +5127 -0
  77. package/dist/chunk-FFADMVIK.mjs.map +1 -0
  78. package/dist/chunk-FJWS7BKT.mjs +3 -0
  79. package/dist/chunk-FJWS7BKT.mjs.map +1 -0
  80. package/dist/chunk-FJZJDUOR.mjs +3 -0
  81. package/dist/chunk-FJZJDUOR.mjs.map +1 -0
  82. package/dist/chunk-GCFLCO2Z.mjs +145 -0
  83. package/dist/chunk-GCFLCO2Z.mjs.map +1 -0
  84. package/dist/chunk-GEXC4LRP.js +61 -0
  85. package/dist/chunk-GEXC4LRP.js.map +1 -0
  86. package/dist/chunk-GTRAXQGC.mjs +3 -0
  87. package/dist/chunk-GTRAXQGC.mjs.map +1 -0
  88. package/dist/chunk-IKOIRUKW.js +270 -0
  89. package/dist/chunk-IKOIRUKW.js.map +1 -0
  90. package/dist/chunk-IXTWOPRN.js +45 -0
  91. package/dist/chunk-IXTWOPRN.js.map +1 -0
  92. package/dist/chunk-JDXOXGOK.js +547 -0
  93. package/dist/chunk-JDXOXGOK.js.map +1 -0
  94. package/dist/chunk-JSLDWYV7.mjs +558 -0
  95. package/dist/chunk-JSLDWYV7.mjs.map +1 -0
  96. package/dist/chunk-JXLSTVBK.js +336 -0
  97. package/dist/chunk-JXLSTVBK.js.map +1 -0
  98. package/dist/chunk-KHYXK7FG.mjs +49 -0
  99. package/dist/chunk-KHYXK7FG.mjs.map +1 -0
  100. package/dist/chunk-KSMBOWQQ.js +2034 -0
  101. package/dist/chunk-KSMBOWQQ.js.map +1 -0
  102. package/dist/chunk-KU2PXHGB.mjs +83 -0
  103. package/dist/chunk-KU2PXHGB.mjs.map +1 -0
  104. package/dist/chunk-KZANIV3S.mjs +37 -0
  105. package/dist/chunk-KZANIV3S.mjs.map +1 -0
  106. package/dist/chunk-L4BP6YOB.js +20 -0
  107. package/dist/chunk-L4BP6YOB.js.map +1 -0
  108. package/dist/chunk-MRKA2OAF.mjs +75 -0
  109. package/dist/chunk-MRKA2OAF.mjs.map +1 -0
  110. package/dist/chunk-N5EC53MH.mjs +80 -0
  111. package/dist/chunk-N5EC53MH.mjs.map +1 -0
  112. package/dist/chunk-NZANQGDM.mjs +34 -0
  113. package/dist/chunk-NZANQGDM.mjs.map +1 -0
  114. package/dist/chunk-O4GS3XPZ.js +10 -0
  115. package/dist/chunk-O4GS3XPZ.js.map +1 -0
  116. package/dist/chunk-O76QDGRM.js +5154 -0
  117. package/dist/chunk-O76QDGRM.js.map +1 -0
  118. package/dist/chunk-OYEUNZJY.js +114 -0
  119. package/dist/chunk-OYEUNZJY.js.map +1 -0
  120. package/dist/chunk-PHXAGQNB.js +74 -0
  121. package/dist/chunk-PHXAGQNB.js.map +1 -0
  122. package/dist/chunk-PIHHPP7J.mjs +16 -0
  123. package/dist/chunk-PIHHPP7J.mjs.map +1 -0
  124. package/dist/chunk-PXRHVVOU.mjs +499 -0
  125. package/dist/chunk-PXRHVVOU.mjs.map +1 -0
  126. package/dist/chunk-QMA6U6AU.js +36 -0
  127. package/dist/chunk-QMA6U6AU.js.map +1 -0
  128. package/dist/chunk-R6J7IULF.js +44 -0
  129. package/dist/chunk-R6J7IULF.js.map +1 -0
  130. package/dist/chunk-R7G6TWIS.mjs +10 -0
  131. package/dist/chunk-R7G6TWIS.mjs.map +1 -0
  132. package/dist/chunk-RUMGFI6L.mjs +544 -0
  133. package/dist/chunk-RUMGFI6L.mjs.map +1 -0
  134. package/dist/chunk-S54JWSJF.js +565 -0
  135. package/dist/chunk-S54JWSJF.js.map +1 -0
  136. package/dist/chunk-SK5UGG6A.js +2041 -0
  137. package/dist/chunk-SK5UGG6A.js.map +1 -0
  138. package/dist/chunk-SKIYDKIS.mjs +70 -0
  139. package/dist/chunk-SKIYDKIS.mjs.map +1 -0
  140. package/dist/chunk-SZNS5IK6.mjs +322 -0
  141. package/dist/chunk-SZNS5IK6.mjs.map +1 -0
  142. package/dist/chunk-T7JIPZAC.js +66 -0
  143. package/dist/chunk-T7JIPZAC.js.map +1 -0
  144. package/dist/chunk-TGYQHO2E.mjs +864 -0
  145. package/dist/chunk-TGYQHO2E.mjs.map +1 -0
  146. package/dist/chunk-TT3MHN42.mjs +8 -0
  147. package/dist/chunk-TT3MHN42.mjs.map +1 -0
  148. package/dist/chunk-UM55U65W.mjs +268 -0
  149. package/dist/chunk-UM55U65W.mjs.map +1 -0
  150. package/dist/chunk-UQ2HALUD.js +72 -0
  151. package/dist/chunk-UQ2HALUD.js.map +1 -0
  152. package/dist/chunk-UXWT7G77.js +82 -0
  153. package/dist/chunk-UXWT7G77.js.map +1 -0
  154. package/dist/chunk-VNS5WDWO.mjs +7 -0
  155. package/dist/chunk-VNS5WDWO.mjs.map +1 -0
  156. package/dist/chunk-VRWZLGR7.js +4 -0
  157. package/dist/chunk-VRWZLGR7.js.map +1 -0
  158. package/dist/chunk-VZLDSNH4.mjs +22 -0
  159. package/dist/chunk-VZLDSNH4.mjs.map +1 -0
  160. package/dist/chunk-W6P3YETJ.js +92 -0
  161. package/dist/chunk-W6P3YETJ.js.map +1 -0
  162. package/dist/chunk-WPKFFQCR.mjs +90 -0
  163. package/dist/chunk-WPKFFQCR.mjs.map +1 -0
  164. package/dist/chunk-WTVTI5TO.mjs +22 -0
  165. package/dist/chunk-WTVTI5TO.mjs.map +1 -0
  166. package/dist/chunk-XJOBZ4RJ.js +44 -0
  167. package/dist/chunk-XJOBZ4RJ.js.map +1 -0
  168. package/dist/chunk-XP2JDNDU.js +325 -0
  169. package/dist/chunk-XP2JDNDU.js.map +1 -0
  170. package/dist/chunk-Y4V5CEWD.mjs +112 -0
  171. package/dist/chunk-Y4V5CEWD.mjs.map +1 -0
  172. package/dist/chunk-YERN2UWM.js +116 -0
  173. package/dist/chunk-YERN2UWM.js.map +1 -0
  174. package/dist/chunk-ZKJQWFAA.mjs +114 -0
  175. package/dist/chunk-ZKJQWFAA.mjs.map +1 -0
  176. package/dist/chunk-ZOON3S3Y.mjs +138 -0
  177. package/dist/chunk-ZOON3S3Y.mjs.map +1 -0
  178. package/dist/chunk-ZP6QRAYC.mjs +2024 -0
  179. package/dist/chunk-ZP6QRAYC.mjs.map +1 -0
  180. package/dist/chunk-ZSTFX7FV.js +9 -0
  181. package/dist/chunk-ZSTFX7FV.js.map +1 -0
  182. package/dist/client/index.js +23 -331
  183. package/dist/client/index.js.map +1 -1
  184. package/dist/client/index.mjs +3 -330
  185. package/dist/client/index.mjs.map +1 -1
  186. package/dist/comparison/index.js +28 -111
  187. package/dist/comparison/index.js.map +1 -1
  188. package/dist/comparison/index.mjs +2 -107
  189. package/dist/comparison/index.mjs.map +1 -1
  190. package/dist/components/contact.js +21 -931
  191. package/dist/components/contact.js.map +1 -1
  192. package/dist/components/contact.mjs +12 -909
  193. package/dist/components/contact.mjs.map +1 -1
  194. package/dist/components/electron-download.js +12 -124
  195. package/dist/components/electron-download.js.map +1 -1
  196. package/dist/components/electron-download.mjs +4 -106
  197. package/dist/components/electron-download.mjs.map +1 -1
  198. package/dist/components/explore-cta.js +8 -112
  199. package/dist/components/explore-cta.js.map +1 -1
  200. package/dist/components/explore-cta.mjs +3 -114
  201. package/dist/components/explore-cta.mjs.map +1 -1
  202. package/dist/components/explore.js +62 -7833
  203. package/dist/components/explore.js.map +1 -1
  204. package/dist/components/explore.mjs +13 -7800
  205. package/dist/components/explore.mjs.map +1 -1
  206. package/dist/components/launch-countdown.js +8 -83
  207. package/dist/components/launch-countdown.js.map +1 -1
  208. package/dist/components/launch-countdown.mjs +3 -85
  209. package/dist/components/launch-countdown.mjs.map +1 -1
  210. package/dist/components/newsletter.js +20 -993
  211. package/dist/components/newsletter.js.map +1 -1
  212. package/dist/components/newsletter.mjs +11 -971
  213. package/dist/components/newsletter.mjs.map +1 -1
  214. package/dist/components/partners.js +24 -1302
  215. package/dist/components/partners.js.map +1 -1
  216. package/dist/components/partners.mjs +15 -1276
  217. package/dist/components/partners.mjs.map +1 -1
  218. package/dist/components/pricing.js +49 -1249
  219. package/dist/components/pricing.js.map +1 -1
  220. package/dist/components/pricing.mjs +8 -1226
  221. package/dist/components/pricing.mjs.map +1 -1
  222. package/dist/components/problems-solved.js +8 -150
  223. package/dist/components/problems-solved.js.map +1 -1
  224. package/dist/components/problems-solved.mjs +4 -133
  225. package/dist/components/problems-solved.mjs.map +1 -1
  226. package/dist/components/resource-links.js +8 -304
  227. package/dist/components/resource-links.js.map +1 -1
  228. package/dist/components/resource-links.mjs +5 -308
  229. package/dist/components/resource-links.mjs.map +1 -1
  230. package/dist/components/social-links.js +8 -343
  231. package/dist/components/social-links.js.map +1 -1
  232. package/dist/components/social-links.mjs +5 -347
  233. package/dist/components/social-links.mjs.map +1 -1
  234. package/dist/components/unsubscribe.js +10 -627
  235. package/dist/components/unsubscribe.js.map +1 -1
  236. package/dist/components/unsubscribe.mjs +6 -611
  237. package/dist/components/unsubscribe.mjs.map +1 -1
  238. package/dist/components/waitlist.js +21 -1001
  239. package/dist/components/waitlist.js.map +1 -1
  240. package/dist/components/waitlist.mjs +12 -982
  241. package/dist/components/waitlist.mjs.map +1 -1
  242. package/dist/components/website-switcher.js +12 -175
  243. package/dist/components/website-switcher.js.map +1 -1
  244. package/dist/components/website-switcher.mjs +4 -157
  245. package/dist/components/website-switcher.mjs.map +1 -1
  246. package/dist/content/index.js +118 -3616
  247. package/dist/content/index.js.map +1 -1
  248. package/dist/content/index.mjs +12 -3567
  249. package/dist/content/index.mjs.map +1 -1
  250. package/dist/hooks/index.js +37 -2321
  251. package/dist/hooks/index.js.map +1 -1
  252. package/dist/hooks/index.mjs +6 -2318
  253. package/dist/hooks/index.mjs.map +1 -1
  254. package/dist/index.js +4145 -20599
  255. package/dist/index.js.map +1 -1
  256. package/dist/index.mjs +3766 -20567
  257. package/dist/index.mjs.map +1 -1
  258. package/dist/product/index.js +20 -393
  259. package/dist/product/index.js.map +1 -1
  260. package/dist/product/index.mjs +5 -394
  261. package/dist/product/index.mjs.map +1 -1
  262. package/dist/seo/index.js +8 -76
  263. package/dist/seo/index.js.map +1 -1
  264. package/dist/seo/index.mjs +3 -78
  265. package/dist/seo/index.mjs.map +1 -1
  266. package/dist/store/index.js +51 -2650
  267. package/dist/store/index.js.map +1 -1
  268. package/dist/store/index.mjs +13 -2619
  269. package/dist/store/index.mjs.map +1 -1
  270. package/dist/utils/index.js +69 -134
  271. package/dist/utils/index.js.map +1 -1
  272. package/dist/utils/index.mjs +5 -122
  273. package/dist/utils/index.mjs.map +1 -1
  274. package/package.json +2 -1
@@ -0,0 +1,2041 @@
1
+ 'use strict';
2
+
3
+ var chunkPHXAGQNB_js = require('./chunk-PHXAGQNB.js');
4
+ var chunkE3GUGJMY_js = require('./chunk-E3GUGJMY.js');
5
+ var chunkJXLSTVBK_js = require('./chunk-JXLSTVBK.js');
6
+ var react = require('react');
7
+
8
+ // src/data/products.ts
9
+ var ECOSYSTEM_PRODUCTS = [
10
+ {
11
+ slug: "workspaces",
12
+ name: "Workspaces",
13
+ websiteUrl: "https://burdenoff.com"
14
+ },
15
+ {
16
+ slug: "vibecontrols",
17
+ name: "VibeControls",
18
+ websiteUrl: "https://vibecontrols.com"
19
+ },
20
+ // FluidGrids ships on www.fluidgrids.ai — fluidgrids.com only redirects there. The explore
21
+ // catalog and the site's own sitemap use this origin, and so must the fallback catalog
22
+ // built from this list, or /explore rejects FluidGrids concept images until it loads.
23
+ {
24
+ slug: "fluidgrids",
25
+ name: "FluidGrids",
26
+ websiteUrl: "https://www.fluidgrids.ai"
27
+ },
28
+ // BotManor ships on www.botmanor.com (the apex redirects there; the old botlit.ai domain
29
+ // still serves the same site but is no longer the name we link to).
30
+ // The slug follows the botlit → botmanor rename switch (utils/product-slug.ts).
31
+ {
32
+ slug: chunkE3GUGJMY_js.emitProductSlug("botmanor"),
33
+ name: "BotManor",
34
+ websiteUrl: "https://www.botmanor.com"
35
+ },
36
+ {
37
+ slug: "bigconsole",
38
+ name: "BigConsole",
39
+ websiteUrl: "https://bigconsole.com"
40
+ },
41
+ {
42
+ slug: "semanticfed",
43
+ name: "SemanticFed",
44
+ websiteUrl: "https://semanticfed.com"
45
+ },
46
+ {
47
+ slug: "intelwatchtower",
48
+ name: "IntelWatchtower",
49
+ websiteUrl: "https://intelwatchtower.com"
50
+ },
51
+ { slug: "buildmyiq", name: "BuildMyIQ", websiteUrl: "https://buildmyiq.com" },
52
+ {
53
+ slug: "assethandler",
54
+ name: "AssetHandler",
55
+ websiteUrl: "https://assethandler.com"
56
+ },
57
+ {
58
+ slug: "crewfoundry",
59
+ name: "CrewFoundry",
60
+ websiteUrl: "https://crewfoundry.com"
61
+ },
62
+ {
63
+ slug: "planmagnet",
64
+ name: "PlanMagnet",
65
+ websiteUrl: "https://planmagnet.com"
66
+ },
67
+ {
68
+ slug: "eventfullymanaged",
69
+ name: "EventfullyManaged",
70
+ websiteUrl: "https://eventfullymanaged.com"
71
+ },
72
+ {
73
+ slug: "headshotmarketing",
74
+ name: "HeadshotMarketing",
75
+ websiteUrl: "https://headshotmarketing.com"
76
+ },
77
+ {
78
+ slug: "technospam",
79
+ name: "TechnoSpam",
80
+ websiteUrl: "https://technospam.com"
81
+ },
82
+ { slug: "kadaikodi", name: "Kadaikodi", websiteUrl: "https://kadaikodi.com" },
83
+ {
84
+ slug: "movethewheels",
85
+ name: "MoveTheWheels",
86
+ websiteUrl: "https://movethewheels.com"
87
+ },
88
+ {
89
+ slug: "healthybowl",
90
+ name: "Healthy Bowl",
91
+ websiteUrl: "https://gethealthybowl.com"
92
+ },
93
+ { slug: "ggnomad", name: "GGNomad", websiteUrl: "https://ggnomad.com" },
94
+ {
95
+ slug: "timecampus",
96
+ name: "TimeCampus",
97
+ websiteUrl: "https://timecampus.com"
98
+ },
99
+ {
100
+ slug: "manufacturedops",
101
+ name: "ManufacturedOps",
102
+ websiteUrl: "https://manufacturedops.com"
103
+ },
104
+ {
105
+ slug: "theglobalfuel",
106
+ name: "TheGlobalFuel",
107
+ websiteUrl: "https://theglobalfuel.com"
108
+ },
109
+ {
110
+ slug: "housingvista",
111
+ name: "HousingVista",
112
+ websiteUrl: "https://housingvista.com"
113
+ },
114
+ {
115
+ slug: "proserviceworld",
116
+ name: "ProServiceWorld",
117
+ websiteUrl: "https://proserviceworld.com"
118
+ },
119
+ {
120
+ slug: "mybodyshield",
121
+ name: "MyBodyShield",
122
+ websiteUrl: "https://mybodyshield.com"
123
+ },
124
+ {
125
+ slug: "artistrybase",
126
+ name: "ArtistryBase",
127
+ websiteUrl: "https://artistrybase.com"
128
+ },
129
+ {
130
+ slug: "theculturepost",
131
+ name: "TheCulturePost",
132
+ websiteUrl: "https://theculturepost.com"
133
+ },
134
+ { slug: "collabkin", name: "CollabKin", websiteUrl: "https://collabkin.com" },
135
+ {
136
+ slug: "comradecircle",
137
+ name: "ComradeCircle",
138
+ websiteUrl: "https://comradecircle.com"
139
+ },
140
+ {
141
+ slug: "brainyrich",
142
+ name: "BrainyRich",
143
+ websiteUrl: "https://brainyrich.com"
144
+ },
145
+ {
146
+ slug: "cosmicintersection",
147
+ name: "CosmicIntersection",
148
+ websiteUrl: "https://cosmicintersection.com"
149
+ },
150
+ {
151
+ slug: "govcitizenhub",
152
+ name: "GovCitizenHub",
153
+ websiteUrl: "https://govcitizenhub.com"
154
+ },
155
+ {
156
+ slug: "adaptercloud",
157
+ name: "AdapterCloud",
158
+ websiteUrl: "https://adaptercloud.com"
159
+ },
160
+ {
161
+ slug: "subscriberbot",
162
+ name: "Subscriber Bot",
163
+ websiteUrl: "https://subscriberbot.com"
164
+ },
165
+ {
166
+ slug: "hookmovies",
167
+ name: "HookMovies",
168
+ websiteUrl: "https://hookmovies.com"
169
+ },
170
+ {
171
+ slug: "coolandlovely",
172
+ name: "CoolAndLovely",
173
+ websiteUrl: "https://coolandlovely.com"
174
+ },
175
+ {
176
+ slug: "atheletebridge",
177
+ name: "AthleteBridge",
178
+ websiteUrl: "https://atheletebridge.com"
179
+ },
180
+ {
181
+ slug: "labsofscience",
182
+ name: "LabsOfScience",
183
+ websiteUrl: "https://labsofscience.com"
184
+ },
185
+ {
186
+ slug: "ecoimpacthub",
187
+ name: "EcoImpactHub",
188
+ websiteUrl: "https://ecoimpacthub.com"
189
+ }
190
+ ];
191
+
192
+ // src/components/explore-types.ts
193
+ var EXPLORE_FEEDBACK_REASONS = [
194
+ "INACCURATE",
195
+ "INCOMPLETE",
196
+ "OFF_TOPIC",
197
+ "HARD_TO_FOLLOW",
198
+ "OTHER"
199
+ ];
200
+ var EXPLORE_MESSAGE_FIELDS = (
201
+ /* GraphQL */
202
+ `
203
+ id
204
+ conversationId
205
+ role
206
+ status
207
+ content
208
+ partialContent
209
+ activity
210
+ references {
211
+ url
212
+ title
213
+ description
214
+ product
215
+ imageUrl
216
+ index
217
+ }
218
+ ctas {
219
+ kind
220
+ label
221
+ url
222
+ product
223
+ }
224
+ followUps
225
+ answered
226
+ attachments {
227
+ name
228
+ mimeType
229
+ size
230
+ textExtracted
231
+ }
232
+ errorCode
233
+ createdAt
234
+ completedAt
235
+ `
236
+ );
237
+ var EXPLORE_OWN_MESSAGE_FIELDS = (
238
+ /* GraphQL */
239
+ `
240
+ ${EXPLORE_MESSAGE_FIELDS}
241
+ feedback {
242
+ rating
243
+ reason
244
+ comment
245
+ createdAt
246
+ }
247
+ `
248
+ );
249
+ var EXPLORE_CATALOG_ESTABLISHED_FIELDS = (
250
+ /* GraphQL */
251
+ `
252
+ enabled
253
+ products {
254
+ slug
255
+ name
256
+ tagline
257
+ website
258
+ }
259
+ examplePrompts
260
+ welcomeTitle
261
+ welcomeBody
262
+ limits {
263
+ maxMessageLength
264
+ maxTurnsPerConversation
265
+ messagesPerDay
266
+ historyTurns
267
+ }
268
+ captchaRequired
269
+ recaptchaSiteKey`
270
+ );
271
+ var EXPLORE_CATALOG_HIGHLIGHT_FIELD = (
272
+ /* GraphQL */
273
+ `
274
+ conceptHighlights {
275
+ product
276
+ productName
277
+ title
278
+ url
279
+ imageUrl
280
+ alt
281
+ }`
282
+ );
283
+ function exploreCatalogDocument(extraFields) {
284
+ return (
285
+ /* GraphQL */
286
+ `
287
+ query ExploreCatalog($productSlug: String) {
288
+ exploreCatalog(productSlug: $productSlug) {${EXPLORE_CATALOG_ESTABLISHED_FIELDS}${extraFields}
289
+ }
290
+ }
291
+ `
292
+ );
293
+ }
294
+ var EXPLORE_CATALOG_QUERY = exploreCatalogDocument(
295
+ EXPLORE_CATALOG_HIGHLIGHT_FIELD
296
+ );
297
+ var EXPLORE_CATALOG_QUERY_WITHOUT_HIGHLIGHTS = exploreCatalogDocument("");
298
+ var EXPLORE_MESSAGE_QUERY = (
299
+ /* GraphQL */
300
+ `
301
+ query ExploreMessage($conversationToken: String!, $id: ID!) {
302
+ exploreMessage(conversationToken: $conversationToken, id: $id) {
303
+ ${EXPLORE_OWN_MESSAGE_FIELDS}
304
+ }
305
+ }
306
+ `
307
+ );
308
+ var SEND_EXPLORE_MESSAGE_MUTATION = (
309
+ /* GraphQL */
310
+ `
311
+ mutation SendExploreMessage($input: SendExploreMessageInput!) {
312
+ sendExploreMessage(input: $input) {
313
+ conversation {
314
+ id
315
+ token
316
+ productSlug
317
+ turnCount
318
+ createdAt
319
+ }
320
+ userMessage {
321
+ ${EXPLORE_OWN_MESSAGE_FIELDS}
322
+ }
323
+ assistantMessage {
324
+ ${EXPLORE_OWN_MESSAGE_FIELDS}
325
+ }
326
+ remainingToday
327
+ }
328
+ }
329
+ `
330
+ );
331
+ var RECORD_EXPLORE_CLICK_MUTATION = (
332
+ /* GraphQL */
333
+ `
334
+ mutation RecordExploreClick($input: RecordExploreClickInput!) {
335
+ recordExploreClick(input: $input) {
336
+ recorded
337
+ }
338
+ }
339
+ `
340
+ );
341
+ var SUBMIT_EXPLORE_FEEDBACK_MUTATION = (
342
+ /* GraphQL */
343
+ `
344
+ mutation SubmitExploreFeedback($input: SubmitExploreFeedbackInput!) {
345
+ submitExploreFeedback(input: $input) {
346
+ recorded
347
+ feedback {
348
+ rating
349
+ reason
350
+ comment
351
+ createdAt
352
+ }
353
+ }
354
+ }
355
+ `
356
+ );
357
+ var EXPLORE_FEEDBACK_COMMENT_SOFT_MAX = 500;
358
+ var ESCALATE_EXPLORE_CONVERSATION_MUTATION = (
359
+ /* GraphQL */
360
+ `
361
+ mutation EscalateExploreConversation(
362
+ $input: EscalateExploreConversationInput!
363
+ ) {
364
+ escalateExploreConversation(input: $input) {
365
+ created
366
+ escalation {
367
+ email
368
+ createdAt
369
+ }
370
+ }
371
+ }
372
+ `
373
+ );
374
+ var EXPLORE_ESCALATION_NOTE_SOFT_MAX = 2e3;
375
+ var DELIVERABLE_EMAIL = /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z]{2,}$/;
376
+ function looksLikeDeliverableEmail(value) {
377
+ const trimmed = value.trim();
378
+ if (trimmed.length === 0 || trimmed.length > 254) return false;
379
+ return DELIVERABLE_EMAIL.test(trimmed);
380
+ }
381
+ var CREATE_EXPLORE_SHARE_LINK_MUTATION = (
382
+ /* GraphQL */
383
+ `
384
+ mutation CreateExploreShareLink($conversationToken: String!) {
385
+ createExploreShareLink(conversationToken: $conversationToken) {
386
+ shareToken
387
+ }
388
+ }
389
+ `
390
+ );
391
+ var EXPLORE_SHARED_CONVERSATION_QUERY = (
392
+ /* GraphQL */
393
+ `
394
+ query ExploreSharedConversation($shareToken: String!) {
395
+ exploreSharedConversation(shareToken: $shareToken) {
396
+ ${EXPLORE_MESSAGE_FIELDS}
397
+ }
398
+ }
399
+ `
400
+ );
401
+ var DEFAULT_STORAGE_KEY = "boff.explore.v1";
402
+ var HISTORY_SUFFIX = ".history";
403
+ var MAX_ARCHIVED_CONVERSATIONS = 15;
404
+ var DEFAULT_POLL_INTERVAL_MS = 1500;
405
+ var DEFAULT_POLL_TIMEOUT_MS = 9e4;
406
+ var POLL_REQUEST_TIMEOUT_MS = 1e4;
407
+ var SEND_REQUEST_TIMEOUT_MS = 18e3;
408
+ var MAX_CONSECUTIVE_POLL_FAILURES = 4;
409
+ var MAX_PERSISTED_MESSAGES = 40;
410
+ var FALLBACK_EXPLORE_LIMITS = {
411
+ maxMessageLength: 2e3,
412
+ maxTurnsPerConversation: 20,
413
+ messagesPerDay: 100,
414
+ historyTurns: 6
415
+ };
416
+ var DEFAULT_EXPLORE_EXAMPLE_PROMPTS = [
417
+ "Every course we run lives in a different spreadsheet.",
418
+ "We only hear a machine is down after the line has stopped.",
419
+ "Members quietly stop showing up and we never know why.",
420
+ "Which of your products fits a problem like mine?"
421
+ ];
422
+ var FALLBACK_WELCOME_TITLE = "What problem are you trying to solve?";
423
+ var FALLBACK_WELCOME_BODY = "Describe the problem, in your own words. You can also ask about a specific product or compare a few. Every answer comes straight from our documentation.";
424
+ function buildFallbackCatalog(examplePrompts, welcome) {
425
+ return {
426
+ enabled: true,
427
+ products: ECOSYSTEM_PRODUCTS.map((p) => ({
428
+ slug: p.slug,
429
+ name: p.name,
430
+ tagline: null,
431
+ website: p.websiteUrl
432
+ })),
433
+ examplePrompts: examplePrompts?.length ? examplePrompts : DEFAULT_EXPLORE_EXAMPLE_PROMPTS,
434
+ welcomeTitle: welcome?.title ?? FALLBACK_WELCOME_TITLE,
435
+ welcomeBody: welcome?.body ?? FALLBACK_WELCOME_BODY,
436
+ limits: FALLBACK_EXPLORE_LIMITS,
437
+ captchaRequired: false,
438
+ recaptchaSiteKey: null,
439
+ // Empty, and deliberately not synthesised from `ECOSYSTEM_PRODUCTS`: a concept highlight
440
+ // needs a real published illustration URL, and this SDK has no registry of them. An
441
+ // invented path would render 38 broken frames on the one screen every prerender captures.
442
+ // The strip renders nothing at all when the list is empty, which is the honest fallback.
443
+ conceptHighlights: []
444
+ };
445
+ }
446
+ var BAKED_CATALOG_ELEMENT_ID = "boff-explore-catalog";
447
+ function bakedCatalogLocale() {
448
+ if (typeof navigator === "undefined") return "";
449
+ return (navigator.language || "").toLowerCase().split("-")[0] ?? "";
450
+ }
451
+ function snapshotBakedElement() {
452
+ if (typeof document === "undefined") return null;
453
+ const el = document.getElementById(BAKED_CATALOG_ELEMENT_ID);
454
+ if (!el || el.tagName !== "SCRIPT" || el.getAttribute("type") !== "application/json")
455
+ return null;
456
+ return {
457
+ product: el.getAttribute("data-product") ?? "",
458
+ locale: el.getAttribute("data-locale") ?? "",
459
+ text: el.textContent ?? ""
460
+ };
461
+ }
462
+ var BAKED_AT_LOAD = snapshotBakedElement();
463
+ function isCatalogShape(value) {
464
+ if (!value || typeof value !== "object") return false;
465
+ const c = value;
466
+ const listOrAbsent = (v) => v === void 0 || v === null || Array.isArray(v);
467
+ const textOrAbsent = (v) => v === void 0 || v === null || typeof v === "string";
468
+ return (c["enabled"] === void 0 || typeof c["enabled"] === "boolean") && listOrAbsent(c["products"]) && listOrAbsent(c["examplePrompts"]) && listOrAbsent(c["conceptHighlights"]) && textOrAbsent(c["welcomeTitle"]) && textOrAbsent(c["welcomeBody"]);
469
+ }
470
+ function readBakedCatalog(productSlug) {
471
+ const baked = snapshotBakedElement() ?? BAKED_AT_LOAD;
472
+ if (!baked) return null;
473
+ if (baked.product !== (productSlug ?? "")) return null;
474
+ if (baked.locale && baked.locale !== bakedCatalogLocale()) return null;
475
+ try {
476
+ const parsed = JSON.parse(baked.text);
477
+ return isCatalogShape(parsed) ? parsed : null;
478
+ } catch {
479
+ return null;
480
+ }
481
+ }
482
+ function serializeBakedCatalog(raw) {
483
+ return JSON.stringify(raw).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
484
+ }
485
+ function normalizeCatalog(raw, fallback) {
486
+ return {
487
+ enabled: raw.enabled !== false,
488
+ products: raw.products?.length ? raw.products : fallback.products,
489
+ examplePrompts: raw.examplePrompts?.length ? raw.examplePrompts : fallback.examplePrompts,
490
+ welcomeTitle: raw.welcomeTitle || fallback.welcomeTitle,
491
+ welcomeBody: raw.welcomeBody || fallback.welcomeBody,
492
+ limits: {
493
+ maxMessageLength: raw.limits?.maxMessageLength || fallback.limits.maxMessageLength,
494
+ maxTurnsPerConversation: raw.limits?.maxTurnsPerConversation || fallback.limits.maxTurnsPerConversation,
495
+ messagesPerDay: raw.limits?.messagesPerDay || fallback.limits.messagesPerDay,
496
+ historyTurns: raw.limits?.historyTurns || fallback.limits.historyTurns
497
+ },
498
+ captchaRequired: raw.captchaRequired === true,
499
+ recaptchaSiteKey: raw.recaptchaSiteKey ?? null,
500
+ // `[ExploreConceptHighlight!]!` on the wire, so a gateway that KNOWS the field always
501
+ // sends an array. The one response that arrives without it is the retry against an older
502
+ // supergraph (`EXPLORE_CATALOG_QUERY_WITHOUT_HIGHLIGHTS`) — that gateway does not answer
503
+ // the full document at all, it refuses it. Either way
504
+ // `catalog.conceptHighlights.filter(...)` on `undefined` would throw inside render,
505
+ // blanking the welcome screen over a decorative strip.
506
+ conceptHighlights: raw.conceptHighlights?.length ? raw.conceptHighlights : fallback.conceptHighlights
507
+ };
508
+ }
509
+ var CATALOG_DOCUMENT_REJECTED_CODES = /* @__PURE__ */ new Set([
510
+ "GRAPHQL_VALIDATION_FAILED",
511
+ "HTTP_400"
512
+ ]);
513
+ function catalogRejectedTheHighlightField(res) {
514
+ if (res.data?.exploreCatalog) return false;
515
+ return (res.errors ?? []).some((error) => {
516
+ const code = error.extensions?.code;
517
+ return typeof code === "string" && CATALOG_DOCUMENT_REJECTED_CODES.has(code) || error.message.includes("conceptHighlights");
518
+ });
519
+ }
520
+ var RATE_LIMIT_CODES = /* @__PURE__ */ new Set([
521
+ "RATE_LIMITED",
522
+ "HTTP_429",
523
+ "EXPLORE_GLOBAL_LIMIT"
524
+ ]);
525
+ var CAPTCHA_CODES = /* @__PURE__ */ new Set(["CAPTCHA_FAILED", "CAPTCHA_REQUIRED"]);
526
+ var NETWORK_CODES = /* @__PURE__ */ new Set([
527
+ "NETWORK_ERROR",
528
+ "UPSTREAM_UNAVAILABLE",
529
+ "CONVERSATION_BUSY",
530
+ "PROVIDER_ERROR",
531
+ "QUEUE_FULL"
532
+ ]);
533
+ var VALIDATION_CODES = /* @__PURE__ */ new Set([
534
+ "MESSAGE_TOO_LONG",
535
+ "MESSAGE_EMPTY",
536
+ "CONVERSATION_LIMIT",
537
+ "INVALID_INPUT"
538
+ ]);
539
+ function escalateOutcomeForCode(code) {
540
+ switch (code) {
541
+ case "INVALID_EMAIL":
542
+ return "invalid-email";
543
+ case "RATE_LIMITED":
544
+ case "HTTP_429":
545
+ return "rate-limited";
546
+ case "CAPTCHA_REQUIRED":
547
+ case "CAPTCHA_FAILED":
548
+ return "captcha";
549
+ // The token owns nothing, or owns a different conversation. The server answers NOT_FOUND
550
+ // rather than FORBIDDEN so the endpoint is not an oracle for whether a thread exists;
551
+ // either way there is nothing this visitor can do about it, so it reads as a failure.
552
+ case "NOT_FOUND":
553
+ return "failed";
554
+ default:
555
+ return "failed";
556
+ }
557
+ }
558
+ function classifyExploreError(code, serverMessage) {
559
+ const c = code ?? "UNKNOWN";
560
+ if (RATE_LIMIT_CODES.has(c)) {
561
+ return {
562
+ kind: "rate-limit",
563
+ code: c,
564
+ message: "You've reached the message limit for now. Please try again later.",
565
+ retryable: false
566
+ };
567
+ }
568
+ if (CAPTCHA_CODES.has(c)) {
569
+ return {
570
+ kind: "captcha",
571
+ code: c,
572
+ message: "We couldn't verify that you're human. Please try sending that again.",
573
+ retryable: true
574
+ };
575
+ }
576
+ if (c === "TOOL_BUDGET") {
577
+ return {
578
+ kind: "scope",
579
+ code: c,
580
+ message: "That question spans more of our products than I can look through in one go. Try asking about two or three specific products.",
581
+ retryable: false
582
+ };
583
+ }
584
+ if (c === "TIMEOUT") {
585
+ return {
586
+ kind: "timeout",
587
+ code: c,
588
+ message: "That answer took too long to come back. Try asking again.",
589
+ retryable: true
590
+ };
591
+ }
592
+ if (NETWORK_CODES.has(c)) {
593
+ return {
594
+ kind: "network",
595
+ code: c,
596
+ message: "We couldn't reach the assistant just now. Check your connection and try again.",
597
+ retryable: true
598
+ };
599
+ }
600
+ if (c === "EXPLORE_DISABLED") {
601
+ return {
602
+ kind: "disabled",
603
+ code: c,
604
+ message: "Explore is unavailable at the moment. Please check back soon.",
605
+ retryable: false
606
+ };
607
+ }
608
+ if (VALIDATION_CODES.has(c)) {
609
+ return {
610
+ kind: "validation",
611
+ code: c,
612
+ message: serverMessage || "That message couldn't be sent.",
613
+ retryable: false
614
+ };
615
+ }
616
+ if (c === "EMPTY_ANSWER") {
617
+ return {
618
+ kind: "unknown",
619
+ code: c,
620
+ message: "No answer came back for that one. Try rephrasing, or ask something more specific.",
621
+ retryable: true
622
+ };
623
+ }
624
+ return {
625
+ kind: "unknown",
626
+ code: c,
627
+ message: serverMessage || "Something went wrong. Please try again.",
628
+ retryable: true
629
+ };
630
+ }
631
+ function historyKey(key) {
632
+ return `${key}${HISTORY_SUFFIX}`;
633
+ }
634
+ function readArchive(key) {
635
+ if (typeof window === "undefined") return [];
636
+ try {
637
+ const raw = window.localStorage.getItem(historyKey(key));
638
+ if (!raw) return [];
639
+ const parsed = JSON.parse(raw);
640
+ if (!Array.isArray(parsed)) return [];
641
+ return parsed.filter(
642
+ (entry) => typeof entry === "object" && entry !== null && typeof entry.token === "string" && Array.isArray(entry.messages)
643
+ );
644
+ } catch {
645
+ return [];
646
+ }
647
+ }
648
+ function writeArchive(key, entries) {
649
+ if (typeof window === "undefined") return;
650
+ try {
651
+ if (entries.length === 0) {
652
+ window.localStorage.removeItem(historyKey(key));
653
+ return;
654
+ }
655
+ window.localStorage.setItem(historyKey(key), JSON.stringify(entries));
656
+ } catch {
657
+ }
658
+ }
659
+ function upsertArchive(key, thread) {
660
+ if (!thread.token) return readArchive(key);
661
+ const real = thread.messages.filter(
662
+ (m) => m.content.trim() !== "" || m.role === "USER"
663
+ );
664
+ if (real.length === 0) return readArchive(key);
665
+ const firstUser = real.find((m) => m.role === "USER");
666
+ const entry = {
667
+ token: thread.token,
668
+ title: (firstUser?.content ?? "Conversation").trim().slice(0, 80),
669
+ updatedAt: real[real.length - 1]?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
670
+ messageCount: real.length,
671
+ focusProduct: thread.focusProduct,
672
+ messages: real.slice(-20)
673
+ };
674
+ const rest = readArchive(key).filter((e) => e.token !== entry.token);
675
+ const next = [entry, ...rest].slice(0, MAX_ARCHIVED_CONVERSATIONS);
676
+ writeArchive(key, next);
677
+ return next;
678
+ }
679
+ function readPersisted(key) {
680
+ if (typeof window === "undefined") return null;
681
+ try {
682
+ const raw = window.localStorage.getItem(key);
683
+ if (!raw) return null;
684
+ const parsed = JSON.parse(raw);
685
+ if (!parsed || typeof parsed !== "object") return null;
686
+ const record = parsed;
687
+ return {
688
+ conversationToken: typeof record.conversationToken === "string" ? record.conversationToken : null,
689
+ messages: Array.isArray(record.messages) ? record.messages.slice(-MAX_PERSISTED_MESSAGES) : [],
690
+ focusProduct: typeof record.focusProduct === "string" ? record.focusProduct : null
691
+ };
692
+ } catch {
693
+ return null;
694
+ }
695
+ }
696
+ function readShareToken() {
697
+ if (typeof window === "undefined") return null;
698
+ try {
699
+ return new URL(window.location.href).searchParams.get("c");
700
+ } catch {
701
+ return null;
702
+ }
703
+ }
704
+ function visibleText(message) {
705
+ return message.content || message.partialContent || "";
706
+ }
707
+ function countUserTurns(messages) {
708
+ return messages.filter((m) => m.role === "USER").length;
709
+ }
710
+ function useExploreChat(options = {}) {
711
+ const {
712
+ productSlug,
713
+ pageUrl,
714
+ locale,
715
+ examplePrompts,
716
+ fallbackWelcome,
717
+ pollIntervalMs = DEFAULT_POLL_INTERVAL_MS,
718
+ pollTimeoutMs = DEFAULT_POLL_TIMEOUT_MS,
719
+ storageKey = DEFAULT_STORAGE_KEY,
720
+ persist = true,
721
+ onSend,
722
+ enabled = true,
723
+ shareToken: shareTokenOption
724
+ } = options;
725
+ const client = chunkJXLSTVBK_js.useWebSDK();
726
+ const { productId } = chunkJXLSTVBK_js.useWebSDKConfig();
727
+ const promptKey = JSON.stringify(examplePrompts ?? []);
728
+ const welcomeKey = JSON.stringify(fallbackWelcome ?? null);
729
+ const fallbackCatalog = react.useMemo(
730
+ () => buildFallbackCatalog(
731
+ JSON.parse(promptKey),
732
+ JSON.parse(welcomeKey) ?? void 0
733
+ ),
734
+ [promptKey, welcomeKey]
735
+ );
736
+ const [bakedRaw] = react.useState(
737
+ () => readBakedCatalog(productSlug)
738
+ );
739
+ const [catalog, setCatalog] = react.useState(
740
+ () => bakedRaw ? normalizeCatalog(bakedRaw, fallbackCatalog) : fallbackCatalog
741
+ );
742
+ const [serverCatalogRaw, setServerCatalogRaw] = react.useState(bakedRaw);
743
+ const [messages, setMessages] = react.useState([]);
744
+ const [phase, setPhase] = react.useState(
745
+ () => bakedRaw ? bakedRaw.enabled === false ? "disabled" : "ready" : "loading"
746
+ );
747
+ const [error, setError] = react.useState(null);
748
+ const [remainingToday, setRemainingToday] = react.useState(null);
749
+ const [focusProduct, setFocusProductState] = react.useState(null);
750
+ const [turnCount, setTurnCount] = react.useState(0);
751
+ const messagesRef = react.useRef([]);
752
+ const [archive, setArchive] = react.useState([]);
753
+ const [hydrated, setHydrated] = react.useState(false);
754
+ const mountedRef = react.useRef(true);
755
+ const pollGenerationRef = react.useRef(0);
756
+ const pollTimerRef = react.useRef(null);
757
+ const conversationTokenRef = react.useRef(null);
758
+ const [hasConversation, setHasConversation] = react.useState(false);
759
+ const shareTokenRef = react.useRef(void 0);
760
+ if (shareTokenRef.current === void 0) {
761
+ shareTokenRef.current = shareTokenOption === void 0 ? readShareToken() : shareTokenOption;
762
+ }
763
+ const isSharedView = shareTokenRef.current !== null;
764
+ const catalogRef = react.useRef(catalog);
765
+ const turnCountRef = react.useRef(0);
766
+ const focusProductRef = react.useRef(null);
767
+ const lastSentTextRef = react.useRef(null);
768
+ const lastSentAttachmentsRef = react.useRef(
769
+ []
770
+ );
771
+ const inFlightRef = react.useRef(false);
772
+ catalogRef.current = catalog;
773
+ const rememberConversationToken = react.useCallback((token) => {
774
+ conversationTokenRef.current = token;
775
+ setHasConversation(token !== null);
776
+ }, []);
777
+ const clearPollTimer = react.useCallback(() => {
778
+ if (pollTimerRef.current !== null) {
779
+ clearTimeout(pollTimerRef.current);
780
+ pollTimerRef.current = null;
781
+ }
782
+ }, []);
783
+ const cancelPolling = react.useCallback(() => {
784
+ pollGenerationRef.current += 1;
785
+ clearPollTimer();
786
+ }, [clearPollTimer]);
787
+ react.useEffect(() => {
788
+ mountedRef.current = true;
789
+ return () => {
790
+ mountedRef.current = false;
791
+ pollGenerationRef.current += 1;
792
+ if (pollTimerRef.current !== null) {
793
+ clearTimeout(pollTimerRef.current);
794
+ pollTimerRef.current = null;
795
+ }
796
+ };
797
+ }, []);
798
+ react.useEffect(() => {
799
+ if (!enabled) return;
800
+ const shareToken = shareTokenRef.current;
801
+ if (!shareToken) return;
802
+ let cancelled = false;
803
+ setHydrated(true);
804
+ void client.query(
805
+ EXPLORE_SHARED_CONVERSATION_QUERY,
806
+ { shareToken },
807
+ { cache: false }
808
+ ).then((res) => {
809
+ if (cancelled || !mountedRef.current) return;
810
+ const shared = res?.data?.exploreSharedConversation;
811
+ if (shared && shared.length > 0) {
812
+ setMessages(shared);
813
+ return;
814
+ }
815
+ setError({
816
+ kind: "unknown",
817
+ code: "SHARE_NOT_FOUND",
818
+ message: "That shared conversation could not be found. The link may have expired.",
819
+ // Nothing to retry: a bad token will stay bad.
820
+ retryable: false
821
+ });
822
+ }).catch(() => {
823
+ if (cancelled || !mountedRef.current) return;
824
+ setError({
825
+ kind: "unknown",
826
+ code: "SHARE_NOT_FOUND",
827
+ message: "That shared conversation could not be loaded.",
828
+ retryable: true
829
+ });
830
+ });
831
+ return () => {
832
+ cancelled = true;
833
+ };
834
+ }, [client, enabled]);
835
+ react.useEffect(() => {
836
+ if (!enabled) return;
837
+ if (shareTokenRef.current !== null) return;
838
+ if (!persist) {
839
+ setHydrated(true);
840
+ return;
841
+ }
842
+ setArchive(readArchive(storageKey));
843
+ const stored = readPersisted(storageKey);
844
+ if (stored) {
845
+ rememberConversationToken(stored.conversationToken);
846
+ focusProductRef.current = stored.focusProduct;
847
+ const settled = stored.messages.flatMap((m) => {
848
+ if (m.role !== "ASSISTANT") return [m];
849
+ if (m.status !== "PENDING" && m.status !== "RUNNING") return [m];
850
+ const text = visibleText(m);
851
+ if (!text) return [];
852
+ return [{ ...m, status: "COMPLETED", content: text }];
853
+ });
854
+ setMessages(settled);
855
+ setFocusProductState(stored.focusProduct);
856
+ const turns = countUserTurns(settled);
857
+ turnCountRef.current = turns;
858
+ setTurnCount(turns);
859
+ }
860
+ setHydrated(true);
861
+ }, [persist, rememberConversationToken, storageKey, enabled]);
862
+ react.useEffect(() => {
863
+ if (!persist || !hydrated || isSharedView || typeof window === "undefined")
864
+ return;
865
+ try {
866
+ const payload = {
867
+ conversationToken: conversationTokenRef.current,
868
+ messages: messages.slice(-MAX_PERSISTED_MESSAGES),
869
+ focusProduct
870
+ };
871
+ if (!payload.conversationToken && payload.messages.length === 0 && !payload.focusProduct) {
872
+ window.localStorage.removeItem(storageKey);
873
+ return;
874
+ }
875
+ window.localStorage.setItem(storageKey, JSON.stringify(payload));
876
+ } catch {
877
+ }
878
+ }, [persist, hydrated, isSharedView, storageKey, messages, focusProduct]);
879
+ react.useEffect(() => {
880
+ messagesRef.current = messages;
881
+ if (!persist || !hydrated || isSharedView) return;
882
+ const settled = messages.some(
883
+ (m) => m.role === "ASSISTANT" && (m.status === "COMPLETED" || m.status === "FAILED")
884
+ );
885
+ if (!settled) return;
886
+ setArchive(
887
+ upsertArchive(storageKey, {
888
+ token: conversationTokenRef.current,
889
+ messages,
890
+ focusProduct: focusProductRef.current
891
+ })
892
+ );
893
+ }, [messages, persist, hydrated, isSharedView, storageKey]);
894
+ react.useEffect(() => {
895
+ if (!enabled) return;
896
+ let cancelled = false;
897
+ const load = async () => {
898
+ const variables = { productSlug: productSlug ?? null };
899
+ let res = await client.query(
900
+ EXPLORE_CATALOG_QUERY,
901
+ variables
902
+ );
903
+ if (cancelled || !mountedRef.current) return;
904
+ if (catalogRejectedTheHighlightField(res)) {
905
+ res = await client.query(
906
+ EXPLORE_CATALOG_QUERY_WITHOUT_HIGHLIGHTS,
907
+ variables
908
+ );
909
+ if (cancelled || !mountedRef.current) return;
910
+ }
911
+ const raw = res.data?.exploreCatalog;
912
+ if (res.errors?.length || !raw) {
913
+ console.warn(
914
+ "[WebSDK] exploreCatalog unavailable \u2014 keeping the catalog the page started with",
915
+ res.errors?.[0]?.message
916
+ );
917
+ setPhase((prev) => prev === "loading" ? "ready" : prev);
918
+ return;
919
+ }
920
+ const next = normalizeCatalog(
921
+ raw,
922
+ bakedRaw ? normalizeCatalog(bakedRaw, fallbackCatalog) : fallbackCatalog
923
+ );
924
+ setCatalog(next);
925
+ setServerCatalogRaw(raw);
926
+ catalogRef.current = next;
927
+ setPhase((prev) => {
928
+ if (!next.enabled) return "disabled";
929
+ return prev === "loading" || prev === "disabled" ? "ready" : prev;
930
+ });
931
+ };
932
+ void load();
933
+ return () => {
934
+ cancelled = true;
935
+ };
936
+ }, [client, productSlug, fallbackCatalog, bakedRaw, enabled]);
937
+ const startPolling = react.useCallback(
938
+ (conversationToken, messageId) => {
939
+ pollGenerationRef.current += 1;
940
+ const generation = pollGenerationRef.current;
941
+ const startedAt = Date.now();
942
+ let consecutiveFailures = 0;
943
+ const isStale = () => !mountedRef.current || generation !== pollGenerationRef.current;
944
+ const finishWithError = (chatError) => {
945
+ inFlightRef.current = false;
946
+ setMessages(
947
+ (prev) => prev.flatMap((m) => {
948
+ if (m.id !== messageId) return [m];
949
+ const text = visibleText(m);
950
+ if (!text) return [];
951
+ return [{ ...m, status: "FAILED", content: text }];
952
+ })
953
+ );
954
+ setError(chatError);
955
+ setPhase(chatError.kind === "rate-limit" ? "limited" : "error");
956
+ };
957
+ const tick = async () => {
958
+ if (isStale()) return;
959
+ if (Date.now() - startedAt > pollTimeoutMs) {
960
+ finishWithError(classifyExploreError("TIMEOUT"));
961
+ return;
962
+ }
963
+ const res = await client.query(
964
+ EXPLORE_MESSAGE_QUERY,
965
+ { conversationToken, id: messageId },
966
+ { cache: false, timeoutMs: POLL_REQUEST_TIMEOUT_MS }
967
+ );
968
+ if (isStale()) return;
969
+ const first = res.errors?.[0];
970
+ if (first) {
971
+ const code = typeof first.extensions?.code === "string" ? first.extensions.code : void 0;
972
+ const classified = classifyExploreError(code, first.message);
973
+ if (!classified.retryable) {
974
+ finishWithError(classified);
975
+ return;
976
+ }
977
+ consecutiveFailures += 1;
978
+ if (consecutiveFailures >= MAX_CONSECUTIVE_POLL_FAILURES) {
979
+ finishWithError(classified);
980
+ return;
981
+ }
982
+ pollTimerRef.current = setTimeout(() => void tick(), pollIntervalMs);
983
+ return;
984
+ }
985
+ const message = res.data?.exploreMessage;
986
+ if (!message) {
987
+ consecutiveFailures += 1;
988
+ if (consecutiveFailures >= MAX_CONSECUTIVE_POLL_FAILURES) {
989
+ finishWithError(classifyExploreError("NOT_FOUND"));
990
+ return;
991
+ }
992
+ pollTimerRef.current = setTimeout(() => void tick(), pollIntervalMs);
993
+ return;
994
+ }
995
+ consecutiveFailures = 0;
996
+ setMessages(
997
+ (prev) => prev.map((m) => m.id === messageId ? message : m)
998
+ );
999
+ if (message.status === "COMPLETED") {
1000
+ inFlightRef.current = false;
1001
+ setError(null);
1002
+ setPhase("ready");
1003
+ return;
1004
+ }
1005
+ if (message.status === "FAILED") {
1006
+ finishWithError(
1007
+ classifyExploreError(message.errorCode ?? "UPSTREAM_UNAVAILABLE")
1008
+ );
1009
+ return;
1010
+ }
1011
+ setPhase("streaming");
1012
+ pollTimerRef.current = setTimeout(() => void tick(), pollIntervalMs);
1013
+ };
1014
+ pollTimerRef.current = setTimeout(() => void tick(), pollIntervalMs);
1015
+ },
1016
+ [client, pollIntervalMs, pollTimeoutMs]
1017
+ );
1018
+ const submit = react.useCallback(
1019
+ async (text, optimisticId, captchaAttempt, attachments) => {
1020
+ const activeCatalog = catalogRef.current;
1021
+ let recaptchaToken;
1022
+ if (activeCatalog.captchaRequired && activeCatalog.recaptchaSiteKey) {
1023
+ try {
1024
+ recaptchaToken = await chunkPHXAGQNB_js.getRecaptchaV3Token(
1025
+ activeCatalog.recaptchaSiteKey
1026
+ );
1027
+ } catch (err) {
1028
+ console.warn("[WebSDK] reCAPTCHA v3 token could not be minted", err);
1029
+ }
1030
+ }
1031
+ const input = {
1032
+ message: text,
1033
+ ...conversationTokenRef.current ? { conversationToken: conversationTokenRef.current } : {},
1034
+ ...focusProductRef.current || productSlug ? { productSlug: focusProductRef.current ?? productSlug } : {},
1035
+ ...recaptchaToken ? { recaptchaToken } : {},
1036
+ ...locale ? { locale } : {},
1037
+ ...pageUrl ? { pageUrl } : {},
1038
+ ...attachments.length > 0 ? { attachments: [...attachments] } : {}
1039
+ };
1040
+ const res = await client.mutate(
1041
+ SEND_EXPLORE_MESSAGE_MUTATION,
1042
+ { input },
1043
+ { timeoutMs: SEND_REQUEST_TIMEOUT_MS }
1044
+ );
1045
+ if (!mountedRef.current) return;
1046
+ const first = res.errors?.[0];
1047
+ const result = res.data?.sendExploreMessage;
1048
+ if (first || !result) {
1049
+ const code = typeof first?.extensions?.code === "string" ? first.extensions.code : void 0;
1050
+ const classified = classifyExploreError(code, first?.message);
1051
+ if (classified.kind === "captcha" && captchaAttempt === 0) {
1052
+ await submit(text, optimisticId, 1, attachments);
1053
+ return;
1054
+ }
1055
+ inFlightRef.current = false;
1056
+ setError(classified);
1057
+ setPhase(classified.kind === "rate-limit" ? "limited" : "error");
1058
+ return;
1059
+ }
1060
+ rememberConversationToken(result.conversation.token);
1061
+ turnCountRef.current = result.conversation.turnCount;
1062
+ setTurnCount(result.conversation.turnCount);
1063
+ setRemainingToday(result.remainingToday ?? null);
1064
+ const userMessage = result.userMessage;
1065
+ const assistantMessage = result.assistantMessage;
1066
+ setMessages((prev) => {
1067
+ const replaced = prev.some((m) => m.id === optimisticId) ? prev.map((m) => m.id === optimisticId ? userMessage : m) : [...prev, userMessage];
1068
+ return [...replaced, assistantMessage];
1069
+ });
1070
+ if (assistantMessage.status === "COMPLETED" || assistantMessage.status === "FAILED") {
1071
+ inFlightRef.current = false;
1072
+ if (assistantMessage.status === "FAILED") {
1073
+ const classified = classifyExploreError(
1074
+ assistantMessage.errorCode ?? "UPSTREAM_UNAVAILABLE"
1075
+ );
1076
+ setError(classified);
1077
+ setPhase("error");
1078
+ } else {
1079
+ setPhase("ready");
1080
+ }
1081
+ return;
1082
+ }
1083
+ setPhase("streaming");
1084
+ startPolling(result.conversation.token, assistantMessage.id);
1085
+ },
1086
+ [
1087
+ client,
1088
+ locale,
1089
+ pageUrl,
1090
+ productSlug,
1091
+ rememberConversationToken,
1092
+ startPolling
1093
+ ]
1094
+ );
1095
+ const send = react.useCallback(
1096
+ async (message, attachments = []) => {
1097
+ const text = message.trim();
1098
+ if (!text) return;
1099
+ if (inFlightRef.current) return;
1100
+ const activeCatalog = catalogRef.current;
1101
+ if (!activeCatalog.enabled) {
1102
+ setError(classifyExploreError("EXPLORE_DISABLED"));
1103
+ setPhase("disabled");
1104
+ return;
1105
+ }
1106
+ if (text.length > activeCatalog.limits.maxMessageLength) {
1107
+ setError({
1108
+ kind: "validation",
1109
+ code: "MESSAGE_TOO_LONG",
1110
+ message: `That message is ${text.length} characters \u2014 the limit is ${activeCatalog.limits.maxMessageLength}.`,
1111
+ retryable: false
1112
+ });
1113
+ return;
1114
+ }
1115
+ if (turnCountRef.current >= activeCatalog.limits.maxTurnsPerConversation) {
1116
+ setError({
1117
+ kind: "validation",
1118
+ code: "CONVERSATION_LIMIT",
1119
+ message: `This conversation has reached its ${activeCatalog.limits.maxTurnsPerConversation}-message limit. Start a new chat to keep going.`,
1120
+ retryable: false
1121
+ });
1122
+ return;
1123
+ }
1124
+ inFlightRef.current = true;
1125
+ lastSentTextRef.current = text;
1126
+ lastSentAttachmentsRef.current = attachments;
1127
+ setError(null);
1128
+ setPhase("sending");
1129
+ cancelPolling();
1130
+ const optimistic = {
1131
+ id: makeOptimisticId(),
1132
+ conversationId: conversationTokenRef.current ?? "pending",
1133
+ role: "USER",
1134
+ status: "COMPLETED",
1135
+ content: text,
1136
+ partialContent: null,
1137
+ activity: [],
1138
+ references: [],
1139
+ ctas: [],
1140
+ errorCode: null,
1141
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1142
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
1143
+ };
1144
+ setMessages((prev) => [...prev, optimistic]);
1145
+ turnCountRef.current += 1;
1146
+ setTurnCount(turnCountRef.current);
1147
+ onSend?.(text);
1148
+ try {
1149
+ await submit(text, optimistic.id, 0, attachments);
1150
+ } catch (err) {
1151
+ if (!mountedRef.current) return;
1152
+ console.error("[WebSDK] Explore send failed", err);
1153
+ inFlightRef.current = false;
1154
+ setError(classifyExploreError("NETWORK_ERROR"));
1155
+ setPhase("error");
1156
+ }
1157
+ },
1158
+ [cancelPolling, onSend, submit]
1159
+ );
1160
+ const stop = react.useCallback(() => {
1161
+ cancelPolling();
1162
+ inFlightRef.current = false;
1163
+ setMessages(
1164
+ (prev) => prev.flatMap((m) => {
1165
+ if (m.role !== "ASSISTANT") return [m];
1166
+ if (m.status !== "PENDING" && m.status !== "RUNNING") return [m];
1167
+ const text = visibleText(m);
1168
+ if (!text) return [];
1169
+ return [
1170
+ {
1171
+ ...m,
1172
+ status: "COMPLETED",
1173
+ content: text,
1174
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
1175
+ }
1176
+ ];
1177
+ })
1178
+ );
1179
+ setPhase(
1180
+ (prev) => prev === "sending" || prev === "streaming" ? "ready" : prev
1181
+ );
1182
+ }, [cancelPolling]);
1183
+ const retry = react.useCallback(() => {
1184
+ const text = lastSentTextRef.current;
1185
+ if (!text) return;
1186
+ cancelPolling();
1187
+ inFlightRef.current = false;
1188
+ setMessages((prev) => {
1189
+ const next = [...prev];
1190
+ const last = next[next.length - 1];
1191
+ if (last?.role === "ASSISTANT" && last.status === "FAILED") next.pop();
1192
+ const prior = next[next.length - 1];
1193
+ if (prior?.role === "USER" && prior.content === text) next.pop();
1194
+ return next;
1195
+ });
1196
+ turnCountRef.current = Math.max(0, turnCountRef.current - 1);
1197
+ setTurnCount(turnCountRef.current);
1198
+ void send(text, lastSentAttachmentsRef.current);
1199
+ }, [cancelPolling, send]);
1200
+ const reset = react.useCallback(() => {
1201
+ setArchive(
1202
+ upsertArchive(storageKey, {
1203
+ token: conversationTokenRef.current,
1204
+ messages: messagesRef.current,
1205
+ focusProduct: focusProductRef.current
1206
+ })
1207
+ );
1208
+ cancelPolling();
1209
+ inFlightRef.current = false;
1210
+ rememberConversationToken(null);
1211
+ lastSentTextRef.current = null;
1212
+ lastSentAttachmentsRef.current = [];
1213
+ turnCountRef.current = 0;
1214
+ setTurnCount(0);
1215
+ setMessages([]);
1216
+ setError(null);
1217
+ setRemainingToday(null);
1218
+ setPhase(catalogRef.current.enabled ? "ready" : "disabled");
1219
+ if (typeof window !== "undefined") {
1220
+ try {
1221
+ window.localStorage.removeItem(storageKey);
1222
+ } catch {
1223
+ }
1224
+ }
1225
+ }, [cancelPolling, rememberConversationToken, storageKey]);
1226
+ const openConversation = react.useCallback(
1227
+ (token) => {
1228
+ const entry = readArchive(storageKey).find((e) => e.token === token);
1229
+ if (!entry) return;
1230
+ upsertArchive(storageKey, {
1231
+ token: conversationTokenRef.current,
1232
+ messages: messagesRef.current,
1233
+ focusProduct: focusProductRef.current
1234
+ });
1235
+ cancelPolling();
1236
+ inFlightRef.current = false;
1237
+ rememberConversationToken(entry.token);
1238
+ turnCountRef.current = entry.messages.filter(
1239
+ (m) => m.role === "USER"
1240
+ ).length;
1241
+ setTurnCount(turnCountRef.current);
1242
+ setMessages(entry.messages);
1243
+ focusProductRef.current = entry.focusProduct;
1244
+ setFocusProductState(entry.focusProduct);
1245
+ setError(null);
1246
+ setPhase(catalogRef.current.enabled ? "ready" : "disabled");
1247
+ setArchive(readArchive(storageKey));
1248
+ },
1249
+ [cancelPolling, rememberConversationToken, storageKey]
1250
+ );
1251
+ const deleteConversation = react.useCallback(
1252
+ (token) => {
1253
+ const next = readArchive(storageKey).filter((e) => e.token !== token);
1254
+ writeArchive(storageKey, next);
1255
+ setArchive(next);
1256
+ },
1257
+ [storageKey]
1258
+ );
1259
+ const clearHistory = react.useCallback(() => {
1260
+ writeArchive(storageKey, []);
1261
+ setArchive([]);
1262
+ }, [storageKey]);
1263
+ const setFocusProduct = react.useCallback((slug) => {
1264
+ focusProductRef.current = slug;
1265
+ setFocusProductState(slug);
1266
+ }, []);
1267
+ const activity = react.useMemo(() => {
1268
+ for (let i = messages.length - 1; i >= 0; i -= 1) {
1269
+ const m = messages[i];
1270
+ if (!m || m.role !== "ASSISTANT") continue;
1271
+ if (m.status !== "PENDING" && m.status !== "RUNNING") return null;
1272
+ const lines = m.activity ?? [];
1273
+ return lines.length ? lines[lines.length - 1] ?? null : null;
1274
+ }
1275
+ return null;
1276
+ }, [messages]);
1277
+ const canSend = (phase === "ready" || phase === "error") && catalog.enabled && turnCount < catalog.limits.maxTurnsPerConversation;
1278
+ const createShareLink = react.useCallback(async () => {
1279
+ const token = conversationTokenRef.current;
1280
+ if (!token) return null;
1281
+ try {
1282
+ const result = await client.mutate(CREATE_EXPLORE_SHARE_LINK_MUTATION, { conversationToken: token });
1283
+ return result?.data?.createExploreShareLink?.shareToken ?? null;
1284
+ } catch {
1285
+ return null;
1286
+ }
1287
+ }, [client]);
1288
+ const recordClick = react.useCallback(
1289
+ (messageId, kind, url) => {
1290
+ const token = conversationTokenRef.current;
1291
+ if (!token) return;
1292
+ try {
1293
+ void client.mutate(RECORD_EXPLORE_CLICK_MUTATION, {
1294
+ input: { conversationToken: token, messageId, kind, url }
1295
+ }).catch(() => {
1296
+ });
1297
+ } catch {
1298
+ }
1299
+ },
1300
+ [client]
1301
+ );
1302
+ const submitFeedback = react.useCallback(
1303
+ async (messageId, rating, detail) => {
1304
+ const token = conversationTokenRef.current;
1305
+ if (!token) return false;
1306
+ const comment = detail?.comment?.trim();
1307
+ const input = {
1308
+ conversationToken: token,
1309
+ messageId,
1310
+ rating,
1311
+ // Only meaningful with NOT_HELPFUL. The server stores null for HELPFUL either
1312
+ // way; sending it would just be noise the backend has to defend against.
1313
+ reason: rating === "NOT_HELPFUL" ? detail?.reason ?? null : null,
1314
+ comment: comment ? comment : null
1315
+ };
1316
+ try {
1317
+ const res = await client.mutate(
1318
+ SUBMIT_EXPLORE_FEEDBACK_MUTATION,
1319
+ { input }
1320
+ );
1321
+ const result = res?.data?.submitExploreFeedback;
1322
+ if (!result?.recorded) return false;
1323
+ const recorded = result.feedback;
1324
+ if (recorded && mountedRef.current) {
1325
+ setMessages(
1326
+ (current) => current.map(
1327
+ (message) => message.id === messageId ? { ...message, feedback: recorded } : message
1328
+ )
1329
+ );
1330
+ }
1331
+ return true;
1332
+ } catch {
1333
+ return false;
1334
+ }
1335
+ },
1336
+ [client]
1337
+ );
1338
+ const escalate = react.useCallback(
1339
+ async (email, note) => {
1340
+ const token = conversationTokenRef.current;
1341
+ if (!token) {
1342
+ return { outcome: "no-conversation", email: null, createdAt: null };
1343
+ }
1344
+ const attempt = async (captchaAttempt) => {
1345
+ const activeCatalog = catalogRef.current;
1346
+ let recaptchaToken;
1347
+ if (activeCatalog.captchaRequired && activeCatalog.recaptchaSiteKey) {
1348
+ try {
1349
+ recaptchaToken = await chunkPHXAGQNB_js.getRecaptchaV3Token(
1350
+ activeCatalog.recaptchaSiteKey
1351
+ );
1352
+ } catch (err) {
1353
+ console.warn(
1354
+ "[WebSDK] reCAPTCHA v3 token could not be minted",
1355
+ err
1356
+ );
1357
+ }
1358
+ }
1359
+ const input = {
1360
+ conversationToken: token,
1361
+ email: email.trim(),
1362
+ note: note?.trim() ? note.trim() : null,
1363
+ ...recaptchaToken ? { recaptchaToken } : {},
1364
+ ...productId ? { productId } : {}
1365
+ };
1366
+ try {
1367
+ const res = await client.mutate(
1368
+ ESCALATE_EXPLORE_CONVERSATION_MUTATION,
1369
+ { input }
1370
+ );
1371
+ const first = res?.errors?.[0];
1372
+ const result = res?.data?.escalateExploreConversation;
1373
+ if (first || !result) {
1374
+ const code = typeof first?.extensions?.code === "string" ? first.extensions.code : "ESCALATION_FAILED";
1375
+ if (code === "CAPTCHA_FAILED" && captchaAttempt === 0) {
1376
+ return attempt(1);
1377
+ }
1378
+ return {
1379
+ outcome: escalateOutcomeForCode(code),
1380
+ email: null,
1381
+ createdAt: null
1382
+ };
1383
+ }
1384
+ return {
1385
+ // `created: false` is the double-click, the retry, the reload. The handover
1386
+ // exists, so this is a success — and the address comes from the SERVER, because
1387
+ // on a repeat submit the reply goes to whatever the FIRST handover used.
1388
+ outcome: result.created ? "sent" : "already-handed-over",
1389
+ email: result.escalation?.email ?? null,
1390
+ createdAt: result.escalation?.createdAt ?? null
1391
+ };
1392
+ } catch {
1393
+ return { outcome: "failed", email: null, createdAt: null };
1394
+ }
1395
+ };
1396
+ return attempt(0);
1397
+ },
1398
+ [client, productId]
1399
+ );
1400
+ const canEscalate = hasConversation && !isSharedView;
1401
+ const getConversationToken = react.useCallback(
1402
+ () => conversationTokenRef.current,
1403
+ []
1404
+ );
1405
+ return {
1406
+ phase,
1407
+ catalog,
1408
+ serverCatalogRaw,
1409
+ messages,
1410
+ activity,
1411
+ remainingToday,
1412
+ error,
1413
+ focusProduct,
1414
+ setFocusProduct,
1415
+ send,
1416
+ stop,
1417
+ retry,
1418
+ reset,
1419
+ canSend,
1420
+ history: archive,
1421
+ openConversation,
1422
+ deleteConversation,
1423
+ clearHistory,
1424
+ recordClick,
1425
+ submitFeedback,
1426
+ escalate,
1427
+ canEscalate,
1428
+ createShareLink,
1429
+ isSharedView,
1430
+ getConversationToken
1431
+ };
1432
+ }
1433
+ var optimisticCounter = 0;
1434
+ function makeOptimisticId() {
1435
+ optimisticCounter += 1;
1436
+ return `boff-explore-local-${Date.now()}-${optimisticCounter}`;
1437
+ }
1438
+ var DRAIN_TARGET_MS = 1200;
1439
+ var MIN_CHARS_PER_SECOND = 90;
1440
+ var MAX_CHARS_PER_SECOND = 2200;
1441
+ var MAX_STEP_MS = 250;
1442
+ var COMMIT_INTERVAL_MS = 45;
1443
+ var FALLBACK_STEP_MS = 50;
1444
+ var FENCE = /^ {0,3}(?:```|~~~)/;
1445
+ var TABLE_ROW = /^ {0,3}\|/;
1446
+ var EMPTY_BLOCK_MARKER = /^ {0,3}(?:[-+>]|#{1,6}|\d{1,9}[.)])\s*$/;
1447
+ function isWordCharacter(char) {
1448
+ return char !== void 0 && /[\p{L}\p{N}]/u.test(char);
1449
+ }
1450
+ function clamp(value, min, max) {
1451
+ return Math.min(Math.max(value, min), max);
1452
+ }
1453
+ function now() {
1454
+ return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
1455
+ }
1456
+ function isHighSurrogate(code) {
1457
+ return code >= 55296 && code <= 56319;
1458
+ }
1459
+ function safeInlineEnd(line) {
1460
+ let codeSpan = null;
1461
+ const links = [];
1462
+ const emphasis = [];
1463
+ let at = 0;
1464
+ while (at < line.length) {
1465
+ const char = line[at] ?? "";
1466
+ if (char === "\\") {
1467
+ at += 2;
1468
+ continue;
1469
+ }
1470
+ const innermost = links[links.length - 1];
1471
+ if (innermost !== void 0 && innermost.kind !== "label") {
1472
+ if (char === "(") links.push({ kind: "paren", start: innermost.start });
1473
+ else if (char === ")") links.pop();
1474
+ at += 1;
1475
+ continue;
1476
+ }
1477
+ if (char === "`") {
1478
+ let run = 1;
1479
+ while (line[at + run] === "`") run += 1;
1480
+ codeSpan = codeSpan === null ? at : null;
1481
+ at += run;
1482
+ continue;
1483
+ }
1484
+ if (codeSpan !== null) {
1485
+ at += 1;
1486
+ continue;
1487
+ }
1488
+ if (char === "[") {
1489
+ links.push({ kind: "label", start: line[at - 1] === "!" ? at - 1 : at });
1490
+ at += 1;
1491
+ continue;
1492
+ }
1493
+ if (char === "]" && innermost !== void 0) {
1494
+ links.pop();
1495
+ if (line[at + 1] === "(") {
1496
+ links.push({ kind: "destination", start: innermost.start });
1497
+ at += 2;
1498
+ continue;
1499
+ }
1500
+ at += 1;
1501
+ continue;
1502
+ }
1503
+ if (char === "*" || char === "_" || char === "~") {
1504
+ let run = 1;
1505
+ while (line[at + run] === char) run += 1;
1506
+ const start = at;
1507
+ at += run;
1508
+ const before = line[start - 1];
1509
+ const after = line[start + run];
1510
+ if (run < 2) continue;
1511
+ if (char === "_" && isWordCharacter(before) && isWordCharacter(after)) {
1512
+ continue;
1513
+ }
1514
+ const marker = char.repeat(run);
1515
+ const open2 = emphasis.findIndex((entry) => entry.marker === marker);
1516
+ if (open2 !== -1) {
1517
+ emphasis.splice(open2, 1);
1518
+ continue;
1519
+ }
1520
+ if (after !== void 0 && /\s/.test(after)) continue;
1521
+ emphasis.push({ marker, start });
1522
+ continue;
1523
+ }
1524
+ at += 1;
1525
+ }
1526
+ const open = [
1527
+ codeSpan,
1528
+ links[0]?.start ?? null,
1529
+ emphasis[0]?.start ?? null
1530
+ ].filter((value) => value !== null);
1531
+ return open.length === 0 ? line.length : Math.min(...open);
1532
+ }
1533
+ function revealBoundary(text, limit) {
1534
+ if (limit <= 0) return 0;
1535
+ const caughtUp = limit >= text.length;
1536
+ const head = caughtUp ? text : text.slice(0, limit);
1537
+ const lineStart = head.lastIndexOf("\n") + 1;
1538
+ const line = head.slice(lineStart);
1539
+ let fenceStart = null;
1540
+ let tableStart = null;
1541
+ let tableRows = 0;
1542
+ let at = 0;
1543
+ while (at < lineStart) {
1544
+ const breakAt = head.indexOf("\n", at);
1545
+ const end = breakAt === -1 ? lineStart : breakAt;
1546
+ const row = head.slice(at, end);
1547
+ if (fenceStart !== null) {
1548
+ if (FENCE.test(row)) fenceStart = null;
1549
+ } else if (FENCE.test(row)) {
1550
+ fenceStart = at;
1551
+ } else if (TABLE_ROW.test(row)) {
1552
+ if (tableStart === null) {
1553
+ tableStart = at;
1554
+ tableRows = 0;
1555
+ }
1556
+ tableRows += 1;
1557
+ } else if (tableStart !== null) {
1558
+ tableStart = null;
1559
+ tableRows = 0;
1560
+ }
1561
+ at = end + 1;
1562
+ }
1563
+ if (fenceStart === null) {
1564
+ const lastIsRow = TABLE_ROW.test(line);
1565
+ if (lastIsRow && tableStart === null) {
1566
+ tableStart = lineStart;
1567
+ tableRows = 0;
1568
+ } else if (!lastIsRow && line !== "") {
1569
+ tableStart = null;
1570
+ tableRows = 0;
1571
+ }
1572
+ if (tableStart !== null && tableRows < 2) return tableStart;
1573
+ }
1574
+ if (caughtUp) return text.length;
1575
+ if (fenceStart !== null) return fenceStart;
1576
+ if (TABLE_ROW.test(line)) return lineStart;
1577
+ if (EMPTY_BLOCK_MARKER.test(line)) return lineStart;
1578
+ const cut = lineStart + safeInlineEnd(line);
1579
+ return isHighSurrogate(text.charCodeAt(cut - 1)) ? cut - 1 : cut;
1580
+ }
1581
+ function prefersReducedMotion() {
1582
+ if (typeof window === "undefined") return true;
1583
+ try {
1584
+ return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
1585
+ } catch {
1586
+ return false;
1587
+ }
1588
+ }
1589
+ function useProgressiveReveal(text, settled) {
1590
+ const [, setFrame] = react.useState(0);
1591
+ const [reduced] = react.useState(prefersReducedMotion);
1592
+ const immediate = settled || reduced;
1593
+ const textRef = react.useRef(text);
1594
+ const cursorRef = react.useRef(immediate ? text.length : 0);
1595
+ const cutRef = react.useRef(immediate ? text.length : 0);
1596
+ const committedRef = react.useRef(0);
1597
+ if (text !== textRef.current) {
1598
+ const revealed = textRef.current.slice(0, Math.floor(cursorRef.current));
1599
+ if (revealed !== "" && !text.startsWith(revealed)) {
1600
+ cursorRef.current = text.length;
1601
+ }
1602
+ cursorRef.current = Math.min(cursorRef.current, text.length);
1603
+ cutRef.current = Math.min(cutRef.current, text.length);
1604
+ textRef.current = text;
1605
+ }
1606
+ if (immediate) cursorRef.current = text.length;
1607
+ const cut = immediate ? text.length : Math.max(
1608
+ cutRef.current,
1609
+ revealBoundary(text, Math.floor(cursorRef.current))
1610
+ );
1611
+ cutRef.current = cut;
1612
+ react.useEffect(() => {
1613
+ if (immediate) return;
1614
+ if (cursorRef.current >= text.length) return;
1615
+ let cancelled = false;
1616
+ let cancelStep = null;
1617
+ let previous = now();
1618
+ const commit = (at, force) => {
1619
+ if (!force && at - committedRef.current < COMMIT_INTERVAL_MS) return;
1620
+ committedRef.current = at;
1621
+ setFrame((value) => value + 1);
1622
+ };
1623
+ const step = () => {
1624
+ cancelStep = null;
1625
+ if (cancelled) return;
1626
+ const at = now();
1627
+ const elapsed = clamp(at - previous, 0, MAX_STEP_MS);
1628
+ previous = at;
1629
+ const length = textRef.current.length;
1630
+ const pending = length - cursorRef.current;
1631
+ if (pending <= 0) {
1632
+ commit(at, true);
1633
+ return;
1634
+ }
1635
+ const perSecond = clamp(
1636
+ pending / (DRAIN_TARGET_MS / 1e3),
1637
+ MIN_CHARS_PER_SECOND,
1638
+ MAX_CHARS_PER_SECOND
1639
+ );
1640
+ cursorRef.current = Math.min(
1641
+ length,
1642
+ cursorRef.current + perSecond * elapsed / 1e3
1643
+ );
1644
+ const done = cursorRef.current >= length;
1645
+ commit(at, done);
1646
+ if (!done) schedule();
1647
+ };
1648
+ const schedule = () => {
1649
+ if (typeof window.requestAnimationFrame === "function") {
1650
+ const id2 = window.requestAnimationFrame(step);
1651
+ cancelStep = () => window.cancelAnimationFrame(id2);
1652
+ return;
1653
+ }
1654
+ const id = setTimeout(step, FALLBACK_STEP_MS);
1655
+ cancelStep = () => clearTimeout(id);
1656
+ };
1657
+ schedule();
1658
+ return () => {
1659
+ cancelled = true;
1660
+ cancelStep?.();
1661
+ };
1662
+ }, [text, immediate]);
1663
+ return text.slice(0, cut);
1664
+ }
1665
+ function getRecognitionCtor() {
1666
+ if (typeof window === "undefined") return null;
1667
+ const w = window;
1668
+ return w.SpeechRecognition ?? w.webkitSpeechRecognition ?? null;
1669
+ }
1670
+ function isTouchDevice() {
1671
+ if (typeof window === "undefined" || !window.matchMedia) return false;
1672
+ try {
1673
+ return window.matchMedia("(pointer: coarse)").matches;
1674
+ } catch {
1675
+ return false;
1676
+ }
1677
+ }
1678
+ var MIC_DENIED_MESSAGE = "Microphone access was blocked. Allow it in your browser's site settings to dictate.";
1679
+ var MIC_UNAVAILABLE_MESSAGE = "Dictation isn't available in this browser. You can type instead.";
1680
+ var RELEASE_SETTLE_MS = 250;
1681
+ var RETRY_DELAY_MS = 350;
1682
+ var sleep = (ms) => new Promise((resolve) => {
1683
+ setTimeout(resolve, ms);
1684
+ });
1685
+ async function ensureMicrophoneAccess() {
1686
+ const media = typeof navigator === "undefined" ? void 0 : navigator.mediaDevices;
1687
+ if (!media?.getUserMedia)
1688
+ return { ok: true, confirmed: false, primed: false };
1689
+ try {
1690
+ const status = await navigator.permissions?.query({
1691
+ name: "microphone"
1692
+ });
1693
+ if (status?.state === "granted")
1694
+ return { ok: true, confirmed: true, primed: false };
1695
+ } catch {
1696
+ }
1697
+ try {
1698
+ const stream = await media.getUserMedia({ audio: true });
1699
+ for (const track of stream.getTracks()) track.stop();
1700
+ return { ok: true, confirmed: true, primed: true };
1701
+ } catch (error) {
1702
+ const name = typeof error === "object" && error !== null && "name" in error ? String(error.name) : "";
1703
+ if (name === "NotAllowedError" || name === "SecurityError") {
1704
+ return { ok: false, message: MIC_DENIED_MESSAGE };
1705
+ }
1706
+ if (name === "NotFoundError" || name === "DevicesNotFoundError") {
1707
+ return { ok: false, message: "No microphone was found." };
1708
+ }
1709
+ return {
1710
+ ok: false,
1711
+ message: "Dictation could not start. You can type instead."
1712
+ };
1713
+ }
1714
+ }
1715
+ function describeError(code) {
1716
+ switch (code) {
1717
+ case "not-allowed":
1718
+ case "service-not-allowed":
1719
+ return MIC_DENIED_MESSAGE;
1720
+ case "no-speech":
1721
+ return "I didn't catch anything \u2014 try again a little closer to the mic.";
1722
+ case "audio-capture":
1723
+ return "No microphone was found.";
1724
+ case "network":
1725
+ return "Speech recognition needs a network connection.";
1726
+ case "aborted":
1727
+ return "";
1728
+ default:
1729
+ return "Dictation stopped unexpectedly. You can type instead.";
1730
+ }
1731
+ }
1732
+ function useSpeechInput({
1733
+ onFinalTranscript,
1734
+ lang,
1735
+ onError
1736
+ }) {
1737
+ const [supported] = react.useState(() => getRecognitionCtor() !== null);
1738
+ const [listening, setListening] = react.useState(false);
1739
+ const [interim, setInterim] = react.useState("");
1740
+ const [error, setError] = react.useState(null);
1741
+ const recognitionRef = react.useRef(null);
1742
+ const startTokenRef = react.useRef(0);
1743
+ const micConfirmedRef = react.useRef(false);
1744
+ const wantsListeningRef = react.useRef(false);
1745
+ const retriedRef = react.useRef(false);
1746
+ const finalRef = react.useRef(onFinalTranscript);
1747
+ const errorRef = react.useRef(onError);
1748
+ finalRef.current = onFinalTranscript;
1749
+ errorRef.current = onError;
1750
+ const langRef = react.useRef(lang);
1751
+ langRef.current = lang;
1752
+ const stop = react.useCallback(() => {
1753
+ startTokenRef.current += 1;
1754
+ wantsListeningRef.current = false;
1755
+ setListening(false);
1756
+ setInterim("");
1757
+ const recognition = recognitionRef.current;
1758
+ if (!recognition) return;
1759
+ try {
1760
+ recognition.stop();
1761
+ } catch {
1762
+ }
1763
+ }, []);
1764
+ const openSession = react.useCallback((token) => {
1765
+ const Ctor = getRecognitionCtor();
1766
+ if (!Ctor || token !== startTokenRef.current) return;
1767
+ const recognition = new Ctor();
1768
+ recognition.lang = langRef.current ?? (typeof navigator === "undefined" ? "en-US" : navigator.language || "en-US");
1769
+ recognition.continuous = !isTouchDevice();
1770
+ recognition.interimResults = true;
1771
+ recognition.maxAlternatives = 1;
1772
+ recognition.onstart = () => {
1773
+ if (token !== startTokenRef.current) return;
1774
+ setError(null);
1775
+ setListening(true);
1776
+ };
1777
+ recognition.onresult = (event) => {
1778
+ if (token !== startTokenRef.current) return;
1779
+ let settled = "";
1780
+ let pending = "";
1781
+ for (let i = event.resultIndex; i < event.results.length; i += 1) {
1782
+ const result = event.results[i];
1783
+ if (!result) continue;
1784
+ const text = result[0]?.transcript ?? "";
1785
+ if (result.isFinal) settled += text;
1786
+ else pending += text;
1787
+ }
1788
+ setInterim(pending);
1789
+ if (settled.trim() !== "") finalRef.current(settled);
1790
+ };
1791
+ recognition.onerror = (event) => {
1792
+ if (token !== startTokenRef.current) return;
1793
+ if ((event.error === "not-allowed" || event.error === "service-not-allowed") && micConfirmedRef.current && !retriedRef.current) {
1794
+ retriedRef.current = true;
1795
+ void sleep(RETRY_DELAY_MS).then(() => {
1796
+ if (token !== startTokenRef.current || !wantsListeningRef.current)
1797
+ return;
1798
+ openSessionRef.current?.(token);
1799
+ });
1800
+ return;
1801
+ }
1802
+ const message = micConfirmedRef.current && (event.error === "not-allowed" || event.error === "service-not-allowed") ? MIC_UNAVAILABLE_MESSAGE : describeError(event.error);
1803
+ wantsListeningRef.current = false;
1804
+ setListening(false);
1805
+ setInterim("");
1806
+ if (message !== "") {
1807
+ setError(message);
1808
+ errorRef.current?.(message);
1809
+ }
1810
+ };
1811
+ recognition.onend = () => {
1812
+ if (token !== startTokenRef.current) return;
1813
+ setInterim("");
1814
+ if (wantsListeningRef.current && isTouchDevice()) {
1815
+ void sleep(120).then(() => {
1816
+ if (token !== startTokenRef.current || !wantsListeningRef.current)
1817
+ return;
1818
+ openSessionRef.current?.(token);
1819
+ });
1820
+ return;
1821
+ }
1822
+ setListening(false);
1823
+ };
1824
+ recognitionRef.current = recognition;
1825
+ try {
1826
+ recognition.start();
1827
+ } catch {
1828
+ wantsListeningRef.current = false;
1829
+ setListening(false);
1830
+ }
1831
+ }, []);
1832
+ const openSessionRef = react.useRef(null);
1833
+ openSessionRef.current = openSession;
1834
+ const start = react.useCallback(() => {
1835
+ if (!getRecognitionCtor()) return;
1836
+ startTokenRef.current += 1;
1837
+ const token = startTokenRef.current;
1838
+ wantsListeningRef.current = true;
1839
+ retriedRef.current = false;
1840
+ micConfirmedRef.current = false;
1841
+ setError(null);
1842
+ setListening(true);
1843
+ void ensureMicrophoneAccess().then(async (access) => {
1844
+ if (token !== startTokenRef.current) return;
1845
+ if (!access.ok) {
1846
+ wantsListeningRef.current = false;
1847
+ setListening(false);
1848
+ setError(access.message);
1849
+ errorRef.current?.(access.message);
1850
+ return;
1851
+ }
1852
+ micConfirmedRef.current = access.confirmed;
1853
+ if (access.primed) {
1854
+ await sleep(RELEASE_SETTLE_MS);
1855
+ if (token !== startTokenRef.current) return;
1856
+ }
1857
+ openSessionRef.current?.(token);
1858
+ });
1859
+ }, []);
1860
+ const toggle = react.useCallback(() => {
1861
+ if (listening) stop();
1862
+ else start();
1863
+ }, [listening, start, stop]);
1864
+ react.useEffect(
1865
+ () => () => {
1866
+ startTokenRef.current += 1;
1867
+ wantsListeningRef.current = false;
1868
+ const recognition = recognitionRef.current;
1869
+ if (!recognition) return;
1870
+ recognition.onresult = null;
1871
+ recognition.onerror = null;
1872
+ recognition.onend = null;
1873
+ recognition.onstart = null;
1874
+ try {
1875
+ recognition.abort();
1876
+ } catch {
1877
+ }
1878
+ },
1879
+ []
1880
+ );
1881
+ return { supported, listening, interim, error, start, stop, toggle };
1882
+ }
1883
+ var SILENT_FAILURE_MS = 1500;
1884
+ function speechPlatform() {
1885
+ if (typeof window === "undefined") return null;
1886
+ const scope = window;
1887
+ const synth = scope.speechSynthesis;
1888
+ const Utterance = scope.SpeechSynthesisUtterance;
1889
+ if (!synth || typeof synth.speak !== "function") return null;
1890
+ if (typeof Utterance !== "function") return null;
1891
+ return { synth, Utterance };
1892
+ }
1893
+ function normaliseTag(tag) {
1894
+ return tag.trim().toLowerCase().replace(/_/g, "-");
1895
+ }
1896
+ function primaryOf(tag) {
1897
+ return normaliseTag(tag).split("-")[0] ?? "";
1898
+ }
1899
+ function pickVoice(voices, lang) {
1900
+ const wanted = normaliseTag(lang);
1901
+ if (wanted === "") return null;
1902
+ const primary = primaryOf(wanted);
1903
+ const exact = voices.filter((voice) => normaliseTag(voice.lang) === wanted);
1904
+ const related = voices.filter((voice) => primaryOf(voice.lang) === primary);
1905
+ return exact.find((voice) => voice.default) ?? exact[0] ?? related.find((voice) => voice.default) ?? related[0] ?? null;
1906
+ }
1907
+ var activeOwner = null;
1908
+ var activeStop = null;
1909
+ function stopSpeaking() {
1910
+ activeStop?.();
1911
+ }
1912
+ function useSpeechOutput({
1913
+ lang
1914
+ } = {}) {
1915
+ const [available, setAvailable] = react.useState(() => speechPlatform() !== null);
1916
+ const [speaking, setSpeaking] = react.useState(false);
1917
+ const utteranceRef = react.useRef(null);
1918
+ const watchdogRef = react.useRef(null);
1919
+ const ownerRef = react.useRef({});
1920
+ const stopRef = react.useRef(() => void 0);
1921
+ const langRef = react.useRef(lang);
1922
+ langRef.current = lang;
1923
+ const clearWatchdog = react.useCallback(() => {
1924
+ if (watchdogRef.current === null) return;
1925
+ clearTimeout(watchdogRef.current);
1926
+ watchdogRef.current = null;
1927
+ }, []);
1928
+ const settle = react.useCallback(() => {
1929
+ clearWatchdog();
1930
+ utteranceRef.current = null;
1931
+ if (activeOwner === ownerRef.current) {
1932
+ activeOwner = null;
1933
+ activeStop = null;
1934
+ }
1935
+ setSpeaking(false);
1936
+ }, [clearWatchdog]);
1937
+ const stop = react.useCallback(() => {
1938
+ const owned = utteranceRef.current !== null;
1939
+ settle();
1940
+ if (owned) speechPlatform()?.synth.cancel();
1941
+ }, [settle]);
1942
+ stopRef.current = stop;
1943
+ const speak = react.useCallback(
1944
+ (text) => {
1945
+ const platform = speechPlatform();
1946
+ if (!platform) {
1947
+ setAvailable(false);
1948
+ return;
1949
+ }
1950
+ const spoken = text.trim();
1951
+ if (spoken === "") return;
1952
+ if (activeStop && activeOwner !== ownerRef.current) activeStop();
1953
+ platform.synth.cancel();
1954
+ const utterance = new platform.Utterance(spoken);
1955
+ const wanted = langRef.current;
1956
+ if (wanted !== void 0 && wanted !== "") {
1957
+ const voice = pickVoice(platform.synth.getVoices(), wanted);
1958
+ utterance.lang = voice?.lang ?? wanted;
1959
+ if (voice) utterance.voice = voice;
1960
+ }
1961
+ const mine = () => utteranceRef.current === utterance;
1962
+ utterance.onstart = () => {
1963
+ if (!mine()) return;
1964
+ clearWatchdog();
1965
+ setSpeaking(true);
1966
+ };
1967
+ utterance.onend = () => {
1968
+ if (!mine()) return;
1969
+ settle();
1970
+ };
1971
+ utterance.onerror = (event) => {
1972
+ if (!mine()) return;
1973
+ const code = typeof event?.error === "string" ? event.error : "";
1974
+ settle();
1975
+ if (code !== "interrupted" && code !== "canceled") setAvailable(false);
1976
+ };
1977
+ utteranceRef.current = utterance;
1978
+ activeOwner = ownerRef.current;
1979
+ activeStop = () => {
1980
+ stopRef.current();
1981
+ };
1982
+ setSpeaking(true);
1983
+ platform.synth.speak(utterance);
1984
+ clearWatchdog();
1985
+ watchdogRef.current = setTimeout(() => {
1986
+ watchdogRef.current = null;
1987
+ if (!mine()) return;
1988
+ if (platform.synth.speaking) return;
1989
+ settle();
1990
+ setAvailable(false);
1991
+ }, SILENT_FAILURE_MS);
1992
+ },
1993
+ [clearWatchdog, settle]
1994
+ );
1995
+ const toggle = react.useCallback(
1996
+ (text) => {
1997
+ if (speaking) stop();
1998
+ else speak(text);
1999
+ },
2000
+ [speak, speaking, stop]
2001
+ );
2002
+ react.useEffect(() => {
2003
+ if (!speaking || typeof window === "undefined") return;
2004
+ const onHide = () => {
2005
+ stopRef.current();
2006
+ };
2007
+ window.addEventListener("pagehide", onHide);
2008
+ return () => window.removeEventListener("pagehide", onHide);
2009
+ }, [speaking]);
2010
+ react.useEffect(
2011
+ () => () => {
2012
+ stopRef.current();
2013
+ },
2014
+ []
2015
+ );
2016
+ return { supported: available, speaking, speak, stop, toggle };
2017
+ }
2018
+
2019
+ exports.BAKED_CATALOG_ELEMENT_ID = BAKED_CATALOG_ELEMENT_ID;
2020
+ exports.DEFAULT_EXPLORE_EXAMPLE_PROMPTS = DEFAULT_EXPLORE_EXAMPLE_PROMPTS;
2021
+ exports.ECOSYSTEM_PRODUCTS = ECOSYSTEM_PRODUCTS;
2022
+ exports.ESCALATE_EXPLORE_CONVERSATION_MUTATION = ESCALATE_EXPLORE_CONVERSATION_MUTATION;
2023
+ exports.EXPLORE_CATALOG_QUERY = EXPLORE_CATALOG_QUERY;
2024
+ exports.EXPLORE_CATALOG_QUERY_WITHOUT_HIGHLIGHTS = EXPLORE_CATALOG_QUERY_WITHOUT_HIGHLIGHTS;
2025
+ exports.EXPLORE_ESCALATION_NOTE_SOFT_MAX = EXPLORE_ESCALATION_NOTE_SOFT_MAX;
2026
+ exports.EXPLORE_FEEDBACK_COMMENT_SOFT_MAX = EXPLORE_FEEDBACK_COMMENT_SOFT_MAX;
2027
+ exports.EXPLORE_FEEDBACK_REASONS = EXPLORE_FEEDBACK_REASONS;
2028
+ exports.EXPLORE_MESSAGE_QUERY = EXPLORE_MESSAGE_QUERY;
2029
+ exports.FALLBACK_EXPLORE_LIMITS = FALLBACK_EXPLORE_LIMITS;
2030
+ exports.SEND_EXPLORE_MESSAGE_MUTATION = SEND_EXPLORE_MESSAGE_MUTATION;
2031
+ exports.bakedCatalogLocale = bakedCatalogLocale;
2032
+ exports.classifyExploreError = classifyExploreError;
2033
+ exports.looksLikeDeliverableEmail = looksLikeDeliverableEmail;
2034
+ exports.serializeBakedCatalog = serializeBakedCatalog;
2035
+ exports.stopSpeaking = stopSpeaking;
2036
+ exports.useExploreChat = useExploreChat;
2037
+ exports.useProgressiveReveal = useProgressiveReveal;
2038
+ exports.useSpeechInput = useSpeechInput;
2039
+ exports.useSpeechOutput = useSpeechOutput;
2040
+ //# sourceMappingURL=chunk-SK5UGG6A.js.map
2041
+ //# sourceMappingURL=chunk-SK5UGG6A.js.map