@adminide-stack/yantra-mobile 12.0.195 → 12.0.196-alpha.1

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
@@ -0,0 +1,14 @@
1
+ const MODEL_LINE_WORDS = /* @__PURE__ */ new Set(["pro", "max", "plus", "mini", "ultra", "air", "lite", "se", "fe", "xl", "slim"]);
2
+ const SPEC_TOKEN = /^\d+(?:gb|tb|mb|in|inch|mm|cm|w|mah|hz|ghz|mhz|k|p|oz|lb|lbs|ml|l|ft|v|qt|pc|pcs|ct|pk|pack|x|gen|th|nd|rd|st)$/;
3
+ function modelWordRole(word) {
4
+ if (MODEL_LINE_WORDS.has(word)) return "line";
5
+ if (/^\d+$/.test(word)) return "number";
6
+ if (SPEC_TOKEN.test(word)) return "spec";
7
+ if (/\d/.test(word) && /[a-z]/.test(word)) return "code";
8
+ return "name";
9
+ }
10
+ function codeFamily(code) {
11
+ const m = /^(.*?)(\d+)([a-z]*)$/.exec(code);
12
+ if (!m || !/[a-z]/.test(code)) return null;
13
+ return `${m[1]}#${m[3]}/${m[2].length}`;
14
+ }export{MODEL_LINE_WORDS,codeFamily,modelWordRole};//# sourceMappingURL=modelWords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelWords.js","sources":["../../../../src/features/shopping/services/modelWords.ts"],"sourcesContent":["/**\n * Native twin of the web surface's `services/modelWords.ts` (0.49.0), verbatim.\n *\n * The grammar of model names, shared by every place that holds a listing to\n * what the shopper typed (the search grid, the Black Friday deal reader).\n *\n * A product's name is a head word plus qualifiers: \"MacBook\" + \"Pro\", \"iPhone\"\n * + \"17\" + \"Pro Max\", \"Galaxy\" + \"S24\" + \"Ultra\". The qualifiers say WHICH one,\n * and none of them is a product on its own - \"M3 Pro\" is a chip in a MacBook and\n * also a garment iron, \"Pro\" is a laptop, a pair of headphones and a Windows\n * edition. These helpers tell a query's words apart by that role, so a title\n * that carries only the qualifiers is not taken for the product.\n */\n\n/**\n * Words that name a model line of the word before them (\"MacBook Pro\", \"iPad\n * mini\", \"iPhone 17 Pro Max\"), never a product on their own.\n */\nexport const MODEL_LINE_WORDS: ReadonlySet<string> = new Set([\n 'pro',\n 'max',\n 'plus',\n 'mini',\n 'ultra',\n 'air',\n 'lite',\n 'se',\n 'fe',\n 'xl',\n 'slim',\n]);\n\n/** A size, capacity or rating with its unit (\"512gb\", \"14in\", \"65w\", \"4k\"): a variant, never a model. */\nconst SPEC_TOKEN =\n /^\\d+(?:gb|tb|mb|in|inch|mm|cm|w|mah|hz|ghz|mhz|k|p|oz|lb|lbs|ml|l|ft|v|qt|pc|pcs|ct|pk|pack|x|gen|th|nd|rd|st)$/;\n\n/**\n * The part a query word plays in a product name:\n *\n * - `name`: a word that names the product or its maker (\"macbook\", \"apple\", \"shoe\");\n * - `line`: a model-line word ({@link MODEL_LINE_WORDS});\n * - `code`: a model code - letters and digits in one word (\"m3\", \"s24\", \"i7\",\n * \"ps5\", \"1000xm5\"); it says which model, so another code of the same shape\n * (\"m2\" for \"m3\") is another model;\n * - `number`: a bare number (\"15\", \"2023\") - which generation or size;\n * - `spec`: a size or capacity with its unit ({@link SPEC_TOKEN}).\n */\nexport type ModelWordRole = 'name' | 'line' | 'code' | 'number' | 'spec';\n\n/** The role of one lowercase word (see {@link ModelWordRole}). */\nexport function modelWordRole(word: string): ModelWordRole {\n if (MODEL_LINE_WORDS.has(word)) return 'line';\n if (/^\\d+$/.test(word)) return 'number';\n if (SPEC_TOKEN.test(word)) return 'spec';\n if (/\\d/.test(word) && /[a-z]/.test(word)) return 'code';\n return 'name';\n}\n\n/**\n * A model code's family: the code with its last run of digits as `#` and that\n * run's length - \"m3\" and \"m2\" are both `m#/1`, \"s24\" and \"s23\" `s#/2`,\n * \"1000xm5\" and \"1000xm4\" `1000xm#/1`. Two different codes of one family are\n * two different models; \"a18\" (`a#/2`) is not of the \"m3\" family.\n */\nexport function codeFamily(code: string): string | null {\n const m = /^(.*?)(\\d+)([a-z]*)$/.exec(code);\n if (!m || !/[a-z]/.test(code)) return null;\n return `${m[1]}#${m[3]}/${m[2].length}`;\n}\n"],"names":[],"mappings":"AAkBO,MAAM,gBAAwC,mBAAA,IAAI,GAAI,CAAA,CAAC,OAAO,KAAO,EAAA,MAAA,EAAQ,MAAQ,EAAA,OAAA,EAAS,OAAO,MAAQ,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,MAAM,CAAC;AAG7I,MAAM,UAAa,GAAA,iHAAA;AAgBZ,SAAS,cAAc,IAA6B,EAAA;AACzD,EAAA,IAAI,gBAAiB,CAAA,GAAA,CAAI,IAAI,CAAA,EAAU,OAAA,MAAA;AACvC,EAAA,IAAI,OAAQ,CAAA,IAAA,CAAK,IAAI,CAAA,EAAU,OAAA,QAAA;AAC/B,EAAA,IAAI,UAAW,CAAA,IAAA,CAAK,IAAI,CAAA,EAAU,OAAA,MAAA;AAClC,EAAI,IAAA,IAAA,CAAK,KAAK,IAAI,CAAA,IAAK,QAAQ,IAAK,CAAA,IAAI,GAAU,OAAA,MAAA;AAClD,EAAO,OAAA,MAAA;AACT;AAQO,SAAS,WAAW,IAA6B,EAAA;AACtD,EAAM,MAAA,CAAA,GAAI,sBAAuB,CAAA,IAAA,CAAK,IAAI,CAAA;AAC1C,EAAA,IAAI,CAAC,CAAK,IAAA,CAAC,QAAQ,IAAK,CAAA,IAAI,GAAU,OAAA,IAAA;AACtC,EAAA,OAAO,CAAG,EAAA,CAAA,CAAE,CAAC,CAAC,CAAI,CAAA,EAAA,CAAA,CAAE,CAAC,CAAC,CAAI,CAAA,EAAA,CAAA,CAAE,CAAC,CAAA,CAAE,MAAM,CAAA,CAAA;AACvC"}
@@ -22,4 +22,8 @@ function isSellable(product) {
22
22
  }
