@adminide-stack/yantra-mobile 12.0.196-alpha.0 → 12.0.196

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 (382) hide show
  1. package/lib/components/CustomDrawer.js +17 -1
  2. package/lib/components/CustomDrawer.js.map +1 -1
  3. package/lib/compute.js +57 -1
  4. package/lib/compute.js.map +1 -1
  5. package/lib/config/env-config.js +11 -1
  6. package/lib/config/env-config.js.map +1 -1
  7. package/lib/features/agent-chat/NativeAgentChat.js +7 -0
  8. package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
  9. package/lib/features/canvas/extendVideo.js +5 -1
  10. package/lib/features/canvas/extendVideo.js.map +1 -1
  11. package/lib/features/canvas/workflow/StepSheet.js +18 -1
  12. package/lib/features/canvas/workflow/StepSheet.js.map +1 -1
  13. package/lib/features/canvas/workflow/workflowSteps.js +102 -31
  14. package/lib/features/canvas/workflow/workflowSteps.js.map +1 -1
  15. package/lib/features/chat/ComposerMicSend.js +35 -0
  16. package/lib/features/chat/ComposerMicSend.js.map +1 -0
  17. package/lib/features/chat/ComposerModeSwitch.js +64 -1
  18. package/lib/features/chat/ComposerModeSwitch.js.map +1 -1
  19. package/lib/features/chat/askUser.js +6 -1
  20. package/lib/features/chat/askUser.js.map +1 -1
  21. package/lib/features/connectors/ConnectorSheet.js +443 -0
  22. package/lib/features/connectors/ConnectorSheet.js.map +1 -0
  23. package/lib/features/connectors/ConnectorsPage.js +320 -0
  24. package/lib/features/connectors/ConnectorsPage.js.map +1 -0
  25. package/lib/features/connectors/connectConnector.js +278 -0
  26. package/lib/features/connectors/connectConnector.js.map +1 -0
  27. package/lib/features/connectors/connectorCatalog.js +222 -0
  28. package/lib/features/connectors/connectorCatalog.js.map +1 -0
  29. package/lib/features/connectors/useConnectorCatalog.js +153 -0
  30. package/lib/features/connectors/useConnectorCatalog.js.map +1 -0
  31. package/lib/features/home/needsYou/HomeNeedsYou.js +618 -0
  32. package/lib/features/home/needsYou/HomeNeedsYou.js.map +1 -0
  33. package/lib/features/home/needsYou/chatFollowUps.js +333 -0
  34. package/lib/features/home/needsYou/chatFollowUps.js.map +1 -0
  35. package/lib/features/home/needsYou/format.js +47 -0
  36. package/lib/features/home/needsYou/format.js.map +1 -0
  37. package/lib/features/home/needsYou/historyText.js +40 -0
  38. package/lib/features/home/needsYou/historyText.js.map +1 -0
  39. package/lib/features/home/needsYou/inboxHighlights.js +152 -0
  40. package/lib/features/home/needsYou/inboxHighlights.js.map +1 -0
  41. package/lib/features/home/needsYou/panelsSettings.js +71 -0
  42. package/lib/features/home/needsYou/panelsSettings.js.map +1 -0
  43. package/lib/features/home/needsYou/ported/commandConfirmProtocol.js +13 -0
  44. package/lib/features/home/needsYou/ported/commandConfirmProtocol.js.map +1 -0
  45. package/lib/features/home/needsYou/ported/paymentApprovalProtocol.js +91 -0
  46. package/lib/features/home/needsYou/ported/paymentApprovalProtocol.js.map +1 -0
  47. package/lib/features/home/needsYou/ported/resultCardModels.js +659 -0
  48. package/lib/features/home/needsYou/ported/resultCardModels.js.map +1 -0
  49. package/lib/features/home/needsYou/types.js +1 -0
  50. package/lib/features/home/needsYou/types.js.map +1 -0
  51. package/lib/features/home/needsYou/useChatFollowUps.js +149 -0
  52. package/lib/features/home/needsYou/useChatFollowUps.js.map +1 -0
  53. package/lib/features/home/needsYou/useHomeBriefing.js +68 -0
  54. package/lib/features/home/needsYou/useHomeBriefing.js.map +1 -0
  55. package/lib/features/home/needsYou/useInboxHighlights.js +173 -0
  56. package/lib/features/home/needsYou/useInboxHighlights.js.map +1 -0
  57. package/lib/features/home/needsYou/usePanelsSettings.js +105 -0
  58. package/lib/features/home/needsYou/usePanelsSettings.js.map +1 -0
  59. package/lib/features/shopping/DealCard.js +8 -1
  60. package/lib/features/shopping/DealCard.js.map +1 -1
  61. package/lib/features/shopping/DealRails.js +24 -7
  62. package/lib/features/shopping/DealRails.js.map +1 -1
  63. package/lib/features/shopping/DealsPanel.js +1 -1
  64. package/lib/features/shopping/DealsPanel.js.map +1 -1
  65. package/lib/features/shopping/HolidayDealsPanel.js +529 -0
  66. package/lib/features/shopping/HolidayDealsPanel.js.map +1 -0
  67. package/lib/features/shopping/HolidayDealsParts.js +954 -0
  68. package/lib/features/shopping/HolidayDealsParts.js.map +1 -0
  69. package/lib/features/shopping/HolidayOffers.js +351 -0
  70. package/lib/features/shopping/HolidayOffers.js.map +1 -0
  71. package/lib/features/shopping/ProductCard.js +80 -14
  72. package/lib/features/shopping/ProductCard.js.map +1 -1
  73. package/lib/features/shopping/ProductDetailSheet.js +22 -3
  74. package/lib/features/shopping/ProductDetailSheet.js.map +1 -1
  75. package/lib/features/shopping/SavedPanel.js +341 -5
  76. package/lib/features/shopping/SavedPanel.js.map +1 -1
  77. package/lib/features/shopping/SearchResults.js +8 -2
  78. package/lib/features/shopping/SearchResults.js.map +1 -1
  79. package/lib/features/shopping/ShoppingAgentChatPane.js +12 -0
  80. package/lib/features/shopping/ShoppingAgentChatPane.js.map +1 -1
  81. package/lib/features/shopping/ShoppingExperience.js +56 -19
  82. package/lib/features/shopping/ShoppingExperience.js.map +1 -1
  83. package/lib/features/shopping/TrendingSections.js +13 -4
  84. package/lib/features/shopping/TrendingSections.js.map +1 -1
  85. package/lib/features/shopping/WatchlistPanel.js +61 -5
  86. package/lib/features/shopping/WatchlistPanel.js.map +1 -1
  87. package/lib/features/shopping/catalog.js +41 -2
  88. package/lib/features/shopping/catalog.js.map +1 -1
  89. package/lib/features/shopping/chat/brainRouter.js +14 -0
  90. package/lib/features/shopping/chat/brainRouter.js.map +1 -1
  91. package/lib/features/shopping/chat/shoppingTurn.js +88 -16
  92. package/lib/features/shopping/chat/shoppingTurn.js.map +1 -1
  93. package/lib/features/shopping/hooks/useHolidayDeals.js +388 -0
  94. package/lib/features/shopping/hooks/useHolidayDeals.js.map +1 -0
  95. package/lib/features/shopping/hooks/useProductMedia.js +33 -6
  96. package/lib/features/shopping/hooks/useProductMedia.js.map +1 -1
  97. package/lib/features/shopping/hooks/useShoppingHistorySync.js +8 -4
  98. package/lib/features/shopping/hooks/useShoppingHistorySync.js.map +1 -1
  99. package/lib/features/shopping/hooks/useTrendingProducts.js +11 -3
  100. package/lib/features/shopping/hooks/useTrendingProducts.js.map +1 -1
  101. package/lib/features/shopping/savedProducts.js +76 -6
  102. package/lib/features/shopping/savedProducts.js.map +1 -1
  103. package/lib/features/shopping/services/aiRelevance.js +212 -0
  104. package/lib/features/shopping/services/aiRelevance.js.map +1 -0
  105. package/lib/features/shopping/services/blackFriday.js +301 -0
  106. package/lib/features/shopping/services/blackFriday.js.map +1 -0
  107. package/lib/features/shopping/services/blackFridayBrowserSites.js +137 -0
  108. package/lib/features/shopping/services/blackFridayBrowserSites.js.map +1 -0
  109. package/lib/features/shopping/services/catalogProductSearch.js +21 -3
  110. package/lib/features/shopping/services/catalogProductSearch.js.map +1 -1
  111. package/lib/features/shopping/services/holidayDeals.js +143 -0
  112. package/lib/features/shopping/services/holidayDeals.js.map +1 -0
  113. package/lib/features/shopping/services/mediaShape.js +7 -0
  114. package/lib/features/shopping/services/mediaShape.js.map +1 -0
  115. package/lib/features/shopping/services/modelStep.js +95 -0
  116. package/lib/features/shopping/services/modelStep.js.map +1 -0
  117. package/lib/features/shopping/services/modelWords.js +14 -0
  118. package/lib/features/shopping/services/modelWords.js.map +1 -0
  119. package/lib/features/shopping/services/productAvailability.js +5 -1
  120. package/lib/features/shopping/services/productAvailability.js.map +1 -1
  121. package/lib/features/shopping/services/productFilters.js +2 -2
  122. package/lib/features/shopping/services/productFilters.js.map +1 -1
  123. package/lib/features/shopping/services/productMedia.js +103 -18
  124. package/lib/features/shopping/services/productMedia.js.map +1 -1
  125. package/lib/features/shopping/services/retailerUrl.js +11 -8
  126. package/lib/features/shopping/services/retailerUrl.js.map +1 -1
  127. package/lib/features/shopping/services/salesDealsStore.js +3 -2
  128. package/lib/features/shopping/services/salesDealsStore.js.map +1 -1
  129. package/lib/features/shopping/services/savedReads.js +82 -0
  130. package/lib/features/shopping/services/savedReads.js.map +1 -0
  131. package/lib/features/shopping/services/searchCardFields.js +2 -0
  132. package/lib/features/shopping/services/searchCardFields.js.map +1 -1
  133. package/lib/features/shopping/services/searchRelevance.js +154 -24
  134. package/lib/features/shopping/services/searchRelevance.js.map +1 -1
  135. package/lib/features/shopping/services/secondHand.js +12 -0
  136. package/lib/features/shopping/services/secondHand.js.map +1 -0
  137. package/lib/features/shopping/services/shoppingProductSearch.js +82 -10
  138. package/lib/features/shopping/services/shoppingProductSearch.js.map +1 -1
  139. package/lib/features/shopping/services/shoppingSearchConnectorClient.js +14 -1
  140. package/lib/features/shopping/services/shoppingSearchConnectorClient.js.map +1 -1
  141. package/lib/features/shopping/services/shoppingSubgraph.js +2 -1
  142. package/lib/features/shopping/services/shoppingSubgraph.js.map +1 -1
  143. package/lib/features/shopping/services/storedGalleries.js +130 -0
  144. package/lib/features/shopping/services/storedGalleries.js.map +1 -0
  145. package/lib/features/shopping/services/usedSites.js +263 -0
  146. package/lib/features/shopping/services/usedSites.js.map +1 -0
  147. package/lib/features/shopping/services/verifyProducts.js +3 -3
  148. package/lib/features/shopping/services/verifyProducts.js.map +1 -1
  149. package/lib/features/shopping/services/watchDeal.js +61 -0
  150. package/lib/features/shopping/services/watchDeal.js.map +1 -0
  151. package/lib/features/shopping/shoppingRuntime.js +7 -2
  152. package/lib/features/shopping/shoppingRuntime.js.map +1 -1
  153. package/lib/features/shopping/state/accountCaches.js +20 -0
  154. package/lib/features/shopping/state/accountCaches.js.map +1 -0
  155. package/lib/features/shopping/state/holidayDealsRequest.js +22 -0
  156. package/lib/features/shopping/state/holidayDealsRequest.js.map +1 -0
  157. package/lib/features/shopping/tutorials/ShoppingTutorialDock.js +1 -1
  158. package/lib/features/shopping/tutorials/ShoppingTutorialDock.js.map +1 -1
  159. package/lib/features/shopping/tutorials/shoppingTutorials.js +2 -0
  160. package/lib/features/shopping/tutorials/shoppingTutorials.js.map +1 -1
  161. package/lib/features/shopping/useShoppingSearch.js +74 -18
  162. package/lib/features/shopping/useShoppingSearch.js.map +1 -1
  163. package/lib/features/team-chat/TeamChatExperience.js +474 -0
  164. package/lib/features/team-chat/TeamChatExperience.js.map +1 -0
  165. package/lib/features/team-chat/api/client.js +198 -0
  166. package/lib/features/team-chat/api/client.js.map +1 -0
  167. package/lib/features/team-chat/api/live.js +160 -0
  168. package/lib/features/team-chat/api/live.js.map +1 -0
  169. package/lib/features/team-chat/api/ops.js +241 -0
  170. package/lib/features/team-chat/api/ops.js.map +1 -0
  171. package/lib/features/team-chat/app.js +12 -0
  172. package/lib/features/team-chat/app.js.map +1 -0
  173. package/lib/features/team-chat/components/Avatar.js +107 -0
  174. package/lib/features/team-chat/components/Avatar.js.map +1 -0
  175. package/lib/features/team-chat/components/Composer.js +641 -0
  176. package/lib/features/team-chat/components/Composer.js.map +1 -0
  177. package/lib/features/team-chat/components/Dialogs.js +598 -0
  178. package/lib/features/team-chat/components/Dialogs.js.map +1 -0
  179. package/lib/features/team-chat/components/EmojiPicker.js +165 -0
  180. package/lib/features/team-chat/components/EmojiPicker.js.map +1 -0
  181. package/lib/features/team-chat/components/MessageItem.js +658 -0
  182. package/lib/features/team-chat/components/MessageItem.js.map +1 -0
  183. package/lib/features/team-chat/components/MessageList.js +248 -0
  184. package/lib/features/team-chat/components/MessageList.js.map +1 -0
  185. package/lib/features/team-chat/components/Mrkdwn.js +228 -0
  186. package/lib/features/team-chat/components/Mrkdwn.js.map +1 -0
  187. package/lib/features/team-chat/components/QuickSwitcher.js +215 -0
  188. package/lib/features/team-chat/components/QuickSwitcher.js.map +1 -0
  189. package/lib/features/team-chat/components/ui.js +662 -0
  190. package/lib/features/team-chat/components/ui.js.map +1 -0
  191. package/lib/features/team-chat/nativeTeamChatRegistry.js +15 -0
  192. package/lib/features/team-chat/nativeTeamChatRegistry.js.map +1 -0
  193. package/lib/features/team-chat/state/fetched.js +39 -0
  194. package/lib/features/team-chat/state/fetched.js.map +1 -0
  195. package/lib/features/team-chat/state/lists.js +230 -0
  196. package/lib/features/team-chat/state/lists.js.map +1 -0
  197. package/lib/features/team-chat/state/store.js +1108 -0
  198. package/lib/features/team-chat/state/store.js.map +1 -0
  199. package/lib/features/team-chat/state/useChannelDirectory.js +21 -0
  200. package/lib/features/team-chat/state/useChannelDirectory.js.map +1 -0
  201. package/lib/features/team-chat/theme.js +77 -0
  202. package/lib/features/team-chat/theme.js.map +1 -0
  203. package/lib/features/team-chat/utils/composeText.js +72 -0
  204. package/lib/features/team-chat/utils/composeText.js.map +1 -0
  205. package/lib/features/team-chat/utils/emoji.js +369 -0
  206. package/lib/features/team-chat/utils/emoji.js.map +1 -0
  207. package/lib/features/team-chat/utils/format.js +109 -0
  208. package/lib/features/team-chat/utils/format.js.map +1 -0
  209. package/lib/features/team-chat/utils/messageRows.js +24 -0
  210. package/lib/features/team-chat/utils/messageRows.js.map +1 -0
  211. package/lib/features/team-chat/utils/mrkdwn.js +222 -0
  212. package/lib/features/team-chat/utils/mrkdwn.js.map +1 -0
  213. package/lib/features/team-chat/utils/notify.js +47 -0
  214. package/lib/features/team-chat/utils/notify.js.map +1 -0
  215. package/lib/features/team-chat/utils/pickFiles.js +81 -0
  216. package/lib/features/team-chat/utils/pickFiles.js.map +1 -0
  217. package/lib/features/team-chat/views/ActivityView.js +235 -0
  218. package/lib/features/team-chat/views/ActivityView.js.map +1 -0
  219. package/lib/features/team-chat/views/BrowseView.js +179 -0
  220. package/lib/features/team-chat/views/BrowseView.js.map +1 -0
  221. package/lib/features/team-chat/views/ChannelView.js +475 -0
  222. package/lib/features/team-chat/views/ChannelView.js.map +1 -0
  223. package/lib/features/team-chat/views/DetailsPane.js +816 -0
  224. package/lib/features/team-chat/views/DetailsPane.js.map +1 -0
  225. package/lib/features/team-chat/views/DraftsView.js +212 -0
  226. package/lib/features/team-chat/views/DraftsView.js.map +1 -0
  227. package/lib/features/team-chat/views/FilesView.js +152 -0
  228. package/lib/features/team-chat/views/FilesView.js.map +1 -0
  229. package/lib/features/team-chat/views/NewMessageView.js +286 -0
  230. package/lib/features/team-chat/views/NewMessageView.js.map +1 -0
  231. package/lib/features/team-chat/views/PeopleView.js +118 -0
  232. package/lib/features/team-chat/views/PeopleView.js.map +1 -0
  233. package/lib/features/team-chat/views/ProfilePane.js +220 -0
  234. package/lib/features/team-chat/views/ProfilePane.js.map +1 -0
  235. package/lib/features/team-chat/views/SavedView.js +113 -0
  236. package/lib/features/team-chat/views/SavedView.js.map +1 -0
  237. package/lib/features/team-chat/views/SearchView.js +307 -0
  238. package/lib/features/team-chat/views/SearchView.js.map +1 -0
  239. package/lib/features/team-chat/views/Sidebar.js +368 -0
  240. package/lib/features/team-chat/views/Sidebar.js.map +1 -0
  241. package/lib/features/team-chat/views/ThreadPane.js +139 -0
  242. package/lib/features/team-chat/views/ThreadPane.js.map +1 -0
  243. package/lib/features/team-chat/views/ThreadsView.js +157 -0
  244. package/lib/features/team-chat/views/ThreadsView.js.map +1 -0
  245. package/lib/features/webbuilder/WebBuilderExperience.js +276 -42
  246. package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
  247. package/lib/features/webbuilder/buildFragments.js +10 -4
  248. package/lib/features/webbuilder/buildFragments.js.map +1 -1
  249. package/lib/features/webbuilder/components/AssetChips.js +61 -0
  250. package/lib/features/webbuilder/components/AssetChips.js.map +1 -0
  251. package/lib/features/webbuilder/components/AssetSiteChooser.js +100 -0
  252. package/lib/features/webbuilder/components/AssetSiteChooser.js.map +1 -0
  253. package/lib/features/webbuilder/components/CommentsLayer.js +485 -0
  254. package/lib/features/webbuilder/components/CommentsLayer.js.map +1 -0
  255. package/lib/features/webbuilder/components/Composer.js +16 -2
  256. package/lib/features/webbuilder/components/Composer.js.map +1 -1
  257. package/lib/features/webbuilder/components/ComposerModeSwitch.js +71 -0
  258. package/lib/features/webbuilder/components/ComposerModeSwitch.js.map +1 -0
  259. package/lib/features/webbuilder/components/MyAssetsPicker.js +500 -0
  260. package/lib/features/webbuilder/components/MyAssetsPicker.js.map +1 -0
  261. package/lib/features/webbuilder/components/PlanDocument.js +165 -0
  262. package/lib/features/webbuilder/components/PlanDocument.js.map +1 -0
  263. package/lib/features/webbuilder/components/PlanDraftCard.js +205 -0
  264. package/lib/features/webbuilder/components/PlanDraftCard.js.map +1 -0
  265. package/lib/features/webbuilder/components/PlanView.js +788 -0
  266. package/lib/features/webbuilder/components/PlanView.js.map +1 -0
  267. package/lib/features/webbuilder/components/PreviewConsoleSheet.js +334 -0
  268. package/lib/features/webbuilder/components/PreviewConsoleSheet.js.map +1 -0
  269. package/lib/features/webbuilder/components/PreviewFrame.js +45 -3
  270. package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
  271. package/lib/features/webbuilder/components/PreviewScreen.js +94 -10
  272. package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
  273. package/lib/features/webbuilder/components/ProjectChat.js +84 -14
  274. package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
  275. package/lib/features/webbuilder/components/StudioHome.js +69 -6
  276. package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
  277. package/lib/features/webbuilder/components/StyleDirectionsSheet.js +291 -0
  278. package/lib/features/webbuilder/components/StyleDirectionsSheet.js.map +1 -0
  279. package/lib/features/webbuilder/components/VersionChangesView.js +574 -0
  280. package/lib/features/webbuilder/components/VersionChangesView.js.map +1 -0
  281. package/lib/features/webbuilder/components/VersionPreviewView.js +186 -0
  282. package/lib/features/webbuilder/components/VersionPreviewView.js.map +1 -0
  283. package/lib/features/webbuilder/components/VersionsSheet.js +673 -16
  284. package/lib/features/webbuilder/components/VersionsSheet.js.map +1 -1
  285. package/lib/features/webbuilder/connectorTemplates.js +6 -1
  286. package/lib/features/webbuilder/connectorTemplates.js.map +1 -1
  287. package/lib/features/webbuilder/myAssets.js +101 -0
  288. package/lib/features/webbuilder/myAssets.js.map +1 -0
  289. package/lib/features/webbuilder/planChat.js +146 -0
  290. package/lib/features/webbuilder/planChat.js.map +1 -0
  291. package/lib/features/webbuilder/planDocument.js +89 -0
  292. package/lib/features/webbuilder/planDocument.js.map +1 -0
  293. package/lib/features/webbuilder/planStore.js +55 -0
  294. package/lib/features/webbuilder/planStore.js.map +1 -0
  295. package/lib/features/webbuilder/previewCommentsScript.js +218 -0
  296. package/lib/features/webbuilder/previewCommentsScript.js.map +1 -0
  297. package/lib/features/webbuilder/previewConsoleScript.js +39 -0
  298. package/lib/features/webbuilder/previewConsoleScript.js.map +1 -0
  299. package/lib/features/webbuilder/styleDirections.js +85 -0
  300. package/lib/features/webbuilder/styleDirections.js.map +1 -0
  301. package/lib/features/webbuilder/useCanvasComments.js +335 -0
  302. package/lib/features/webbuilder/useCanvasComments.js.map +1 -0
  303. package/lib/features/webbuilder/useCatalogTemplates.js +37 -0
  304. package/lib/features/webbuilder/useCatalogTemplates.js.map +1 -0
  305. package/lib/features/webbuilder/usePlanMode.js +145 -0
  306. package/lib/features/webbuilder/usePlanMode.js.map +1 -0
  307. package/lib/features/webbuilder/useStyleDirections.js +112 -0
  308. package/lib/features/webbuilder/useStyleDirections.js.map +1 -0
  309. package/lib/features/webbuilder/web/assets/assetsApi.js +174 -0
  310. package/lib/features/webbuilder/web/assets/assetsApi.js.map +1 -0
  311. package/lib/features/webbuilder/web/assets/assetsApi.ts +173 -0
  312. package/lib/features/webbuilder/web/assets/myAssets.js +341 -0
  313. package/lib/features/webbuilder/web/assets/myAssets.js.map +1 -0
  314. package/lib/features/webbuilder/web/assets/myAssets.ts +396 -0
  315. package/lib/features/webbuilder/web/canvas/elementName.js +46 -0
  316. package/lib/features/webbuilder/web/canvas/elementName.js.map +1 -0
  317. package/lib/features/webbuilder/web/canvas/visualEditorBridge.js +95 -0
  318. package/lib/features/webbuilder/web/canvas/visualEditorBridge.js.map +1 -0
  319. package/lib/features/webbuilder/web/chat/agentTurn.js +24 -0
  320. package/lib/features/webbuilder/web/chat/agentTurn.js.map +1 -0
  321. package/lib/features/webbuilder/web/chat/planMode.js +164 -0
  322. package/lib/features/webbuilder/web/chat/planMode.js.map +1 -0
  323. package/lib/features/webbuilder/web/chat/realPlans.js +66 -0
  324. package/lib/features/webbuilder/web/chat/realPlans.js.map +1 -0
  325. package/lib/features/webbuilder/web/comments/comments.js +336 -0
  326. package/lib/features/webbuilder/web/comments/comments.js.map +1 -0
  327. package/lib/features/webbuilder/web/comments/commentsApi.js +59 -0
  328. package/lib/features/webbuilder/web/comments/commentsApi.js.map +1 -0
  329. package/lib/features/webbuilder/web/components/planView.js +21 -0
  330. package/lib/features/webbuilder/web/components/planView.js.map +1 -0
  331. package/lib/features/webbuilder/web/console/consolePanel.js +43 -0
  332. package/lib/features/webbuilder/web/console/consolePanel.js.map +1 -0
  333. package/lib/features/webbuilder/web/console/previewConsole.js +256 -0
  334. package/lib/features/webbuilder/web/console/previewConsole.js.map +1 -0
  335. package/lib/features/webbuilder/web/console/usePreviewConsole.js +147 -0
  336. package/lib/features/webbuilder/web/console/usePreviewConsole.js.map +1 -0
  337. package/lib/features/webbuilder/web/design/directions.js +419 -1
  338. package/lib/features/webbuilder/web/design/directions.js.map +1 -1
  339. package/lib/features/webbuilder/web/history/diffActions.js +222 -0
  340. package/lib/features/webbuilder/web/history/diffActions.js.map +1 -0
  341. package/lib/features/webbuilder/web/history/diffHighlight.js +18 -0
  342. package/lib/features/webbuilder/web/history/diffHighlight.js.map +1 -0
  343. package/lib/features/webbuilder/web/history/versionActions.js +272 -0
  344. package/lib/features/webbuilder/web/history/versionActions.js.map +1 -0
  345. package/lib/features/webbuilder/web/history/versionDiff.js +338 -0
  346. package/lib/features/webbuilder/web/history/versionDiff.js.map +1 -0
  347. package/lib/features/webbuilder/web/history/versionPreview.js +83 -0
  348. package/lib/features/webbuilder/web/history/versionPreview.js.map +1 -0
  349. package/lib/features/webbuilder/web/history/versionPreviewMachine.js +150 -0
  350. package/lib/features/webbuilder/web/history/versionPreviewMachine.js.map +1 -0
  351. package/lib/features/webbuilder/web/history/versions.js +326 -1
  352. package/lib/features/webbuilder/web/history/versions.js.map +1 -1
  353. package/lib/features/webbuilder/web/hosted/hostedTurn.js +36 -0
  354. package/lib/features/webbuilder/web/hosted/hostedTurn.js.map +1 -0
  355. package/lib/features/webbuilder/web/studio/brandKit.js +25 -0
  356. package/lib/features/webbuilder/web/studio/brandKit.js.map +1 -0
  357. package/lib/features/webbuilder/web/utils/promptSafe.js +15 -0
  358. package/lib/features/webbuilder/web/utils/promptSafe.js.map +1 -0
  359. package/lib/features/webbuilder/web/webServices.js +3 -1
  360. package/lib/features/webbuilder/web/webServices.js.map +1 -1
  361. package/lib/index.js +1 -1
  362. package/lib/index.js.map +1 -1
  363. package/lib/routes.json +55 -0
  364. package/lib/screens/Account/index.js +13 -5
  365. package/lib/screens/Account/index.js.map +1 -1
  366. package/lib/screens/Chat/index.js +16 -0
  367. package/lib/screens/Chat/index.js.map +1 -1
  368. package/lib/screens/Home/HomeScreen.js +202 -39
  369. package/lib/screens/Home/HomeScreen.js.map +1 -1
  370. package/lib/screens/Home/components/HomeHero.js +52 -38
  371. package/lib/screens/Home/components/HomeHero.js.map +1 -1
  372. package/lib/screens/Home/components/homeCatalog.js +8 -1
  373. package/lib/screens/Home/components/homeCatalog.js.map +1 -1
  374. package/lib/screens/TeamChat/index.js +41 -0
  375. package/lib/screens/TeamChat/index.js.map +1 -0
  376. package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js +9 -2
  377. package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js.map +1 -1
  378. package/lib/screens/WebBuilderNative/index.js +13 -3
  379. package/lib/screens/WebBuilderNative/index.js.map +1 -1
  380. package/lib/screens/WebBuilderNative/useConnectorTemplates.js +2 -2
  381. package/lib/screens/WebBuilderNative/useConnectorTemplates.js.map +1 -1
  382. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"retailerUrl.js","sources":["../../../../src/features/shopping/services/retailerUrl.ts"],"sourcesContent":["/**\n * Retailer URL classification — the single place that decides \"which shop is this\n * link, and is it a real product page?\".\n *\n * The connector's SERP reads sometimes hand back a retailer's CATEGORY / browse\n * page (Best Buy `abcat…`/`pcmcat…` hubs, Amazon `/s?k=`, Walmart `/browse/…`)\n * rather than an individual product. Turned into a card those become two bugs the\n * storefront must not ship:\n * 1. a wrong badge — a bestbuy.com link wearing an \"Amazon\" tag, and\n * 2. a dead \"product details\" link that 404s / lands on a category page.\n *\n * A card is only trustworthy when its URL is a genuine product page for a shop we\n * recognise, so mappers gate on {@link isRetailerProductUrl} and tag with\n * {@link detectRetailerSourceFromUrl}.\n */\nimport type { ProductSource } from '../catalog';\n\n/** Host substring → storefront source. Ordered most-specific first. */\nconst HOST_SOURCE: Array<{ re: RegExp; source: ProductSource }> = [\n { re: /amazon\\./i, source: 'amazon' },\n { re: /walmart\\./i, source: 'walmart' },\n { re: /bestbuy\\./i, source: 'bestbuy' },\n { re: /ebay\\./i, source: 'ebay' },\n { re: /target\\./i, source: 'target' },\n { re: /costco\\./i, source: 'costco' },\n { re: /homedepot\\./i, source: 'homedepot' },\n { re: /lowes\\./i, source: 'lowes' },\n { re: /newegg\\./i, source: 'newegg' },\n { re: /temu\\./i, source: 'temu' },\n { re: /myshopify\\.com/i, source: 'shopify' },\n];\n\n/**\n * Per-retailer product-page URL shapes. A category, search or browse URL for the\n * same host will not match these, which is exactly how hub pages get rejected.\n */\nconst PRODUCT_URL_PATTERNS: Partial<Record<ProductSource, RegExp>> = {\n // /dp/ASIN, /gp/product/ASIN, /gp/aw/d/ASIN, /product/ASIN\n amazon: /\\/(?:dp|gp\\/product|gp\\/aw\\/d|product)\\/([A-Z0-9]{10})(?:[/?#]|$)/i,\n // /ip/<slug>/<id> or /ip/<id>\n walmart: /\\/ip\\/[^?#]*\\d/i,\n // /site/<slug>/<skuId>.p (category pages end in `.c`)\n bestbuy: /\\/site\\/[^?#]*\\d\\.p(?:[/?#]|$)/i,\n // /itm/<itemId>\n ebay: /\\/itm\\/\\d+/i,\n // /p/<slug>/-/A-<tcin>\n target: /\\/-\\/A-\\w+/i,\n // /<slug>.product.<itemId>.html\n costco: /\\.product\\.\\d+\\.html/i,\n // /p/<slug>/<itemId>\n homedepot: /\\/p\\/[^?#]*\\d/i,\n // /pd/<slug>/<itemId>\n lowes: /\\/pd\\/[^?#]*\\d/i,\n // /p/<itemId>\n newegg: /\\/p\\/[A-Za-z0-9]+/i,\n // /products/<handle>\n shopify: /\\/products\\/[a-z0-9][a-z0-9-]*/i,\n // /<slug>-g-<goodsId>.html or /goods.html?goods_id=<goodsId>, optionally\n // behind a locale prefix (/uk/, /de-en/). Search and channel hubs match neither.\n temu: /\\/(?:[a-z]{2}(?:-[a-z]{2})?\\/)?(?:[^/?#]*-g-\\d{6,}\\.html|goods\\.html\\?[^#]*\\bgoods_id=\\d{6,})/i,\n};\n\n/**\n * Sources that rank OTHER shops' pages instead of hosting products themselves.\n *\n * Every other source is a storefront, so a link on a different host than the one\n * it claims is mislabeled and gets dropped. An aggregator inverts that: a Google\n * Shopping row is *supposed* to be on bestbuy.com, and applying the host/source\n * match to it would reject the entire lane.\n */\nconst AGGREGATOR_SOURCES = new Set<ProductSource>(['google']);\n\n/** True when `source` names a lane that ranks other shops' pages. */\nexport function isAggregatorSource(source?: ProductSource): boolean {\n return !!source && AGGREGATOR_SOURCES.has(source);\n}\n\n/**\n * Product-detail path shapes, for a shop we have no per-source rule for. Reading\n * the PATH rather than keeping a list of shops is what lets the aggregator lane\n * reach the long tail — a brand storefront nobody enumerated still gets in, and\n * that same shop's category page still does not.\n */\nconst GENERIC_PRODUCT_PATH =\n /\\/(?:dp|gp\\/product)\\/[A-Z0-9]{10}(?:[/?#]|$)|\\/ip\\/[^?#]*\\d|\\/itm\\/\\d{9,}|\\/-\\/A-\\w+|\\/site\\/[^?#]*\\d\\.p(?:[/?#]|$)|\\/products?\\/[a-z0-9][a-z0-9-]{2,}|\\/pd?\\/[^?#]*\\d|\\.product\\.\\d+\\.html/i;\n\n/**\n * Hosts that carry product-shaped paths but sell nothing: search engines, socials\n * and forums. Not a retailer vocabulary — the lane accepts every shop it has never\n * heard of, and this is the short list of things that are definitively not shops.\n */\nconst NON_MERCHANT_HOST =\n /(?:^|\\/\\/|\\.)(?:google|googleusercontent|gstatic|bing|duckduckgo|yahoo|youtube|facebook|instagram|pinterest|reddit|quora|wikipedia|medium|blogspot|substack|tiktok|twitter)\\./i;\n\n/** True when `url` is on a host that sells nothing (search engine, social, forum). */\nexport function isNonMerchantHost(url?: string): boolean {\n return !!url && NON_MERCHANT_HOST.test(url);\n}\n\n/**\n * True when `url` is a product page on SOME merchant — a shop we recognise, or an\n * unknown one whose URL has a product-detail shape. The gate for aggregator rows.\n */\nexport function isAggregatorProductUrl(url?: string): boolean {\n if (!url) return false;\n if (NON_MERCHANT_HOST.test(url)) return false;\n const source = detectRetailerSourceFromUrl(url);\n if (source) return isRetailerProductUrl(url, source);\n return GENERIC_PRODUCT_PATH.test(url);\n}\n\n/** Strict Amazon ASIN — ten alphanumerics. \"BESTBUY-ABCAT0204000.C\" is not one. */\nexport const ASIN_PATTERN = /^[A-Z0-9]{10}$/;\n\n/** Detect the storefront source a URL belongs to, by host — Best Buy included. */\nexport function detectRetailerSourceFromUrl(url?: string): ProductSource | undefined {\n if (!url) return undefined;\n for (const { re, source } of HOST_SOURCE) {\n if (re.test(url)) return source;\n }\n return undefined;\n}\n\n/** True only when `url` is a real product page for `source`. */\nexport function isRetailerProductUrl(url: string | undefined, source: ProductSource): boolean {\n if (!url) return false;\n // An aggregator's rows live on the merchants' hosts, so the host/source match\n // below would reject every one of them.\n if (AGGREGATOR_SOURCES.has(source)) return isAggregatorProductUrl(url);\n const host = detectRetailerSourceFromUrl(url);\n // A link claiming to be one shop but hosted on another is mislabeled, not a product.\n if (host && host !== source) return false;\n const pattern = PRODUCT_URL_PATTERNS[source];\n if (!pattern) return false;\n return pattern.test(url);\n}\n\n/** True when `url` is a product page for any shop we recognise. */\nexport function isKnownRetailerProductUrl(url?: string): boolean {\n const source = detectRetailerSourceFromUrl(url);\n return !!source && isRetailerProductUrl(url, source);\n}\n\n/** Pull the ASIN out of an Amazon product URL, if present. */\nexport function extractAsinFromUrl(url?: string): string | undefined {\n if (!url) return undefined;\n const match = url.match(PRODUCT_URL_PATTERNS.amazon as RegExp);\n return match?.[1]?.toUpperCase();\n}\n\n/**\n * Query params that carry the real destination inside an affiliate redirect\n * wrapper (Impact `goto.*?u=`, LinkSynergy/Rakuten `murl`, Awin `ued`, eBay\n * rover `mpre`, Skimlinks/VigLink `url`/`r`, …).\n */\nconst DESTINATION_PARAMS = [\n 'u',\n 'url',\n 'murl',\n 'ued',\n 'r',\n 'redirect',\n 'dest',\n 'destination',\n 'target',\n 'to',\n 'link',\n 'mpre',\n 'RD_PARM1',\n];\n\n/**\n * Params a canonical product page never needs — dropping them avoids the malformed\n * tracking strings that make a live product 404 (the reported Walmart case).\n * Anything not listed here is dropped too; only functionally-required params are\n * re-added per source in {@link KEEP_PARAMS}.\n */\nconst KEEP_PARAMS: Partial<Record<ProductSource, string[]>> = {\n // Best Buy resolves by the `.p` path but keeps `skuId` for the exact variant.\n bestbuy: ['skuId'],\n // Shopify variant selection lives in the query.\n shopify: ['variant'],\n // Temu's app share link IS the query: /goods.html?goods_id=<id> resolves to\n // nothing without it. Harmless on the /<slug>-g-<id>.html shape, which has none.\n temu: ['goods_id'],\n};\n\nfunction tryParseUrl(url: string): URL | null {\n try {\n return new URL(url);\n } catch {\n return null;\n }\n}\n\n/**\n * Follow an affiliate redirect wrapper to the real retailer URL embedded in its\n * query (`goto.target.com/c/…?u=https%3A%2F%2Fwww.target.com%2Fp%2F…`). Loops a\n * few times for double-wrapped links; leaves a genuine product URL untouched.\n */\nexport function unwrapAffiliateUrl(url: string): string {\n let current = url;\n for (let depth = 0; depth < 4; depth += 1) {\n // A real product page is the destination, not a wrapper — stop unwrapping.\n if (isKnownRetailerProductUrl(current)) break;\n const parsed = tryParseUrl(current);\n if (!parsed) break;\n\n let embedded: string | undefined;\n for (const key of DESTINATION_PARAMS) {\n const value = parsed.searchParams.get(key);\n if (value && /^https?:\\/\\//i.test(value)) {\n embedded = value;\n break;\n }\n }\n // Fallback: any param whose value is an absolute URL on a shop we recognise.\n if (!embedded) {\n for (const [, value] of parsed.searchParams) {\n if (/^https?:\\/\\//i.test(value) && detectRetailerSourceFromUrl(value)) {\n embedded = value;\n break;\n }\n }\n }\n if (!embedded || embedded === current) break;\n current = embedded;\n }\n return current;\n}\n\n/** Strip tracking noise from a product URL, keeping only params the page needs. */\nexport function canonicalizeProductUrl(url: string): string {\n const parsed = tryParseUrl(url);\n if (!parsed) return url;\n const source = detectRetailerSourceFromUrl(url);\n if (!source) return url;\n const kept = new URLSearchParams();\n for (const key of KEEP_PARAMS[source] ?? []) {\n const value = parsed.searchParams.get(key);\n if (value) kept.set(key, value);\n }\n const query = kept.toString();\n return `${parsed.origin}${parsed.pathname}${query ? `?${query}` : ''}`;\n}\n\n/**\n * Repair a catalog/affiliate URL into a link that actually resolves: unwrap the\n * redirect wrapper, then drop tracking params so the canonical product page loads.\n * A URL we cannot map to a known retailer product is returned unwrapped but\n * otherwise untouched.\n */\nexport function sanitizeRetailerUrl(url?: string): string | undefined {\n if (!url) return url;\n const unwrapped = unwrapAffiliateUrl(url);\n if (isKnownRetailerProductUrl(unwrapped)) return canonicalizeProductUrl(unwrapped);\n return unwrapped;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,cAGD,CAAC;AAAA,EACJ,EAAI,EAAA,WAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,YAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,YAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,SAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,MA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CAAO,QAAQ,CAAA,EAAG,KAAQ,GAAA,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA;AACtE;AAQO,SAAS,oBAAoB,GAAkC,EAAA;AACpE,EAAI,IAAA,CAAC,KAAY,OAAA,GAAA;AACjB,EAAM,MAAA,SAAA,GAAY,mBAAmB,GAAG,CAAA;AACxC,EAAA,IAAI,yBAA0B,CAAA,SAAS,CAAG,EAAA,OAAO,uBAAuB,SAAS,CAAA;AACjF,EAAO,OAAA,SAAA;AACT"}
