@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,1108 @@
1
+ import {useSyncExternalStore}from'react';import {api,fetchThread,fetchMessages,fetchChannel,fetchBootstrap,fetchMessage,fetchMe,fetchSidebar,fetchPeople}from'../api/ops.js';var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __restKey = (key) => typeof key === "symbol" ? key : key + "";
21
+ var __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
33
+ const emptyHistory = () => ({
34
+ messages: [],
35
+ hasMoreBefore: false,
36
+ hasMoreAfter: false,
37
+ loaded: false,
38
+ loading: false,
39
+ loadingOlder: false,
40
+ error: null,
41
+ openedAtReadSeq: null,
42
+ focusSeq: null
43
+ });
44
+ const emptyThread = () => ({
45
+ root: null,
46
+ replies: [],
47
+ following: false,
48
+ lastReadSeq: 0,
49
+ loaded: false,
50
+ loading: false,
51
+ error: null
52
+ });
53
+ const initial = {
54
+ phase: "loading",
55
+ error: null,
56
+ me: null,
57
+ people: {},
58
+ channels: {},
59
+ histories: {},
60
+ threads: {},
61
+ latest: {},
62
+ typing: {},
63
+ live: "connecting",
64
+ activeChannelId: null,
65
+ activeThreadId: null,
66
+ versions: {
67
+ activity: 0,
68
+ saved: 0,
69
+ drafts: 0,
70
+ threads: 0
71
+ }
72
+ };
73
+ const typingKey = (channelId, rootId) => `${channelId}:${rootId != null ? rootId : ""}`;
74
+ const PENDING_SEQ = Number.MAX_SAFE_INTEGER - 1e6;
75
+ function upsertMessage(list, m, insert = true) {
76
+ const i = list.findIndex((x) => x.id === m.id || m.clientMsgId && x.clientMsgId === m.clientMsgId && x.pending);
77
+ if (i >= 0) {
78
+ const next2 = list.slice();
79
+ next2[i] = m;
80
+ if (list[i].seq !== m.seq) next2.sort((a, b) => a.seq - b.seq);
81
+ return next2;
82
+ }
83
+ if (!insert) return list;
84
+ const next = [...list, m];
85
+ if (next.length > 1 && next[next.length - 2].seq > m.seq) next.sort((a, b) => a.seq - b.seq);
86
+ return next;
87
+ }
88
+ function removeMessage(list, id) {
89
+ const i = list.findIndex((x) => x.id === id);
90
+ if (i < 0) return list;
91
+ return [...list.slice(0, i), ...list.slice(i + 1)];
92
+ }
93
+ const isChannelLevel = (m) => !m.threadRootId || m.alsoInChannel;
94
+ function rememberAll(latest, list) {
95
+ let next = latest;
96
+ for (const m of list) {
97
+ if (m.pending || next[m.id] === m) continue;
98
+ if (next === latest) next = __spreadValues({}, latest);
99
+ next[m.id] = m;
100
+ }
101
+ return next;
102
+ }
103
+ function createChatStore() {
104
+ let state = initial;
105
+ const listeners = /* @__PURE__ */ new Set();
106
+ const set = (fn) => {
107
+ const next = fn(state);
108
+ if (next === state) return;
109
+ state = next;
110
+ for (const l of listeners) l();
111
+ };
112
+ const store = {
113
+ getState: () => state,
114
+ subscribe(fn) {
115
+ listeners.add(fn);
116
+ return () => listeners.delete(fn);
117
+ }
118
+ };
119
+ const ctx = {
120
+ get: () => state,
121
+ set,
122
+ live: null
123
+ };
124
+ const actions = createActions(ctx);
125
+ const applyEvent = (ev) => reduceEvent(ctx, actions, ev);
126
+ return __spreadProps(__spreadValues({}, store), {
127
+ actions,
128
+ applyEvent,
129
+ attachLive(live) {
130
+ ctx.live = live;
131
+ const offEvent = live.onEvent(applyEvent);
132
+ let presenceTimer = null;
133
+ const offStatus = live.onStatus((s) => {
134
+ set((st) => __spreadProps(__spreadValues({}, st), {
135
+ live: s
136
+ }));
137
+ if (s === "online") {
138
+ if (presenceTimer) clearTimeout(presenceTimer);
139
+ presenceTimer = setTimeout(() => {
140
+ presenceTimer = null;
141
+ void actions.refreshPeople();
142
+ actions.refreshMe();
143
+ }, 1200);
144
+ }
145
+ });
146
+ set((st) => __spreadProps(__spreadValues({}, st), {
147
+ live: live.status()
148
+ }));
149
+ return () => {
150
+ if (presenceTimer) clearTimeout(presenceTimer);
151
+ offEvent();
152
+ offStatus();
153
+ ctx.live = null;
154
+ };
155
+ }
156
+ });
157
+ }
158
+ function createActions(ctx) {
159
+ const {
160
+ get,
161
+ set
162
+ } = ctx;
163
+ const putChannel = (c) => set((s) => {
164
+ const prev = s.channels[c.id];
165
+ return __spreadProps(__spreadValues({}, s), {
166
+ channels: __spreadProps(__spreadValues({}, s.channels), {
167
+ [c.id]: prev ? __spreadValues(__spreadValues({}, prev), c) : c
168
+ })
169
+ });
170
+ });
171
+ const remember = (list) => set((s) => {
172
+ const latest = rememberAll(s.latest, list);
173
+ return latest === s.latest ? s : __spreadProps(__spreadValues({}, s), {
174
+ latest
175
+ });
176
+ });
177
+ const patchHistory = (channelId, fn) => set((s) => {
178
+ var _a;
179
+ const h = (_a = s.histories[channelId]) != null ? _a : emptyHistory();
180
+ const next = fn(h);
181
+ return next === h ? s : __spreadProps(__spreadValues({}, s), {
182
+ histories: __spreadProps(__spreadValues({}, s.histories), {
183
+ [channelId]: next
184
+ })
185
+ });
186
+ });
187
+ const patchThread = (rootId, fn) => set((s) => {
188
+ var _a;
189
+ const t = (_a = s.threads[rootId]) != null ? _a : emptyThread();
190
+ const next = fn(t);
191
+ return next === t ? s : __spreadProps(__spreadValues({}, s), {
192
+ threads: __spreadProps(__spreadValues({}, s.threads), {
193
+ [rootId]: next
194
+ })
195
+ });
196
+ });
197
+ const replaceEverywhere = (m, insert = {}) => set((s) => {
198
+ var _a, _b;
199
+ let histories = s.histories;
200
+ let threads = s.threads;
201
+ const h = s.histories[m.channelId];
202
+ if (h == null ? void 0 : h.loaded) {
203
+ const live = !h.hasMoreAfter;
204
+ const list = upsertMessage(h.messages, m, Boolean(insert.channel && live && isChannelLevel(m)));
205
+ if (list !== h.messages) histories = __spreadProps(__spreadValues({}, histories), {
206
+ [m.channelId]: __spreadProps(__spreadValues({}, h), {
207
+ messages: list
208
+ })
209
+ });
210
+ }
211
+ if (!m.threadRootId && ((_a = threads[m.id]) == null ? void 0 : _a.loaded)) {
212
+ threads = __spreadProps(__spreadValues({}, threads), {
213
+ [m.id]: __spreadProps(__spreadValues({}, threads[m.id]), {
214
+ root: m
215
+ })
216
+ });
217
+ }
218
+ if (m.threadRootId && ((_b = threads[m.threadRootId]) == null ? void 0 : _b.loaded)) {
219
+ const t = threads[m.threadRootId];
220
+ const replies = upsertMessage(t.replies, m, Boolean(insert.thread));
221
+ if (replies !== t.replies) threads = __spreadProps(__spreadValues({}, threads), {
222
+ [m.threadRootId]: __spreadProps(__spreadValues({}, t), {
223
+ replies
224
+ })
225
+ });
226
+ }
227
+ const latest = rememberAll(s.latest, [m]);
228
+ return histories === s.histories && threads === s.threads && latest === s.latest ? s : __spreadProps(__spreadValues({}, s), {
229
+ histories,
230
+ threads,
231
+ latest
232
+ });
233
+ });
234
+ const dirty = /* @__PURE__ */ new Set();
235
+ let flushTimer = null;
236
+ const refreshChannel = (id) => {
237
+ dirty.add(id);
238
+ if (flushTimer) return;
239
+ flushTimer = setTimeout(async () => {
240
+ flushTimer = null;
241
+ const ids = [...dirty];
242
+ dirty.clear();
243
+ await Promise.all(ids.map(async (cid) => {
244
+ try {
245
+ const c = await fetchChannel(cid);
246
+ if (c) putChannel(c);
247
+ else set((s) => removeFromSidebar(s, cid));
248
+ } catch (e) {
249
+ }
250
+ }));
251
+ }, 250);
252
+ };
253
+ let meTimer = null;
254
+ const refreshMe = () => {
255
+ if (meTimer) return;
256
+ meTimer = setTimeout(async () => {
257
+ meTimer = null;
258
+ try {
259
+ const me = await fetchMe();
260
+ set((s) => __spreadProps(__spreadValues({}, s), {
261
+ me,
262
+ people: __spreadProps(__spreadValues({}, s.people), {
263
+ [me.user.id]: me.user
264
+ })
265
+ }));
266
+ } catch (e) {
267
+ }
268
+ }, 300);
269
+ };
270
+ const refreshSidebar = async () => {
271
+ try {
272
+ const list = await fetchSidebar();
273
+ set((s) => {
274
+ const channels = __spreadValues({}, s.channels);
275
+ for (const c of list) channels[c.id] = __spreadValues(__spreadValues({}, channels[c.id]), c);
276
+ const ids = new Set(list.map((c) => c.id));
277
+ for (const [id, c] of Object.entries(channels)) if (c.membership && !ids.has(id)) channels[id] = __spreadProps(__spreadValues({}, c), {
278
+ membership: null
279
+ });
280
+ return __spreadProps(__spreadValues({}, s), {
281
+ channels
282
+ });
283
+ });
284
+ } catch (e) {
285
+ }
286
+ };
287
+ const refreshPeople = async () => {
288
+ try {
289
+ const people = await fetchPeople();
290
+ set((s) => __spreadProps(__spreadValues({}, s), {
291
+ people: __spreadValues(__spreadValues({}, s.people), Object.fromEntries(people.map((p) => [p.id, p])))
292
+ }));
293
+ } catch (e) {
294
+ }
295
+ };
296
+ const readTimers = /* @__PURE__ */ new Map();
297
+ const markRead = (channelId, seq) => {
298
+ const c = get().channels[channelId];
299
+ if (!(c == null ? void 0 : c.membership)) return;
300
+ const target = Math.min(seq != null ? seq : c.lastSeq, c.lastSeq);
301
+ if (target <= c.membership.lastReadSeq && c.membership.unreadCount === 0 && c.membership.mentionCount === 0) return;
302
+ putChannel(__spreadProps(__spreadValues({}, c), {
303
+ membership: __spreadProps(__spreadValues({}, c.membership), {
304
+ lastReadSeq: Math.max(target, c.membership.lastReadSeq),
305
+ unreadCount: 0,
306
+ mentionCount: 0
307
+ })
308
+ }));
309
+ clearTimeout(readTimers.get(channelId));
310
+ readTimers.set(channelId, setTimeout(() => {
311
+ readTimers.delete(channelId);
312
+ api.markRead(channelId, target).then(putChannel, () => refreshChannel(channelId));
313
+ }, 600));
314
+ };
315
+ let typingAt = 0;
316
+ let typingFor = "";
317
+ return {
318
+ refreshChannel,
319
+ refreshMe,
320
+ refreshSidebar,
321
+ refreshPeople,
322
+ putChannel,
323
+ /** List views record what they fetched, so their rows follow later edits and reactions. */
324
+ remember,
325
+ async bootstrap() {
326
+ set((s) => __spreadProps(__spreadValues({}, s), {
327
+ phase: s.me ? s.phase : "loading",
328
+ error: null
329
+ }));
330
+ try {
331
+ const {
332
+ me,
333
+ sidebar,
334
+ people
335
+ } = await fetchBootstrap();
336
+ set((s) => __spreadProps(__spreadValues({}, s), {
337
+ phase: "ready",
338
+ me,
339
+ people: __spreadProps(__spreadValues({}, Object.fromEntries(people.map((p) => [p.id, p]))), {
340
+ [me.user.id]: me.user
341
+ }),
342
+ channels: __spreadValues(__spreadValues({}, s.channels), Object.fromEntries(sidebar.map((c) => [c.id, c])))
343
+ }));
344
+ } catch (err) {
345
+ set((s) => __spreadProps(__spreadValues({}, s), {
346
+ phase: s.me ? s.phase : "error",
347
+ error: err.message
348
+ }));
349
+ }
350
+ },
351
+ /** Everything on screen again (after the socket was away). */
352
+ async resync() {
353
+ const s = get();
354
+ await Promise.all([this.bootstrap(), s.activeChannelId ? this.loadHistory(s.activeChannelId, {
355
+ reload: true
356
+ }) : null, s.activeThreadId ? this.loadThread(s.activeThreadId) : null]);
357
+ set((st) => __spreadProps(__spreadValues({}, st), {
358
+ versions: {
359
+ activity: st.versions.activity + 1,
360
+ saved: st.versions.saved + 1,
361
+ drafts: st.versions.drafts + 1,
362
+ threads: st.versions.threads + 1
363
+ }
364
+ }));
365
+ },
366
+ setActive(channelId, threadId) {
367
+ set((s) => s.activeChannelId === channelId && s.activeThreadId === threadId ? s : __spreadProps(__spreadValues({}, s), {
368
+ activeChannelId: channelId,
369
+ activeThreadId: threadId
370
+ }));
371
+ },
372
+ async ensureChannel(id) {
373
+ const known = get().channels[id];
374
+ if (known) return known;
375
+ const c = await fetchChannel(id);
376
+ if (c) putChannel(c);
377
+ return c;
378
+ },
379
+ /**
380
+ * Coming back to a channel whose history is cached: the "New" line marks what is unread
381
+ * now, not what was the first time it opened. Call it before anything can mark the channel
382
+ * read on this visit.
383
+ */
384
+ anchorUnread(channelId) {
385
+ var _a, _b, _c;
386
+ const h = get().histories[channelId];
387
+ const lastRead = (_c = (_b = (_a = get().channels[channelId]) == null ? void 0 : _a.membership) == null ? void 0 : _b.lastReadSeq) != null ? _c : null;
388
+ if ((h == null ? void 0 : h.loaded) && h.openedAtReadSeq !== lastRead) patchHistory(channelId, (x) => __spreadProps(__spreadValues({}, x), {
389
+ openedAtReadSeq: lastRead
390
+ }));
391
+ },
392
+ /** Open a channel's history: at the first unread when there is a backlog, else the latest page. */
393
+ async loadHistory(channelId, opts = {}) {
394
+ var _a, _b, _c, _d;
395
+ const h = get().histories[channelId];
396
+ if (h == null ? void 0 : h.loading) return;
397
+ if ((h == null ? void 0 : h.loaded) && !opts.reload && opts.around == null) return;
398
+ const c = get().channels[channelId];
399
+ const lastRead = (_b = (_a = c == null ? void 0 : c.membership) == null ? void 0 : _a.lastReadSeq) != null ? _b : null;
400
+ const backlog = (c == null ? void 0 : c.membership) && c.membership.unreadCount >= 25 ? lastRead : null;
401
+ const around = (_d = (_c = opts.around) != null ? _c : backlog) != null ? _d : void 0;
402
+ patchHistory(channelId, (x) => __spreadProps(__spreadValues({}, x), {
403
+ loading: true,
404
+ error: null
405
+ }));
406
+ try {
407
+ const page = await fetchMessages(channelId, around != null ? {
408
+ around,
409
+ limit: 60
410
+ } : {
411
+ limit: 50
412
+ });
413
+ remember(page.messages);
414
+ patchHistory(channelId, (x) => {
415
+ var _a2;
416
+ return __spreadProps(__spreadValues({}, x), {
417
+ messages: [...page.messages, ...opts.reload ? x.messages.filter((m) => m.pending) : []],
418
+ hasMoreBefore: page.hasMoreBefore,
419
+ hasMoreAfter: page.hasMoreAfter,
420
+ loaded: true,
421
+ loading: false,
422
+ openedAtReadSeq: x.loaded && opts.reload ? x.openedAtReadSeq : lastRead,
423
+ focusSeq: (_a2 = opts.around) != null ? _a2 : null
424
+ });
425
+ });
426
+ } catch (err) {
427
+ patchHistory(channelId, (x) => __spreadProps(__spreadValues({}, x), {
428
+ loading: false,
429
+ error: err.message
430
+ }));
431
+ }
432
+ },
433
+ async loadOlder(channelId) {
434
+ const h = get().histories[channelId];
435
+ if (!(h == null ? void 0 : h.loaded) || h.loadingOlder || !h.hasMoreBefore) return;
436
+ const first = h.messages.find((m) => !m.pending);
437
+ if (!first) return;
438
+ patchHistory(channelId, (x) => __spreadProps(__spreadValues({}, x), {
439
+ loadingOlder: true
440
+ }));
441
+ try {
442
+ const page = await fetchMessages(channelId, {
443
+ before: first.seq,
444
+ limit: 50
445
+ });
446
+ remember(page.messages);
447
+ patchHistory(channelId, (x) => __spreadProps(__spreadValues({}, x), {
448
+ messages: [...page.messages.filter((m) => !x.messages.some((y) => y.id === m.id)), ...x.messages],
449
+ hasMoreBefore: page.hasMoreBefore,
450
+ loadingOlder: false
451
+ }));
452
+ } catch (e) {
453
+ patchHistory(channelId, (x) => __spreadProps(__spreadValues({}, x), {
454
+ loadingOlder: false
455
+ }));
456
+ }
457
+ },
458
+ async loadNewer(channelId) {
459
+ const h = get().histories[channelId];
460
+ if (!(h == null ? void 0 : h.loaded) || h.loading || !h.hasMoreAfter) return;
461
+ const last = [...h.messages].reverse().find((m) => !m.pending);
462
+ if (!last) return;
463
+ try {
464
+ const page = await fetchMessages(channelId, {
465
+ after: last.seq,
466
+ limit: 100
467
+ });
468
+ remember(page.messages);
469
+ patchHistory(channelId, (x) => __spreadProps(__spreadValues({}, x), {
470
+ messages: [...x.messages, ...page.messages.filter((m) => !x.messages.some((y) => y.id === m.id))],
471
+ hasMoreAfter: page.hasMoreAfter
472
+ }));
473
+ } catch (e) {
474
+ }
475
+ },
476
+ /** Back to the live end of the channel. */
477
+ async jumpToLatest(channelId) {
478
+ patchHistory(channelId, (x) => __spreadProps(__spreadValues({}, x), {
479
+ focusSeq: null
480
+ }));
481
+ await this.loadHistory(channelId, {
482
+ reload: true
483
+ });
484
+ },
485
+ clearFocus(channelId) {
486
+ patchHistory(channelId, (x) => x.focusSeq == null ? x : __spreadProps(__spreadValues({}, x), {
487
+ focusSeq: null
488
+ }));
489
+ },
490
+ async loadThread(rootId) {
491
+ patchThread(rootId, (t) => __spreadProps(__spreadValues({}, t), {
492
+ loading: true,
493
+ error: null
494
+ }));
495
+ try {
496
+ const t = await fetchThread(rootId);
497
+ if (t.channel) putChannel(t.channel);
498
+ remember([t.root, ...t.replies]);
499
+ patchThread(rootId, (x) => ({
500
+ root: t.root,
501
+ replies: [...t.replies, ...x.replies.filter((r) => r.pending)],
502
+ following: t.following,
503
+ lastReadSeq: t.lastReadSeq,
504
+ loaded: true,
505
+ loading: false,
506
+ error: null
507
+ }));
508
+ } catch (err) {
509
+ patchThread(rootId, (x) => __spreadProps(__spreadValues({}, x), {
510
+ loading: false,
511
+ error: err.message
512
+ }));
513
+ }
514
+ },
515
+ markRead,
516
+ markThreadRead(rootId) {
517
+ var _a, _b, _c;
518
+ const t = get().threads[rootId];
519
+ if (!(t == null ? void 0 : t.loaded)) return;
520
+ const sent = t.replies.filter((r) => !r.pending);
521
+ const last = sent[sent.length - 1];
522
+ const seq = (_c = (_b = last == null ? void 0 : last.seq) != null ? _b : (_a = t.root) == null ? void 0 : _a.seq) != null ? _c : 0;
523
+ if (seq <= t.lastReadSeq) return;
524
+ patchThread(rootId, (x) => __spreadProps(__spreadValues({}, x), {
525
+ lastReadSeq: seq
526
+ }));
527
+ api.markThreadRead(rootId, seq).then(() => refreshMe(), () => void 0);
528
+ },
529
+ async send(input) {
530
+ var _a, _b;
531
+ const me = get().me;
532
+ if (!me) return;
533
+ const clientMsgId = `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
534
+ const optimistic = {
535
+ id: clientMsgId,
536
+ channelId: input.channelId,
537
+ seq: PENDING_SEQ + Date.now() % 1e6,
538
+ kind: "message",
539
+ body: input.body,
540
+ system: null,
541
+ author: {
542
+ id: me.user.id
543
+ },
544
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
545
+ editedAt: null,
546
+ deleted: false,
547
+ threadRootId: (_a = input.threadRootId) != null ? _a : null,
548
+ alsoInChannel: Boolean(input.alsoSendToChannel),
549
+ replyCount: 0,
550
+ replyUsers: [],
551
+ lastReplyAt: null,
552
+ mentions: [],
553
+ mentionAll: false,
554
+ reactions: [],
555
+ files: (_b = input.files) != null ? _b : [],
556
+ pinned: false,
557
+ pinnedBy: null,
558
+ saved: false,
559
+ clientMsgId,
560
+ pending: "sending"
561
+ };
562
+ const place = (m) => {
563
+ if (m.threadRootId) patchThread(m.threadRootId, (t) => t.loaded ? __spreadProps(__spreadValues({}, t), {
564
+ replies: upsertMessage(t.replies, m)
565
+ }) : t);
566
+ if (isChannelLevel(m)) patchHistory(m.channelId, (h) => h.loaded ? __spreadProps(__spreadValues({}, h), {
567
+ messages: upsertMessage(h.messages, m)
568
+ }) : h);
569
+ };
570
+ place(optimistic);
571
+ const attempt = async () => {
572
+ try {
573
+ const real2 = await api.send(__spreadProps(__spreadValues({}, input), {
574
+ clientMsgId
575
+ }));
576
+ place(real2);
577
+ remember([real2]);
578
+ const c = get().channels[input.channelId];
579
+ if (c && isChannelLevel(real2)) putChannel(__spreadProps(__spreadValues({}, c), {
580
+ lastSeq: Math.max(c.lastSeq, real2.seq),
581
+ lastMessageAt: real2.createdAt,
582
+ draft: null,
583
+ membership: c.membership ? __spreadProps(__spreadValues({}, c.membership), {
584
+ lastReadSeq: Math.max(c.membership.lastReadSeq, real2.seq)
585
+ }) : null
586
+ }));
587
+ if (real2.threadRootId) patchThread(real2.threadRootId, (t) => __spreadProps(__spreadValues({}, t), {
588
+ lastReadSeq: Math.max(t.lastReadSeq, real2.seq),
589
+ following: true
590
+ }));
591
+ return real2;
592
+ } catch (err) {
593
+ place(__spreadProps(__spreadValues({}, optimistic), {
594
+ pending: "failed",
595
+ body: input.body
596
+ }));
597
+ throw err;
598
+ }
599
+ };
600
+ retries.set(clientMsgId, attempt);
601
+ const real = await attempt();
602
+ retries.delete(clientMsgId);
603
+ return real;
604
+ },
605
+ async retry(m) {
606
+ const attempt = m.clientMsgId ? retries.get(m.clientMsgId) : null;
607
+ if (!attempt) return;
608
+ const sending = __spreadProps(__spreadValues({}, m), {
609
+ pending: "sending"
610
+ });
611
+ if (m.threadRootId) patchThread(m.threadRootId, (t) => __spreadProps(__spreadValues({}, t), {
612
+ replies: upsertMessage(t.replies, sending)
613
+ }));
614
+ if (isChannelLevel(m)) patchHistory(m.channelId, (h) => __spreadProps(__spreadValues({}, h), {
615
+ messages: upsertMessage(h.messages, sending)
616
+ }));
617
+ try {
618
+ await attempt();
619
+ retries.delete(m.clientMsgId);
620
+ } catch (e) {
621
+ }
622
+ },
623
+ discard(m) {
624
+ if (m.clientMsgId) retries.delete(m.clientMsgId);
625
+ if (m.threadRootId) patchThread(m.threadRootId, (t) => __spreadProps(__spreadValues({}, t), {
626
+ replies: removeMessage(t.replies, m.id)
627
+ }));
628
+ patchHistory(m.channelId, (h) => __spreadProps(__spreadValues({}, h), {
629
+ messages: removeMessage(h.messages, m.id)
630
+ }));
631
+ },
632
+ async edit(m, body) {
633
+ const before = m;
634
+ replaceEverywhere(__spreadProps(__spreadValues({}, m), {
635
+ body,
636
+ editedAt: (/* @__PURE__ */ new Date()).toISOString()
637
+ }));
638
+ try {
639
+ replaceEverywhere(await api.edit(m.id, body));
640
+ } catch (err) {
641
+ replaceEverywhere(before);
642
+ throw err;
643
+ }
644
+ },
645
+ async remove(m) {
646
+ await api.remove(m.id);
647
+ applyDeleted(__spreadProps(__spreadValues({}, m), {
648
+ deleted: true,
649
+ body: "",
650
+ reactions: [],
651
+ files: []
652
+ }));
653
+ },
654
+ async react(m, emoji) {
655
+ var _a;
656
+ const me = (_a = get().me) == null ? void 0 : _a.user.id;
657
+ if (!me) return;
658
+ const has = m.reactions.find((r) => r.emoji === emoji);
659
+ const reactions = has ? has.reacted ? m.reactions.map((r) => r.emoji === emoji ? __spreadProps(__spreadValues({}, r), {
660
+ count: r.count - 1,
661
+ reacted: false,
662
+ userIds: r.userIds.filter((u) => u !== me)
663
+ }) : r).filter((r) => r.count > 0) : m.reactions.map((r) => r.emoji === emoji ? __spreadProps(__spreadValues({}, r), {
664
+ count: r.count + 1,
665
+ reacted: true,
666
+ userIds: [...r.userIds, me]
667
+ }) : r) : [...m.reactions, {
668
+ emoji,
669
+ count: 1,
670
+ reacted: true,
671
+ userIds: [me]
672
+ }];
673
+ replaceEverywhere(__spreadProps(__spreadValues({}, m), {
674
+ reactions
675
+ }));
676
+ try {
677
+ replaceEverywhere(await api.react(m.id, emoji));
678
+ } catch (err) {
679
+ replaceEverywhere(m);
680
+ throw err;
681
+ }
682
+ },
683
+ async pin(m, pinned) {
684
+ replaceEverywhere(await api.pin(m.id, pinned));
685
+ refreshChannel(m.channelId);
686
+ },
687
+ async save(m, saved) {
688
+ replaceEverywhere(__spreadProps(__spreadValues({}, m), {
689
+ saved
690
+ }));
691
+ try {
692
+ await api.save(m.id, saved);
693
+ set((s) => __spreadProps(__spreadValues({}, s), {
694
+ versions: __spreadProps(__spreadValues({}, s.versions), {
695
+ saved: s.versions.saved + 1
696
+ })
697
+ }));
698
+ } catch (err) {
699
+ replaceEverywhere(m);
700
+ throw err;
701
+ }
702
+ },
703
+ async follow(rootId, following) {
704
+ patchThread(rootId, (t) => __spreadProps(__spreadValues({}, t), {
705
+ following
706
+ }));
707
+ await api.follow(rootId, following);
708
+ set((s) => __spreadProps(__spreadValues({}, s), {
709
+ versions: __spreadProps(__spreadValues({}, s.versions), {
710
+ threads: s.versions.threads + 1
711
+ })
712
+ }));
713
+ refreshMe();
714
+ },
715
+ async markUnread(m) {
716
+ putChannel(await api.markUnread(m.channelId, m.seq));
717
+ patchHistory(m.channelId, (h) => __spreadProps(__spreadValues({}, h), {
718
+ openedAtReadSeq: m.seq - 1
719
+ }));
720
+ },
721
+ /** Tell the channel you are typing (throttled; over the socket when it is up). */
722
+ typing(channelId, threadRootId) {
723
+ var _a;
724
+ const key = typingKey(channelId, threadRootId);
725
+ const now = Date.now();
726
+ if (key === typingFor && now - typingAt < 3e3) return;
727
+ typingAt = now;
728
+ typingFor = key;
729
+ const viaSocket = (_a = ctx.live) == null ? void 0 : _a.exec(`mutation($c: ID!, $r: ID) { typing(channelId: $c, threadRootId: $r) }`, {
730
+ c: channelId,
731
+ r: threadRootId
732
+ });
733
+ void Promise.resolve(viaSocket).then((r) => r === null ? api.typing(channelId, threadRootId).catch(() => void 0) : void 0);
734
+ },
735
+ setPresenceActive(active) {
736
+ var _a;
737
+ void ((_a = ctx.live) == null ? void 0 : _a.exec(`mutation($a: Boolean!) { setActive(active: $a) }`, {
738
+ a: active
739
+ }));
740
+ },
741
+ putUser(u) {
742
+ set((s) => __spreadProps(__spreadValues({}, s), {
743
+ people: __spreadProps(__spreadValues({}, s.people), {
744
+ [u.id]: u
745
+ }),
746
+ me: s.me && u.id === s.me.user.id ? __spreadProps(__spreadValues({}, s.me), {
747
+ user: u
748
+ }) : s.me
749
+ }));
750
+ },
751
+ pruneTyping() {
752
+ set((s) => pruneTyping(s));
753
+ },
754
+ bump(key) {
755
+ set((s) => __spreadProps(__spreadValues({}, s), {
756
+ versions: __spreadProps(__spreadValues({}, s.versions), {
757
+ [key]: s.versions[key] + 1
758
+ })
759
+ }));
760
+ }
761
+ };
762
+ function applyDeleted(m) {
763
+ set((s) => {
764
+ var _a, _b;
765
+ let histories = s.histories;
766
+ let threads = s.threads;
767
+ const h = s.histories[m.channelId];
768
+ if (h == null ? void 0 : h.loaded) {
769
+ const list = !m.threadRootId && m.replyCount > 0 ? upsertMessage(h.messages, m, false) : removeMessage(h.messages, m.id);
770
+ if (list !== h.messages) histories = __spreadProps(__spreadValues({}, histories), {
771
+ [m.channelId]: __spreadProps(__spreadValues({}, h), {
772
+ messages: list
773
+ })
774
+ });
775
+ }
776
+ if (m.threadRootId && ((_a = threads[m.threadRootId]) == null ? void 0 : _a.loaded)) {
777
+ const t = threads[m.threadRootId];
778
+ threads = __spreadProps(__spreadValues({}, threads), {
779
+ [m.threadRootId]: __spreadProps(__spreadValues({}, t), {
780
+ replies: removeMessage(t.replies, m.id)
781
+ })
782
+ });
783
+ }
784
+ if (!m.threadRootId && ((_b = threads[m.id]) == null ? void 0 : _b.loaded)) threads = __spreadProps(__spreadValues({}, threads), {
785
+ [m.id]: __spreadProps(__spreadValues({}, threads[m.id]), {
786
+ root: m
787
+ })
788
+ });
789
+ return __spreadProps(__spreadValues({}, s), {
790
+ histories,
791
+ threads,
792
+ latest: __spreadProps(__spreadValues({}, s.latest), {
793
+ [m.id]: m
794
+ })
795
+ });
796
+ });
797
+ }
798
+ }
799
+ const retries = /* @__PURE__ */ new Map();
800
+ function removeFromSidebar(s, id) {
801
+ const c = s.channels[id];
802
+ if (!c) return s;
803
+ return __spreadProps(__spreadValues({}, s), {
804
+ channels: __spreadProps(__spreadValues({}, s.channels), {
805
+ [id]: __spreadProps(__spreadValues({}, c), {
806
+ membership: null
807
+ })
808
+ })
809
+ });
810
+ }
811
+ function reduceEvent(ctx, actions, ev) {
812
+ var _a, _b, _d, _e, _f, _g;
813
+ const s = ctx.get();
814
+ const meId = (_a = s.me) == null ? void 0 : _a.user.id;
815
+ switch (ev.type) {
816
+ case "resync":
817
+ void actions.resync();
818
+ return;
819
+ case "message.created": {
820
+ const m = ev.message;
821
+ if (!m) return;
822
+ if (m.author && !s.people[m.author.id]) void actions.refreshPeople();
823
+ if (m.author) {
824
+ const key = typingKey(m.channelId, m.threadRootId);
825
+ const t = s.typing[key];
826
+ if (t == null ? void 0 : t[m.author.id]) {
827
+ const _c = t, {
828
+ [_b = m.author.id]: _gone
829
+ } = _c, rest = __objRest(_c, [
830
+ __restKey(_b)
831
+ ]);
832
+ ctx.set((st) => __spreadProps(__spreadValues({}, st), {
833
+ typing: __spreadProps(__spreadValues({}, st.typing), {
834
+ [key]: rest
835
+ })
836
+ }));
837
+ }
838
+ }
839
+ placeIncoming(ctx, m);
840
+ const c = ctx.get().channels[m.channelId];
841
+ if (!(c == null ? void 0 : c.membership)) {
842
+ if (!c && ((_d = m.author) == null ? void 0 : _d.id) !== meId) void actions.refreshSidebar();
843
+ else if (c && isChannelLevel(m)) actions.putChannel(__spreadProps(__spreadValues({}, c), {
844
+ lastSeq: Math.max(c.lastSeq, m.seq),
845
+ lastMessageAt: m.createdAt
846
+ }));
847
+ return;
848
+ }
849
+ if (isChannelLevel(m)) {
850
+ actions.putChannel(__spreadProps(__spreadValues({}, c), {
851
+ lastSeq: Math.max(c.lastSeq, m.seq),
852
+ lastMessageAt: m.createdAt,
853
+ membership: __spreadProps(__spreadValues({}, c.membership), {
854
+ hidden: false
855
+ })
856
+ }));
857
+ }
858
+ if (((_e = m.author) == null ? void 0 : _e.id) === meId || m.kind !== "message") return;
859
+ if (m.threadRootId) {
860
+ actions.refreshMe();
861
+ ctx.set((st) => __spreadProps(__spreadValues({}, st), {
862
+ versions: __spreadProps(__spreadValues({}, st.versions), {
863
+ threads: st.versions.threads + 1,
864
+ activity: st.versions.activity + 1
865
+ })
866
+ }));
867
+ if (!m.alsoInChannel) return;
868
+ }
869
+ if (m.mentions.includes(meId != null ? meId : "") || m.mentionAll) {
870
+ actions.refreshMe();
871
+ ctx.set((st) => __spreadProps(__spreadValues({}, st), {
872
+ versions: __spreadProps(__spreadValues({}, st.versions), {
873
+ activity: st.versions.activity + 1
874
+ })
875
+ }));
876
+ }
877
+ actions.refreshChannel(m.channelId);
878
+ return;
879
+ }
880
+ case "message.updated":
881
+ case "thread.updated":
882
+ case "reaction.changed": {
883
+ const m = ev.message;
884
+ if (!m) return;
885
+ if (m.deleted) return void placeDeleted(ctx, m);
886
+ placeUpdate(ctx, m);
887
+ if (ev.type === "reaction.changed" && ((_f = m.author) == null ? void 0 : _f.id) === meId) ctx.set((st) => __spreadProps(__spreadValues({}, st), {
888
+ versions: __spreadProps(__spreadValues({}, st.versions), {
889
+ activity: st.versions.activity + 1
890
+ })
891
+ }));
892
+ if (ev.type === "thread.updated") ctx.set((st) => __spreadProps(__spreadValues({}, st), {
893
+ versions: __spreadProps(__spreadValues({}, st.versions), {
894
+ threads: st.versions.threads + 1
895
+ })
896
+ }));
897
+ return;
898
+ }
899
+ case "message.deleted": {
900
+ const m = ev.message;
901
+ if (m) placeDeleted(ctx, m);
902
+ else if (ev.messageId && ev.channelId) placeDeleted(ctx, {
903
+ id: ev.messageId,
904
+ channelId: ev.channelId,
905
+ threadRootId: ev.rootId,
906
+ replyCount: 0
907
+ });
908
+ if (ev.channelId) actions.refreshChannel(ev.channelId);
909
+ return;
910
+ }
911
+ case "channel.created":
912
+ case "channel.updated":
913
+ if (ev.channel) actions.putChannel(ev.channel);
914
+ else if (ev.channelId) actions.refreshChannel(ev.channelId);
915
+ return;
916
+ case "member.joined":
917
+ case "member.left":
918
+ if (ev.channel) actions.putChannel(ev.channel);
919
+ if (ev.userId === meId) void actions.refreshSidebar();
920
+ else if (ev.channelId) actions.refreshChannel(ev.channelId);
921
+ return;
922
+ case "typing": {
923
+ if (!ev.channelId || !ev.userId || ev.userId === meId) return;
924
+ const key = typingKey(ev.channelId, ev.rootId);
925
+ ctx.set((st) => __spreadProps(__spreadValues({}, st), {
926
+ typing: __spreadProps(__spreadValues({}, st.typing), {
927
+ [key]: __spreadProps(__spreadValues({}, st.typing[key]), {
928
+ [ev.userId]: Date.now() + 6e3
929
+ })
930
+ })
931
+ }));
932
+ return;
933
+ }
934
+ case "presence.changed":
935
+ if (!ev.userId) return;
936
+ if (ev.user) actions.putUser(ev.user);
937
+ else ctx.set((st) => {
938
+ const u = st.people[ev.userId];
939
+ return u && ev.presence ? __spreadProps(__spreadValues({}, st), {
940
+ people: __spreadProps(__spreadValues({}, st.people), {
941
+ [u.id]: __spreadProps(__spreadValues({}, u), {
942
+ presence: ev.presence
943
+ })
944
+ })
945
+ }) : st;
946
+ });
947
+ return;
948
+ case "user.updated":
949
+ if (ev.user) actions.putUser(ev.user);
950
+ return;
951
+ case "read.updated":
952
+ if (ev.channelId) actions.refreshChannel(ev.channelId);
953
+ else {
954
+ actions.refreshMe();
955
+ actions.bump("activity");
956
+ }
957
+ return;
958
+ case "thread.read":
959
+ actions.refreshMe();
960
+ actions.bump("threads");
961
+ if (ev.rootId && ev.seq != null) {
962
+ const t = ctx.get().threads[ev.rootId];
963
+ if ((t == null ? void 0 : t.loaded) && ev.seq > t.lastReadSeq) ctx.set((st) => __spreadProps(__spreadValues({}, st), {
964
+ threads: __spreadProps(__spreadValues({}, st.threads), {
965
+ [ev.rootId]: __spreadProps(__spreadValues({}, t), {
966
+ lastReadSeq: ev.seq
967
+ })
968
+ })
969
+ }));
970
+ } else if (ev.rootId && ((_g = ctx.get().threads[ev.rootId]) == null ? void 0 : _g.loaded)) void actions.loadThread(ev.rootId);
971
+ return;
972
+ case "saved.changed":
973
+ actions.bump("saved");
974
+ if (ev.messageId) void fetchMessage(ev.messageId).then((m) => m && placeUpdate(ctx, m), () => void 0);
975
+ return;
976
+ case "draft.changed":
977
+ actions.bump("drafts");
978
+ if (ev.channelId) actions.refreshChannel(ev.channelId);
979
+ return;
980
+ case "prefs.changed":
981
+ if (ev.channelId) actions.refreshChannel(ev.channelId);
982
+ return;
983
+ }
984
+ }
985
+ function placeIncoming(ctx, m) {
986
+ ctx.set((s) => {
987
+ var _a;
988
+ let histories = s.histories;
989
+ let threads = s.threads;
990
+ const h = s.histories[m.channelId];
991
+ if ((h == null ? void 0 : h.loaded) && !h.hasMoreAfter && isChannelLevel(m)) {
992
+ const list = upsertMessage(h.messages, m);
993
+ if (list !== h.messages) histories = __spreadProps(__spreadValues({}, histories), {
994
+ [m.channelId]: __spreadProps(__spreadValues({}, h), {
995
+ messages: list
996
+ })
997
+ });
998
+ }
999
+ if (m.threadRootId && ((_a = threads[m.threadRootId]) == null ? void 0 : _a.loaded)) {
1000
+ const t = threads[m.threadRootId];
1001
+ const replies = upsertMessage(t.replies, m);
1002
+ if (replies !== t.replies) threads = __spreadProps(__spreadValues({}, threads), {
1003
+ [m.threadRootId]: __spreadProps(__spreadValues({}, t), {
1004
+ replies
1005
+ })
1006
+ });
1007
+ }
1008
+ return __spreadProps(__spreadValues({}, s), {
1009
+ histories,
1010
+ threads,
1011
+ latest: rememberAll(s.latest, [m])
1012
+ });
1013
+ });
1014
+ }
1015
+ function placeUpdate(ctx, m) {
1016
+ ctx.set((s) => {
1017
+ var _a, _b;
1018
+ let histories = s.histories;
1019
+ let threads = s.threads;
1020
+ const h = s.histories[m.channelId];
1021
+ if (h == null ? void 0 : h.loaded) {
1022
+ const list = upsertMessage(h.messages, m, false);
1023
+ if (list !== h.messages) histories = __spreadProps(__spreadValues({}, histories), {
1024
+ [m.channelId]: __spreadProps(__spreadValues({}, h), {
1025
+ messages: list
1026
+ })
1027
+ });
1028
+ }
1029
+ if (!m.threadRootId && ((_a = threads[m.id]) == null ? void 0 : _a.loaded)) threads = __spreadProps(__spreadValues({}, threads), {
1030
+ [m.id]: __spreadProps(__spreadValues({}, threads[m.id]), {
1031
+ root: m
1032
+ })
1033
+ });
1034
+ if (m.threadRootId && ((_b = threads[m.threadRootId]) == null ? void 0 : _b.loaded)) {
1035
+ const t = threads[m.threadRootId];
1036
+ const replies = upsertMessage(t.replies, m, false);
1037
+ if (replies !== t.replies) threads = __spreadProps(__spreadValues({}, threads), {
1038
+ [m.threadRootId]: __spreadProps(__spreadValues({}, t), {
1039
+ replies
1040
+ })
1041
+ });
1042
+ }
1043
+ return __spreadProps(__spreadValues({}, s), {
1044
+ histories,
1045
+ threads,
1046
+ latest: rememberAll(s.latest, [m])
1047
+ });
1048
+ });
1049
+ }
1050
+ function placeDeleted(ctx, m) {
1051
+ ctx.set((s) => {
1052
+ var _a, _b;
1053
+ let histories = s.histories;
1054
+ let threads = s.threads;
1055
+ const h = s.histories[m.channelId];
1056
+ if (h == null ? void 0 : h.loaded) {
1057
+ const list = !m.threadRootId && m.replyCount > 0 ? upsertMessage(h.messages, m, false) : removeMessage(h.messages, m.id);
1058
+ if (list !== h.messages) histories = __spreadProps(__spreadValues({}, histories), {
1059
+ [m.channelId]: __spreadProps(__spreadValues({}, h), {
1060
+ messages: list
1061
+ })
1062
+ });
1063
+ }
1064
+ if (m.threadRootId && ((_a = threads[m.threadRootId]) == null ? void 0 : _a.loaded)) {
1065
+ const t = threads[m.threadRootId];
1066
+ threads = __spreadProps(__spreadValues({}, threads), {
1067
+ [m.threadRootId]: __spreadProps(__spreadValues({}, t), {
1068
+ replies: removeMessage(t.replies, m.id)
1069
+ })
1070
+ });
1071
+ }
1072
+ if (!m.threadRootId && ((_b = threads[m.id]) == null ? void 0 : _b.loaded)) threads = __spreadProps(__spreadValues({}, threads), {
1073
+ [m.id]: __spreadProps(__spreadValues({}, threads[m.id]), {
1074
+ root: m
1075
+ })
1076
+ });
1077
+ const known = s.latest[m.id];
1078
+ const tomb = m.author ? m : known ? __spreadProps(__spreadValues({}, known), {
1079
+ deleted: true,
1080
+ body: "",
1081
+ reactions: [],
1082
+ files: []
1083
+ }) : null;
1084
+ return __spreadProps(__spreadValues({}, s), {
1085
+ histories,
1086
+ threads,
1087
+ latest: tomb ? __spreadProps(__spreadValues({}, s.latest), {
1088
+ [m.id]: tomb
1089
+ }) : s.latest
1090
+ });
1091
+ });
1092
+ }
1093
+ function useChatStore(store, selector) {
1094
+ return useSyncExternalStore(store.subscribe, () => selector(store.getState()), () => selector(store.getState()));
1095
+ }
1096
+ function pruneTyping(s, now = Date.now()) {
1097
+ let changed = false;
1098
+ const typing = {};
1099
+ for (const [key, who] of Object.entries(s.typing)) {
1100
+ const kept = Object.fromEntries(Object.entries(who).filter(([, until]) => until > now));
1101
+ if (Object.keys(kept).length !== Object.keys(who).length) changed = true;
1102
+ if (Object.keys(kept).length) typing[key] = kept;
1103
+ else if (Object.keys(who).length) changed = true;
1104
+ }
1105
+ return changed ? __spreadProps(__spreadValues({}, s), {
1106
+ typing
1107
+ }) : s;
1108
+ }export{createChatStore,pruneTyping,rememberAll,removeMessage,typingKey,upsertMessage,useChatStore};//# sourceMappingURL=store.js.map