23
23
  function keepSellableProducts(products) {
24
24
  return products.filter(isSellable);
25
- }export{isPlausibleProductUrl,isSellable,keepSellableProducts};//# sourceMappingURL=productAvailability.js.map
25
+ }
26
+ function keepShowableProducts(products) {
27
+ const linked = products.filter((product) => isPlausibleProductUrl(product.url));
28
+ return [...linked.filter((product) => product.inStock !== false), ...linked.filter((product) => product.inStock === false)];
29
+ }export{isPlausibleProductUrl,isSellable,keepSellableProducts,keepShowableProducts};//# sourceMappingURL=productAvailability.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"productAvailability.js","sources":["../../../../src/features/shopping/services/productAvailability.ts"],"sourcesContent":["/**\n * The bar a row has to clear before it is a RESULT - before the grid shows it\n * and, more to the point, before the AI repeats it to a shopper.\n *\n * Two rules, both about not asserting what we cannot stand behind:\n *\n * - a row a source marked out of stock is not a result. An \"Out of stock\"\n * badge on a card is honest; an assistant saying \"here are 8 products\" with\n * two of them unbuyable is not, and the assistant reads the same rows.\n * - a row with no link, or a link that is not a product page, is not a result.\n * Every retailer lane already gates on URL shape; the research lane did not,\n * and a \"product\" that opens a search page or a forum thread is a broken\n * promise however good the title looked.\n *\n * Unknown stock (`inStock` unset) passes: the SERP lanes report none, and\n * refusing them would empty the page. The live page check\n * ({@link ./verifyProducts}) is what turns \"unknown\" into a verdict.\n */\nimport type { Product } from '../catalog';\nimport { detectRetailerSourceFromUrl, isNonMerchantHost, isRetailerProductUrl } from './retailerUrl';\n\nfunction isGoogleShoppingProductUrl(parsed: URL): boolean {\n return /(?:^|\\.)google\\.[a-z.]+$/i.test(parsed.hostname) && /^\\/shopping\\/product\\/\\d+/i.test(parsed.pathname);\n}\n\n/**\n * True when `url` could open a product: absolute http(s), on a host that sells\n * things, and - for a shop we know the URL grammar of - a product-page path\n * rather than a search or category hub. An unknown shop passes on shape alone;\n * the live check decides for it.\n */\nexport function isPlausibleProductUrl(url: string | undefined): boolean {\n if (!url) return false;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return false;\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return false;\n // Google sells nothing, but its Shopping product page is where the offers\n // lane's rows point (the merchant link lives behind /product-offers), and it\n // opens a real listing with live merchant prices.\n if (isGoogleShoppingProductUrl(parsed)) return true;\n if (isNonMerchantHost(url)) return false;\n const source = detectRetailerSourceFromUrl(url);\n if (source && source !== 'google') return isRetailerProductUrl(url, source);\n return true;\n}\n\n/** True when the row is one the page can show AND the AI can repeat. */\nexport function isSellable(product: Pick<Product, 'inStock' | 'url'>): boolean {\n if (product.inStock === false) return false;\n return isPlausibleProductUrl(product.url);\n}\n\n/** Drop rows that fail {@link isSellable}. */\nexport function keepSellableProducts<T extends Pick<Product, 'inStock' | 'url'>>(products: T[]): T[] {\n return products.filter(isSellable);\n}\n"],"names":[],"mappings":"kGAoBA,SAAS,2BAA2B,MAAsB,EAAA;AACxD,EAAO,OAAA,2BAAA,CAA4B,KAAK,MAAO,CAAA,QAAQ,KAAK,4BAA6B,CAAA,IAAA,CAAK,OAAO,QAAQ,CAAA;AAC/G;AAQO,SAAS,sBAAsB,GAAkC,EAAA;AACtE,EAAI,IAAA,CAAC,KAAY,OAAA,KAAA;AACjB,EAAI,IAAA,MAAA;AACJ,EAAI,IAAA;AACF,IAAS,MAAA,GAAA,IAAI,IAAI,GAAG,CAAA;AAAA,GACd,CAAA,OAAA,CAAA,EAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAET,EAAA,IAAI,OAAO,QAAa,KAAA,OAAA,IAAW,MAAO,CAAA,QAAA,KAAa,UAAiB,OAAA,KAAA;AAIxE,EAAI,IAAA,0BAAA,CAA2B,MAAM,CAAA,EAAU,OAAA,IAAA;AAC/C,EAAI,IAAA,iBAAA,CAAkB,GAAG,CAAA,EAAU,OAAA,KAAA;AACnC,EAAM,MAAA,MAAA,GAAS,4BAA4B,GAAG,CAAA;AAC9C,EAAA,IAAI,UAAU,MAAW,KAAA,QAAA,EAAiB,OAAA,oBAAA,CAAqB,KAAK,MAAM,CAAA;AAC1E,EAAO,OAAA,IAAA;AACT;AAGO,SAAS,WAAW,OAAoD,EAAA;AAC7E,EAAI,IAAA,OAAA,CAAQ,OAAY,KAAA,KAAA,EAAc,OAAA,KAAA;AACtC,EAAO,OAAA,qBAAA,CAAsB,QAAQ,GAAG,CAAA;AAC1C;AAGO,SAAS,qBAAiE,QAAoB,EAAA;AACnG,EAAO,OAAA,QAAA,CAAS,OAAO,UAAU,CAAA;AACnC"}
1
+ {"version":3,"file":"productAvailability.js","sources":["../../../../src/features/shopping/services/productAvailability.ts"],"sourcesContent":["/**\n * The bar a row has to clear before it is a RESULT - before the grid shows it\n * and, more to the point, before the AI repeats it to a shopper.\n *\n * Two rules, both about not asserting what we cannot stand behind:\n *\n * - a row a source marked out of stock is not a result. An \"Out of stock\"\n * badge on a card is honest; an assistant saying \"here are 8 products\" with\n * two of them unbuyable is not, and the assistant reads the same rows.\n * - a row with no link, or a link that is not a product page, is not a result.\n * Every retailer lane already gates on URL shape; the research lane did not,\n * and a \"product\" that opens a search page or a forum thread is a broken\n * promise however good the title looked.\n *\n * Unknown stock (`inStock` unset) passes: the SERP lanes report none, and\n * refusing them would empty the page. The live page check\n * ({@link ./verifyProducts}) is what turns \"unknown\" into a verdict.\n *\n * The GRID is a different reader (decided 2026-11-19): the shopper sees what the\n * store's own results show. Walmart and Amazon list an item they cannot sell\n * with an \"Out of stock\" / \"Currently unavailable\" mark, and so does the grid -\n * {@link keepShowableProducts} keeps such a row, labelled, after every row that\n * can be bought. What the agent repeats and picks from still drops it\n * ({@link keepSellableProducts}).\n */\nimport type { Product } from '../catalog';\nimport { detectRetailerSourceFromUrl, isNonMerchantHost, isRetailerProductUrl } from './retailerUrl';\n\nfunction isGoogleShoppingProductUrl(parsed: URL): boolean {\n return /(?:^|\\.)google\\.[a-z.]+$/i.test(parsed.hostname) && /^\\/shopping\\/product\\/\\d+/i.test(parsed.pathname);\n}\n\n/**\n * True when `url` could open a product: absolute http(s), on a host that sells\n * things, and - for a shop we know the URL grammar of - a product-page path\n * rather than a search or category hub. An unknown shop passes on shape alone;\n * the live check decides for it.\n */\nexport function isPlausibleProductUrl(url: string | undefined): boolean {\n if (!url) return false;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return false;\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return false;\n // Google sells nothing, but its Shopping product page is where the offers\n // lane's rows point (the merchant link lives behind /product-offers), and it\n // opens a real listing with live merchant prices.\n if (isGoogleShoppingProductUrl(parsed)) return true;\n if (isNonMerchantHost(url)) return false;\n const source = detectRetailerSourceFromUrl(url);\n if (source && source !== 'google') return isRetailerProductUrl(url, source);\n return true;\n}\n\n/** True when the row is one the page can show AND the AI can repeat. */\nexport function isSellable(product: Pick<Product, 'inStock' | 'url'>): boolean {\n if (product.inStock === false) return false;\n return isPlausibleProductUrl(product.url);\n}\n\n/** Drop rows that fail {@link isSellable}. */\nexport function keepSellableProducts<T extends Pick<Product, 'inStock' | 'url'>>(products: T[]): T[] {\n return products.filter(isSellable);\n}\n\n/**\n * The rows the grid shows: every row with a product link, the ones the store\n * marks out of stock moved after the ones that can be bought (each keeps its\n * place among its own kind).\n */\nexport function keepShowableProducts<T extends Pick<Product, 'inStock' | 'url'>>(products: T[]): T[] {\n const linked = products.filter((product) => isPlausibleProductUrl(product.url));\n return [\n ...linked.filter((product) => product.inStock !== false),\n ...linked.filter((product) => product.inStock === false),\n ];\n}\n"],"names":[],"mappings":"kGA2BA,SAAS,2BAA2B,MAAsB,EAAA;AACxD,EAAO,OAAA,2BAAA,CAA4B,KAAK,MAAO,CAAA,QAAQ,KAAK,4BAA6B,CAAA,IAAA,CAAK,OAAO,QAAQ,CAAA;AAC/G;AAQO,SAAS,sBAAsB,GAAkC,EAAA;AACtE,EAAI,IAAA,CAAC,KAAY,OAAA,KAAA;AACjB,EAAI,IAAA,MAAA;AACJ,EAAI,IAAA;AACF,IAAS,MAAA,GAAA,IAAI,IAAI,GAAG,CAAA;AAAA,GACd,CAAA,OAAA,CAAA,EAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAET,EAAA,IAAI,OAAO,QAAa,KAAA,OAAA,IAAW,MAAO,CAAA,QAAA,KAAa,UAAiB,OAAA,KAAA;AAIxE,EAAI,IAAA,0BAAA,CAA2B,MAAM,CAAA,EAAU,OAAA,IAAA;AAC/C,EAAI,IAAA,iBAAA,CAAkB,GAAG,CAAA,EAAU,OAAA,KAAA;AACnC,EAAM,MAAA,MAAA,GAAS,4BAA4B,GAAG,CAAA;AAC9C,EAAA,IAAI,UAAU,MAAW,KAAA,QAAA,EAAiB,OAAA,oBAAA,CAAqB,KAAK,MAAM,CAAA;AAC1E,EAAO,OAAA,IAAA;AACT;AAGO,SAAS,WAAW,OAAoD,EAAA;AAC7E,EAAI,IAAA,OAAA,CAAQ,OAAY,KAAA,KAAA,EAAc,OAAA,KAAA;AACtC,EAAO,OAAA,qBAAA,CAAsB,QAAQ,GAAG,CAAA;AAC1C;AAGO,SAAS,qBAAiE,QAAoB,EAAA;AACnG,EAAO,OAAA,QAAA,CAAS,OAAO,UAAU,CAAA;AACnC;AAOO,SAAS,qBAAiE,QAAoB,EAAA;AACnG,EAAA,MAAM,SAAS,QAAS,CAAA,MAAA,CAAO,aAAW,qBAAsB,CAAA,OAAA,CAAQ,GAAG,CAAC,CAAA;AAC5E,EAAA,OAAO,CAAC,GAAG,MAAA,CAAO,MAAO,CAAA,CAAA,OAAA,KAAW,QAAQ,OAAY,KAAA,KAAK,CAAG,EAAA,GAAG,OAAO,MAAO,CAAA,CAAA,OAAA,KAAW,OAAQ,CAAA,OAAA,KAAY,KAAK,CAAC,CAAA;AACxH"}
@@ -128,8 +128,8 @@ function compare(a, b, sort) {
128
128
  }
129
129
  function applyProductFilters(products, filters) {
130
130
  const kept = products.filter((product) => matches(product, filters));
131
- if (filters.sort === "relevance") return kept;
132
- return [...kept].sort((a, b) => compare(a, b, filters.sort));
131
+ const ordered = filters.sort === "relevance" ? kept : [...kept].sort((a, b) => compare(a, b, filters.sort));
132
+ return [...ordered.filter((product) => product.inStock !== false), ...ordered.filter((product) => product.inStock === false)];
133
133
  }