1
+ {"version":3,"file":"retailerUrl.js","sources":["../../../../src/features/shopping/services/retailerUrl.ts"],"sourcesContent":["/**\n * Retailer URL classification — the single place that decides \"which shop is this\n * link, and is it a real product page?\".\n *\n * The connector's SERP reads sometimes hand back a retailer's CATEGORY / browse\n * page (Best Buy `abcat…`/`pcmcat…` hubs, Amazon `/s?k=`, Walmart `/browse/…`)\n * rather than an individual product. Turned into a card those become two bugs the\n * storefront must not ship:\n * 1. a wrong badge — a bestbuy.com link wearing an \"Amazon\" tag, and\n * 2. a dead \"product details\" link that 404s / lands on a category page.\n *\n * A card is only trustworthy when its URL is a genuine product page for a shop we\n * recognise, so mappers gate on {@link isRetailerProductUrl} and tag with\n * {@link detectRetailerSourceFromUrl}.\n */\nimport type { ProductSource } from '../catalog';\nimport { usedSiteOfHost, usedSiteOfListing } from './usedSites';\n\n/** Host substring → storefront source. Ordered most-specific first. */\nconst HOST_SOURCE: Array<{ re: RegExp; source: ProductSource }> = [\n { re: /amazon\\./i, source: 'amazon' },\n { re: /walmart\\./i, source: 'walmart' },\n { re: /bestbuy\\./i, source: 'bestbuy' },\n { re: /ebay\\./i, source: 'ebay' },\n { re: /target\\./i, source: 'target' },\n { re: /costco\\./i, source: 'costco' },\n { re: /homedepot\\./i, source: 'homedepot' },\n { re: /lowes\\./i, source: 'lowes' },\n { re: /newegg\\./i, source: 'newegg' },\n { re: /temu\\./i, source: 'temu' },\n { re: /myshopify\\.com/i, source: 'shopify' },\n];\n\n/**\n * Per-retailer product-page URL shapes. A category, search or browse URL for the\n * same host will not match these, which is exactly how hub pages get rejected.\n */\nconst PRODUCT_URL_PATTERNS: Partial<Record<ProductSource, RegExp>> = {\n // /dp/ASIN, /gp/product/ASIN, /gp/aw/d/ASIN, /product/ASIN\n amazon: /\\/(?:dp|gp\\/product|gp\\/aw\\/d|product)\\/([A-Z0-9]{10})(?:[/?#]|$)/i,\n // /ip/<slug>/<id> or /ip/<id>\n walmart: /\\/ip\\/[^?#]*\\d/i,\n // /site/<slug>/<skuId>.p (category pages end in `.c`), or the newer\n // /product/<slug>/<code>[/sku/<skuId>] that Best Buy and Google Shopping link to now\n bestbuy: /\\/(?:site\\/[^?#]*\\d\\.p|product\\/[^/?#]+\\/[A-Za-z0-9]{6,})(?:[/?#]|$)/i,\n // /itm/<itemId>\n ebay: /\\/itm\\/\\d+/i,\n // /p/<slug>/-/A-<tcin>\n target: /\\/-\\/A-\\w+/i,\n // /<slug>.product.<itemId>.html, or /p/-/<slug>/<itemId> - what its results link to now (2026-11-20);\n // its category pages are /f/-/<slug>\n costco: /\\.product\\.\\d+\\.html|\\/p\\/-\\/[^/?#]+\\/\\d{4,}(?:[/?#]|$)/i,\n // /p/<slug>/<itemId>\n homedepot: /\\/p\\/[^?#]*\\d/i,\n // /pd/<slug>/<itemId>\n lowes: /\\/pd\\/[^?#]*\\d/i,\n // /p/<itemId>\n newegg: /\\/p\\/[A-Za-z0-9]+/i,\n // /products/<handle>\n shopify: /\\/products\\/[a-z0-9][a-z0-9-]*/i,\n // /<slug>-g-<goodsId>.html or /goods.html?goods_id=<goodsId>, optionally\n // behind a locale prefix (/uk/, /de-en/). Search and channel hubs match neither.\n temu: /\\/(?:[a-z]{2}(?:-[a-z]{2})?\\/)?(?:[^/?#]*-g-\\d{6,}\\.html|goods\\.html\\?[^#]*\\bgoods_id=\\d{6,})/i,\n};\n\n/**\n * Sources that rank OTHER shops' pages instead of hosting products themselves.\n *\n * Every other source is a storefront, so a link on a different host than the one\n * it claims is mislabeled and gets dropped. An aggregator inverts that: a Google\n * Shopping row is *supposed* to be on bestbuy.com, and applying the host/source\n * match to it would reject the entire lane.\n */\nconst AGGREGATOR_SOURCES = new Set<ProductSource>(['google']);\n\n/** True when `source` names a lane that ranks other shops' pages. */\nexport function isAggregatorSource(source?: ProductSource): boolean {\n return !!source && AGGREGATOR_SOURCES.has(source);\n}\n\n/**\n * Product-detail path shapes, for a shop we have no per-source rule for. Reading\n * the PATH rather than keeping a list of shops is what lets the aggregator lane\n * reach the long tail — a brand storefront nobody enumerated still gets in, and\n * that same shop's category page still does not.\n */\nconst GENERIC_PRODUCT_PATH =\n /\\/(?:dp|gp\\/product)\\/[A-Z0-9]{10}(?:[/?#]|$)|\\/ip\\/[^?#]*\\d|\\/itm\\/\\d{9,}|\\/-\\/A-\\w+|\\/site\\/[^?#]*\\d\\.p(?:[/?#]|$)|\\/products?\\/[a-z0-9][a-z0-9-]{2,}|\\/pd?\\/[^?#]*\\d|\\.product\\.\\d+\\.html/i;\n\n/**\n * Hosts that carry product-shaped paths but sell nothing: search engines, socials\n * and forums. Not a retailer vocabulary — the lane accepts every shop it has never\n * heard of, and this is the short list of things that are definitively not shops.\n */\nconst NON_MERCHANT_HOST =\n /(?:^|\\/\\/|\\.)(?:google|googleusercontent|gstatic|bing|duckduckgo|yahoo|youtube|facebook|instagram|pinterest|reddit|quora|wikipedia|medium|blogspot|substack|tiktok|twitter)\\./i;\n\n/**\n * True when `url` is on a host that sells nothing (search engine, social, forum).\n * Facebook Marketplace sells, on the social network's own host: its pages are\n * a second-hand site (usedSites), not a social post.\n */\nexport function isNonMerchantHost(url?: string): boolean {\n return !!url && NON_MERCHANT_HOST.test(url) && !usedSiteOfHost(url);\n}\n\n/**\n * True when `url` is a product page on SOME merchant — a shop we recognise, or an\n * unknown one whose URL has a product-detail shape. The gate for aggregator rows.\n */\nexport function isAggregatorProductUrl(url?: string): boolean {\n if (!url) return false;\n if (isNonMerchantHost(url)) return false;\n const source = detectRetailerSourceFromUrl(url);\n if (source) return isRetailerProductUrl(url, source);\n return GENERIC_PRODUCT_PATH.test(url);\n}\n\n/** Strict Amazon ASIN — ten alphanumerics. \"BESTBUY-ABCAT0204000.C\" is not one. */\nexport const ASIN_PATTERN = /^[A-Z0-9]{10}$/;\n\n/** Detect the storefront source a URL belongs to, by host — Best Buy included. */\nexport function detectRetailerSourceFromUrl(url?: string): ProductSource | undefined {\n if (!url) return undefined;\n for (const { re, source } of HOST_SOURCE) {\n if (re.test(url)) return source;\n }\n // A second-hand site, all sharing the Used section (Facebook only under /marketplace/).\n return usedSiteOfHost(url) ? 'used' : undefined;\n}\n\n/** True only when `url` is a real product page for `source`. */\nexport function isRetailerProductUrl(url: string | undefined, source: ProductSource): boolean {\n if (!url) return false;\n // An aggregator's rows live on the merchants' hosts, so the host/source match\n // below would reject every one of them.\n if (AGGREGATOR_SOURCES.has(source)) return isAggregatorProductUrl(url);\n const host = detectRetailerSourceFromUrl(url);\n // A link claiming to be one shop but hosted on another is mislabeled, not a product.\n if (host && host !== source) return false;\n // Each second-hand site has its own listing grammar (usedSites); a listing page\n // of one it reads the long tail of (Google Shopping's links) passes on shape.\n if (source === 'used') return !!usedSiteOfListing(url) || (!!host && GENERIC_PRODUCT_PATH.test(url));\n const pattern = PRODUCT_URL_PATTERNS[source];\n if (!pattern) return false;\n return pattern.test(url);\n}\n\n/** True when `url` is a product page for any shop we recognise. */\nexport function isKnownRetailerProductUrl(url?: string): boolean {\n const source = detectRetailerSourceFromUrl(url);\n return !!source && isRetailerProductUrl(url, source);\n}\n\n/** Pull the ASIN out of an Amazon product URL, if present. */\nexport function extractAsinFromUrl(url?: string): string | undefined {\n if (!url) return undefined;\n const match = url.match(PRODUCT_URL_PATTERNS.amazon as RegExp);\n return match?.[1]?.toUpperCase();\n}\n\n/**\n * Query params that carry the real destination inside an affiliate redirect\n * wrapper (Impact `goto.*?u=`, LinkSynergy/Rakuten `murl`, Awin `ued`, eBay\n * rover `mpre`, Skimlinks/VigLink `url`/`r`, …).\n */\nconst DESTINATION_PARAMS = [\n 'u',\n 'url',\n 'murl',\n 'ued',\n 'r',\n 'redirect',\n 'dest',\n 'destination',\n 'target',\n 'to',\n 'link',\n 'mpre',\n 'RD_PARM1',\n];\n\n/**\n * Params a canonical product page never needs — dropping them avoids the malformed\n * tracking strings that make a live product 404 (the reported Walmart case).\n * Anything not listed here is dropped too; only functionally-required params are\n * re-added per source in {@link KEEP_PARAMS}.\n */\nconst KEEP_PARAMS: Partial<Record<ProductSource, string[]>> = {\n // Best Buy resolves by the `.p` path but keeps `skuId` for the exact variant.\n bestbuy: ['skuId'],\n // Shopify variant selection lives in the query.\n shopify: ['variant'],\n // Temu's app share link IS the query: /goods.html?goods_id=<id> resolves to\n // nothing without it. Harmless on the /<slug>-g-<id>.html shape, which has none.\n temu: ['goods_id'],\n};\n\nfunction tryParseUrl(url: string): URL | null {\n try {\n return new URL(url);\n } catch {\n return null;\n }\n}\n\n/**\n * Follow an affiliate redirect wrapper to the real retailer URL embedded in its\n * query (`goto.target.com/c/…?u=https%3A%2F%2Fwww.target.com%2Fp%2F…`). Loops a\n * few times for double-wrapped links; leaves a genuine product URL untouched.\n */\nexport function unwrapAffiliateUrl(url: string): string {\n let current = url;\n for (let depth = 0; depth < 4; depth += 1) {\n // A real product page is the destination, not a wrapper — stop unwrapping.\n if (isKnownRetailerProductUrl(current)) break;\n const parsed = tryParseUrl(current);\n if (!parsed) break;\n\n let embedded: string | undefined;\n for (const key of DESTINATION_PARAMS) {\n const value = parsed.searchParams.get(key);\n if (value && /^https?:\\/\\//i.test(value)) {\n embedded = value;\n break;\n }\n }\n // Fallback: any param whose value is an absolute URL on a shop we recognise.\n if (!embedded) {\n for (const [, value] of parsed.searchParams) {\n if (/^https?:\\/\\//i.test(value) && detectRetailerSourceFromUrl(value)) {\n embedded = value;\n break;\n }\n }\n }\n if (!embedded || embedded === current) break;\n current = embedded;\n }\n return current;\n}\n\n/** Strip tracking noise from a product URL, keeping only params the page needs. */\nexport function canonicalizeProductUrl(url: string): string {\n const parsed = tryParseUrl(url);\n if (!parsed) return url;\n const source = detectRetailerSourceFromUrl(url);\n if (!source) return url;\n const kept = new URLSearchParams();\n for (const key of KEEP_PARAMS[source] ?? []) {\n const value = parsed.searchParams.get(key);\n if (value) kept.set(key, value);\n }\n const query = kept.toString();\n return `${parsed.origin}${parsed.pathname}${query ? `?${query}` : ''}`;\n}\n\n/**\n * Repair a catalog/affiliate URL into a link that actually resolves: unwrap the\n * redirect wrapper, then drop tracking params so the canonical product page loads.\n * A URL we cannot map to a known retailer product is returned unwrapped but\n * otherwise untouched.\n */\nexport function sanitizeRetailerUrl(url?: string): string | undefined {\n if (!url) return url;\n const unwrapped = unwrapAffiliateUrl(url);\n if (isKnownRetailerProductUrl(unwrapped)) return canonicalizeProductUrl(unwrapped);\n return unwrapped;\n}\n"],"names":[],"mappings":"8DAmBA,MAAM,cAGD,CAAC;AAAA,EACJ,EAAI,EAAA,WAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,YAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,YAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,SAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,cAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,UAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,MAAQ,EAAA;AACV,CAAG,EA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QAAQ,CAAA,EAAG,KAAQ,GAAA,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA;AACtE;AAQO,SAAS,oBAAoB,GAAkC,EAAA;AACpE,EAAI,IAAA,CAAC,KAAY,OAAA,GAAA;AACjB,EAAM,MAAA,SAAA,GAAY,mBAAmB,GAAG,CAAA;AACxC,EAAA,IAAI,yBAA0B,CAAA,SAAS,CAAG,EAAA,OAAO,uBAAuB,SAAS,CAAA;AACjF,EAAO,OAAA,SAAA;AACT"}
@@ -36,9 +36,10 @@ const STORED_BOARD_LIMIT = 24;
36
36
  function salesDealsConfigured() {
37
37
  return shoppingSubgraphConfigured();
38
38
  }
39
- function query(gql, variables) {
39
+ function storeQuery(gql, variables) {
40
40
  return (shoppingSubgraphQuery)(gql, variables);
41
41
  }
42
+ const query = storeQuery;
42
43
  const STORED_DEALS_QUERY = (
43
44
  /* GraphQL */
44
45
  `
@@ -333,4 +334,4 @@ async function saveTrendingBoard(departmentId, products) {
333
334
  await query(SAVE_DEALS_MUTATION, {
334
335
  deals: records.map((record) => toUpsertInput(record, "trending"))
335
336
  });
336
- }export{SAVE_DEALS_MUTATION,STORED_BOARD_FRESH_MS,STORED_BOARD_LIMIT,STORED_DEALS_LABEL,STORED_DEALS_PROVIDER_ID,STORED_DEALS_QUERY,dealSlug,dropGoneProductRecords,fromSalesDealRecord,isStoredBoardFresh,loadStoredDeals,loadStoredTrending,newestObservation,productToRecord,recordFromStoredRow,recordToProduct,saveDealsBoard,saveTrendingBoard,slugifyTitle,toSalesDealRecord,toUpsertInput,trendingSlug,visibleSources};//# sourceMappingURL=salesDealsStore.js.map
337
+ }export{SAVE_DEALS_MUTATION,STORED_BOARD_FRESH_MS,STORED_BOARD_LIMIT,STORED_DEALS_LABEL,STORED_DEALS_PROVIDER_ID,STORED_DEALS_QUERY,dealSlug,dropGoneProductRecords,fnv1a,fromSalesDealRecord,isStoredBoardFresh,loadStoredDeals,loadStoredTrending,newestObservation,productToRecord,recordFromStoredRow,recordToProduct,salesDealsConfigured,saveDealsBoard,saveTrendingBoard,slugifyTitle,storeQuery,toSalesDealRecord,toUpsertInput,trendingSlug,visibleSources};//# sourceMappingURL=salesDealsStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"salesDealsStore.js","sources":["../../../../src/features/shopping/services/salesDealsStore.ts"],"sourcesContent":["/**\n * The Deals board's memory: the latest deals it ranked, kept in the shopping\n * subgraph (`servers/shopping-subgraph-server`, collection `shoppingSalesDeals`).\n *\n * Why the board needs one at all: its live answer is a fan-out over quota-metered\n * feeds, and the product lane sweeps several seed queries SEQUENTIALLY (see\n * `dealsSearch`) - a cold Deals tab is a spinner for up to a minute. Discover\n * solved the same problem for news by storing each day's stories and showing the\n * newest it has while today's are gathered; this module does the same for deals.\n * The board paints the stored rows first, the live sweep replaces them as it\n * lands, and the finished board is written back so the next reader gets it.\n *\n * Everything here is a pure mapping except the two subgraph calls, which are\n * best-effort by contract: a store that is unreachable costs a reader the\n * head-start, never the board.\n */\nimport {\n dealIdentity,\n mergeDealResults,\n type DealKind,\n type DealSourceReport,\n type UniversalDeal,\n type UniversalDealsRequest,\n type UniversalDealsResult,\n} from '../deals';\nimport type { Product } from '../catalog';\nimport { shoppingSubgraphConfigured, shoppingSubgraphQuery } from './shoppingSubgraph';\nimport { checkProductLink } from './verifyProducts';\n\n/**\n * One stored deal as the subgraph exchanges it: the board's own\n * {@link UniversalDeal} plus the `slug` that identifies it across refreshes and\n * the department chip the sweep was scoped to. Dates stay ISO strings, as the\n * board carries them.\n */\nexport type SalesDealRecord = Omit<UniversalDeal, 'id' | 'raw'> & {\n slug: string;\n departmentId?: string | null;\n /** When a sweep last saw this row. Read back from the store; never written. */\n observedAt?: string;\n raw?: unknown;\n};\n\n/**\n * Which board a stored row belongs to.\n *\n * `deals` is the discount board; `trending` is the landing page's per-aisle\n * rails. They answer different questions - \"what is marked down\" versus \"what is\n * worth looking at in this aisle\" - so they must never be read as one set, but\n * they share the store, the freshness rule and every mapping below.\n */\nexport type StoredBoard = 'deals' | 'trending';\n\n/**\n * How long a saved board is treated as the ANSWER rather than a head start.\n *\n * Inside this window the live lanes are not called at all: the first visitor of\n * the period pays for the sweep and everyone after them reads what it found.\n * That is the point of storing boards - these are quota-metered providers, and\n * before this every visitor re-bought the same answer.\n */\nexport const STORED_BOARD_FRESH_MS = 12 * 60 * 60 * 1000;\n\n/**\n * Provider id the board shows stored rows under.\n *\n * Stored rows are re-tagged to this one provider so the sources strip can say\n * \"Saved deals · 24\" while the live lanes are still pending. Each row's original\n * providers survive in `sources`, which is what the store carries them in.\n */\nexport const STORED_DEALS_PROVIDER_ID = 'stored-deals';\nexport const STORED_DEALS_LABEL = 'Saved deals';\n\n/** How many stored rows to paint. One board, not the whole history. */\nexport const STORED_BOARD_LIMIT = 24;\n\n// ─── Transport ──────────────────────────────────────────────────────────────\n\n/** A GraphQL round trip to the subgraph: `null` on any failure, never a throw. */\nexport type SalesDealsTransport = <T>(query: string, variables?: Record<string, unknown>) => Promise<T | null>;\n\nlet transport: SalesDealsTransport | null = null;\nlet configured: (() => boolean) | null = null;\n\n/**\n * Swap the subgraph transport — for tests and for a host that wants to route\n * the calls itself. `null` restores the default (a direct fetch with the cdecli\n * bearer, see `shoppingSubgraph.ts`).\n */\nexport function setSalesDealsTransport(\n next: SalesDealsTransport | null,\n isConfigured: (() => boolean) | null = next ? () => true : null,\n): void {\n transport = next;\n configured = isConfigured;\n}\n\nfunction salesDealsConfigured(): boolean {\n return configured ? configured() : shoppingSubgraphConfigured();\n}\n\nfunction query<T>(gql: string, variables: Record<string, unknown>): Promise<T | null> {\n return (transport ?? shoppingSubgraphQuery)<T>(gql, variables);\n}\n\nexport const STORED_DEALS_QUERY = /* GraphQL */ `\n query StoredSalesDeals($filter: ShoppingSalesDealsFilter) {\n shoppingSalesDeals(filter: $filter) {\n totalCount\n data {\n slug\n kind\n title\n merchant\n url\n imageUrl\n description\n price\n originalPrice\n discountPercent\n currency\n code\n location\n startsAt\n endsAt\n rating\n reviews\n inStock\n tags\n providerId\n sources\n departmentId\n raw\n observedAt\n }\n }\n }\n`;\n\nexport const SAVE_DEALS_MUTATION = /* GraphQL */ `\n mutation SaveSalesDealsBoard($deals: [UpsertShoppingSalesDealInput!]!) {\n upsertShoppingSalesDeals(deals: $deals) {\n insertedCount\n updatedCount\n }\n }\n`;\n\n// ─── Slugs and records ──────────────────────────────────────────────────────\n\n/**\n * FNV-1a, 32-bit. Not cryptographic - it only has to be deterministic across\n * hosts and short enough to read, and the identity string it hashes is already\n * a normalised URL or code, not free text.\n */\nfunction fnv1a(text: string, seed: number): string {\n let hash = seed >>> 0;\n for (let index = 0; index < text.length; index += 1) {\n hash ^= text.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193) >>> 0;\n }\n return hash.toString(16).padStart(8, '0');\n}\n\nconst TITLE_SLUG_MAX = 48;\n\n/** The readable half of a slug: lowercase, ascii, hyphenated, bounded. */\nexport function slugifyTitle(title: string): string {\n const slug = title\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, TITLE_SLUG_MAX)\n .replace(/-+$/g, '');\n return slug || 'deal';\n}\n\n/**\n * The stable id a deal is stored under.\n *\n * `kind-<title>-<hash>`, like a Discover article's `<title>-<id>`: readable in a\n * database and a URL, and unique through the hash of the deal's IDENTITY - the\n * page it links to, else its code at a store, else the merchant's wording (see\n * `dealIdentity`). Two providers carrying the same landing page get the same\n * slug, so a re-observation is an upsert and not a duplicate; two stores running\n * word-for-word the same offer differ by merchant and stay apart.\n */\nexport function dealSlug(deal: Pick<UniversalDeal, 'kind' | 'title' | 'url' | 'code' | 'merchant'>): string {\n const identity = dealIdentity(deal as UniversalDeal);\n return `${deal.kind}-${slugifyTitle(deal.title)}-${fnv1a(identity, 0x811c9dc5)}${fnv1a(identity, 0x9747b28c)}`;\n}\n\n/** A ranked row, as the store takes it. */\nexport function toSalesDealRecord(deal: UniversalDeal, departmentId?: string | null): SalesDealRecord {\n const { id: _id, raw, ...fields } = deal;\n return {\n ...fields,\n slug: dealSlug(deal),\n ...(deal.sources && deal.sources.length > 0 ? { sources: deal.sources } : { sources: [deal.providerId] }),\n departmentId: departmentId ?? null,\n ...(raw !== undefined ? { raw } : {}),\n };\n}\n\n/**\n * A stored row, as a board row again.\n *\n * Tagged to the stored provider (see {@link STORED_DEALS_PROVIDER_ID}); the\n * original providers stay on `sources`. The slug doubles as the row id, which is\n * stable within a stored result set - all a key needs.\n */\nexport function fromSalesDealRecord(record: SalesDealRecord): UniversalDeal {\n const { slug, departmentId: _departmentId, observedAt: _observedAt, raw, ...fields } = record;\n return {\n ...fields,\n id: slug,\n providerId: STORED_DEALS_PROVIDER_ID,\n sources: record.sources && record.sources.length > 0 ? record.sources : [record.providerId],\n ...(raw !== undefined ? { raw } : {}),\n };\n}\n\n/** One stored row as the subgraph returns it; nulls where the store has nothing. */\ntype StoredDealRow = { [K in keyof SalesDealRecord]?: SalesDealRecord[K] | null };\n\nfunction present<T>(value: T | null | undefined): T | undefined {\n return value === null || value === undefined ? undefined : value;\n}\n\n/** A subgraph row as a record: nulls become absent fields, as the board expects. */\nexport function recordFromStoredRow(row: StoredDealRow): SalesDealRecord | null {\n const slug = present(row.slug);\n const title = present(row.title);\n const providerId = present(row.providerId);\n const kind = present(row.kind);\n if (!slug || !title || !providerId || !kind) return null;\n const record: SalesDealRecord = { slug, kind, title, providerId };\n const optional = [\n 'merchant',\n 'url',\n 'imageUrl',\n 'description',\n 'price',\n 'originalPrice',\n 'discountPercent',\n 'currency',\n 'code',\n 'location',\n 'startsAt',\n 'endsAt',\n 'rating',\n 'reviews',\n 'inStock',\n 'tags',\n 'sources',\n 'raw',\n 'observedAt',\n ] as const;\n for (const key of optional) {\n const value = present(row[key]);\n if (value !== undefined) (record as Record<string, unknown>)[key] = value;\n }\n record.departmentId = present(row.departmentId) ?? null;\n return record;\n}\n\n/**\n * A record as the subgraph's upsert input — the KNOWN fields only. GraphQL\n * rejects an input carrying a field the schema does not name, so a board row\n * that grows a new property must not leak it into the write.\n */\nexport function toUpsertInput(record: SalesDealRecord, board: StoredBoard = 'deals'): Record<string, unknown> {\n return {\n slug: record.slug,\n board,\n kind: record.kind,\n title: record.title,\n merchant: record.merchant,\n url: record.url,\n imageUrl: record.imageUrl,\n description: record.description,\n price: record.price,\n originalPrice: record.originalPrice,\n discountPercent: record.discountPercent,\n currency: record.currency,\n code: record.code,\n location: record.location,\n startsAt: record.startsAt,\n endsAt: record.endsAt,\n rating: record.rating,\n reviews: record.reviews,\n inStock: record.inStock,\n tags: record.tags ?? [],\n providerId: record.providerId,\n sources: record.sources ?? [record.providerId],\n departmentId: record.departmentId ?? undefined,\n raw: record.raw ?? undefined,\n };\n}\n\n// ─── The two board operations ───────────────────────────────────────────────\n\n/**\n * The stored board for a request, ranked by the same rules the live board uses.\n *\n * Runs the rows through `mergeDealResults` so every chip (kind, discount floor,\n * ceiling, rating, sort, expiry) applies to the stored set exactly as it does to\n * the live one - a reader toggling \"40%+\" over saved rows must get the same\n * answer they would get over live ones. The per-provider cap is dropped because\n * the stored set is one provider; the board's overall limit still applies.\n *\n * `null` when no store is reachable (no endpoint, or not signed in), so a caller\n * can tell \"no memory\" from \"an empty memory\".\n */\nexport function newestObservation(records: readonly SalesDealRecord[], now = Date.now()): number {\n let newest = 0;\n for (const record of records) {\n const at = record.observedAt ? Date.parse(record.observedAt) : NaN;\n if (Number.isFinite(at) && at > newest && at <= now) newest = at;\n }\n return newest;\n}\n\n/**\n * Is a saved board recent enough to BE the answer?\n *\n * A row with no timestamp counts as stale rather than fresh: the whole point of\n * the window is to stop calling metered providers, and getting that wrong in the\n * generous direction would serve a board from an unknown point in the past.\n */\nexport function isStoredBoardFresh(records: readonly SalesDealRecord[], now = Date.now()): boolean {\n const newest = newestObservation(records, now);\n return newest > 0 && now - newest < STORED_BOARD_FRESH_MS;\n}\n\n/** A saved board, plus whether it is recent enough to skip the live lanes. */\nexport interface StoredDealsResult extends UniversalDealsResult {\n /** True when the newest row was observed inside {@link STORED_BOARD_FRESH_MS}. */\n fresh: boolean;\n /** Newest observation across the rows, epoch ms; 0 when the store had none. */\n observedAt: number;\n}\n\n/**\n * A saved board was verified when it was swept, but it is read back up to a\n * freshness window later: a product deal whose page has since gone (delisted or\n * sold out) is dropped before it paints. Coupons, vouchers and fares have no\n * product page and pass through; an unreadable page is not evidence and stays.\n */\nexport async function dropGoneProductRecords(records: SalesDealRecord[]): Promise<SalesDealRecord[]> {\n const verdicts = await Promise.all(\n records.map((record) =>\n record.kind === 'product' && record.url ? checkProductLink(record.url) : Promise.resolve(null),\n ),\n );\n return records.filter((_, i) => {\n const check = verdicts[i];\n if (!check) return true;\n return check.status !== 'dead' && check.facts?.availability !== 'out_of_stock';\n });\n}\n\nexport async function loadStoredDeals(\n request: UniversalDealsRequest,\n board: StoredBoard = 'deals',\n): Promise<StoredDealsResult | null> {\n if (!salesDealsConfigured()) return null;\n\n const kind: DealKind | undefined = request.kinds && request.kinds.length === 1 ? request.kinds[0] : undefined;\n const data = await query<{ shoppingSalesDeals?: { data?: StoredDealRow[] } }>(STORED_DEALS_QUERY, {\n filter: {\n board,\n ...(kind ? { kind } : {}),\n ...(request.departmentId ? { departmentId: request.departmentId } : {}),\n limit: STORED_BOARD_LIMIT,\n },\n });\n const saved = (data?.shoppingSalesDeals?.data ?? [])\n .map(recordFromStoredRow)\n .filter((record): record is SalesDealRecord => record !== null);\n const records = await dropGoneProductRecords(saved);\n\n const observedAt = newestObservation(records);\n const { maxPerProvider: _cap, ...boardRequest } = request;\n const merged = mergeDealResults(\n [\n {\n providerId: STORED_DEALS_PROVIDER_ID,\n label: STORED_DEALS_LABEL,\n status: 'ok',\n result: { deals: records.map(fromSalesDealRecord) },\n },\n ],\n boardRequest,\n );\n return { ...merged, fresh: isStoredBoardFresh(records), observedAt };\n}\n\n/**\n * The sources strip to show while a board is mid-answer.\n *\n * The rule it encodes: while the rows on screen came from the STORE, the stored\n * source line stays attached to them. A provider that settles EMPTY reports only\n * itself, so painting that report alone leaves stored rows on screen with no\n * answering source - which a rail renders as its department tagline and a board\n * as a bare count, making a remembered board look like it was never saved.\n *\n * Once live rows replace the stored ones the caller passes `storedPainted: false`\n * and the live reports stand alone, because the stored rows are gone.\n */\nexport function visibleSources(\n storedSources: readonly DealSourceReport[],\n liveSources: readonly DealSourceReport[],\n storedPainted: boolean,\n): DealSourceReport[] {\n return storedPainted ? [...storedSources, ...liveSources] : [...liveSources];\n}\n\n/**\n * Remember a finished live board.\n *\n * Only LIVE rows are written: a row the board itself painted from the store is\n * skipped, so a board that showed stored rows and got nothing live back does not\n * re-save its own memory as a fresh observation. Fire-and-forget by design - the\n * board on screen is the answer, and the store catches up on the next sweep.\n */\nexport async function saveDealsBoard(deals: readonly UniversalDeal[], departmentId?: string | null): Promise<void> {\n if (!salesDealsConfigured()) return;\n\n const records = deals\n .filter((deal) => deal.providerId !== STORED_DEALS_PROVIDER_ID)\n .map((deal) => toSalesDealRecord(deal, departmentId));\n if (records.length === 0) return;\n\n await query(SAVE_DEALS_MUTATION, { deals: records.map((record) => toUpsertInput(record, 'deals')) });\n}\n\n// ─── The landing page's trending rails ──────────────────────────────────────\n//\n// Same store, same freshness rule, different board. A trending rail is not a\n// discount board - it answers \"what is worth looking at in this aisle\" - so its\n// rows are namespaced away from the deals board rather than merged into it.\n\n/**\n * A trending row's identity. Prefixed, so the same product appearing on both\n * boards is two rows rather than one that keeps overwriting itself - which also\n * kept `{tenant, slug}` unique and made `board` a purely additive column.\n */\nexport function trendingSlug(product: Product): string {\n return `trending-${dealSlug({\n kind: 'product',\n title: product.name,\n ...(product.url ? { url: product.url } : {}),\n ...(product.retailerId ? { merchant: product.retailerId } : {}),\n })}`;\n}\n\n/**\n * A trending product as the store takes it.\n *\n * The whole `Product` rides on `raw`, exactly as a product deal does, because\n * the rail renders `ProductRow` from it - flattening it into the common shape\n * would cost the card its image, rating and cart button on the way back.\n */\nexport function productToRecord(product: Product, departmentId: string): SalesDealRecord {\n return {\n slug: trendingSlug(product),\n kind: 'product',\n title: product.name,\n providerId: product.source || 'trending',\n ...(product.retailerId ? { merchant: product.retailerId } : {}),\n ...(product.url ? { url: product.url } : {}),\n ...(product.imageUrl ? { imageUrl: product.imageUrl } : {}),\n ...(Number.isFinite(product.price) ? { price: product.price } : {}),\n ...(product.originalPrice != null ? { originalPrice: product.originalPrice } : {}),\n ...(product.discountPercent != null ? { discountPercent: product.discountPercent } : {}),\n ...(product.currency ? { currency: product.currency } : {}),\n ...(product.rating ? { rating: product.rating } : {}),\n ...(product.reviews ? { reviews: product.reviews } : {}),\n ...(typeof product.inStock === 'boolean' ? { inStock: product.inStock } : {}),\n sources: [product.source || 'trending'],\n departmentId,\n raw: product,\n };\n}\n\n/** A stored trending row, back as the `Product` the rail renders. */\nexport function recordToProduct(record: SalesDealRecord): Product | null {\n const raw = record.raw as Product | undefined;\n // Only a row that kept its whole card can be rendered as one; a row without\n // it would have to invent the department icon, accent and id the card needs.\n return raw && typeof raw === 'object' && raw.name ? raw : null;\n}\n\n/** A saved trending rail, plus whether it is recent enough to skip the live lanes. */\nexport interface StoredTrending {\n products: Product[];\n fresh: boolean;\n observedAt: number;\n}\n\n/**\n * The saved trending rail for one department.\n *\n * `null` when no store is reachable, so a caller can tell \"no memory\" from \"an\n * empty memory\" - the same contract as {@link loadStoredDeals}.\n */\nexport async function loadStoredTrending(\n departmentId: string,\n limit = STORED_BOARD_LIMIT,\n): Promise<StoredTrending | null> {\n if (!salesDealsConfigured()) return null;\n\n const data = await query<{ shoppingSalesDeals?: { data?: StoredDealRow[] } }>(STORED_DEALS_QUERY, {\n filter: { board: 'trending', departmentId, limit },\n });\n const records = (data?.shoppingSalesDeals?.data ?? [])\n .map(recordFromStoredRow)\n .filter((record): record is SalesDealRecord => record !== null);\n\n return {\n products: records.map(recordToProduct).filter((product): product is Product => product !== null),\n fresh: isStoredBoardFresh(records),\n observedAt: newestObservation(records),\n };\n}\n\n/** Remember a finished trending rail. Fire-and-forget, like the deals board. */\nexport async function saveTrendingBoard(departmentId: string, products: readonly Product[]): Promise<void> {\n if (!salesDealsConfigured() || products.length === 0) return;\n\n const records = products.map((product) => productToRecord(product, departmentId));\n await query(SAVE_DEALS_MUTATION, { deals: records.map((record) => toUpsertInput(record, 'trending')) });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDa,MAAA,qBAAA,GAAwB,EAAK,GAAA,EAAA,GAAK,EAAK,GAAA;AAS7C,MAAM,wBAA2B,GAAA;AACjC,MAAM,kBAAqB,GAAA;AAG3B,MAAM,kBAAqB,GAAA;AAkBlC,SAAS,oBAAgC,GAAA;AACvC,EAAO,OAA4B,0BAA2B,EAAA;AAChE;AACA,SAAS,KAAA,CAAS,KAAa,SAAuD,EAAA;AACpF,EAAQ,OAAA,CAAa,qBAA0B,EAAA,GAAA,EAAK,SAAS,CAAA;AAC/D;AACa,MAAA,kBAAA;AAAA;AAAA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiClC,MAAA,mBAAA;AAAA;AAAA,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBhD,SAAS,KAAA,CAAM,MAAc,IAAsB,EAAA;AACjD,EAAA,IAAI,OAAO,IAAS,KAAA,CAAA;AACpB,EAAA,KAAA,IAAS,QAAQ,CAAG,EAAA,KAAA,GAAQ,IAAK,CAAA,MAAA,EAAQ,SAAS,CAAG,EAAA;AACnD,IAAQ,IAAA,IAAA,IAAA,CAAK,WAAW,KAAK,CAAA;AAC7B,IAAA,IAAA,GAAO,IAAK,CAAA,IAAA,CAAK,IA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;AACtD,EAAA,MAAM,UAAU,QAAS,CAAA,GAAA,CAAI,aAAW,eAAgB,CAAA,OAAA,EAAS,YAAY,CAAC,CAAA;AAC9E,EAAA,MAAM,MAAM,mBAAqB,EAAA;AAAA,IAC/B,OAAO,OAAQ,CAAA,GAAA,CAAI,YAAU,aAAc,CAAA,MAAA,EAAQ,UAAU,CAAC;AAAA,GAC/D,CAAA;AACH"}
1
+ {"version":3,"file":"salesDealsStore.js","sources":["../../../../src/features/shopping/services/salesDealsStore.ts"],"sourcesContent":["/**\n * The Deals board's memory: the latest deals it ranked, kept in the shopping\n * subgraph (`servers/shopping-subgraph-server`, collection `shoppingSalesDeals`).\n *\n * Why the board needs one at all: its live answer is a fan-out over quota-metered\n * feeds, and the product lane sweeps several seed queries SEQUENTIALLY (see\n * `dealsSearch`) - a cold Deals tab is a spinner for up to a minute. Discover\n * solved the same problem for news by storing each day's stories and showing the\n * newest it has while today's are gathered; this module does the same for deals.\n * The board paints the stored rows first, the live sweep replaces them as it\n * lands, and the finished board is written back so the next reader gets it.\n *\n * Everything here is a pure mapping except the two subgraph calls, which are\n * best-effort by contract: a store that is unreachable costs a reader the\n * head-start, never the board.\n */\nimport {\n dealIdentity,\n mergeDealResults,\n type DealKind,\n type DealSourceReport,\n type UniversalDeal,\n type UniversalDealsRequest,\n type UniversalDealsResult,\n} from '../deals';\nimport type { Product } from '../catalog';\nimport { shoppingSubgraphConfigured, shoppingSubgraphQuery } from './shoppingSubgraph';\nimport { checkProductLink } from './verifyProducts';\n\n/**\n * One stored deal as the subgraph exchanges it: the board's own\n * {@link UniversalDeal} plus the `slug` that identifies it across refreshes and\n * the department chip the sweep was scoped to. Dates stay ISO strings, as the\n * board carries them.\n */\nexport type SalesDealRecord = Omit<UniversalDeal, 'id' | 'raw'> & {\n slug: string;\n departmentId?: string | null;\n /** When a sweep last saw this row. Read back from the store; never written. */\n observedAt?: string;\n raw?: unknown;\n};\n\n/**\n * Which board a stored row belongs to.\n *\n * `deals` is the discount board; `trending` is the landing page's per-aisle\n * rails. They answer different questions - \"what is marked down\" versus \"what is\n * worth looking at in this aisle\" - so they must never be read as one set, but\n * they share the store, the freshness rule and every mapping below.\n */\nexport type StoredBoard = 'deals' | 'trending';\n\n/**\n * How long a saved board is treated as the ANSWER rather than a head start.\n *\n * Inside this window the live lanes are not called at all: the first visitor of\n * the period pays for the sweep and everyone after them reads what it found.\n * That is the point of storing boards - these are quota-metered providers, and\n * before this every visitor re-bought the same answer.\n */\nexport const STORED_BOARD_FRESH_MS = 12 * 60 * 60 * 1000;\n\n/**\n * Provider id the board shows stored rows under.\n *\n * Stored rows are re-tagged to this one provider so the sources strip can say\n * \"Saved deals · 24\" while the live lanes are still pending. Each row's original\n * providers survive in `sources`, which is what the store carries them in.\n */\nexport const STORED_DEALS_PROVIDER_ID = 'stored-deals';\nexport const STORED_DEALS_LABEL = 'Saved deals';\n\n/** How many stored rows to paint. One board, not the whole history. */\nexport const STORED_BOARD_LIMIT = 24;\n\n// ─── Transport ──────────────────────────────────────────────────────────────\n\n/** A GraphQL round trip to the subgraph: `null` on any failure, never a throw. */\nexport type SalesDealsTransport = <T>(query: string, variables?: Record<string, unknown>) => Promise<T | null>;\n\nlet transport: SalesDealsTransport | null = null;\nlet configured: (() => boolean) | null = null;\n\n/**\n * Swap the subgraph transport — for tests and for a host that wants to route\n * the calls itself. `null` restores the default (a direct fetch with the cdecli\n * bearer, see `shoppingSubgraph.ts`).\n */\nexport function setSalesDealsTransport(\n next: SalesDealsTransport | null,\n isConfigured: (() => boolean) | null = next ? () => true : null,\n): void {\n transport = next;\n configured = isConfigured;\n}\n\n/** Whether the store is reachable at all. Shared with the other records kept beside the boards (storedGalleries). */\nexport function salesDealsConfigured(): boolean {\n return configured ? configured() : shoppingSubgraphConfigured();\n}\n\n/** One round trip to the store, through the swappable transport. Shared like {@link salesDealsConfigured}. */\nexport function storeQuery<T>(gql: string, variables: Record<string, unknown>): Promise<T | null> {\n return (transport ?? shoppingSubgraphQuery)<T>(gql, variables);\n}\n\nconst query = storeQuery;\n\nexport const STORED_DEALS_QUERY = /* GraphQL */ `\n query StoredSalesDeals($filter: ShoppingSalesDealsFilter) {\n shoppingSalesDeals(filter: $filter) {\n totalCount\n data {\n slug\n kind\n title\n merchant\n url\n imageUrl\n description\n price\n originalPrice\n discountPercent\n currency\n code\n location\n startsAt\n endsAt\n rating\n reviews\n inStock\n tags\n providerId\n sources\n departmentId\n raw\n observedAt\n }\n }\n }\n`;\n\nexport const SAVE_DEALS_MUTATION = /* GraphQL */ `\n mutation SaveSalesDealsBoard($deals: [UpsertShoppingSalesDealInput!]!) {\n upsertShoppingSalesDeals(deals: $deals) {\n insertedCount\n updatedCount\n }\n }\n`;\n\n// ─── Slugs and records ──────────────────────────────────────────────────────\n\n/**\n * FNV-1a, 32-bit. Not cryptographic - it only has to be deterministic across\n * hosts and short enough to read, and the identity string it hashes is already\n * a normalised URL or code, not free text.\n */\nexport function fnv1a(text: string, seed: number): string {\n let hash = seed >>> 0;\n for (let index = 0; index < text.length; index += 1) {\n hash ^= text.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193) >>> 0;\n }\n return hash.toString(16).padStart(8, '0');\n}\n\nconst TITLE_SLUG_MAX = 48;\n\n/** The readable half of a slug: lowercase, ascii, hyphenated, bounded. */\nexport function slugifyTitle(title: string): string {\n const slug = title\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, TITLE_SLUG_MAX)\n .replace(/-+$/g, '');\n return slug || 'deal';\n}\n\n/**\n * The stable id a deal is stored under.\n *\n * `kind-<title>-<hash>`, like a Discover article's `<title>-<id>`: readable in a\n * database and a URL, and unique through the hash of the deal's IDENTITY - the\n * page it links to, else its code at a store, else the merchant's wording (see\n * `dealIdentity`). Two providers carrying the same landing page get the same\n * slug, so a re-observation is an upsert and not a duplicate; two stores running\n * word-for-word the same offer differ by merchant and stay apart.\n */\nexport function dealSlug(deal: Pick<UniversalDeal, 'kind' | 'title' | 'url' | 'code' | 'merchant'>): string {\n const identity = dealIdentity(deal as UniversalDeal);\n return `${deal.kind}-${slugifyTitle(deal.title)}-${fnv1a(identity, 0x811c9dc5)}${fnv1a(identity, 0x9747b28c)}`;\n}\n\n/** A ranked row, as the store takes it. */\nexport function toSalesDealRecord(deal: UniversalDeal, departmentId?: string | null): SalesDealRecord {\n const { id: _id, raw, ...fields } = deal;\n return {\n ...fields,\n slug: dealSlug(deal),\n ...(deal.sources && deal.sources.length > 0 ? { sources: deal.sources } : { sources: [deal.providerId] }),\n departmentId: departmentId ?? null,\n ...(raw !== undefined ? { raw } : {}),\n };\n}\n\n/**\n * A stored row, as a board row again.\n *\n * Tagged to the stored provider (see {@link STORED_DEALS_PROVIDER_ID}); the\n * original providers stay on `sources`. The slug doubles as the row id, which is\n * stable within a stored result set - all a key needs.\n */\nexport function fromSalesDealRecord(record: SalesDealRecord): UniversalDeal {\n const { slug, departmentId: _departmentId, observedAt: _observedAt, raw, ...fields } = record;\n return {\n ...fields,\n id: slug,\n providerId: STORED_DEALS_PROVIDER_ID,\n sources: record.sources && record.sources.length > 0 ? record.sources : [record.providerId],\n ...(raw !== undefined ? { raw } : {}),\n };\n}\n\n/** One stored row as the subgraph returns it; nulls where the store has nothing. */\ntype StoredDealRow = { [K in keyof SalesDealRecord]?: SalesDealRecord[K] | null };\n\nfunction present<T>(value: T | null | undefined): T | undefined {\n return value === null || value === undefined ? undefined : value;\n}\n\n/** A subgraph row as a record: nulls become absent fields, as the board expects. */\nexport function recordFromStoredRow(row: StoredDealRow): SalesDealRecord | null {\n const slug = present(row.slug);\n const title = present(row.title);\n const providerId = present(row.providerId);\n const kind = present(row.kind);\n if (!slug || !title || !providerId || !kind) return null;\n const record: SalesDealRecord = { slug, kind, title, providerId };\n const optional = [\n 'merchant',\n 'url',\n 'imageUrl',\n 'description',\n 'price',\n 'originalPrice',\n 'discountPercent',\n 'currency',\n 'code',\n 'location',\n 'startsAt',\n 'endsAt',\n 'rating',\n 'reviews',\n 'inStock',\n 'tags',\n 'sources',\n 'raw',\n 'observedAt',\n ] as const;\n for (const key of optional) {\n const value = present(row[key]);\n if (value !== undefined) (record as Record<string, unknown>)[key] = value;\n }\n record.departmentId = present(row.departmentId) ?? null;\n return record;\n}\n\n/**\n * A record as the subgraph's upsert input — the KNOWN fields only. GraphQL\n * rejects an input carrying a field the schema does not name, so a board row\n * that grows a new property must not leak it into the write.\n */\nexport function toUpsertInput(record: SalesDealRecord, board: StoredBoard = 'deals'): Record<string, unknown> {\n return {\n slug: record.slug,\n board,\n kind: record.kind,\n title: record.title,\n merchant: record.merchant,\n url: record.url,\n imageUrl: record.imageUrl,\n description: record.description,\n price: record.price,\n originalPrice: record.originalPrice,\n discountPercent: record.discountPercent,\n currency: record.currency,\n code: record.code,\n location: record.location,\n startsAt: record.startsAt,\n endsAt: record.endsAt,\n rating: record.rating,\n reviews: record.reviews,\n inStock: record.inStock,\n tags: record.tags ?? [],\n providerId: record.providerId,\n sources: record.sources ?? [record.providerId],\n departmentId: record.departmentId ?? undefined,\n raw: record.raw ?? undefined,\n };\n}\n\n// ─── The two board operations ───────────────────────────────────────────────\n\n/**\n * The stored board for a request, ranked by the same rules the live board uses.\n *\n * Runs the rows through `mergeDealResults` so every chip (kind, discount floor,\n * ceiling, rating, sort, expiry) applies to the stored set exactly as it does to\n * the live one - a reader toggling \"40%+\" over saved rows must get the same\n * answer they would get over live ones. The per-provider cap is dropped because\n * the stored set is one provider; the board's overall limit still applies.\n *\n * `null` when no store is reachable (no endpoint, or not signed in), so a caller\n * can tell \"no memory\" from \"an empty memory\".\n */\nexport function newestObservation(records: readonly SalesDealRecord[], now = Date.now()): number {\n let newest = 0;\n for (const record of records) {\n const at = record.observedAt ? Date.parse(record.observedAt) : NaN;\n if (Number.isFinite(at) && at > newest && at <= now) newest = at;\n }\n return newest;\n}\n\n/**\n * Is a saved board recent enough to BE the answer?\n *\n * A row with no timestamp counts as stale rather than fresh: the whole point of\n * the window is to stop calling metered providers, and getting that wrong in the\n * generous direction would serve a board from an unknown point in the past.\n */\nexport function isStoredBoardFresh(records: readonly SalesDealRecord[], now = Date.now()): boolean {\n const newest = newestObservation(records, now);\n return newest > 0 && now - newest < STORED_BOARD_FRESH_MS;\n}\n\n/** A saved board, plus whether it is recent enough to skip the live lanes. */\nexport interface StoredDealsResult extends UniversalDealsResult {\n /** True when the newest row was observed inside {@link STORED_BOARD_FRESH_MS}. */\n fresh: boolean;\n /** Newest observation across the rows, epoch ms; 0 when the store had none. */\n observedAt: number;\n}\n\n/**\n * A saved board was verified when it was swept, but it is read back up to a\n * freshness window later: a product deal whose page has since gone (delisted or\n * sold out) is dropped before it paints. Coupons, vouchers and fares have no\n * product page and pass through; an unreadable page is not evidence and stays.\n */\nexport async function dropGoneProductRecords(records: SalesDealRecord[]): Promise<SalesDealRecord[]> {\n const verdicts = await Promise.all(\n records.map((record) =>\n record.kind === 'product' && record.url ? checkProductLink(record.url) : Promise.resolve(null),\n ),\n );\n return records.filter((_, i) => {\n const check = verdicts[i];\n if (!check) return true;\n return check.status !== 'dead' && check.facts?.availability !== 'out_of_stock';\n });\n}\n\nexport async function loadStoredDeals(\n request: UniversalDealsRequest,\n board: StoredBoard = 'deals',\n): Promise<StoredDealsResult | null> {\n if (!salesDealsConfigured()) return null;\n\n const kind: DealKind | undefined = request.kinds && request.kinds.length === 1 ? request.kinds[0] : undefined;\n const data = await query<{ shoppingSalesDeals?: { data?: StoredDealRow[] } }>(STORED_DEALS_QUERY, {\n filter: {\n board,\n ...(kind ? { kind } : {}),\n ...(request.departmentId ? { departmentId: request.departmentId } : {}),\n limit: STORED_BOARD_LIMIT,\n },\n });\n const saved = (data?.shoppingSalesDeals?.data ?? [])\n .map(recordFromStoredRow)\n .filter((record): record is SalesDealRecord => record !== null);\n const records = await dropGoneProductRecords(saved);\n\n const observedAt = newestObservation(records);\n const { maxPerProvider: _cap, ...boardRequest } = request;\n const merged = mergeDealResults(\n [\n {\n providerId: STORED_DEALS_PROVIDER_ID,\n label: STORED_DEALS_LABEL,\n status: 'ok',\n result: { deals: records.map(fromSalesDealRecord) },\n },\n ],\n boardRequest,\n );\n return { ...merged, fresh: isStoredBoardFresh(records), observedAt };\n}\n\n/**\n * The sources strip to show while a board is mid-answer.\n *\n * The rule it encodes: while the rows on screen came from the STORE, the stored\n * source line stays attached to them. A provider that settles EMPTY reports only\n * itself, so painting that report alone leaves stored rows on screen with no\n * answering source - which a rail renders as its department tagline and a board\n * as a bare count, making a remembered board look like it was never saved.\n *\n * Once live rows replace the stored ones the caller passes `storedPainted: false`\n * and the live reports stand alone, because the stored rows are gone.\n */\nexport function visibleSources(\n storedSources: readonly DealSourceReport[],\n liveSources: readonly DealSourceReport[],\n storedPainted: boolean,\n): DealSourceReport[] {\n return storedPainted ? [...storedSources, ...liveSources] : [...liveSources];\n}\n\n/**\n * Remember a finished live board.\n *\n * Only LIVE rows are written: a row the board itself painted from the store is\n * skipped, so a board that showed stored rows and got nothing live back does not\n * re-save its own memory as a fresh observation. Fire-and-forget by design - the\n * board on screen is the answer, and the store catches up on the next sweep.\n */\nexport async function saveDealsBoard(deals: readonly UniversalDeal[], departmentId?: string | null): Promise<void> {\n if (!salesDealsConfigured()) return;\n\n const records = deals\n .filter((deal) => deal.providerId !== STORED_DEALS_PROVIDER_ID)\n .map((deal) => toSalesDealRecord(deal, departmentId));\n if (records.length === 0) return;\n\n await query(SAVE_DEALS_MUTATION, { deals: records.map((record) => toUpsertInput(record, 'deals')) });\n}\n\n// ─── The landing page's trending rails ──────────────────────────────────────\n//\n// Same store, same freshness rule, different board. A trending rail is not a\n// discount board - it answers \"what is worth looking at in this aisle\" - so its\n// rows are namespaced away from the deals board rather than merged into it.\n\n/**\n * A trending row's identity. Prefixed, so the same product appearing on both\n * boards is two rows rather than one that keeps overwriting itself - which also\n * kept `{tenant, slug}` unique and made `board` a purely additive column.\n */\nexport function trendingSlug(product: Product): string {\n return `trending-${dealSlug({\n kind: 'product',\n title: product.name,\n ...(product.url ? { url: product.url } : {}),\n ...(product.retailerId ? { merchant: product.retailerId } : {}),\n })}`;\n}\n\n/**\n * A trending product as the store takes it.\n *\n * The whole `Product` rides on `raw`, exactly as a product deal does, because\n * the rail renders `ProductRow` from it - flattening it into the common shape\n * would cost the card its image, rating and cart button on the way back.\n */\nexport function productToRecord(product: Product, departmentId: string): SalesDealRecord {\n return {\n slug: trendingSlug(product),\n kind: 'product',\n title: product.name,\n providerId: product.source || 'trending',\n ...(product.retailerId ? { merchant: product.retailerId } : {}),\n ...(product.url ? { url: product.url } : {}),\n ...(product.imageUrl ? { imageUrl: product.imageUrl } : {}),\n ...(Number.isFinite(product.price) ? { price: product.price } : {}),\n ...(product.originalPrice != null ? { originalPrice: product.originalPrice } : {}),\n ...(product.discountPercent != null ? { discountPercent: product.discountPercent } : {}),\n ...(product.currency ? { currency: product.currency } : {}),\n ...(product.rating ? { rating: product.rating } : {}),\n ...(product.reviews ? { reviews: product.reviews } : {}),\n ...(typeof product.inStock === 'boolean' ? { inStock: product.inStock } : {}),\n sources: [product.source || 'trending'],\n departmentId,\n raw: product,\n };\n}\n\n/** A stored trending row, back as the `Product` the rail renders. */\nexport function recordToProduct(record: SalesDealRecord): Product | null {\n const raw = record.raw as Product | undefined;\n // Only a row that kept its whole card can be rendered as one; a row without\n // it would have to invent the department icon, accent and id the card needs.\n return raw && typeof raw === 'object' && raw.name ? raw : null;\n}\n\n/** A saved trending rail, plus whether it is recent enough to skip the live lanes. */\nexport interface StoredTrending {\n products: Product[];\n fresh: boolean;\n observedAt: number;\n}\n\n/**\n * The saved trending rail for one department.\n *\n * `null` when no store is reachable, so a caller can tell \"no memory\" from \"an\n * empty memory\" - the same contract as {@link loadStoredDeals}.\n */\nexport async function loadStoredTrending(\n departmentId: string,\n limit = STORED_BOARD_LIMIT,\n): Promise<StoredTrending | null> {\n if (!salesDealsConfigured()) return null;\n\n const data = await query<{ shoppingSalesDeals?: { data?: StoredDealRow[] } }>(STORED_DEALS_QUERY, {\n filter: { board: 'trending', departmentId, limit },\n });\n const records = (data?.shoppingSalesDeals?.data ?? [])\n .map(recordFromStoredRow)\n .filter((record): record is SalesDealRecord => record !== null);\n\n return {\n products: records.map(recordToProduct).filter((product): product is Product => product !== null),\n fresh: isStoredBoardFresh(records),\n observedAt: newestObservation(records),\n };\n}\n\n/** Remember a finished trending rail. Fire-and-forget, like the deals board. */\nexport async function saveTrendingBoard(departmentId: string, products: readonly Product[]): Promise<void> {\n if (!salesDealsConfigured() || products.length === 0) return;\n\n const records = products.map((product) => productToRecord(product, departmentId));\n await query(SAVE_DEALS_MUTATION, { deals: records.map((record) => toUpsertInput(record, 'trending')) });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDa,MAAA,qBAAA,GAAwB,EAAK,GAAA,EAAA,GAAK,EAAK,GAAA;AAS7C,MAAM,wBAA2B,GAAA;AACjC,MAAM,kBAAqB,GAAA;AAG3B,MAAM,kBAAqB,GAAA;AAoB3B,SAAS,oBAAgC,GAAA;AAC9C,EAAO,OAA4B,0BAA2B,EAAA;AAChE;AAGgB,SAAA,UAAA,CAAc,KAAa,SAAuD,EAAA;AAChG,EAAQ,OAAA,CAAa,qBAA0B,EAAA,GAAA,EAAK,SAAS,CAAA;AAC/D;AACA,MAAM,KAAQ,GAAA,UAAA;AACD,MAAA,kBAAA;AAAA;AAAA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiClC,MAAA,mBAAA;AAAA;AAAA,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBhC,SAAA,KAAA,CAAM,MAAc,IAAsB,EAAA;AACxD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AAA,KAAY,IAAI,CAAA;AAAA,IAC/F,KAAA,EAAO,mBAAmB,OAAO,CAAA;AAAA,IACjC,UAAA,EAAY,kBAAkB,OAAO;AAAA,GACvC;AACF;AAGsB,eAAA,iBAAA,CAAkB,cAAsB,QAA6C,EAAA;AACzG,EAAA,IAAI,CAAC,oBAAA,EAA0B,IAAA,QAAA,CAAS,WAAW,CAAG,EAAA;AACtD,EAAA,MAAM,UAAU,QAAS,CAAA,GAAA,CAAI,aAAW,eAAgB,CAAA,OAAA,EAAS,YAAY,CAAC,CAAA;AAC9E,EAAA,MAAM,MAAM,mBAAqB,EAAA;AAAA,IAC/B,OAAO,OAAQ,CAAA,GAAA,CAAI,YAAU,aAAc,CAAA,MAAA,EAAQ,UAAU,CAAC;AAAA,GAC/D,CAAA;AACH"}
@@ -0,0 +1,82 @@
1
+ var _a;
2
+ const PREFIX = "yantra.shopping.holiday.v1:";
3
+ const MAX_ENTRIES = 160;
4
+ let AsyncStorage = null;
5
+ try {
6
+ AsyncStorage = (_a = require("@react-native-async-storage/async-storage").default) != null ? _a : null;
7
+ } catch (e) {
8
+ AsyncStorage = null;
9
+ }
10
+ const memory = /* @__PURE__ */ new Map();
11
+ function fresh(saved, maxAgeMs, now) {
12
+ if (!saved || typeof saved.at !== "number" || saved.data === void 0 || now - saved.at >= maxAgeMs || saved.at > now + 6e4) {
13
+ return void 0;
14
+ }
15
+ return saved;
16
+ }
17
+ function savedReadNow(key, maxAgeMs, now = Date.now()) {
18
+ return fresh(memory.get(PREFIX + key), maxAgeMs, now);
19
+ }
20
+ async function savedRead(key, maxAgeMs, now = Date.now()) {
21
+ const held = savedReadNow(key, maxAgeMs, now);
22
+ if (held) return held;
23
+ try {
24
+ const raw = await (AsyncStorage == null ? void 0 : AsyncStorage.getItem(PREFIX + key));
25
+ if (!raw) return void 0;
26
+ const saved = fresh(JSON.parse(raw), maxAgeMs, now);
27
+ if (saved) memory.set(PREFIX + key, saved);
28
+ return saved;
29
+ } catch (e) {
30
+ return void 0;
31
+ }
32
+ }
33
+ async function saveRead(key, data, at = Date.now()) {
34
+ const entry = {
35
+ at,
36
+ data
37
+ };
38
+ memory.set(PREFIX + key, entry);
39
+ const store = AsyncStorage;
40
+ if (!store) return;
41
+ const write = () => store.setItem(PREFIX + key, JSON.stringify(entry));
42
+ try {
43
+ await write();
44
+ } catch (e) {
45
+ await prune(store, Math.floor(MAX_ENTRIES / 2));
46
+ try {
47
+ await write();
48
+ } catch (e2) {
49
+ return;
50
+ }
51
+ }
52
+ await prune(store, MAX_ENTRIES);
53
+ }
54
+ async function prune(store, keep) {
55
+ try {
56
+ if (!store.getAllKeys || !store.multiGet) return;
57
+ const keys = (await store.getAllKeys()).filter((key) => key.startsWith(PREFIX));
58
+ if (keys.length <= keep) return;
59
+ const rows = await store.multiGet(keys);
60
+ const entries = rows.map(([key, raw]) => {
61
+ var _a2;
62
+ let at = 0;
63
+ try {
64
+ at = (_a2 = JSON.parse(raw != null ? raw : "{}").at) != null ? _a2 : 0;
65
+ } catch (e) {
66
+ at = 0;
67
+ }
68
+ return {
69
+ key,
70
+ at
71
+ };
72
+ });
73
+ entries.sort((a, b) => a.at - b.at);
74
+ const drop = entries.slice(0, entries.length - keep).map(({
75
+ key
76
+ }) => key);
77
+ for (const key of drop) memory.delete(key);
78
+ if (store.multiRemove) await store.multiRemove(drop);
79
+ else if (store.removeItem) for (const key of drop) await store.removeItem(key);
80
+ } catch (e) {
81
+ }
82
+ }export{saveRead,savedRead,savedReadNow};//# sourceMappingURL=savedReads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"savedReads.js","sources":["../../../../src/features/shopping/services/savedReads.ts"],"sourcesContent":["/**\n * The shopper's own copy of what the holiday deals section read, on this\n * device: coming back to the section (or relaunching the app) shows it at once\n * instead of a blank grid for the seconds a cold search takes. Native twin of\n * the web surface's `services/savedReads.ts` (0.49.0).\n *\n * Kept with the time it was read, so the section shows it as cached data and\n * asks again only once it is stale. Per device only: what one shopper read is\n * never shown to anyone else. Storage can be missing or full: every read and\n * write is guarded, and the section works without it.\n *\n * Native differences: AsyncStorage is asynchronous, so {@link savedRead} and\n * {@link saveRead} return promises. A copy of every entry read or written in\n * this app session is also kept in memory, so {@link savedReadNow} answers\n * synchronously - a section re-opened in the same session paints its last\n * answer on the first frame, as the web's localStorage read does. On the web\n * the same store also keeps what the shopper's browser read for each site;\n * a phone reads no site itself, so only the server's answers are kept here.\n */\n\nconst PREFIX = 'yantra.shopping.holiday.v1:';\n/** At most this many saved reads; the oldest go first. */\nconst MAX_ENTRIES = 160;\n\nexport interface Saved<T> {\n at: number;\n data: T;\n}\n\ntype StorageLike = {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem?(key: string): Promise<void>;\n multiRemove?(keys: readonly string[]): Promise<void>;\n getAllKeys?(): Promise<readonly string[]>;\n multiGet?(keys: readonly string[]): Promise<ReadonlyArray<readonly [string, string | null]>>;\n};\n\nlet AsyncStorage: StorageLike | null = null;\ntry {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require\n AsyncStorage = require('@react-native-async-storage/async-storage').default ?? null;\n} catch {\n AsyncStorage = null;\n}\n\n/** This session's copy of every entry read or written, by full key. */\nconst memory = new Map<string, Saved<unknown>>();\n\nfunction fresh<T>(saved: Saved<T> | undefined | null, maxAgeMs: number, now: number): Saved<T> | undefined {\n if (\n !saved ||\n typeof saved.at !== 'number' ||\n saved.data === undefined ||\n now - saved.at >= maxAgeMs ||\n saved.at > now + 60_000\n ) {\n return undefined;\n }\n return saved;\n}\n\n/** What this session already holds under `key`, when it is younger than `maxAgeMs` - no storage read. */\nexport function savedReadNow<T>(key: string, maxAgeMs: number, now = Date.now()): Saved<T> | undefined {\n return fresh(memory.get(PREFIX + key) as Saved<T> | undefined, maxAgeMs, now);\n}\n\n/** What was saved under `key`, when it is younger than `maxAgeMs`. */\nexport async function savedRead<T>(key: string, maxAgeMs: number, now = Date.now()): Promise<Saved<T> | undefined> {\n const held = savedReadNow<T>(key, maxAgeMs, now);\n if (held) return held;\n try {\n const raw = await AsyncStorage?.getItem(PREFIX + key);\n if (!raw) return undefined;\n const saved = fresh(JSON.parse(raw) as Saved<T>, maxAgeMs, now);\n if (saved) memory.set(PREFIX + key, saved);\n return saved;\n } catch {\n return undefined;\n }\n}\n\n/** Keeps `data` under `key`, read at `at`; drops the oldest reads past MAX_ENTRIES. */\nexport async function saveRead<T>(key: string, data: T, at = Date.now()): Promise<void> {\n const entry: Saved<T> = { at, data };\n memory.set(PREFIX + key, entry);\n const store = AsyncStorage;\n if (!store) return;\n const write = () => store.setItem(PREFIX + key, JSON.stringify(entry));\n try {\n await write();\n } catch {\n // Full: make room once, then give up quietly\n await prune(store, Math.floor(MAX_ENTRIES / 2));\n try {\n await write();\n } catch {\n return;\n }\n }\n await prune(store, MAX_ENTRIES);\n}\n\nasync function prune(store: StorageLike, keep: number): Promise<void> {\n try {\n if (!store.getAllKeys || !store.multiGet) return;\n const keys = (await store.getAllKeys()).filter((key) => key.startsWith(PREFIX));\n if (keys.length <= keep) return;\n const rows = await store.multiGet(keys);\n const entries = rows.map(([key, raw]) => {\n let at = 0;\n try {\n at = (JSON.parse(raw ?? '{}') as { at?: number }).at ?? 0;\n } catch {\n at = 0;\n }\n return { key, at };\n });\n entries.sort((a, b) => a.at - b.at);\n const drop = entries.slice(0, entries.length - keep).map(({ key }) => key);\n for (const key of drop) memory.delete(key);\n if (store.multiRemove) await store.multiRemove(drop);\n else if (store.removeItem) for (const key of drop) await store.removeItem(key);\n } catch {\n // Storage that cannot be listed is left as it is\n }\n}\n\n/** Tests only: forget this session's copies (what is in storage stays). */\nexport function resetSavedReadsMemoryForTests(): void {\n memory.clear();\n}\n"],"names":["e","_a"],"mappings":"AAAA,IAAA,EAAA;AAoBA,MAAM,MAAS,GAAA,6BAAA;AAEf,MAAM,WAAc,GAAA,GAAA;AAapB,IAAI,YAAmC,GAAA,IAAA;AACvC,IAAI;AAEF,EAAA,YAAA,GAAA,CAAe,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AAM,CAAA,QAAA,CAAS,IAAI,CAAA;AACtC,IAAA,MAAM,UAAU,IAAK,CAAA,GAAA,CAAI,CAAC,CAAC,GAAA,EAAK,GAAG,CAAM,KAAA;AArG7C,MAAAC,IAAAA,GAAAA;AAsGM,MAAA,IAAI,EAAK,GAAA,CAAA;AACT,MAAI,IAAA;AACF,QAAMA,EAAAA,GAAAA,CAAAA,GAAAA,GAAA,KAAK,KAAM,CAAA,GAAA,IAAA,IAAA,GAAA,GAAA,GAAO,IAAI,CAEzB,CAAA,EAAA,KAFG,OAAAA,GAEG,GAAA,CAAA;AAAA,OACH,CAAA,OAAA,CAAA,EAAA;AACN,QAAK,EAAA,GAAA,CAAA;AAAA;AAEP,MAAO,OAAA;AAAA,QACL,GAAA;AAAA,QACA;AAAA,OACF;AAAA,KACD,CAAA;AACD,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA,EAAG,MAAM,CAAE,CAAA,EAAA,GAAK,EAAE,EAAE,CAAA;AAClC,IAAM,MAAA,IAAA,GAAO,QAAQ,KAAM,CAAA,CAAA,EAAG,QAAQ,MAAS,GAAA,IAAI,CAAE,CAAA,GAAA,CAAI,CAAC;AAAA,MACxD;AAAA,UACI,GAAG,CAAA;AACT,IAAA,KAAA,MAAW,GAAO,IAAA,IAAA,EAAa,MAAA,CAAA,MAAA,CAAO,GAAG,CAAA;AACzC,IAAA,IAAI,KAAM,CAAA,WAAA,EAAmB,MAAA,KAAA,CAAM,YAAY,IAAI,CAAA;AAAA,SAAW,IAAA,KAAA,CAAM,YAAuB,KAAA,MAAA,GAAA,IAAO,MAAY,MAAA,KAAA,CAAM,WAAW,GAAG,CAAA;AAAA,GAC5H,CAAA,OAAA,CAAA,EAAA;AAAA;AAGV"}
@@ -120,6 +120,8 @@ function searchCardFields(row) {
120
120
  if (variantCount && variantCount > 1) out.variantCount = variantCount;
121
121
  const brand = words(row.brand, 60);
122
122
  if (brand) out.brand = brand;
123
+ const inStock = pick(row, "inStock", "in_stock");
124
+ if (typeof inStock === "boolean") out.inStock = inStock;
123
125
  return out;
124
126
  }
125
127
  function searchFacetsOf(data) {
@@ -1 +1 @@
1
- {"version":3,"file":"searchCardFields.js","sources":["../../../../src/features/shopping/services/searchCardFields.ts"],"sourcesContent":["/**\n * The store details a search card carries beyond title, price and rating -\n * delivery, coupon, badges, \"bought in past month\", Prime, list price, colour\n * and size variants - read off one connector row (shopping parity contract,\n * section 1), plus the store's own refinement column (`facets`) off the\n * response.\n *\n * The scraper writes snake_case and older connector lanes camelCase, so both\n * are read. Every field is optional: a store that did not print it, or an\n * older scraper, leaves it out and the card shows nothing for it. Nothing here\n * invents a value - a delivery date is kept only when it is a real ISO date, a\n * list price only when it is a positive number.\n */\nimport type { Product, ProductVariant } from '../catalog';\nimport { positiveCount } from './countText';\nimport { parsePriceText } from './pricing';\n\ntype Row = Record<string, unknown>;\n\nconst isRow = (value: unknown): value is Row => !!value && typeof value === 'object' && !Array.isArray(value);\n\n/** A store's words, whitespace-collapsed, or undefined when it printed nothing. */\nfunction words(value: unknown, max = 160): string | undefined {\n if (typeof value !== 'string') return undefined;\n const text = value.replace(/\\s+/g, ' ').trim();\n return text ? text.slice(0, max) : undefined;\n}\n\nfunction positiveNumber(value: unknown): number | undefined {\n const n = typeof value === 'number' ? value : typeof value === 'string' ? parsePriceText(value) : Number.NaN;\n return Number.isFinite(n) && n > 0 ? n : undefined;\n}\n\nfunction httpUrl(value: unknown): string | undefined {\n const url = words(value, 2048);\n return url && /^https?:\\/\\//i.test(url) ? url : undefined;\n}\n\n/** First field present under any of the spellings the lanes use. */\nfunction pick(row: Row, ...keys: string[]): unknown {\n for (const key of keys) {\n if (row[key] !== undefined && row[key] !== null) return row[key];\n }\n return undefined;\n}\n\n/** `2026-11-14` (or a timestamp starting with one), else undefined. */\nexport function isoDate(value: unknown): string | undefined {\n const text = words(value, 40);\n const match = text?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/);\n if (!match) return undefined;\n const [, y, m, d] = match;\n const date = new Date(Date.UTC(Number(y), Number(m) - 1, Number(d)));\n // `2026-02-31` is not a day; Date would roll it into March.\n if (date.getUTCMonth() !== Number(m) - 1 || date.getUTCDate() !== Number(d)) return undefined;\n return `${y}-${m}-${d}`;\n}\n\n/** Dimension names kept as the store wrote them (\"Color\"); readers match them case-insensitively. */\nfunction attributesOf(value: unknown): Record<string, string> {\n if (!isRow(value)) return {};\n const out: Record<string, string> = {};\n for (const [key, raw] of Object.entries(value)) {\n const name = words(key, 40);\n const text = typeof raw === 'number' ? String(raw) : words(raw, 80);\n if (name && text) out[name] = text;\n }\n return out;\n}\n\n/** One `_variant` row from the scraper, or undefined when it names nothing. */\nexport function variantOf(value: unknown): ProductVariant | undefined {\n if (!isRow(value)) return undefined;\n const attributes = attributesOf(value.attributes);\n const label = words(value.label, 80) ?? (Object.values(attributes).join(' / ') || undefined);\n if (!label) return undefined;\n const amount = positiveNumber(pick(value, 'amount'));\n const price = words(pick(value, 'price', 'price_text', 'priceText'), 40);\n const currency = words(value.currency, 8)?.toUpperCase();\n const url = httpUrl(value.url);\n const image = httpUrl(pick(value, 'image', 'image_url', 'imageUrl'));\n const available = typeof value.available === 'boolean' ? value.available : undefined;\n const asin = words(value.asin, 10)?.toUpperCase();\n return {\n label,\n attributes,\n selected: value.selected === true,\n ...(price ? { price } : {}),\n ...(amount !== undefined ? { amount } : {}),\n ...(currency ? { currency } : {}),\n ...(url ? { url } : {}),\n ...(image ? { image } : {}),\n ...(available !== undefined ? { available } : {}),\n ...(asin && /^[A-Z0-9]{10}$/.test(asin) ? { asin } : {}),\n };\n}\n\n/** Distinct, trimmed store tags, in the order the store printed them. */\nfunction badgesOf(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n const out: string[] = [];\n for (const item of value) {\n const badge = words(item, 40);\n if (badge && !out.some((b) => b.toLowerCase() === badge.toLowerCase())) out.push(badge);\n }\n return out.slice(0, 4);\n}\n\n/**\n * The parity fields of one search row, ready to spread onto its {@link Product}.\n * `prime` maps to the existing `isPrime`, `list_price` / `list_amount` to the\n * existing `originalPrice` (`reconcilePricing` later drops one that is not\n * above the price).\n */\nexport function searchCardFields(row: unknown): Partial<Product> {\n if (!isRow(row)) return {};\n const out: Partial<Product> = {};\n const delivery = words(row.delivery);\n if (delivery) out.delivery = delivery;\n const deliveryDate = isoDate(pick(row, 'delivery_date', 'deliveryDate'));\n if (deliveryDate) out.deliveryDate = deliveryDate;\n const fastest = words(pick(row, 'fastest_delivery', 'fastestDelivery'));\n if (fastest) out.fastestDelivery = fastest;\n const coupon = words(row.coupon, 80);\n if (coupon) out.coupon = coupon;\n const bought = words(pick(row, 'bought_recently', 'boughtRecently'), 80);\n if (bought) out.boughtRecently = bought;\n if (pick(row, 'prime', 'isPrime', 'is_prime') === true) out.isPrime = true;\n const listAmount =\n positiveNumber(pick(row, 'list_amount', 'listAmount')) ?? positiveNumber(pick(row, 'list_price', 'listPrice'));\n if (listAmount !== undefined) out.originalPrice = listAmount;\n const badges = badgesOf(row.badges);\n if (badges.length > 0) out.badges = badges;\n const variants = Array.isArray(row.variants)\n ? row.variants.map(variantOf).filter((v): v is ProductVariant => v !== undefined)\n : [];\n if (variants.length > 1) out.variants = variants;\n const variantCount = positiveCount(pick(row, 'variant_count', 'variantCount'));\n if (variantCount && variantCount > 1) out.variantCount = variantCount;\n const brand = words(row.brand, 60);\n if (brand) out.brand = brand;\n return out;\n}\n\n/** One refinement the store offers in its own column (\"Brand\", \"Color\", \"Capacity\"). */\nexport interface SearchFacet {\n name: string;\n values: SearchFacetValue[];\n}\n\nexport interface SearchFacetValue {\n label: string;\n count?: number;\n refineUrl?: string;\n}\n\n/** The response's `facets`, cleaned; an empty list when the store had no refinement column. */\nexport function searchFacetsOf(data: unknown): SearchFacet[] {\n if (!isRow(data) || !Array.isArray(data.facets)) return [];\n const facets: SearchFacet[] = [];\n for (const raw of data.facets) {\n if (!isRow(raw)) continue;\n const name = words(raw.name, 40);\n if (!name || !Array.isArray(raw.values)) continue;\n const values: SearchFacetValue[] = [];\n for (const item of raw.values) {\n const value: Row = isRow(item) ? item : { label: item };\n const label = words(value.label, 60);\n if (!label || values.some((v) => v.label.toLowerCase() === label.toLowerCase())) continue;\n const count = positiveCount(value.count);\n const refineUrl = httpUrl(pick(value, 'refine_url', 'refineUrl'));\n values.push({ label, ...(count ? { count } : {}), ...(refineUrl ? { refineUrl } : {}) });\n }\n if (values.length > 0) facets.push({ name, values });\n }\n return facets;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,KAAQ,GAAA,CAAC,KAAiC,KAAA,CAAC,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAY,IAAA,CAAC,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAA;AAG5G,SAAS,KAAA,CAAM,KAAgB,EAAA,GAAA,GAAM,GAAyB,EAAA;AAC5D,EAAI,IAAA,OAAO,KAAU,KAAA,QAAA,EAAiB,OAAA,MAAA;AACtC,EAAA,MAAM,OAAO,KAAM,CAAA,OAAA,CAAQ,MAAQ,EAAA,GAAG,EAAE,IAAK,EAAA;AAC7C,EAAA,OAAO,IAAO,GAAA,IAAA,CAAK,KAAM,CAAA,CAAA,EAAG,GAAG,CAAI,GAAA,MAAA;AACrC;AACA,SAAS,eAAe,KAAoC,EAAA;AAC1D,EAAM,MAAA,CAAA,GAAI,OAAO,KAAA,KAAU,QAAW,GAAA,KAAA,GAAQ,OAAO,KAAA,KAAU,QAAW,GAAA,cAAA,CAAe,KAAK,CAAA,GAAI,MAAO,CAAA,GAAA;AACzG,EAAA,OAAO,OAAO,QAAS,CAAA,CAAC,CAAK,IAAA,CAAA,GAAI,IAAI,CAAI,GAAA,MAAA;AAC3C;AACA,SAAS,QAAQ,KAAoC,EAAA;AACnD,EAAM,MAAA,GAAA,GAAM,KAAM,CAAA,KAAA,EAAO,IAAI,CAAA;AAC7B,EAAA,OAAO,GAAO,IAAA,eAAA,CAAgB,IAAK,CAAA,GAAG,IAAI,GAAM,GAAA,MAAA;AAClD;AAG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IAAA,IAAI,CAAC,IAAQ,IAAA,CAAC,MAAM,OAAQ,CAAA,GAAA,CAAI,MAAM,CAAG,EAAA;AACzC,IAAA,MAAM,SAA6B,EAAC;AACpC,IAAW,KAAA,MAAA,IAAA,IAAQ,IAAI,MAAQ,EAAA;AAC7B,MAAA,MAAM,KAAa,GAAA,KAAA,CAAM,IAAI,CAAA,GAAI,IAAO,GAAA;AAAA,QACtC,KAAO,EAAA;AAAA,OACT;AACA,MAAA,MAAM,KAAQ,GAAA,KAAA,CAAM,KAAM,CAAA,KAAA,EAAO,EAAE,CAAA;AACnC,MAAA,IAAI,CAAC,KAAA,IAAS,MAAO,CAAA,IAAA,CAAK,CAAK,CAAA,KAAA,CAAA,CAAE,KAAM,CAAA,WAAA,EAAkB,KAAA,KAAA,CAAM,WAAY,EAAC,CAAG,EAAA;AAC/E,MAAM,MAAA,KAAA,GAAQ,aAAc,CAAA,KAAA,CAAM,KAAK,CAAA;AACvC,MAAA,MAAM,YAAY,OAAQ,CAAA,IAAA,CAAK,KAAO,EAAA,YAAA,EAAc,WAAW,CAAC,CAAA;AAChE,MAAA,MAAA,CAAO,IAAK,CAAA,cAAA,CAAA,cAAA,CAAA;AAAA,QACV;AAAA,OAAA,EACI,KAAQ,GAAA;AAAA,QACV;AAAA,OACF,GAAI,EAAC,CAAA,EACD,SAAY,GAAA;AAAA,QACd;AAAA,OACF,GAAI,EACL,CAAA,CAAA;AAAA;AAEH,IAAA,IAAI,MAAO,CAAA,MAAA,GAAS,CAAG,EAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACjC,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA;AAEH,EAAO,OAAA,MAAA;AACT"}
1
+ {"version":3,"file":"searchCardFields.js","sources":["../../../../src/features/shopping/services/searchCardFields.ts"],"sourcesContent":["/**\n * The store details a search card carries beyond title, price and rating -\n * delivery, coupon, badges, \"bought in past month\", Prime, list price, colour\n * and size variants - read off one connector row (shopping parity contract,\n * section 1), plus the store's own refinement column (`facets`) off the\n * response.\n *\n * The scraper writes snake_case and older connector lanes camelCase, so both\n * are read. Every field is optional: a store that did not print it, or an\n * older scraper, leaves it out and the card shows nothing for it. Nothing here\n * invents a value - a delivery date is kept only when it is a real ISO date, a\n * list price only when it is a positive number.\n */\nimport type { Product, ProductVariant } from '../catalog';\nimport { positiveCount } from './countText';\nimport { parsePriceText } from './pricing';\n\ntype Row = Record<string, unknown>;\n\nconst isRow = (value: unknown): value is Row => !!value && typeof value === 'object' && !Array.isArray(value);\n\n/** A store's words, whitespace-collapsed, or undefined when it printed nothing. */\nfunction words(value: unknown, max = 160): string | undefined {\n if (typeof value !== 'string') return undefined;\n const text = value.replace(/\\s+/g, ' ').trim();\n return text ? text.slice(0, max) : undefined;\n}\n\nfunction positiveNumber(value: unknown): number | undefined {\n const n = typeof value === 'number' ? value : typeof value === 'string' ? parsePriceText(value) : Number.NaN;\n return Number.isFinite(n) && n > 0 ? n : undefined;\n}\n\nfunction httpUrl(value: unknown): string | undefined {\n const url = words(value, 2048);\n return url && /^https?:\\/\\//i.test(url) ? url : undefined;\n}\n\n/** First field present under any of the spellings the lanes use. */\nfunction pick(row: Row, ...keys: string[]): unknown {\n for (const key of keys) {\n if (row[key] !== undefined && row[key] !== null) return row[key];\n }\n return undefined;\n}\n\n/** `2026-11-14` (or a timestamp starting with one), else undefined. */\nexport function isoDate(value: unknown): string | undefined {\n const text = words(value, 40);\n const match = text?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/);\n if (!match) return undefined;\n const [, y, m, d] = match;\n const date = new Date(Date.UTC(Number(y), Number(m) - 1, Number(d)));\n // `2026-02-31` is not a day; Date would roll it into March.\n if (date.getUTCMonth() !== Number(m) - 1 || date.getUTCDate() !== Number(d)) return undefined;\n return `${y}-${m}-${d}`;\n}\n\n/** Dimension names kept as the store wrote them (\"Color\"); readers match them case-insensitively. */\nfunction attributesOf(value: unknown): Record<string, string> {\n if (!isRow(value)) return {};\n const out: Record<string, string> = {};\n for (const [key, raw] of Object.entries(value)) {\n const name = words(key, 40);\n const text = typeof raw === 'number' ? String(raw) : words(raw, 80);\n if (name && text) out[name] = text;\n }\n return out;\n}\n\n/** One `_variant` row from the scraper, or undefined when it names nothing. */\nexport function variantOf(value: unknown): ProductVariant | undefined {\n if (!isRow(value)) return undefined;\n const attributes = attributesOf(value.attributes);\n const label = words(value.label, 80) ?? (Object.values(attributes).join(' / ') || undefined);\n if (!label) return undefined;\n const amount = positiveNumber(pick(value, 'amount'));\n const price = words(pick(value, 'price', 'price_text', 'priceText'), 40);\n const currency = words(value.currency, 8)?.toUpperCase();\n const url = httpUrl(value.url);\n const image = httpUrl(pick(value, 'image', 'image_url', 'imageUrl'));\n const available = typeof value.available === 'boolean' ? value.available : undefined;\n const asin = words(value.asin, 10)?.toUpperCase();\n return {\n label,\n attributes,\n selected: value.selected === true,\n ...(price ? { price } : {}),\n ...(amount !== undefined ? { amount } : {}),\n ...(currency ? { currency } : {}),\n ...(url ? { url } : {}),\n ...(image ? { image } : {}),\n ...(available !== undefined ? { available } : {}),\n ...(asin && /^[A-Z0-9]{10}$/.test(asin) ? { asin } : {}),\n };\n}\n\n/** Distinct, trimmed store tags, in the order the store printed them. */\nfunction badgesOf(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n const out: string[] = [];\n for (const item of value) {\n const badge = words(item, 40);\n if (badge && !out.some((b) => b.toLowerCase() === badge.toLowerCase())) out.push(badge);\n }\n return out.slice(0, 4);\n}\n\n/**\n * The parity fields of one search row, ready to spread onto its {@link Product}.\n * `prime` maps to the existing `isPrime`, `list_price` / `list_amount` to the\n * existing `originalPrice` (`reconcilePricing` later drops one that is not\n * above the price).\n */\nexport function searchCardFields(row: unknown): Partial<Product> {\n if (!isRow(row)) return {};\n const out: Partial<Product> = {};\n const delivery = words(row.delivery);\n if (delivery) out.delivery = delivery;\n const deliveryDate = isoDate(pick(row, 'delivery_date', 'deliveryDate'));\n if (deliveryDate) out.deliveryDate = deliveryDate;\n const fastest = words(pick(row, 'fastest_delivery', 'fastestDelivery'));\n if (fastest) out.fastestDelivery = fastest;\n const coupon = words(row.coupon, 80);\n if (coupon) out.coupon = coupon;\n const bought = words(pick(row, 'bought_recently', 'boughtRecently'), 80);\n if (bought) out.boughtRecently = bought;\n if (pick(row, 'prime', 'isPrime', 'is_prime') === true) out.isPrime = true;\n const listAmount =\n positiveNumber(pick(row, 'list_amount', 'listAmount')) ?? positiveNumber(pick(row, 'list_price', 'listPrice'));\n if (listAmount !== undefined) out.originalPrice = listAmount;\n const badges = badgesOf(row.badges);\n if (badges.length > 0) out.badges = badges;\n const variants = Array.isArray(row.variants)\n ? row.variants.map(variantOf).filter((v): v is ProductVariant => v !== undefined)\n : [];\n if (variants.length > 1) out.variants = variants;\n const variantCount = positiveCount(pick(row, 'variant_count', 'variantCount'));\n if (variantCount && variantCount > 1) out.variantCount = variantCount;\n const brand = words(row.brand, 60);\n if (brand) out.brand = brand;\n // The store's own results page marked it (Walmart \"Out of stock\", Amazon \"Currently unavailable.\").\n const inStock = pick(row, 'inStock', 'in_stock');\n if (typeof inStock === 'boolean') out.inStock = inStock;\n return out;\n}\n\n/** One refinement the store offers in its own column (\"Brand\", \"Color\", \"Capacity\"). */\nexport interface SearchFacet {\n name: string;\n values: SearchFacetValue[];\n}\n\nexport interface SearchFacetValue {\n label: string;\n count?: number;\n refineUrl?: string;\n}\n\n/** The response's `facets`, cleaned; an empty list when the store had no refinement column. */\nexport function searchFacetsOf(data: unknown): SearchFacet[] {\n if (!isRow(data) || !Array.isArray(data.facets)) return [];\n const facets: SearchFacet[] = [];\n for (const raw of data.facets) {\n if (!isRow(raw)) continue;\n const name = words(raw.name, 40);\n if (!name || !Array.isArray(raw.values)) continue;\n const values: SearchFacetValue[] = [];\n for (const item of raw.values) {\n const value: Row = isRow(item) ? item : { label: item };\n const label = words(value.label, 60);\n if (!label || values.some((v) => v.label.toLowerCase() === label.toLowerCase())) continue;\n const count = positiveCount(value.count);\n const refineUrl = httpUrl(pick(value, 'refine_url', 'refineUrl'));\n values.push({ label, ...(count ? { count } : {}), ...(refineUrl ? { refineUrl } : {}) });\n }\n if (values.length > 0) facets.push({ name, values });\n }\n return facets;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,KAAQ,GAAA,CAAC,KAAiC,KAAA,CAAC,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAY,IAAA,CAAC,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAA;AAG5G,SAAS,KAAA,CAAM,KAAgB,EAAA,GAAA,GAAM,GAAyB,EAAA;AAC5D,EAAI,IAAA,OAAO,KAAU,KAAA,QAAA,EAAiB,OAAA,MAAA;AACtC,EAAA,MAAM,OAAO,KAAM,CAAA,OAAA,CAAQ,MAAQ,EAAA,GAAG,EAAE,IAAK,EAAA;AAC7C,EAAA,OAAO,IAAO,GAAA,IAAA,CAAK,KAAM,CAAA,CAAA,EAAG,GAAG,CAAI,GAAA,MAAA;AACrC;AACA,SAAS,eAAe,KAAoC,EAAA;AAC1D,EAAM,MAAA,CAAA,GAAI,OAAO,KAAA,KAAU,QAAW,GAAA,KAAA,GAAQ,OAAO,KAAA,KAAU,QAAW,GAAA,cAAA,CAAe,KAAK,CAAA,GAAI,MAAO,CAAA,GAAA;AACzG,EAAA,OAAO,OAAO,QAAS,CAAA,CAAC,CAAK,IAAA,CAAA,GAAI,IAAI,CAAI,GAAA,MAAA;AAC3C;AACA,SAAS,QAAQ,KAAoC,EAAA;AACnD,EAAM,MAAA,GAAA,GAAM,KAAM,CAAA,KAAA,EAAO,IAAI,CAAA;AAC7B,EAAA,OAAO,GAAO,IAAA,eAAA,CAAgB,IAAK,CAAA,GAAG,IAAI,GAAM,GAAA,MAAA;AAClD;AAGA,SAAS,IAAA,CAAK,QAAa,IAAyB,EAAA;AAClD,EAAA,KAAA,MAAW,OAAO,IAAM,EAAA;AACtB,IAAI,IAAA,GAAA,CAAI,GAAG,CAAA,KAAM,MAAa,IAAA,GAAA,CAAI,G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