134
134
  function productFacets(products) {
135
135
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"productFilters.js","sources":["../../../../src/features/shopping/services/productFilters.ts"],"sourcesContent":["/**\n * The filter model shared by the landing page's trending rails and the search\n * results grid.\n *\n * Pure functions over `Product[]` — no fetching. Every lane (catalog, the\n * retailer SERPs, the paired browser) returns the same {@link Product}, so one\n * filter pass serves all of them, and the same chips mean the same thing\n * whether the user is browsing trending rows or reading search results.\n *\n * Two rules exist because a shopping row is routinely PARTIAL, and \"the field\n * is missing\" must never be read as \"the field is false\":\n *\n * - `inStockOnly` drops only rows that say `inStock === false`. Only the typed\n * catalog knows stock; a SERP scrape leaves it undefined, so treating\n * undefined as out-of-stock would empty the grid on every non-catalog lane.\n * - `maxPrice` DOES drop rows with no usable price (a row that only says \"see\n * price on Amazon\"). A ceiling is a claim about what the shopper will pay,\n * and a row we cannot price cannot be claimed to satisfy it.\n */\n\nimport type { Product, ProductSource } from '../catalog';\nimport type { SearchFacet } from './searchCardFields';\nimport { splitTitleVariant, variantAttribute } from './variantCards';\n\nexport type ProductSortOrder = 'relevance' | 'price-asc' | 'price-desc' | 'rating' | 'discount';\n\nexport interface ProductFilters {\n /** Price ceiling in the row's own currency units. `null` = no ceiling. */\n maxPrice: number | null;\n /** Minimum star rating, 0–5. `null` = unrated rows welcome. */\n minRating: number | null;\n /** Minimum discount percent off list price. `null` = full-price rows welcome. */\n minDiscount: number | null;\n /** Hide rows the catalog reports as out of stock. */\n inStockOnly: boolean;\n /** Retailer lanes to keep. Empty = every lane. */\n sources: ProductSource[];\n sort: ProductSortOrder;\n // ─── Result refinements (brand, attributes, delivery) ───\n // Optional so a filter object written before they existed still reads as\n // \"not narrowing\". They describe ONE result set, so a new search resets\n // them (see {@link withoutRefinements}).\n /** Brands to keep, lower-case. Empty = every brand. */\n brands?: string[];\n /** Attribute name (lower-case, \"color\") -> values to keep (lower-case). OR within, AND across. */\n attributes?: Record<string, string[]>;\n /** Only rows the store marks Prime. */\n primeOnly?: boolean;\n /** Only rows whose stated delivery date is on or before this ISO date. */\n arrivesBy?: string | null;\n}\n\nexport const DEFAULT_PRODUCT_FILTERS: ProductFilters = {\n maxPrice: null,\n minRating: null,\n minDiscount: null,\n inStockOnly: false,\n sources: [],\n sort: 'relevance',\n};\n\nfunction attributeSelectionCount(filters: ProductFilters): number {\n return Object.values(filters.attributes ?? {}).reduce((n, values) => n + values.length, 0);\n}\n\n/** Is anything actually narrowing the rows? (Sort alone is not a filter.) */\nexport function hasActiveFilters(filters: ProductFilters): boolean {\n return activeFilterCount(filters) > 0;\n}\n\n/** How many chips are narrowing — the count on the \"Filters\" button. */\nexport function activeFilterCount(filters: ProductFilters): number {\n return (\n (filters.maxPrice !== null ? 1 : 0) +\n (filters.minRating !== null ? 1 : 0) +\n (filters.minDiscount !== null ? 1 : 0) +\n (filters.inStockOnly ? 1 : 0) +\n filters.sources.length +\n (filters.brands?.length ?? 0) +\n attributeSelectionCount(filters) +\n (filters.primeOnly ? 1 : 0) +\n (filters.arrivesBy ? 1 : 0)\n );\n}\n\n/**\n * The filters with this result set's own refinements (brand, attributes,\n * delivery) dropped and the general ones (price, rating, deal, store, sort)\n * kept. A brand picked for \"espresso machine\" means nothing for \"toaster\", and\n * carried over it would blank the next grid.\n */\nexport function withoutRefinements(filters: ProductFilters): ProductFilters {\n const { brands: _b, attributes: _a, primeOnly: _p, arrivesBy: _d, ...general } = filters;\n return general;\n}\n\n/**\n * The discount a card can honestly claim: a percent is only real when there is\n * a list price ABOVE the current one to discount from. Mirrors the same\n * reconciliation ProductRow does before it paints a badge, so the chip can\n * never select rows whose card shows no discount.\n */\nexport function effectiveDiscountPercent(product: Product): number {\n if (!(product.price > 0)) return 0;\n const original = product.originalPrice;\n if (typeof original !== 'number' || !(original > product.price)) return 0;\n return Math.round(((original - product.price) / original) * 100);\n}\n\nconst normalize = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9.]+/g, ' ')\n .trim();\n\n/** Does `text` contain `phrase` as whole words? */\nfunction hasPhrase(text: string, phrase: string): boolean {\n const want = normalize(phrase);\n return want.length > 0 && ` ${normalize(text)} `.includes(` ${want} `);\n}\n\n/** The brand a row is sold under: its `brand`, else a known brand its title opens with. */\nexport function productBrandMatches(product: Product, brand: string): boolean {\n const want = normalize(brand);\n if (!want) return false;\n if (product.brand) return normalize(product.brand) === want;\n return ` ${normalize(product.name)} `.startsWith(` ${want} `);\n}\n\n/** Every text a row states its attributes in: its title, and its variants' labels and attributes. */\nfunction attributeTexts(product: Product): string[] {\n return [product.name, ...(product.variants ?? []).flatMap((v) => [v.label, ...Object.values(v.attributes)])];\n}\n\n/** Does the row offer this value of an attribute (\"color\" = \"black truffle\")? */\nexport function productHasAttribute(product: Product, name: string, value: string): boolean {\n const key = name.toLowerCase();\n // Structured first: a variant that names the dimension.\n for (const variant of product.variants ?? []) {\n const stated = variantAttribute(variant, key);\n if (stated && normalize(stated) === normalize(value)) return true;\n }\n if (derivedAttribute(product, key) === normalize(value)) return true;\n return attributeTexts(product).some((text) => hasPhrase(text, value));\n}\n\nfunction matches(product: Product, filters: ProductFilters): boolean {\n if (filters.sources.length > 0) {\n const source = product.source ?? 'yantra';\n if (!filters.sources.includes(source)) return false;\n }\n // Unpriced rows cannot satisfy a ceiling — see the module note.\n if (filters.maxPrice !== null && !(product.price > 0 && product.price <= filters.maxPrice)) return false;\n if (filters.minRating !== null && !(product.rating >= filters.minRating)) return false;\n if (filters.minDiscount !== null && effectiveDiscountPercent(product) < filters.minDiscount) return false;\n // Explicit `false` only — undefined means \"this lane does not report stock\".\n if (filters.inStockOnly && product.inStock === false) return false;\n if (filters.brands?.length && !filters.brands.some((brand) => productBrandMatches(product, brand))) return false;\n for (const [name, values] of Object.entries(filters.attributes ?? {})) {\n if (values.length > 0 && !values.some((value) => productHasAttribute(product, name, value))) return false;\n }\n if (filters.primeOnly && product.isPrime !== true) return false;\n // A row that names no date cannot be claimed to arrive by one.\n if (filters.arrivesBy && !(product.deliveryDate && product.deliveryDate <= filters.arrivesBy)) return false;\n return true;\n}\n\n/**\n * Sort comparator. `relevance` keeps the incoming order, which is already\n * meaningful: the search lanes merge sources in a deliberate order (typed\n * catalog rows first), and re-sorting by a scraped field would discard that.\n */\nfunction compare(a: Product, b: Product, sort: ProductSortOrder): number {\n switch (sort) {\n case 'price-asc':\n // Unpriced rows sink rather than sorting as free.\n return (a.price > 0 ? a.price : Infinity) - (b.price > 0 ? b.price : Infinity);\n case 'price-desc':\n return (b.price > 0 ? b.price : -Infinity) - (a.price > 0 ? a.price : -Infinity);\n case 'rating':\n // Ties broken by review count: 5.0 from two reviewers is not 4.7 from ten thousand.\n return b.rating - a.rating || b.reviews - a.reviews;\n case 'discount':\n return effectiveDiscountPercent(b) - effectiveDiscountPercent(a);\n case 'relevance':\n default:\n return 0;\n }\n}\n\nexport function applyProductFilters(products: Product[], filters: ProductFilters): Product[] {\n const kept = products.filter((product) => matches(product, filters));\n if (filters.sort === 'relevance') return kept;\n // Copy first: the caller's array is state elsewhere, and `sort` mutates.\n return [...kept].sort((a, b) => compare(a, b, filters.sort));\n}\n\nexport interface ProductFacets {\n /** Lanes actually present in these rows, in the order the rows arrived. */\n sources: ProductSource[];\n /** Highest priced row, so a price slider can bound itself to real data. */\n maxPrice: number;\n /** True when at least one row carries a real discount worth offering a chip for. */\n hasDiscounts: boolean;\n /** True when at least one row is rated, so the rating chips are not dead controls. */\n hasRatings: boolean;\n}\n\n/**\n * What the rows on screen can actually be filtered BY.\n *\n * Chips are built from this rather than from the full source list, so the bar\n * never offers \"Costco\" to a result set with no Costco rows — selecting it\n * would blank the grid and read as a broken filter.\n */\nexport function productFacets(products: Product[]): ProductFacets {\n const sources: ProductSource[] = [];\n let maxPrice = 0;\n let hasDiscounts = false;\n let hasRatings = false;\n for (const product of products) {\n const source = product.source ?? 'yantra';\n if (!sources.includes(source)) sources.push(source);\n if (product.price > maxPrice) maxPrice = product.price;\n if (effectiveDiscountPercent(product) > 0) hasDiscounts = true;\n if (product.rating > 0) hasRatings = true;\n }\n return { sources, maxPrice, hasDiscounts, hasRatings };\n}\n\n// ─── Result refinements: brand, attributes, delivery ─────────────────────────\n\n/** One chip a refinement group offers, with how many rows it would leave. */\nexport interface FacetOption {\n /** What the filter stores (lower-case). */\n value: string;\n /** What the chip says. */\n label: string;\n /** Rows on screen this chip would keep, given every OTHER active filter. */\n count: number;\n}\n\nexport interface RefinementGroup {\n /** Lower-case attribute name (\"color\", \"capacity\"). */\n name: string;\n /** As the store titles it (\"Color\"). */\n label: string;\n options: FacetOption[];\n}\n\nexport interface RefinementFacets {\n brands: FacetOption[];\n attributes: RefinementGroup[];\n /** Rows that would remain with \"Prime\" on; absent when the chip would not narrow. */\n prime?: number;\n /** \"Arrives by\" dates (ISO) and how many rows each keeps. */\n arrivesBy: FacetOption[];\n}\n\n/** Refinement names that are not a product attribute this page can read off a row (it has its own chips for them). */\nconst NOT_ATTRIBUTE =\n /brand|price|review|rating|deliver|shipping|ship|department|categor|seller|condition|availab|deal|discount|prime|climate|new arrival|subscribe|international|from our brands|eligible/i;\n\n/** Capacity / size stated in a title: \"64GB\", \"12 Cup\", \"1.8 L\", \"32 oz\", \"15.6 inch\". */\nconst MEASURE =\n /(?:^|\\s)(\\d+(?:\\.\\d+)?)\\s*-?\\s*(gb|tb|cups?|qt|quarts?|oz|fl oz|ounces?|l|liters?|litres?|ml|inch|inches|in|gal|gallons?|lbs?|bars?|watts?|w)(?=\\s|$)/i;\n\nconst UNIT_NAMES: Record<string, string> = {\n gb: 'GB',\n tb: 'TB',\n cup: 'Cup',\n cups: 'Cup',\n qt: 'qt',\n quart: 'qt',\n quarts: 'qt',\n oz: 'oz',\n 'fl oz': 'fl oz',\n ounce: 'oz',\n ounces: 'oz',\n l: 'L',\n liter: 'L',\n liters: 'L',\n litre: 'L',\n litres: 'L',\n ml: 'ml',\n inch: 'inch',\n inches: 'inch',\n in: 'inch',\n gal: 'gal',\n gallon: 'gal',\n gallons: 'gal',\n lb: 'lb',\n lbs: 'lb',\n bar: 'bar',\n bars: 'bar',\n watt: 'W',\n watts: 'W',\n w: 'W',\n};\n\n/** A capacity the title states, as a chip label (\"12 Cup\"), or undefined. */\nfunction titleMeasure(product: Product): string | undefined {\n const match = normalize(product.name).match(MEASURE);\n if (!match) return undefined;\n const unit = UNIT_NAMES[match[2].toLowerCase()] ?? match[2];\n return `${match[1]} ${unit}`;\n}\n\n/** An attribute the surface reads off a row itself: colour / size from its title's variant part, capacity from its title. */\nfunction derivedAttribute(product: Product, name: string): string | undefined {\n if (name === 'capacity') {\n const measure = titleMeasure(product);\n return measure ? normalize(measure) : undefined;\n }\n if (name === 'color' || name === 'size') {\n const value = splitTitleVariant(product.name).attributes[name];\n return value ? normalize(value) : undefined;\n }\n return undefined;\n}\n\nfunction countWith(products: readonly Product[], filters: ProductFilters): number {\n return products.reduce((n, product) => n + (matches(product, filters) ? 1 : 0), 0);\n}\n\n/** Options that keep at least one row; a chip that would blank the grid is never offered (unless it is on). */\nfunction keepLive(options: FacetOption[], selected: readonly string[]): FacetOption[] {\n return options.filter((o) => o.count > 0 || selected.includes(o.value));\n}\n\n/** Title-case a lower-case attribute name for its group label. */\nfunction titleCase(text: string): string {\n return text.replace(/\\b\\w/g, (c) => c.toUpperCase());\n}\n\n/**\n * The brand, attribute and delivery chips for these rows.\n *\n * Brand comes from the store's own refinement column when it sent one, else\n * from the rows' `brand`. Attributes come from the store's column (Color,\n * Capacity, ...), else from what the rows state reliably: their variants'\n * colours and sizes, and a capacity written as a number and a unit. Delivery\n * offers Prime and \"arrives by\" dates the rows actually name.\n *\n * Every count is what the chip would leave GIVEN the other active filters, and\n * a chip that would leave nothing is not offered - productFacets' rule, applied\n * across groups. A group with fewer than two live chips is dropped: one chip\n * that keeps everything narrows nothing.\n */\nexport function refinementFacets(\n products: readonly Product[],\n filters: ProductFilters,\n storeFacets: readonly SearchFacet[] = [],\n): RefinementFacets {\n const brandsSelected = filters.brands ?? [];\n const otherThanBrand: ProductFilters = { ...filters, brands: [] };\n const brandRows = products.filter((p) => matches(p, otherThanBrand));\n\n // ── Brand ──\n const storeBrands = storeFacets.find((f) => /^brands?$/i.test(f.name.trim()));\n const brandLabels: string[] = storeBrands\n ? storeBrands.values.map((v) => v.label)\n : products.map((p) => p.brand?.trim()).filter((b): b is string => Boolean(b));\n const brandOptions: FacetOption[] = [];\n for (const label of brandLabels) {\n const value = normalize(label);\n if (!value || brandOptions.some((o) => o.value === value)) continue;\n // Offered only when it names rows on screen at all - the store's column lists brands from every page.\n if (!products.some((p) => productBrandMatches(p, label))) continue;\n brandOptions.push({ value, label, count: brandRows.filter((p) => productBrandMatches(p, label)).length });\n }\n const brands = keepLive(brandOptions, brandsSelected);\n\n // ── Attributes ──\n const groups: RefinementGroup[] = [];\n const addGroup = (name: string, label: string, values: string[]) => {\n const key = name.toLowerCase();\n if (groups.some((g) => g.name === key)) return;\n const selected = filters.attributes?.[key] ?? [];\n const others: ProductFilters = { ...filters, attributes: { ...filters.attributes, [key]: [] } };\n const rows = products.filter((p) => matches(p, others));\n const options: FacetOption[] = [];\n for (const raw of values) {\n const value = normalize(raw);\n if (!value || options.some((o) => o.value === value)) continue;\n if (!products.some((p) => productHasAttribute(p, key, raw))) continue;\n options.push({ value, label: raw, count: rows.filter((p) => productHasAttribute(p, key, raw)).length });\n }\n const live = keepLive(options, selected);\n if (live.length >= 2 || selected.length > 0) groups.push({ name: key, label, options: live });\n };\n for (const facet of storeFacets) {\n if (NOT_ATTRIBUTE.test(facet.name)) continue;\n addGroup(\n facet.name,\n facet.name,\n facet.values.map((v) => v.label),\n );\n }\n // Derived, only where the store sent no column of its own for that attribute.\n const variantValues = (dimension: string) =>\n products.flatMap((p) =>\n [\n ...(p.variants ?? []).map((v) => variantAttribute(v, dimension)),\n splitTitleVariant(p.name).attributes[dimension],\n ].filter((v): v is string => Boolean(v)),\n );\n addGroup('color', 'Color', variantValues('color'));\n addGroup('size', 'Size', variantValues('size'));\n // A capacity is \"reliable\" when most rows state one; a stray \"2 Pack\" in one title is not a dimension.\n const measured = products.map(titleMeasure).filter((m): m is string => Boolean(m));\n if (measured.length >= Math.max(2, Math.ceil(products.length / 2))) addGroup('capacity', 'Capacity', measured);\n\n // ── Delivery ──\n const otherThanPrime: ProductFilters = { ...filters, primeOnly: false };\n const primeCount = countWith(products, { ...otherThanPrime, primeOnly: true });\n const primeBase = countWith(products, otherThanPrime);\n const prime = filters.primeOnly || (primeCount > 0 && primeCount < primeBase) ? primeCount : undefined;\n\n const otherThanDate: ProductFilters = { ...filters, arrivesBy: null };\n const dateBase = countWith(products, otherThanDate);\n const dates = [...new Set(products.map((p) => p.deliveryDate).filter((d): d is string => Boolean(d)))].sort();\n const arrivesBy = keepLive(\n dates.slice(0, 3).map((date) => ({\n value: date,\n label: date,\n count: countWith(products, { ...otherThanDate, arrivesBy: date }),\n })),\n filters.arrivesBy ? [filters.arrivesBy] : [],\n ).filter((o) => o.count < dateBase || o.value === filters.arrivesBy);\n\n return {\n brands: brands.length >= 2 || brandsSelected.length > 0 ? brands : [],\n attributes: groups,\n prime,\n arrivesBy,\n };\n}\n\n/** Toggle one value of a multi-select refinement. */\nexport function toggleValue(list: readonly string[] | undefined, value: string): string[] {\n const current = list ?? [];\n return current.includes(value) ? current.filter((v) => v !== value) : [...current, value];\n}\n\nexport { titleCase as refinementLabel };\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDO,MAAM,uBAA0C,GAAA;AAAA,EACrD,QAAU,EAAA,IAAA;AAAA,EACV,SAAW,EAAA,IAAA;AAAA,EACX,WAAa,EAAA,IAAA;AAAA,EACb,WAAa,EAAA,KAAA;AAAA,EACb,SAAS,EAAC;AAAA,EACV,IAAM,EAAA;AACR;AACA,SAAS,wBAAwB,OAAiC,EAAA;AAzDlE,EAAA,IAAA,EAAA;AA0DE,EAAA,OAAO,MAAO,CAAA,MAAA,CAAA,CAAO,EAAQ,GAAA,OAAA,CAAA,UAAA,KAAR,YAAsB,EAAE,CAAE,CAAA,MAAA,CAAO,CAAC,CAAG,EAAA,MAAA,KAAW,CAAI,GAAA,MAAA,CAAO,QAAQ,CAAC,CAAA;AAC3F;AAGO,SAAS,iBAAiB,OAAkC,EAAA;AACjE,EAAO,OAAA,iBAAA,CAAkB,OAAO,CAAI,GAAA,CAAA;AACtC;AAGO,SAAS,kBAAkB,OAAiC,EAAA;AAnEnE,EAAA,IAAA,EAAA,EAAA,EAAA;AAoEE,EAAA,OAAA,CAAQ,QAAQ,QAAa,KAAA,IAAA,GAAO,CAAI,GAAA,CAAA,KAAM,QAAQ,SAAc,KA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AS,KAAK,CAAA,GAAI,OAAQ,CAAA,MAAA,CAAO,CAAK,CAAA,KAAA,CAAA,KAAM,KAAK,CAAA,GAAI,CAAC,GAAG,SAAS,KAAK,CAAA;AACxF"}
1
+ {"version":3,"file":"productFilters.js","sources":["../../../../src/features/shopping/services/productFilters.ts"],"sourcesContent":["/**\n * The filter model shared by the landing page's trending rails and the search\n * results grid.\n *\n * Pure functions over `Product[]` — no fetching. Every lane (catalog, the\n * retailer SERPs, the paired browser) returns the same {@link Product}, so one\n * filter pass serves all of them, and the same chips mean the same thing\n * whether the user is browsing trending rows or reading search results.\n *\n * Two rules exist because a shopping row is routinely PARTIAL, and \"the field\n * is missing\" must never be read as \"the field is false\":\n *\n * - `inStockOnly` drops only rows that say `inStock === false`. Only the typed\n * catalog knows stock; a SERP scrape leaves it undefined, so treating\n * undefined as out-of-stock would empty the grid on every non-catalog lane.\n * - `maxPrice` DOES drop rows with no usable price (a row that only says \"see\n * price on Amazon\"). A ceiling is a claim about what the shopper will pay,\n * and a row we cannot price cannot be claimed to satisfy it.\n */\n\nimport type { Product, ProductSource } from '../catalog';\nimport type { SearchFacet } from './searchCardFields';\nimport { splitTitleVariant, variantAttribute } from './variantCards';\n\nexport type ProductSortOrder = 'relevance' | 'price-asc' | 'price-desc' | 'rating' | 'discount';\n\nexport interface ProductFilters {\n /** Price ceiling in the row's own currency units. `null` = no ceiling. */\n maxPrice: number | null;\n /** Minimum star rating, 0–5. `null` = unrated rows welcome. */\n minRating: number | null;\n /** Minimum discount percent off list price. `null` = full-price rows welcome. */\n minDiscount: number | null;\n /** Hide rows the catalog reports as out of stock. */\n inStockOnly: boolean;\n /** Retailer lanes to keep. Empty = every lane. */\n sources: ProductSource[];\n sort: ProductSortOrder;\n // ─── Result refinements (brand, attributes, delivery) ───\n // Optional so a filter object written before they existed still reads as\n // \"not narrowing\". They describe ONE result set, so a new search resets\n // them (see {@link withoutRefinements}).\n /** Brands to keep, lower-case. Empty = every brand. */\n brands?: string[];\n /** Attribute name (lower-case, \"color\") -> values to keep (lower-case). OR within, AND across. */\n attributes?: Record<string, string[]>;\n /** Only rows the store marks Prime. */\n primeOnly?: boolean;\n /** Only rows whose stated delivery date is on or before this ISO date. */\n arrivesBy?: string | null;\n}\n\nexport const DEFAULT_PRODUCT_FILTERS: ProductFilters = {\n maxPrice: null,\n minRating: null,\n minDiscount: null,\n inStockOnly: false,\n sources: [],\n sort: 'relevance',\n};\n\nfunction attributeSelectionCount(filters: ProductFilters): number {\n return Object.values(filters.attributes ?? {}).reduce((n, values) => n + values.length, 0);\n}\n\n/** Is anything actually narrowing the rows? (Sort alone is not a filter.) */\nexport function hasActiveFilters(filters: ProductFilters): boolean {\n return activeFilterCount(filters) > 0;\n}\n\n/** How many chips are narrowing — the count on the \"Filters\" button. */\nexport function activeFilterCount(filters: ProductFilters): number {\n return (\n (filters.maxPrice !== null ? 1 : 0) +\n (filters.minRating !== null ? 1 : 0) +\n (filters.minDiscount !== null ? 1 : 0) +\n (filters.inStockOnly ? 1 : 0) +\n filters.sources.length +\n (filters.brands?.length ?? 0) +\n attributeSelectionCount(filters) +\n (filters.primeOnly ? 1 : 0) +\n (filters.arrivesBy ? 1 : 0)\n );\n}\n\n/**\n * The filters with this result set's own refinements (brand, attributes,\n * delivery) dropped and the general ones (price, rating, deal, store, sort)\n * kept. A brand picked for \"espresso machine\" means nothing for \"toaster\", and\n * carried over it would blank the next grid.\n */\nexport function withoutRefinements(filters: ProductFilters): ProductFilters {\n const { brands: _b, attributes: _a, primeOnly: _p, arrivesBy: _d, ...general } = filters;\n return general;\n}\n\n/**\n * The discount a card can honestly claim: a percent is only real when there is\n * a list price ABOVE the current one to discount from. Mirrors the same\n * reconciliation ProductRow does before it paints a badge, so the chip can\n * never select rows whose card shows no discount.\n */\nexport function effectiveDiscountPercent(product: Product): number {\n if (!(product.price > 0)) return 0;\n const original = product.originalPrice;\n if (typeof original !== 'number' || !(original > product.price)) return 0;\n return Math.round(((original - product.price) / original) * 100);\n}\n\nconst normalize = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9.]+/g, ' ')\n .trim();\n\n/** Does `text` contain `phrase` as whole words? */\nfunction hasPhrase(text: string, phrase: string): boolean {\n const want = normalize(phrase);\n return want.length > 0 && ` ${normalize(text)} `.includes(` ${want} `);\n}\n\n/** The brand a row is sold under: its `brand`, else a known brand its title opens with. */\nexport function productBrandMatches(product: Product, brand: string): boolean {\n const want = normalize(brand);\n if (!want) return false;\n if (product.brand) return normalize(product.brand) === want;\n return ` ${normalize(product.name)} `.startsWith(` ${want} `);\n}\n\n/** Every text a row states its attributes in: its title, and its variants' labels and attributes. */\nfunction attributeTexts(product: Product): string[] {\n return [product.name, ...(product.variants ?? []).flatMap((v) => [v.label, ...Object.values(v.attributes)])];\n}\n\n/** Does the row offer this value of an attribute (\"color\" = \"black truffle\")? */\nexport function productHasAttribute(product: Product, name: string, value: string): boolean {\n const key = name.toLowerCase();\n // Structured first: a variant that names the dimension.\n for (const variant of product.variants ?? []) {\n const stated = variantAttribute(variant, key);\n if (stated && normalize(stated) === normalize(value)) return true;\n }\n if (derivedAttribute(product, key) === normalize(value)) return true;\n return attributeTexts(product).some((text) => hasPhrase(text, value));\n}\n\nfunction matches(product: Product, filters: ProductFilters): boolean {\n if (filters.sources.length > 0) {\n const source = product.source ?? 'yantra';\n if (!filters.sources.includes(source)) return false;\n }\n // Unpriced rows cannot satisfy a ceiling — see the module note.\n if (filters.maxPrice !== null && !(product.price > 0 && product.price <= filters.maxPrice)) return false;\n if (filters.minRating !== null && !(product.rating >= filters.minRating)) return false;\n if (filters.minDiscount !== null && effectiveDiscountPercent(product) < filters.minDiscount) return false;\n // Explicit `false` only — undefined means \"this lane does not report stock\".\n if (filters.inStockOnly && product.inStock === false) return false;\n if (filters.brands?.length && !filters.brands.some((brand) => productBrandMatches(product, brand))) return false;\n for (const [name, values] of Object.entries(filters.attributes ?? {})) {\n if (values.length > 0 && !values.some((value) => productHasAttribute(product, name, value))) return false;\n }\n if (filters.primeOnly && product.isPrime !== true) return false;\n // A row that names no date cannot be claimed to arrive by one.\n if (filters.arrivesBy && !(product.deliveryDate && product.deliveryDate <= filters.arrivesBy)) return false;\n return true;\n}\n\n/**\n * Sort comparator. `relevance` keeps the incoming order, which is already\n * meaningful: the search lanes merge sources in a deliberate order (typed\n * catalog rows first), and re-sorting by a scraped field would discard that.\n */\nfunction compare(a: Product, b: Product, sort: ProductSortOrder): number {\n switch (sort) {\n case 'price-asc':\n // Unpriced rows sink rather than sorting as free.\n return (a.price > 0 ? a.price : Infinity) - (b.price > 0 ? b.price : Infinity);\n case 'price-desc':\n return (b.price > 0 ? b.price : -Infinity) - (a.price > 0 ? a.price : -Infinity);\n case 'rating':\n // Ties broken by review count: 5.0 from two reviewers is not 4.7 from ten thousand.\n return b.rating - a.rating || b.reviews - a.reviews;\n case 'discount':\n return effectiveDiscountPercent(b) - effectiveDiscountPercent(a);\n case 'relevance':\n default:\n return 0;\n }\n}\n\nexport function applyProductFilters(products: Product[], filters: ProductFilters): Product[] {\n const kept = products.filter((product) => matches(product, filters));\n // Copy first: the caller's array is state elsewhere, and `sort` mutates.\n const ordered = filters.sort === 'relevance' ? kept : [...kept].sort((a, b) => compare(a, b, filters.sort));\n // What the store marks out of stock goes after everything that can be bought, whatever the sort -\n // the way the stores' own results list it - and however late either row arrived.\n return [\n ...ordered.filter((product) => product.inStock !== false),\n ...ordered.filter((product) => product.inStock === false),\n ];\n}\n\nexport interface ProductFacets {\n /** Lanes actually present in these rows, in the order the rows arrived. */\n sources: ProductSource[];\n /** Highest priced row, so a price slider can bound itself to real data. */\n maxPrice: number;\n /** True when at least one row carries a real discount worth offering a chip for. */\n hasDiscounts: boolean;\n /** True when at least one row is rated, so the rating chips are not dead controls. */\n hasRatings: boolean;\n}\n\n/**\n * What the rows on screen can actually be filtered BY.\n *\n * Chips are built from this rather than from the full source list, so the bar\n * never offers \"Costco\" to a result set with no Costco rows — selecting it\n * would blank the grid and read as a broken filter.\n */\nexport function productFacets(products: Product[]): ProductFacets {\n const sources: ProductSource[] = [];\n let maxPrice = 0;\n let hasDiscounts = false;\n let hasRatings = false;\n for (const product of products) {\n const source = product.source ?? 'yantra';\n if (!sources.includes(source)) sources.push(source);\n if (product.price > maxPrice) maxPrice = product.price;\n if (effectiveDiscountPercent(product) > 0) hasDiscounts = true;\n if (product.rating > 0) hasRatings = true;\n }\n return { sources, maxPrice, hasDiscounts, hasRatings };\n}\n\n// ─── Result refinements: brand, attributes, delivery ─────────────────────────\n\n/** One chip a refinement group offers, with how many rows it would leave. */\nexport interface FacetOption {\n /** What the filter stores (lower-case). */\n value: string;\n /** What the chip says. */\n label: string;\n /** Rows on screen this chip would keep, given every OTHER active filter. */\n count: number;\n}\n\nexport interface RefinementGroup {\n /** Lower-case attribute name (\"color\", \"capacity\"). */\n name: string;\n /** As the store titles it (\"Color\"). */\n label: string;\n options: FacetOption[];\n}\n\nexport interface RefinementFacets {\n brands: FacetOption[];\n attributes: RefinementGroup[];\n /** Rows that would remain with \"Prime\" on; absent when the chip would not narrow. */\n prime?: number;\n /** \"Arrives by\" dates (ISO) and how many rows each keeps. */\n arrivesBy: FacetOption[];\n}\n\n/** Refinement names that are not a product attribute this page can read off a row (it has its own chips for them). */\nconst NOT_ATTRIBUTE =\n /brand|price|review|rating|deliver|shipping|ship|department|categor|seller|condition|availab|deal|discount|prime|climate|new arrival|subscribe|international|from our brands|eligible/i;\n\n/** Capacity / size stated in a title: \"64GB\", \"12 Cup\", \"1.8 L\", \"32 oz\", \"15.6 inch\". */\nconst MEASURE =\n /(?:^|\\s)(\\d+(?:\\.\\d+)?)\\s*-?\\s*(gb|tb|cups?|qt|quarts?|oz|fl oz|ounces?|l|liters?|litres?|ml|inch|inches|in|gal|gallons?|lbs?|bars?|watts?|w)(?=\\s|$)/i;\n\nconst UNIT_NAMES: Record<string, string> = {\n gb: 'GB',\n tb: 'TB',\n cup: 'Cup',\n cups: 'Cup',\n qt: 'qt',\n quart: 'qt',\n quarts: 'qt',\n oz: 'oz',\n 'fl oz': 'fl oz',\n ounce: 'oz',\n ounces: 'oz',\n l: 'L',\n liter: 'L',\n liters: 'L',\n litre: 'L',\n litres: 'L',\n ml: 'ml',\n inch: 'inch',\n inches: 'inch',\n in: 'inch',\n gal: 'gal',\n gallon: 'gal',\n gallons: 'gal',\n lb: 'lb',\n lbs: 'lb',\n bar: 'bar',\n bars: 'bar',\n watt: 'W',\n watts: 'W',\n w: 'W',\n};\n\n/** A capacity the title states, as a chip label (\"12 Cup\"), or undefined. */\nfunction titleMeasure(product: Product): string | undefined {\n const match = normalize(product.name).match(MEASURE);\n if (!match) return undefined;\n const unit = UNIT_NAMES[match[2].toLowerCase()] ?? match[2];\n return `${match[1]} ${unit}`;\n}\n\n/** An attribute the surface reads off a row itself: colour / size from its title's variant part, capacity from its title. */\nfunction derivedAttribute(product: Product, name: string): string | undefined {\n if (name === 'capacity') {\n const measure = titleMeasure(product);\n return measure ? normalize(measure) : undefined;\n }\n if (name === 'color' || name === 'size') {\n const value = splitTitleVariant(product.name).attributes[name];\n return value ? normalize(value) : undefined;\n }\n return undefined;\n}\n\nfunction countWith(products: readonly Product[], filters: ProductFilters): number {\n return products.reduce((n, product) => n + (matches(product, filters) ? 1 : 0), 0);\n}\n\n/** Options that keep at least one row; a chip that would blank the grid is never offered (unless it is on). */\nfunction keepLive(options: FacetOption[], selected: readonly string[]): FacetOption[] {\n return options.filter((o) => o.count > 0 || selected.includes(o.value));\n}\n\n/** Title-case a lower-case attribute name for its group label. */\nfunction titleCase(text: string): string {\n return text.replace(/\\b\\w/g, (c) => c.toUpperCase());\n}\n\n/**\n * The brand, attribute and delivery chips for these rows.\n *\n * Brand comes from the store's own refinement column when it sent one, else\n * from the rows' `brand`. Attributes come from the store's column (Color,\n * Capacity, ...), else from what the rows state reliably: their variants'\n * colours and sizes, and a capacity written as a number and a unit. Delivery\n * offers Prime and \"arrives by\" dates the rows actually name.\n *\n * Every count is what the chip would leave GIVEN the other active filters, and\n * a chip that would leave nothing is not offered - productFacets' rule, applied\n * across groups. A group with fewer than two live chips is dropped: one chip\n * that keeps everything narrows nothing.\n */\nexport function refinementFacets(\n products: readonly Product[],\n filters: ProductFilters,\n storeFacets: readonly SearchFacet[] = [],\n): RefinementFacets {\n const brandsSelected = filters.brands ?? [];\n const otherThanBrand: ProductFilters = { ...filters, brands: [] };\n const brandRows = products.filter((p) => matches(p, otherThanBrand));\n\n // ── Brand ──\n const storeBrands = storeFacets.find((f) => /^brands?$/i.test(f.name.trim()));\n const brandLabels: string[] = storeBrands\n ? storeBrands.values.map((v) => v.label)\n : products.map((p) => p.brand?.trim()).filter((b): b is string => Boolean(b));\n const brandOptions: FacetOption[] = [];\n for (const label of brandLabels) {\n const value = normalize(label);\n if (!value || brandOptions.some((o) => o.value === value)) continue;\n // Offered only when it names rows on screen at all - the store's column lists brands from every page.\n if (!products.some((p) => productBrandMatches(p, label))) continue;\n brandOptions.push({ value, label, count: brandRows.filter((p) => productBrandMatches(p, label)).length });\n }\n const brands = keepLive(brandOptions, brandsSelected);\n\n // ── Attributes ──\n const groups: RefinementGroup[] = [];\n const addGroup = (name: string, label: string, values: string[]) => {\n const key = name.toLowerCase();\n if (groups.some((g) => g.name === key)) return;\n const selected = filters.attributes?.[key] ?? [];\n const others: ProductFilters = { ...filters, attributes: { ...filters.attributes, [key]: [] } };\n const rows = products.filter((p) => matches(p, others));\n const options: FacetOption[] = [];\n for (const raw of values) {\n const value = normalize(raw);\n if (!value || options.some((o) => o.value === value)) continue;\n if (!products.some((p) => productHasAttribute(p, key, raw))) continue;\n options.push({ value, label: raw, count: rows.filter((p) => productHasAttribute(p, key, raw)).length });\n }\n const live = keepLive(options, selected);\n if (live.length >= 2 || selected.length > 0) groups.push({ name: key, label, options: live });\n };\n for (const facet of storeFacets) {\n if (NOT_ATTRIBUTE.test(facet.name)) continue;\n addGroup(\n facet.name,\n facet.name,\n facet.values.map((v) => v.label),\n );\n }\n // Derived, only where the store sent no column of its own for that attribute.\n const variantValues = (dimension: string) =>\n products.flatMap((p) =>\n [\n ...(p.variants ?? []).map((v) => variantAttribute(v, dimension)),\n splitTitleVariant(p.name).attributes[dimension],\n ].filter((v): v is string => Boolean(v)),\n );\n addGroup('color', 'Color', variantValues('color'));\n addGroup('size', 'Size', variantValues('size'));\n // A capacity is \"reliable\" when most rows state one; a stray \"2 Pack\" in one title is not a dimension.\n const measured = products.map(titleMeasure).filter((m): m is string => Boolean(m));\n if (measured.length >= Math.max(2, Math.ceil(products.length / 2))) addGroup('capacity', 'Capacity', measured);\n\n // ── Delivery ──\n const otherThanPrime: ProductFilters = { ...filters, primeOnly: false };\n const primeCount = countWith(products, { ...otherThanPrime, primeOnly: true });\n const primeBase = countWith(products, otherThanPrime);\n const prime = filters.primeOnly || (primeCount > 0 && primeCount < primeBase) ? primeCount : undefined;\n\n const otherThanDate: ProductFilters = { ...filters, arrivesBy: null };\n const dateBase = countWith(products, otherThanDate);\n const dates = [...new Set(products.map((p) => p.deliveryDate).filter((d): d is string => Boolean(d)))].sort();\n const arrivesBy = keepLive(\n dates.slice(0, 3).map((date) => ({\n value: date,\n label: date,\n count: countWith(products, { ...otherThanDate, arrivesBy: date }),\n })),\n filters.arrivesBy ? [filters.arrivesBy] : [],\n ).filter((o) => o.count < dateBase || o.value === filters.arrivesBy);\n\n return {\n brands: brands.length >= 2 || brandsSelected.length > 0 ? brands : [],\n attributes: groups,\n prime,\n arrivesBy,\n };\n}\n\n/** Toggle one value of a multi-select refinement. */\nexport function toggleValue(list: readonly string[] | undefined, value: string): string[] {\n const current = list ?? [];\n return current.includes(value) ? current.filter((v) => v !== value) : [...current, value];\n}\n\nexport { titleCase as refinementLabel };\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDO,MAAM,uBAA0C,GAAA;AAAA,EACrD,QAAU,EAAA,IAAA;AAAA,EACV,SAAW,EAAA,IAAA;AAAA,EACX,WAAa,EAAA,IAAA;AAAA,EACb,WAAa,EAAA,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CAAC,CAAA,CAAE,IAAI,CAAS,IAAA,MAAA;AAAA,IACxD,KAAO,EAAA,IAAA;AAAA,IACP,KAAO,EAAA,IAAA;AAAA,IACP,KAAO,EAAA,SAAA,CAAU,QAAU,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACtB,aADsB,CAAA,EAAA;AAAA,MAEzB,SAAW,EAAA;AAAA,KACZ,CAAA;AAAA,IACD,CAAG,EAAA,OAAA,CAAQ,YAAY,CAAC,OAAA,CAAQ,SAAS,CAAI,GAAA,EAAE,CAAE,CAAA,MAAA,CAAO,OAAK,CAAE,CAAA,KAAA,GAAQ,YAAY,CAAE,CAAA,KAAA,KAAU,QAAQ,SAAS,CAAA;AAClH,EAAO,OAAA;AAAA,IACL,MAAA,EAAQ,OAAO,MAAU,IAAA,CAAA,IAAK,eAAe,MAAS,GAAA,CAAA,GAAI,SAAS,EAAC;AAAA,IACpE,UAAY,EAAA,MAAA;AAAA,IACZ,KAAA;AAAA,IACA;AAAA,GACF;AACF;AAGgB,SAAA,WAAA,CAAY,MAAqC,KAAyB,EAAA;AACxF,EAAM,MAAA,OAAA,GAAU,sBAAQ,EAAC;AACzB,EAAA,OAAO,OAAQ,CAAA,QAAA,CAAS,KAAK,CAAA,GAAI,OAAQ,CAAA,MAAA,CAAO,CAAK,CAAA,KAAA,CAAA,KAAM,KAAK,CAAA,GAAI,CAAC,GAAG,SAAS,KAAK,CAAA;AACxF"}
@@ -1,4 +1,4 @@
1
- import {invokeShoppingSearchConnector,SHOPPING_SEARCH_ACTIONS}from'./shoppingSearchConnectorClient.js';var __defProp = Object.defineProperty;
1
+ import {playableVideos,httpsImages}from'./mediaShape.js';import {invokeShoppingSearchConnector,SHOPPING_SEARCH_ACTIONS}from'./shoppingSearchConnectorClient.js';import {loadStoredGallery,saveStoredGallery}from'./storedGalleries.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -23,6 +23,67 @@ const BATCH_WINDOW_MS = 120;
23
23
  const cache = /* @__PURE__ */ new Map();
24
24
  const inflight = /* @__PURE__ */ new Map();
25
25
  const listeners = /* @__PURE__ */ new Map();
26
+ const ID_PATTERN = {
27
+ amazon: /^[A-Z0-9]{10}$/,
28
+ walmart: /^[0-9]{5,15}$/,
29
+ ebay: /^[0-9]{9,15}$/,
30
+ target: /^[0-9]{6,12}$/
31
+ };
32
+ function isGalleryId(store, id) {
33
+ return ID_PATTERN[store].test(id);
34
+ }
35
+ function galleryTarget(product) {
36
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
37
+ const asin = (_a = product.asin) == null ? void 0 : _a.trim().toUpperCase();
38
+ if (asin && isGalleryId("amazon", asin)) return {
39
+ store: "amazon",
40
+ id: asin
41
+ };
42
+ const sku = (_c = (_b = product.sku) == null ? void 0 : _b.trim()) != null ? _c : "";
43
+ if (/^walmart$/i.test((_e = (_d = product.retailerId) == null ? void 0 : _d.trim()) != null ? _e : "") && isGalleryId("walmart", sku)) {
44
+ return {
45
+ store: "walmart",
46
+ id: sku
47
+ };
48
+ }
49
+ let url;
50
+ try {
51
+ url = new URL((_g = (_f = product.url) == null ? void 0 : _f.trim()) != null ? _g : "");
52
+ } catch (e) {
53
+ return null;
54
+ }
55
+ const host = url.hostname.toLowerCase();
56
+ const path = url.pathname;
57
+ if (/(^|\.)amazon\.com$/.test(host)) {
58
+ const id = (_i = (_h = path.match(/\/(?:dp|gp\/product)\/([A-Z0-9]{10})(?:[/?]|$)/i)) == null ? void 0 : _h[1]) == null ? void 0 : _i.toUpperCase();
59
+ return id ? {
60
+ store: "amazon",
61
+ id
62
+ } : null;
63
+ }
64
+ if (/(^|\.)walmart\.com$/.test(host)) {
65
+ const id = (_j = path.match(/^\/ip\/(?:[^/]+\/)?(\d{5,15})\/?$/)) == null ? void 0 : _j[1];
66
+ return id ? {
67
+ store: "walmart",
68
+ id
69
+ } : null;
70
+ }
71
+ if (/(^|\.)ebay\.com$/.test(host)) {
72
+ const id = (_k = path.match(/^\/itm\/(?:[^/]+\/)?(\d{9,15})\/?$/)) == null ? void 0 : _k[1];
73
+ return id ? {
74
+ store: "ebay",
75
+ id
76
+ } : null;
77
+ }
78
+ if (/(^|\.)target\.com$/.test(host)) {
79
+ const id = (_l = path.match(/^\/p\/(?:[^/]+\/)?-\/A-(\d{6,12})\/?$/)) == null ? void 0 : _l[1];
80
+ return id ? {
81
+ store: "target",
82
+ id
83
+ } : null;
84
+ }
85
+ return null;
86
+ }
26
87
  const queues = {
27
88
  paid: {
28
89
  items: [],
@@ -87,13 +148,6 @@ function notify(key) {
87
148
  var _a;
88
149
  (_a = listeners.get(key)) == null ? void 0 : _a.forEach((listener) => listener());
89
150
  }
90
- function readImages(value) {
91
- return Array.isArray(value) ? value.filter((url) => typeof url === "string" && /^https:\/\//i.test(url)) : [];
92
- }
93
- function readVideos(value) {
94
- if (!Array.isArray(value)) return [];
95
- return value.filter((video) => !!video && typeof video === "object" && typeof video.url === "string" && /^https:\/\//i.test(video.url) && typeof video.mime === "string");
96
- }
97
151
  async function flush(kind) {
98
152
  var _a;
99
153
  const queue = queues[kind];
@@ -118,30 +172,54 @@ async function flush(kind) {
118
172
  batch.forEach((item, index) => {
119
173
  const answer = answers[index];
120
174
  const media = answer ? {
121
- images: readImages(answer.images),
122
- videos: readVideos(answer.videos)
175
+ images: httpsImages(answer.images),
176
+ videos: playableVideos(answer.videos)
123
177
  } : EMPTY;
124
178
  if (answer) cache.set(item.key, {
125
179
  media,
126
180
  paid: kind === "paid"
127
181
  });
182
+ if (answer && kind === "paid") remember(item.product, item.key, media, "connector");
128
183
  item.resolve(media);
129
184
  notify(item.key);
130
185
  });
131
186
  }
132
- function loadProductMedia(product, opts) {
187
+ function remember(product, key, media, lane) {
188
+ var _a, _b, _c, _d, _e;
189
+ const store = (_d = (_c = (_a = galleryTarget(product)) == null ? void 0 : _a.store) != null ? _c : (_b = product.retailerId) == null ? void 0 : _b.trim().toLowerCase()) != null ? _d : product.source;
190
+ const url = (_e = product.url) == null ? void 0 : _e.trim();
191
+ saveStoredGallery(__spreadValues(__spreadValues(__spreadValues({
192
+ key,
193
+ lane
194
+ }, product.name ? {
195
+ name: product.name
196
+ } : {}), url ? {
197
+ url
198
+ } : {}), store ? {
199
+ store
200
+ } : {}), media);
201
+ }
202
+ function loadProductMedia(product, ask) {
133
203
  var _a;
134
204
  const key = mediaKey(product);
135
205
  if (!key) return Promise.resolve(EMPTY);
136
206
  const cached = cache.get(key);
137
207
  const emptyCached = cached && cached.media.images.length === 0 && cached.media.videos.length === 0;
138
- if (cached && !(emptyCached && opts.paid && !cached.paid)) return Promise.resolve(cached.media);
208
+ if (cached && !(emptyCached && ask.paid && !cached.paid)) return Promise.resolve(cached.media);
139
209
  const running = inflight.get(key);
140
- if (running && (running.paid || !opts.paid)) return running.promise;
141
- const kind = opts.paid ? "paid" : "free";
210
+ if (running && (running.paid || !ask.paid)) return running.promise;
211
+ const kind = ask.paid ? "paid" : "free";
142
212
  const asin = key.startsWith("asin:") ? key.slice(5) : void 0;
143
213
  const url = ((_a = product.url) == null ? void 0 : _a.trim()) || (asin ? `https://www.amazon.com/dp/${asin}` : "");
144
- const promise = new Promise((resolve) => {
214
+ const found = (media) => {
215
+ cache.set(key, {
216
+ media,
217
+ paid: ask.paid
218
+ });
219
+ notify(key);
220
+ return media;
221
+ };
222
+ const viaConnector = () => new Promise((resolve) => {
145
223
  const queue = queues[kind];
146
224
  queue.items.push(__spreadProps(__spreadValues({
147
225
  key,
@@ -149,6 +227,7 @@ function loadProductMedia(product, opts) {
149
227
  }, asin ? {
150
228
  asin
151
229
  } : {}), {
230
+ product,
152
231
  resolve
153
232
  }));
154
233
  if (queue.items.length >= MAX_PER_CALL) {
@@ -157,13 +236,19 @@ function loadProductMedia(product, opts) {
157
236
  } else if (!queue.timer) {
158
237
  queue.timer = setTimeout(() => void flush(kind), BATCH_WINDOW_MS);
159
238
  }
160
- }).finally(() => {
239
+ });
240
+ const promise = (async () => {
241
+ const stored = await loadStoredGallery(key);
242
+ if (stored) return found(stored);
243
+ if (ask.connector === false) return found(EMPTY);
244
+ return viaConnector();
245
+ })().finally(() => {
161
246
  var _a2;
162
247
  if (((_a2 = inflight.get(key)) == null ? void 0 : _a2.promise) === promise) inflight.delete(key);
163
248
  });
164
249
  inflight.set(key, {
165
- paid: opts.paid,
250
+ paid: ask.paid,
166
251
  promise
167
252
  });
168
253
  return promise;
169
- }export{PAID_GALLERY_BUDGET,cachedProductMedia,claimPaidGallery,loadProductMedia,mediaKey,subscribeProductMedia};//# sourceMappingURL=productMedia.js.map
254
+ }export{PAID_GALLERY_BUDGET,cachedProductMedia,claimPaidGallery,galleryTarget,loadProductMedia,mediaKey,subscribeProductMedia};//# sourceMappingURL=productMedia.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"productMedia.js","sources":["../../../../src/features/shopping/services/productMedia.ts"],"sourcesContent":["/**\n * A listing's whole gallery - every photo and video - from the connector's\n * PRODUCT_MEDIA action. The search lanes carry one small thumbnail per row;\n * this is what lets a card swipe through the rest.\n *\n * Cost model (decided 2026-10-18): reading a shop's page is free, but Amazon\n * answers a server with a robot check, so an Amazon gallery is a metered\n * RapidAPI lookup billed to the shopper's credits. The surface spends it:\n *\n * - for search results as their cards come into view, capped at\n * {@link PAID_GALLERY_BUDGET} cards per search, so one long scroll cannot\n * run up a bill;\n * - whenever the shopper opens a product (an explicit ask, outside the cap);\n * - never for the landing page's trending and deals rails - those ask for free\n * reads only, which still return any gallery the connector already cached.\n *\n * Requests made in the same moment ride one exec (cards scroll in together),\n * and every answer is cached for the session, empty ones included, so a card\n * scrolled past twice never asks twice.\n */\nimport type { Product, ProductVideo } from '../catalog';\nimport { invokeShoppingSearchConnector, SHOPPING_SEARCH_ACTIONS } from './shoppingSearchConnectorClient';\n\nexport interface ProductMedia {\n images: string[];\n videos: ProductVideo[];\n}\n\n/** Paid gallery lookups per search, in the order cards scroll into view. */\nexport const PAID_GALLERY_BUDGET = 12;\n/** The connector's own per-call cap. */\nconst MAX_PER_CALL = 8;\n/** Long enough to gather a row of cards that scrolled in together. */\nconst BATCH_WINDOW_MS = 120;\n\ninterface ConnectorMedia {\n url?: string;\n images?: unknown;\n videos?: unknown;\n source?: string;\n note?: string;\n}\n\ninterface CacheEntry {\n media: ProductMedia;\n /** A paid lookup already ran for this answer; a paid ask must not buy it again. */\n paid: boolean;\n}\n\ntype Listener = () => void;\n\nconst cache = new Map<string, CacheEntry>();\nconst inflight = new Map<string, { paid: boolean; promise: Promise<ProductMedia> }>();\nconst listeners = new Map<string, Set<Listener>>();\n\ninterface Pending {\n key: string;\n url: string;\n asin?: string;\n resolve: (media: ProductMedia) => void;\n}\n\nconst queues: Record<'paid' | 'free', { items: Pending[]; timer: ReturnType<typeof setTimeout> | null }> = {\n paid: { items: [], timer: null },\n free: { items: [], timer: null },\n};\n\nlet budgetSearch: string | null = null;\nconst budgetClaims = new Set<string>();\n\nconst EMPTY: ProductMedia = { images: [], videos: [] };\n\nexport function resetProductMediaForTests(): void {\n cache.clear();\n inflight.clear();\n listeners.clear();\n for (const queue of Object.values(queues)) {\n if (queue.timer) clearTimeout(queue.timer);\n queue.items = [];\n queue.timer = null;\n }\n budgetSearch = null;\n budgetClaims.clear();\n}\n\n/**\n * The listing this product's gallery is read from, or null when it has none\n * worth reading: no page, or a Google Shopping page (Google answers a server\n * with a consent wall; its rows already carry their photos in `images`).\n */\nexport function mediaKey(product: Pick<Product, 'url' | 'asin'>): string | null {\n const asin = product.asin?.trim().toUpperCase();\n if (asin && /^[A-Z0-9]{10}$/.test(asin)) return `asin:${asin}`;\n const raw = product.url?.trim();\n if (!raw) return null;\n try {\n const url = new URL(raw);\n if (url.protocol !== 'https:' && url.protocol !== 'http:') return null;\n if (/(^|\\.)google\\.[a-z.]+$/i.test(url.hostname)) return null;\n const fromPath = url.pathname.match(/\\/(?:dp|gp\\/product)\\/([A-Z0-9]{10})(?:[/?]|$)/i)?.[1];\n if (fromPath && /(^|\\.)amazon\\./i.test(url.hostname)) return `asin:${fromPath.toUpperCase()}`;\n url.hash = '';\n return url.href;\n } catch {\n return null;\n }\n}\n\n/**\n * Whether this card may spend a paid lookup for `search`. Claims are counted\n * per search in the order asked, so the first {@link PAID_GALLERY_BUDGET} cards\n * a shopper scrolls to get galleries; a new search starts a new count.\n */\nexport function claimPaidGallery(search: string, key: string): boolean {\n if (search !== budgetSearch) {\n budgetSearch = search;\n budgetClaims.clear();\n }\n if (budgetClaims.has(key)) return true;\n if (budgetClaims.size >= PAID_GALLERY_BUDGET) return false;\n budgetClaims.add(key);\n return true;\n}\n\nexport function cachedProductMedia(key: string): ProductMedia | undefined {\n return cache.get(key)?.media;\n}\n\nexport function subscribeProductMedia(key: string, listener: Listener): () => void {\n let set = listeners.get(key);\n if (!set) {\n set = new Set();\n listeners.set(key, set);\n }\n set.add(listener);\n return () => {\n set?.delete(listener);\n if (set && set.size === 0) listeners.delete(key);\n };\n}\n\nfunction notify(key: string): void {\n listeners.get(key)?.forEach((listener) => listener());\n}\n\nfunction readImages(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((url): url is string => typeof url === 'string' && /^https:\\/\\//i.test(url))\n : [];\n}\n\nfunction readVideos(value: unknown): ProductVideo[] {\n if (!Array.isArray(value)) return [];\n return value.filter(\n (video): video is ProductVideo =>\n !!video &&\n typeof video === 'object' &&\n typeof (video as ProductVideo).url === 'string' &&\n /^https:\\/\\//i.test((video as ProductVideo).url) &&\n typeof (video as ProductVideo).mime === 'string',\n );\n}\n\nasync function flush(kind: 'paid' | 'free'): Promise<void> {\n const queue = queues[kind];\n queue.timer = null;\n const batch = queue.items.splice(0, MAX_PER_CALL);\n if (queue.items.length > 0) queue.timer = setTimeout(() => void flush(kind), 0);\n if (batch.length === 0) return;\n\n let answers: ConnectorMedia[] = [];\n try {\n const result = await invokeShoppingSearchConnector<{ items?: ConnectorMedia[] }>(\n {\n products: batch.map((item) => ({ url: item.url, ...(item.asin ? { asin: item.asin } : {}) })),\n paid: kind === 'paid',\n },\n SHOPPING_SEARCH_ACTIONS.PRODUCT_MEDIA,\n );\n answers = result.success && Array.isArray(result.data?.items) ? result.data.items : [];\n } catch {\n answers = [];\n }\n batch.forEach((item, index) => {\n const answer = answers[index];\n const media = answer ? { images: readImages(answer.images), videos: readVideos(answer.videos) } : EMPTY;\n // A failed call (no answer at all) is not remembered: the next view may reach the agent.\n if (answer) cache.set(item.key, { media, paid: kind === 'paid' });\n item.resolve(media);\n notify(item.key);\n });\n}\n\n/**\n * The gallery for `product`, from cache or one batched connector call. Resolves\n * empty (never rejects) when there is nothing to read or the read failed.\n */\nexport function loadProductMedia(\n product: Pick<Product, 'url' | 'asin'>,\n opts: { paid: boolean },\n): Promise<ProductMedia> {\n const key = mediaKey(product);\n if (!key) return Promise.resolve(EMPTY);\n const cached = cache.get(key);\n const emptyCached = cached && cached.media.images.length === 0 && cached.media.videos.length === 0;\n // A free answer that came back empty is worth one paid retry; anything else is final.\n if (cached && !(emptyCached && opts.paid && !cached.paid)) return Promise.resolve(cached.media);\n\n const running = inflight.get(key);\n if (running && (running.paid || !opts.paid)) return running.promise;\n\n const kind = opts.paid ? 'paid' : 'free';\n const asin = key.startsWith('asin:') ? key.slice(5) : undefined;\n const url = product.url?.trim() || (asin ? `https://www.amazon.com/dp/${asin}` : '');\n const promise = new Promise<ProductMedia>((resolve) => {\n const queue = queues[kind];\n queue.items.push({ key, url, ...(asin ? { asin } : {}), resolve });\n if (queue.items.length >= MAX_PER_CALL) {\n if (queue.timer) clearTimeout(queue.timer);\n void flush(kind);\n } else if (!queue.timer) {\n queue.timer = setTimeout(() => void flush(kind), BATCH_WINDOW_MS);\n }\n }).finally(() => {\n if (inflight.get(key)?.promise === promise) inflight.delete(key);\n });\n inflight.set(key, { paid: opts.paid, promise });\n return promise;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BO,MAAM,mBAAsB,GA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["../../../../src/features/shopping/services/productMedia.ts"],"sourcesContent":["/**\n * A listing's whole gallery - every photo and video - from the connector's\n * PRODUCT_MEDIA action. The search lanes carry one small thumbnail per row;\n * this is what lets a card swipe through the rest.\n *\n * Cost model (decided 2026-10-18): reading a shop's page is free, but Amazon\n * answers a server with a robot check, so an Amazon gallery is a metered\n * RapidAPI lookup billed to the shopper's credits. The surface spends it:\n *\n * - for search results as their cards come into view, capped at\n * {@link PAID_GALLERY_BUDGET} cards per search, so one long scroll cannot\n * run up a bill;\n * - whenever the shopper opens a product (an explicit ask, outside the cap);\n * - never for the landing page's trending and deals rails.\n *\n * Requests made in the same moment ride one exec (cards scroll in together),\n * and every answer is cached for the session, empty ones included, so a card\n * scrolled past twice never asks twice.\n *\n * Ahead of every read sits the tenant's memory (storedGalleries): a gallery any\n * browser or paid read found in the last week is shown from there at once, and\n * whatever a paid read finds now is saved there. That is what gives the rails\n * their photos (a rail card asks the store only - `connector: false`), and\n * what keeps a listing's gallery from being read again for every shopper.\n *\n * Native twin of web 0.49.0 `services/productMedia.ts`. Left out: the\n * shopper's own browser lane (`loadOwnBrowserGallery`, `claimBrowserGallery`,\n * the browser budgets, `urgency`, `wanted`) - a phone has no paired browser, so\n * on native a stored gallery exists only when a paired desktop browser or a\n * paid read (here or on web) stored it.\n */\nimport type { Product, ProductVideo } from '../catalog';\nimport { httpsImages, playableVideos } from './mediaShape';\nimport { invokeShoppingSearchConnector, SHOPPING_SEARCH_ACTIONS } from './shoppingSearchConnectorClient';\nimport { loadStoredGallery, saveStoredGallery, type GalleryLane } from './storedGalleries';\n\nexport interface ProductMedia {\n images: string[];\n videos: ProductVideo[];\n}\n\n/** Paid gallery lookups per search, in the order cards scroll into view. */\nexport const PAID_GALLERY_BUDGET = 12;\n/** The connector's own per-call cap. */\nconst MAX_PER_CALL = 8;\n/** Long enough to gather a row of cards that scrolled in together. */\nconst BATCH_WINDOW_MS = 120;\n\ninterface ConnectorMedia {\n url?: string;\n images?: unknown;\n videos?: unknown;\n source?: string;\n note?: string;\n}\n\ninterface CacheEntry {\n media: ProductMedia;\n /** A paid lookup already ran for this answer; a paid ask must not buy it again. */\n paid: boolean;\n}\n\ntype Listener = () => void;\n\nconst cache = new Map<string, CacheEntry>();\nconst inflight = new Map<string, { paid: boolean; promise: Promise<ProductMedia> }>();\nconst listeners = new Map<string, Set<Listener>>();\n\n/**\n * A listing as the gallery lookups read it: the link (or ASIN) it is keyed by,\n * and what a saved row describes it with (web `GalleryProduct`).\n */\nexport type GalleryProduct = Pick<Product, 'url' | 'asin'> &\n Partial<Pick<Product, 'name' | 'source' | 'retailerId' | 'sku'>>;\n\n/** The stores whose listing ids web's browser gallery lane reads (web `ownBrowserGalleryReader` `GalleryStore`). */\nexport type GalleryStore = 'amazon' | 'walmart' | 'ebay' | 'target';\n\n/** A listing id as each store writes it (web `ownBrowserGalleryReader` `ID_PATTERN`, verbatim). */\nconst ID_PATTERN: Record<GalleryStore, RegExp> = {\n amazon: /^[A-Z0-9]{10}$/,\n walmart: /^[0-9]{5,15}$/,\n ebay: /^[0-9]{9,15}$/,\n target: /^[0-9]{6,12}$/,\n};\n\nfunction isGalleryId(store: GalleryStore, id: string): boolean {\n return ID_PATTERN[store].test(id);\n}\n\n/**\n * Which store's gallery this listing is, and its id there, or null (web\n * `ownBrowserGallery` `galleryTarget`, verbatim). Native reads no browser; it\n * only names the store a saved gallery row is filed under, as web does.\n */\nexport function galleryTarget(product: GalleryProduct): { store: GalleryStore; id: string } | null {\n const asin = product.asin?.trim().toUpperCase();\n if (asin && isGalleryId('amazon', asin)) return { store: 'amazon', id: asin };\n // A catalog row links through an affiliate redirect, but its SKU at Walmart is the item id.\n const sku = product.sku?.trim() ?? '';\n if (/^walmart$/i.test(product.retailerId?.trim() ?? '') && isGalleryId('walmart', sku)) {\n return { store: 'walmart', id: sku };\n }\n let url: URL;\n try {\n url = new URL(product.url?.trim() ?? '');\n } catch {\n return null;\n }\n const host = url.hostname.toLowerCase();\n const path = url.pathname;\n if (/(^|\\.)amazon\\.com$/.test(host)) {\n const id = path.match(/\\/(?:dp|gp\\/product)\\/([A-Z0-9]{10})(?:[/?]|$)/i)?.[1]?.toUpperCase();\n return id ? { store: 'amazon', id } : null;\n }\n if (/(^|\\.)walmart\\.com$/.test(host)) {\n const id = path.match(/^\\/ip\\/(?:[^/]+\\/)?(\\d{5,15})\\/?$/)?.[1];\n return id ? { store: 'walmart', id } : null;\n }\n if (/(^|\\.)ebay\\.com$/.test(host)) {\n const id = path.match(/^\\/itm\\/(?:[^/]+\\/)?(\\d{9,15})\\/?$/)?.[1];\n return id ? { store: 'ebay', id } : null;\n }\n if (/(^|\\.)target\\.com$/.test(host)) {\n const id = path.match(/^\\/p\\/(?:[^/]+\\/)?-\\/A-(\\d{6,12})\\/?$/)?.[1];\n return id ? { store: 'target', id } : null;\n }\n return null;\n}\n\ninterface Pending {\n key: string;\n url: string;\n asin?: string;\n product: GalleryProduct;\n resolve: (media: ProductMedia) => void;\n}\n\nconst queues: Record<'paid' | 'free', { items: Pending[]; timer: ReturnType<typeof setTimeout> | null }> = {\n paid: { items: [], timer: null },\n free: { items: [], timer: null },\n};\n\nlet budgetSearch: string | null = null;\nconst budgetClaims = new Set<string>();\n\nconst EMPTY: ProductMedia = { images: [], videos: [] };\n\nexport function resetProductMediaForTests(): void {\n cache.clear();\n inflight.clear();\n listeners.clear();\n for (const queue of Object.values(queues)) {\n if (queue.timer) clearTimeout(queue.timer);\n queue.items = [];\n queue.timer = null;\n }\n budgetSearch = null;\n budgetClaims.clear();\n}\n\n/**\n * The listing this product's gallery is read from, or null when it has none\n * worth reading: no page, or a Google Shopping page (Google answers a server\n * with a consent wall; its rows already carry their photos in `images`).\n */\nexport function mediaKey(product: Pick<Product, 'url' | 'asin'>): string | null {\n const asin = product.asin?.trim().toUpperCase();\n if (asin && /^[A-Z0-9]{10}$/.test(asin)) return `asin:${asin}`;\n const raw = product.url?.trim();\n if (!raw) return null;\n try {\n const url = new URL(raw);\n if (url.protocol !== 'https:' && url.protocol !== 'http:') return null;\n if (/(^|\\.)google\\.[a-z.]+$/i.test(url.hostname)) return null;\n const fromPath = url.pathname.match(/\\/(?:dp|gp\\/product)\\/([A-Z0-9]{10})(?:[/?]|$)/i)?.[1];\n if (fromPath && /(^|\\.)amazon\\./i.test(url.hostname)) return `asin:${fromPath.toUpperCase()}`;\n url.hash = '';\n return url.href;\n } catch {\n return null;\n }\n}\n\n/**\n * Whether this card may spend a paid lookup for `search`. Claims are counted\n * per search in the order asked, so the first {@link PAID_GALLERY_BUDGET} cards\n * a shopper scrolls to get galleries; a new search starts a new count.\n */\nexport function claimPaidGallery(search: string, key: string): boolean {\n if (search !== budgetSearch) {\n budgetSearch = search;\n budgetClaims.clear();\n }\n if (budgetClaims.has(key)) return true;\n if (budgetClaims.size >= PAID_GALLERY_BUDGET) return false;\n budgetClaims.add(key);\n return true;\n}\n\nexport function cachedProductMedia(key: string): ProductMedia | undefined {\n return cache.get(key)?.media;\n}\n\nexport function subscribeProductMedia(key: string, listener: Listener): () => void {\n let set = listeners.get(key);\n if (!set) {\n set = new Set();\n listeners.set(key, set);\n }\n set.add(listener);\n return () => {\n set?.delete(listener);\n if (set && set.size === 0) listeners.delete(key);\n };\n}\n\nfunction notify(key: string): void {\n listeners.get(key)?.forEach((listener) => listener());\n}\n\nasync function flush(kind: 'paid' | 'free'): Promise<void> {\n const queue = queues[kind];\n queue.timer = null;\n const batch = queue.items.splice(0, MAX_PER_CALL);\n if (queue.items.length > 0) queue.timer = setTimeout(() => void flush(kind), 0);\n if (batch.length === 0) return;\n\n let answers: ConnectorMedia[] = [];\n try {\n const result = await invokeShoppingSearchConnector<{ items?: ConnectorMedia[] }>(\n {\n products: batch.map((item) => ({ url: item.url, ...(item.asin ? { asin: item.asin } : {}) })),\n paid: kind === 'paid',\n },\n SHOPPING_SEARCH_ACTIONS.PRODUCT_MEDIA,\n );\n answers = result.success && Array.isArray(result.data?.items) ? result.data.items : [];\n } catch {\n answers = [];\n }\n batch.forEach((item, index) => {\n const answer = answers[index];\n const media = answer ? { images: httpsImages(answer.images), videos: playableVideos(answer.videos) } : EMPTY;\n // A failed call (no answer at all) is not remembered: the next view may reach the agent.\n if (answer) cache.set(item.key, { media, paid: kind === 'paid' });\n // A paid answer is remembered for the tenant: nobody should buy it again. A free page read is not -\n // it is often one photo (Target's og:image) where the shopper's browser would read the whole gallery.\n if (answer && kind === 'paid') remember(item.product, item.key, media, 'connector');\n item.resolve(media);\n notify(item.key);\n });\n}\n\n/** Saves what a read found for everyone in the tenant (storedGalleries). */\nfunction remember(product: GalleryProduct, key: string, media: ProductMedia, lane: GalleryLane): void {\n const store = galleryTarget(product)?.store ?? product.retailerId?.trim().toLowerCase() ?? product.source;\n const url = product.url?.trim();\n saveStoredGallery(\n {\n key,\n lane,\n ...(product.name ? { name: product.name } : {}),\n ...(url ? { url } : {}),\n ...(store ? { store } : {}),\n },\n media,\n );\n}\n\n/** How one card asks for a listing's gallery (web `MediaAsk`, less the shopper's-browser fields). */\nexport interface MediaAsk {\n /** May spend a metered lookup (Amazon) when nothing free found the gallery. */\n paid: boolean;\n /**\n * Ask the connector's page read when the stored galleries have none (default: yes). The rails do not: on\n * their own listings that read is a bot wall (Amazon, Walmart, Kohl's) or a single photo (Target) - measured\n * 2026-11-20 - so it would be one exec per batch of cards that finds nothing.\n */\n connector?: boolean;\n /**\n * Aborted once the card has gone. Web skips a queued browser turn nobody still waits on with it; native has\n * no browser turn, so nothing reads it yet - kept so a card withdraws its ask the same way on both.\n */\n signal?: AbortSignal;\n}\n\n/**\n * The gallery for `product`: from this session's cache, else the tenant's stored\n * galleries, else one batched connector call (unless `connector` is false).\n * Resolves empty (never rejects) when there is nothing to read or the read\n * failed. What a paid read finds is saved for the tenant.\n */\nexport function loadProductMedia(product: GalleryProduct, ask: MediaAsk): Promise<ProductMedia> {\n const key = mediaKey(product);\n if (!key) return Promise.resolve(EMPTY);\n const cached = cache.get(key);\n const emptyCached = cached && cached.media.images.length === 0 && cached.media.videos.length === 0;\n // A free answer that came back empty is worth one paid retry; anything else is final for the session.\n if (cached && !(emptyCached && ask.paid && !cached.paid)) return Promise.resolve(cached.media);\n\n const running = inflight.get(key);\n if (running && (running.paid || !ask.paid)) return running.promise;\n\n const kind = ask.paid ? 'paid' : 'free';\n const asin = key.startsWith('asin:') ? key.slice(5) : undefined;\n const url = product.url?.trim() || (asin ? `https://www.amazon.com/dp/${asin}` : '');\n const found = (media: ProductMedia): ProductMedia => {\n cache.set(key, { media, paid: ask.paid });\n notify(key);\n return media;\n };\n const viaConnector = () =>\n new Promise<ProductMedia>((resolve) => {\n const queue = queues[kind];\n queue.items.push({ key, url, ...(asin ? { asin } : {}), product, resolve });\n if (queue.items.length >= MAX_PER_CALL) {\n if (queue.timer) clearTimeout(queue.timer);\n void flush(kind);\n } else if (!queue.timer) {\n queue.timer = setTimeout(() => void flush(kind), BATCH_WINDOW_MS);\n }\n });\n const promise = (async (): Promise<ProductMedia> => {\n // Read before, by anyone in the tenant: shown at once, and nothing is read again.\n const stored = await loadStoredGallery(key);\n if (stored) return found(stored);\n if (ask.connector === false) return found(EMPTY);\n return viaConnector();\n })().finally(() => {\n if (inflight.get(key)?.promise === promise) inflight.delete(key);\n });\n inflight.set(key, { paid: ask.paid, promise });\n return promise;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;AAyCO,MAAM,mBAAsB,GAAA;AAEnC,MAAM,YAAe,GAAA,CAAA;AAErB,MAAM,eAAkB,GAAA,GAAA;AAcxB,MAAM,KAAA,uBAAY,GAAwB,EAAA;AAC1C,MAAM,QAAA,uBAAe,GAGlB,EAAA;AACH,MAAM,SAAA,uBAAgB,GAA2B,EAAA;AAYjD,MAAM,UAA2C,GAAA;AAAA,EAC/C,MAAQ,EAAA,gBAAA;AAAA,EACR,OAAS,EAAA,eAAA;AAAA,EACT,IAAM,EAAA,eAAA;AAAA,EACN,MAAQ,EAAA;AACV,CAAA;AACA,SAAS,WAAA,CAAY,OAAqB,EAA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37,14 +37,16 @@ const PRODUCT_URL_PATTERNS = {
37
37
  amazon: /\/(?:dp|gp\/product|gp\/aw\/d|product)\/([A-Z0-9]{10})(?:[/?#]|$)/i,
38
38
  // /ip/<slug>/<id> or /ip/<id>
39
39
  walmart: /\/ip\/[^?#]*\d/i,
40
- // /site/<slug>/<skuId>.p (category pages end in `.c`)
41
- bestbuy: /\/site\/[^?#]*\d\.p(?:[/?#]|$)/i,
40
+ // /site/<slug>/<skuId>.p (category pages end in `.c`), or the newer
41
+ // /product/<slug>/<code>[/sku/<skuId>] that Best Buy and Google Shopping link to now
42
+ bestbuy: /\/(?:site\/[^?#]*\d\.p|product\/[^/?#]+\/[A-Za-z0-9]{6,})(?:[/?#]|$)/i,
42
43
  // /itm/<itemId>
43
44
  ebay: /\/itm\/\d+/i,
44
45
  // /p/<slug>/-/A-<tcin>
45
46
  target: /\/-\/A-\w+/i,
46
- // /<slug>.product.<itemId>.html
47
- costco: /\.product\.\d+\.html/i,
47
+ // /<slug>.product.<itemId>.html, or /p/-/<slug>/<itemId> - what its results link to now (2026-11-20);
48
+ // its category pages are /f/-/<slug>
49
+ costco: /\.product\.\d+\.html|\/p\/-\/[^/?#]+\/\d{4,}(?:[/?#]|$)/i,
48
50
  // /p/<slug>/<itemId>
49
51
  homedepot: /\/p\/[^?#]*\d/i,
50
52
  // /pd/<slug>/<itemId>
@@ -64,11 +66,11 @@ function isAggregatorSource(source) {
64
66
  const GENERIC_PRODUCT_PATH = /\/(?: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;
65
67
  const NON_MERCHANT_HOST = /(?:^|\/\/|\.)(?:google|googleusercontent|gstatic|bing|duckduckgo|yahoo|youtube|facebook|instagram|pinterest|reddit|quora|wikipedia|medium|blogspot|substack|tiktok|twitter)\./i;
66
68
  function isNonMerchantHost(url) {
67
- return !!url && NON_MERCHANT_HOST.test(url);
69
+ return !!url && NON_MERCHANT_HOST.test(url) && !usedSiteOfHost(url);
68
70
  }
69
71
  function isAggregatorProductUrl(url) {
70
72
  if (!url) return false;
71
- if (NON_MERCHANT_HOST.test(url)) return false;
73
+ if (isNonMerchantHost(url)) return false;
72
74
  const source = detectRetailerSourceFromUrl(url);
73
75
  if (source) return isRetailerProductUrl(url, source);
74
76
  return GENERIC_PRODUCT_PATH.test(url);
@@ -82,13 +84,14 @@ function detectRetailerSourceFromUrl(url) {
82
84
  } of HOST_SOURCE) {
83
85
  if (re.test(url)) return source;
84
86
  }
85
- return void 0;
87
+ return usedSiteOfHost(url) ? "used" : void 0;
86
88
  }
87
89
  function isRetailerProductUrl(url, source) {
88
90
  if (!url) return false;
89
91
  if (AGGREGATOR_SOURCES.has(source)) return isAggregatorProductUrl(url);
90
92
  const host = detectRetailerSourceFromUrl(url);
91
93
  if (host && host !== source) return false;
94
+ if (source === "used") return !!usedSiteOfListing(url) || !!host && GENERIC_PRODUCT_PATH.test(url);
92
95
  const pattern = PRODUCT_URL_PATTERNS[source];
93
96
  if (!pattern) return false;
94
97
  return pattern.test(url);