@ozdao/martyrs 0.2.521 → 0.2.523

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 (285) hide show
  1. package/dist/_virtual/index.cjs +4 -4
  2. package/dist/_virtual/index.js +4 -4
  3. package/dist/_virtual/index2.cjs +4 -4
  4. package/dist/_virtual/index2.js +4 -4
  5. package/dist/auth.server.cjs +1 -1
  6. package/dist/auth.server.js +1 -1
  7. package/dist/chats.server.cjs +22 -4
  8. package/dist/chats.server.js +22 -4
  9. package/dist/events.server.cjs +1 -1
  10. package/dist/events.server.js +1 -1
  11. package/dist/globals.server.cjs +40 -0
  12. package/dist/globals.server.js +40 -0
  13. package/dist/{mailing-Bs9ThyVZ.cjs → mailing-DCvDBHVh.cjs} +0 -3
  14. package/dist/{mailing-DzlhsxCC.js → mailing-DuEFRsa3.js} +0 -3
  15. package/dist/martyrs/src/components/Button/Button.vue.cjs +1 -1
  16. package/dist/martyrs/src/components/Button/Button.vue.js +1 -1
  17. package/dist/martyrs/src/components/EditImages/EditImages.vue.cjs +0 -93
  18. package/dist/martyrs/src/components/EditImages/EditImages.vue.cjs.map +1 -1
  19. package/dist/martyrs/src/components/EditImages/EditImages.vue.js +1 -94
  20. package/dist/martyrs/src/components/EditImages/EditImages.vue.js.map +1 -1
  21. package/dist/martyrs/src/components/EditImages/EditImages.vue2.cjs +93 -0
  22. package/dist/martyrs/src/components/EditImages/EditImages.vue2.cjs.map +1 -1
  23. package/dist/martyrs/src/components/EditImages/EditImages.vue2.js +94 -1
  24. package/dist/martyrs/src/components/EditImages/EditImages.vue2.js.map +1 -1
  25. package/dist/martyrs/src/components/Feed/Carousel.vue.cjs +1 -1
  26. package/dist/martyrs/src/components/Feed/Carousel.vue.js +1 -1
  27. package/dist/martyrs/src/components/Feed/Feed.vue.cjs +2 -2
  28. package/dist/martyrs/src/components/Feed/Feed.vue.js +2 -2
  29. package/dist/martyrs/src/components/FieldTags/FieldTags.vue.cjs +1 -1
  30. package/dist/martyrs/src/components/FieldTags/FieldTags.vue.js +1 -1
  31. package/dist/martyrs/src/components/Loader/{Loader.vue.cjs → Loader.vue2.cjs} +2 -2
  32. package/dist/martyrs/src/components/Loader/Loader.vue2.cjs.map +1 -0
  33. package/dist/martyrs/src/components/Loader/{Loader.vue.js → Loader.vue2.js} +2 -2
  34. package/dist/martyrs/src/components/Loader/{Loader.vue.cjs.map → Loader.vue2.js.map} +1 -1
  35. package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue.cjs +1 -1
  36. package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue.js +1 -1
  37. package/dist/martyrs/src/components/Menu/{Menu.vue.cjs → Menu.vue2.cjs} +2 -2
  38. package/dist/martyrs/src/components/Menu/Menu.vue2.cjs.map +1 -0
  39. package/dist/martyrs/src/components/Menu/{Menu.vue.js → Menu.vue2.js} +2 -2
  40. package/dist/martyrs/src/components/Menu/Menu.vue2.js.map +1 -0
  41. package/dist/martyrs/src/components/Select/{Select.vue.cjs → Select.vue2.cjs} +2 -2
  42. package/dist/martyrs/src/components/Select/Select.vue2.cjs.map +1 -0
  43. package/dist/martyrs/src/components/Select/{Select.vue.js → Select.vue2.js} +2 -2
  44. package/dist/martyrs/src/components/Select/{Select.vue.cjs.map → Select.vue2.js.map} +1 -1
  45. package/dist/martyrs/src/components/Spoiler/{Spoiler.vue.cjs → Spoiler.vue2.cjs} +2 -2
  46. package/dist/martyrs/src/components/Spoiler/Spoiler.vue2.cjs.map +1 -0
  47. package/dist/martyrs/src/components/Spoiler/{Spoiler.vue.js → Spoiler.vue2.js} +2 -2
  48. package/dist/martyrs/src/components/Spoiler/{Spoiler.vue.cjs.map → Spoiler.vue2.js.map} +1 -1
  49. package/dist/martyrs/src/components/Tab/{Tab.vue.cjs → Tab.vue2.cjs} +2 -2
  50. package/dist/martyrs/src/components/Tab/Tab.vue2.cjs.map +1 -0
  51. package/dist/martyrs/src/components/Tab/{Tab.vue.js → Tab.vue2.js} +2 -2
  52. package/dist/martyrs/src/components/Tab/{Tab.vue.cjs.map → Tab.vue2.js.map} +1 -1
  53. package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.cjs +1 -1
  54. package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.js +1 -1
  55. package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.cjs +1 -1
  56. package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.js +1 -1
  57. package/dist/martyrs/src/modules/auth/views/components/pages/Invite.vue.cjs +1 -1
  58. package/dist/martyrs/src/modules/auth/views/components/pages/Invite.vue.js +1 -1
  59. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +2 -2
  60. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +2 -2
  61. package/dist/martyrs/src/modules/auth/views/components/pages/ProfileBlogposts.vue.cjs +1 -1
  62. package/dist/martyrs/src/modules/auth/views/components/pages/ProfileBlogposts.vue.js +1 -1
  63. package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.cjs +1 -1
  64. package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.js +1 -1
  65. package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.cjs +1 -1
  66. package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.js +1 -1
  67. package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.cjs +1 -1
  68. package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.js +1 -1
  69. package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.cjs +1 -1
  70. package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.js +1 -1
  71. package/dist/martyrs/src/modules/auth/views/store/auth.cjs +4 -6
  72. package/dist/martyrs/src/modules/auth/views/store/auth.cjs.map +1 -1
  73. package/dist/martyrs/src/modules/auth/views/store/auth.js +4 -6
  74. package/dist/martyrs/src/modules/auth/views/store/auth.js.map +1 -1
  75. package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.cjs +5 -1
  76. package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.cjs.map +1 -1
  77. package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.js +5 -1
  78. package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.js.map +1 -1
  79. package/dist/martyrs/src/modules/chats/store/chat.store.cjs +38 -11
  80. package/dist/martyrs/src/modules/chats/store/chat.store.cjs.map +1 -1
  81. package/dist/martyrs/src/modules/chats/store/chat.store.js +38 -11
  82. package/dist/martyrs/src/modules/chats/store/chat.store.js.map +1 -1
  83. package/dist/martyrs/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  84. package/dist/martyrs/src/modules/community/components/layouts/Community.vue.js +1 -1
  85. package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs +1 -1
  86. package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +1 -1
  87. package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  88. package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
  89. package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs +2 -2
  90. package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +2 -2
  91. package/dist/martyrs/src/modules/events/components/pages/Event.vue.cjs +2 -2
  92. package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +2 -2
  93. package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.cjs +1 -1
  94. package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.js +1 -1
  95. package/dist/martyrs/src/modules/events/components/sections/Feed.vue.cjs +1 -1
  96. package/dist/martyrs/src/modules/events/components/sections/Feed.vue.js +1 -1
  97. package/dist/martyrs/src/modules/events/components/sections/List.vue.cjs +1 -1
  98. package/dist/martyrs/src/modules/events/components/sections/List.vue.js +1 -1
  99. package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +2 -2
  100. package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +2 -2
  101. package/dist/martyrs/src/modules/globals/globals.client.cjs +1 -1
  102. package/dist/martyrs/src/modules/globals/globals.client.cjs.map +1 -1
  103. package/dist/martyrs/src/modules/globals/globals.client.js +1 -1
  104. package/dist/martyrs/src/modules/globals/globals.client.js.map +1 -1
  105. package/dist/martyrs/src/modules/globals/views/classes/globals.i18n.cjs +1 -1
  106. package/dist/martyrs/src/modules/globals/views/classes/globals.i18n.js +1 -1
  107. package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.cjs +29 -4
  108. package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.cjs.map +1 -1
  109. package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.js +29 -4
  110. package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.js.map +1 -1
  111. package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +1 -1
  112. package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +1 -1
  113. package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.cjs +1 -1
  114. package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.js +1 -1
  115. package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs +1 -1
  116. package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js +1 -1
  117. package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.cjs +1 -1
  118. package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.js +1 -1
  119. package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs +1 -1
  120. package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js +1 -1
  121. package/dist/martyrs/src/modules/globals/views/components/sections/{Filters.vue.cjs → Filters.vue2.cjs} +2 -2
  122. package/dist/martyrs/src/modules/globals/views/components/sections/Filters.vue2.cjs.map +1 -0
  123. package/dist/martyrs/src/modules/globals/views/components/sections/{Filters.vue.js → Filters.vue2.js} +2 -2
  124. package/dist/martyrs/src/modules/globals/views/components/sections/{Filters.vue.cjs.map → Filters.vue2.js.map} +1 -1
  125. package/dist/martyrs/src/modules/globals/views/components/sections/SectionPageTitle.vue.cjs +1 -1
  126. package/dist/martyrs/src/modules/globals/views/components/sections/SectionPageTitle.vue.js +1 -1
  127. package/dist/martyrs/src/modules/globals/views/components/sections/Walkthrough.vue.cjs +1 -1
  128. package/dist/martyrs/src/modules/globals/views/components/sections/Walkthrough.vue.js +1 -1
  129. package/dist/martyrs/src/modules/inventory/components/forms/AdjustmentForm.vue.cjs +1 -1
  130. package/dist/martyrs/src/modules/inventory/components/forms/AdjustmentForm.vue.js +1 -1
  131. package/dist/martyrs/src/modules/inventory/components/forms/StockAlertsForm.vue.cjs +1 -1
  132. package/dist/martyrs/src/modules/inventory/components/forms/StockAlertsForm.vue.js +1 -1
  133. package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.cjs +1 -1
  134. package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.cjs +1 -1
  135. package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.js +1 -1
  136. package/dist/martyrs/src/modules/landing/components/sections/SectionGuide.vue.cjs +1 -1
  137. package/dist/martyrs/src/modules/landing/components/sections/SectionGuide.vue.js +1 -1
  138. package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.cjs +1 -1
  139. package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.js +1 -1
  140. package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.cjs +1 -1
  141. package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js +1 -1
  142. package/dist/martyrs/src/modules/music/components/forms/AlbumForm.vue.cjs +1 -1
  143. package/dist/martyrs/src/modules/music/components/forms/AlbumForm.vue.js +1 -1
  144. package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.cjs +2 -2
  145. package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.js +2 -2
  146. package/dist/martyrs/src/modules/music/components/forms/TrackForm.vue.cjs +1 -1
  147. package/dist/martyrs/src/modules/music/components/forms/TrackForm.vue.js +1 -1
  148. package/dist/martyrs/src/modules/music/components/pages/Album.vue.cjs +1 -1
  149. package/dist/martyrs/src/modules/music/components/pages/Album.vue.js +1 -1
  150. package/dist/martyrs/src/modules/music/components/pages/Artist.vue.cjs +1 -1
  151. package/dist/martyrs/src/modules/music/components/pages/Artist.vue.js +1 -1
  152. package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.cjs +1 -1
  153. package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.js +1 -1
  154. package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.cjs +1 -1
  155. package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.js +1 -1
  156. package/dist/martyrs/src/modules/music/components/pages/Track.vue.cjs +1 -1
  157. package/dist/martyrs/src/modules/music/components/pages/Track.vue.js +1 -1
  158. package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.cjs +1 -1
  159. package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.js +1 -1
  160. package/dist/martyrs/src/modules/music/router/music.cjs +2 -2
  161. package/dist/martyrs/src/modules/music/router/music.js +2 -2
  162. package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.cjs +1 -1
  163. package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.js +1 -1
  164. package/dist/martyrs/src/modules/notifications/notifications.client.cjs +14 -3
  165. package/dist/martyrs/src/modules/notifications/notifications.client.cjs.map +1 -1
  166. package/dist/martyrs/src/modules/notifications/notifications.client.js +14 -3
  167. package/dist/martyrs/src/modules/notifications/notifications.client.js.map +1 -1
  168. package/dist/martyrs/src/modules/notifications/store/notifications.store.cjs +2 -0
  169. package/dist/martyrs/src/modules/notifications/store/notifications.store.cjs.map +1 -1
  170. package/dist/martyrs/src/modules/notifications/store/notifications.store.js +2 -0
  171. package/dist/martyrs/src/modules/notifications/store/notifications.store.js.map +1 -1
  172. package/dist/martyrs/src/modules/orders/components/forms/FormApplicationDetails.vue.cjs +1 -1
  173. package/dist/martyrs/src/modules/orders/components/forms/FormApplicationDetails.vue.js +1 -1
  174. package/dist/martyrs/src/modules/orders/components/forms/FormCustomerDetails.vue.cjs +1 -1
  175. package/dist/martyrs/src/modules/orders/components/forms/FormCustomerDetails.vue.js +1 -1
  176. package/dist/martyrs/src/modules/orders/components/forms/FormSelectCustomer.vue.cjs +1 -1
  177. package/dist/martyrs/src/modules/orders/components/forms/FormSelectCustomer.vue.js +1 -1
  178. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
  179. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
  180. package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  181. package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +1 -1
  182. package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
  183. package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.js +1 -1
  184. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +2 -2
  185. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +2 -2
  186. package/dist/martyrs/src/modules/orders/components/sections/FormPayment.vue.cjs +1 -1
  187. package/dist/martyrs/src/modules/orders/components/sections/FormPayment.vue.js +1 -1
  188. package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +1 -1
  189. package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.js +1 -1
  190. package/dist/martyrs/src/modules/organizations/components/forms/DepartmentForm.vue.cjs +1 -1
  191. package/dist/martyrs/src/modules/organizations/components/forms/DepartmentForm.vue.js +1 -1
  192. package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.cjs +1 -1
  193. package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.js +1 -1
  194. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  195. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +1 -1
  196. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  197. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  198. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +2 -2
  199. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.js +2 -2
  200. package/dist/martyrs/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
  201. package/dist/martyrs/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
  202. package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  203. package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +1 -1
  204. package/dist/martyrs/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  205. package/dist/martyrs/src/modules/organizations/components/sections/MembersAdd.vue.js +1 -1
  206. package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.cjs +3 -3
  207. package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
  208. package/dist/martyrs/src/modules/organizations/router/organizations.cjs +1 -1
  209. package/dist/martyrs/src/modules/organizations/router/organizations.js +1 -1
  210. package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.cjs +1 -1
  211. package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +1 -1
  212. package/dist/martyrs/src/modules/products/components/elements/Image360.vue.cjs +1 -1
  213. package/dist/martyrs/src/modules/products/components/elements/Image360.vue.js +1 -1
  214. package/dist/martyrs/src/modules/products/components/pages/Categories.vue.cjs +1 -1
  215. package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +1 -1
  216. package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +3 -3
  217. package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +3 -3
  218. package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +2 -2
  219. package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +2 -2
  220. package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.cjs +3 -3
  221. package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.js +3 -3
  222. package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.cjs +1 -1
  223. package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.js +1 -1
  224. package/dist/martyrs/src/modules/products/components/pages/Products.vue.cjs +3 -3
  225. package/dist/martyrs/src/modules/products/components/pages/Products.vue.js +3 -3
  226. package/dist/martyrs/src/modules/products/components/sections/EditDiscounts.vue.cjs +1 -1
  227. package/dist/martyrs/src/modules/products/components/sections/EditDiscounts.vue.js +1 -1
  228. package/dist/martyrs/src/modules/products/components/sections/EditVariants.vue.cjs +2 -2
  229. package/dist/martyrs/src/modules/products/components/sections/EditVariants.vue.js +2 -2
  230. package/dist/martyrs/src/modules/products/components/sections/FilterProducts.vue.cjs +1 -1
  231. package/dist/martyrs/src/modules/products/components/sections/FilterProducts.vue.js +1 -1
  232. package/dist/martyrs/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
  233. package/dist/martyrs/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
  234. package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.cjs +1 -1
  235. package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.js +1 -1
  236. package/dist/martyrs/src/modules/rents/views/components/pages/Rents.vue.cjs +1 -1
  237. package/dist/martyrs/src/modules/rents/views/components/pages/Rents.vue.js +1 -1
  238. package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  239. package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.js +1 -1
  240. package/dist/martyrs/src/modules/spots/components/blocks/SpotMemberModify.vue.cjs +1 -1
  241. package/dist/martyrs/src/modules/spots/components/blocks/SpotMemberModify.vue.js +1 -1
  242. package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
  243. package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.js +1 -1
  244. package/dist/martyrs/src/modules/spots/components/pages/Spot.vue.cjs +1 -1
  245. package/dist/martyrs/src/modules/spots/components/pages/Spot.vue.js +1 -1
  246. package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.cjs +2 -2
  247. package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.js +2 -2
  248. package/dist/martyrs/src/modules/spots/components/sections/WorktimeEdit.vue.cjs +1 -1
  249. package/dist/martyrs/src/modules/spots/components/sections/WorktimeEdit.vue.js +1 -1
  250. package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs +1 -1
  251. package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +1 -1
  252. package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  253. package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js +1 -1
  254. package/dist/notifications.server.cjs +21 -33
  255. package/dist/notifications.server.js +21 -33
  256. package/dist/orders.server.cjs +1 -1
  257. package/dist/orders.server.js +1 -1
  258. package/dist/organizations.server.cjs +1 -1
  259. package/dist/organizations.server.js +1 -1
  260. package/dist/{tickets.controller-DdnndM6c.cjs → tickets.controller-9zoaVPcx.cjs} +1 -1
  261. package/dist/{tickets.controller-C56OvH6v.js → tickets.controller-C8sWVqbB.js} +1 -1
  262. package/dist/wallet.server.cjs +1 -1
  263. package/dist/wallet.server.js +1 -1
  264. package/package.json +1 -1
  265. package/src/modules/auth/views/store/auth.js +6 -10
  266. package/src/modules/chats/components/sections/ChatWindow.vue +10 -1
  267. package/src/modules/chats/models/chat.model.js +5 -1
  268. package/src/modules/chats/routes/chats.routes.js +17 -2
  269. package/src/modules/chats/store/chat.store.js +49 -11
  270. package/src/modules/globals/controllers/classes/globals.websocket.js +56 -2
  271. package/src/modules/globals/controllers/utils/mailing.js +0 -4
  272. package/src/modules/globals/globals.client.js +3 -4
  273. package/src/modules/globals/views/classes/globals.websocket.js +40 -4
  274. package/src/modules/notifications/controllers/notifications.controller.js +27 -36
  275. package/src/modules/notifications/notifications.client.js +17 -4
  276. package/src/modules/notifications/store/notifications.store.js +2 -0
  277. package/dist/martyrs/src/components/Loader/Loader.vue.js.map +0 -1
  278. package/dist/martyrs/src/components/Menu/Menu.vue.cjs.map +0 -1
  279. package/dist/martyrs/src/components/Menu/Menu.vue.js.map +0 -1
  280. package/dist/martyrs/src/components/Select/Select.vue.js.map +0 -1
  281. package/dist/martyrs/src/components/Spoiler/Spoiler.vue.js.map +0 -1
  282. package/dist/martyrs/src/components/Tab/Tab.vue.js.map +0 -1
  283. package/dist/martyrs/src/modules/globals/views/components/sections/Filters.vue.js.map +0 -1
  284. package/src/modules/chats/CLAUDE.md +0 -137
  285. package/src/modules/globals/views/classes/globals.websocket.ws.js +0 -212
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.client.cjs","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { toRefs, watch } from 'vue';\n// Router import\nimport routerNotifications from './router/notifications.router.js';\n// Store\nimport * as storeNotifications from './store/notifications.store.js';\n// Auth store import\n// Global WebSocket import\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\n// Capacitor Preferences\nimport { Preferences } from '@capacitor/preferences';\n// Layouts\nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue';\n// Sections\nimport NotificationPreferences from './components/sections/NotificationPreferences.vue';\nimport NotificationsList from './components/sections/NotificationsList.vue';\n// Pages\nimport Notifications from './components/pages/Notifications.vue';\n// Components\nimport NotificationItem from './components/blocks/NotificationItem.vue';\nimport NotificationBadge from './components/elements/NotificationBadge.vue';\n\n/**\n * Capacitor Push Notification handler\n */\nclass CapacitorPushHandler {\n constructor(store) {\n this.store = store;\n this.pushNotifications = null;\n this.device = null;\n this.isInitialized = false;\n }\n\n /**\n * Initialize Capacitor plugins\n */\n async initialize() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n // Dynamic imports to prevent errors in web environment\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n\n this.capacitor = Capacitor;\n this.pushNotifications = PushNotifications;\n this.device = Device;\n\n // Only proceed if running on a native platform\n if (!this.capacitor.isNativePlatform()) {\n return false;\n }\n\n this.isInitialized = true;\n return true;\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n }\n\n /**\n * Request permission and register for push notifications\n */\n async requestPermissions() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n if (!this.isInitialized) {\n const initialized = await this.initialize();\n if (!initialized) return false;\n }\n\n try {\n // Request permission\n const permissionResult = await this.pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n\n // Set up event listeners\n this._setupListeners();\n\n // Register with Apple/Google\n await this.pushNotifications.register();\n return true;\n } catch (error) {\n console.error('Error requesting push notification permissions:', error);\n return false;\n }\n }\n\n /**\n * Setup push notification event listeners\n */\n _setupListeners() {\n // Registration event\n this.pushNotifications.addListener('registration', this._handleRegistration.bind(this));\n\n // Notification received event\n this.pushNotifications.addListener('pushNotificationReceived', this._handleNotificationReceived.bind(this));\n\n // Notification action performed event\n this.pushNotifications.addListener('pushNotificationActionPerformed', this._handleNotificationAction.bind(this));\n }\n\n /**\n * Handle registration token received\n */\n async _handleRegistration(token) {\n try {\n // Get device info\n const deviceInfo = await this.device.getInfo();\n const deviceId = await this.device.getId();\n\n // Prepare device data\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value,\n };\n\n // For anonymous users, add anonymousId\n if (!this.store.auth.state.user?._id) {\n let anonymousId = null;\n try {\n const result = await Preferences.get({ key: 'notifications_anonymous_id' });\n anonymousId = result.value;\n } catch (error) {\n console.warn('Could not get anonymous ID from preferences:', error);\n }\n \n if (!anonymousId) {\n anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n deviceData.anonymousId = anonymousId;\n }\n\n // Register device with backend\n await this.store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n }\n\n /**\n * Handle received notification\n */\n _handleNotificationReceived(notification) {\n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {},\n });\n }\n\n /**\n * Handle notification action (when user taps on notification)\n */\n _handleNotificationAction(actionData) {\n if (actionData.notification && actionData.notification.data) {\n this.store.notifications.actions.handleNotificationAction(actionData.notification.data);\n }\n }\n\n /**\n * Remove push notification listeners\n */\n removeListeners() {\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.pushNotifications) {\n this.pushNotifications.removeAllListeners();\n }\n }\n}\n\n/**\n * Notification Manager for coordinating WebSocket and Push notifications\n */\n\nclass NotificationManager {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.pushHandler = new CapacitorPushHandler(store);\n this.initialized = false;\n this.isServer = typeof window === 'undefined';\n }\n\n async registerWebPush(store) {\n if (!('Notification' in window) || !('serviceWorker' in navigator) || !('PushManager' in window)) {\n console.warn('Web Push не поддерживается в браузере');\n return;\n }\n\n const permission = await Notification.requestPermission();\n if (permission !== 'granted') {\n console.warn('Разрешение на уведомления не получено');\n return;\n }\n\n const registration = await navigator.serviceWorker.ready;\n const subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: 'BJtNnRrx05VQS0abnkHC-8gHJWpnmoqC_iQveENCmZOZIs-adWzqAiqFCdGVVd7CbiaLW-Q5iuIBDRgM9G-VnKg',\n });\n\n console.log('New subscription:', JSON.stringify(subscription));\n\n const deviceToken = JSON.stringify(subscription);\n const deviceId = await this.generateDeviceId();\n \n // Store device data for re-registration after login\n try {\n await Preferences.set({\n key: 'notifications_device_token',\n value: deviceToken\n });\n } catch (error) {\n console.warn('Could not save device token to preferences:', error);\n }\n\n const deviceData = {\n deviceToken,\n deviceType: 'web',\n deviceId\n };\n\n // For anonymous users, get or generate anonymousId\n if (!store.auth.state.user?._id) {\n let anonymousId = null;\n try {\n const result = await Preferences.get({ key: 'notifications_anonymous_id' });\n anonymousId = result.value;\n } catch (error) {\n console.warn('Could not get anonymous ID from preferences:', error);\n }\n \n if (!anonymousId) {\n anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n deviceData.anonymousId = anonymousId;\n }\n\n // Register device\n await store.notifications.actions.registerDevice(deviceData);\n }\n\n async generateDeviceId() {\n // Try to get or generate a persistent device ID\n try {\n const result = await Preferences.get({ key: 'notifications_device_id' });\n let deviceId = result.value;\n \n if (!deviceId) {\n deviceId = 'web_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n await Preferences.set({\n key: 'notifications_device_id',\n value: deviceId\n });\n }\n return deviceId;\n } catch (error) {\n console.warn('Could not access preferences for device ID:', error);\n return 'web_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n }\n }\n\n async initialize() {\n if (this.initialized || this.isServer) return;\n\n const userId = this.store.auth.state.user?._id;\n \n // Connect WebSocket only for authenticated users\n if (userId) {\n console.log('Connecting to websockets via notifications');\n globalWebSocket.initialize({\n wsUrl: process.env.WSS_URL,\n maxReconnectAttempts: 10,\n reconnectDelay: 2000,\n });\n\n await globalWebSocket.connect(userId);\n\n globalWebSocket.removeModuleListeners('notification');\n\n await globalWebSocket.subscribeModule('notification');\n\n globalWebSocket.addEventListener(\n 'notification',\n data => {\n this.store.notifications.actions.addLocalNotification(data.data);\n },\n { module: 'notification' }\n );\n\n // Load notifications from API for authenticated users\n await this.store.notifications.actions.getNotifications(userId);\n } else {\n console.log('Initializing notifications for anonymous user');\n }\n\n // Enable push notifications for both authenticated and anonymous users\n // Skip auto-init for mobile apps - will be triggered manually from Walkthrough\n if (this.options.enablePush !== false && !process.env.MOBILE_APP) {\n await this.pushHandler.requestPermissions();\n await this.registerWebPush(this.store);\n }\n\n this.initialized = true;\n }\n\n disconnect() {\n if (this.isServer) return;\n\n globalWebSocket.removeModuleListeners('notification');\n this.pushHandler.removeListeners();\n this.initialized = false;\n }\n}\n\n/**\n * Server-side utility for pre-fetching notification data\n */\nconst SSRUtils = {\n /**\n * Pre-fetch notifications for SSR\n * @param {Object} store - Store instance\n * @param {Object} context - SSR context\n */\n async prefetchNotifications(store, context) {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n // Fetch notifications without WebSocket or push setup\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n },\n};\n\n/**\n * Function to initialize the notifications module\n * @param {Object} app - Vue app instance\n * @param {Object} store - Vuex/Pinia store\n * @param {Object} router - Vue Router instance\n * @param {Object} options - Configuration options\n */\nfunction initializeNotifications(app, store, router, options = {}) {\n // Add routes and store\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n\n // Initialize global WebSocket if needed\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: process.env.WSS_URL });\n }\n\n // Create notification manager\n const notificationManager = new NotificationManager(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000,\n });\n\n // Attach notification manager to store for access in components\n store.notificationManager = notificationManager;\n\n // Don't auto-initialize on server\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n\n if (autoInit) {\n // Initialize immediately (supports both authenticated and anonymous users)\n notificationManager.initialize();\n\n // Watch for user login/logout using auth store\n watch(\n () => store.auth.state.access.status,\n isAuthenticated => {\n if (isAuthenticated) {\n // Re-register device for authenticated user\n store.notifications.actions.reregisterDeviceAfterLogin();\n // Reinitialize for authenticated user\n notificationManager.disconnect();\n notificationManager.initialize();\n } else {\n // Keep notifications active for anonymous users, just reset user-specific data\n store.notifications.mutations.resetNotifications();\n }\n }\n );\n }\n\n // Provide composable for components to access notification functionality\n app.provide('useNotifications', () => {\n return {\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: notificationManager.initialize.bind(notificationManager),\n disconnect: notificationManager.disconnect.bind(notificationManager),\n isServer,\n };\n });\n\n return notificationManager;\n}\n\n// Module export\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n SSR: SSRUtils, // Export SSR utilities\n views: {\n store: {\n storeNotifications,\n },\n router: {\n routerNotifications,\n },\n components: {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n },\n },\n};\n\n// Component exports\nexport {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n // Sections\n NotificationsList,\n // SSR Utilities\n SSRUtils,\n};\n\nexport default ModuleNotifications;\n"],"names":["Preferences","globalWebSocket","routerNotifications","storeNotifications","watch","toRefs","NotificationBadge","NotificationItem","NotificationsList","NotificationPreferences","Notifications","NotificationsLayout"],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,qBAAqB;AAAA,EACzB,YAAY,OAAO;AACjB,SAAK,QAAQ;AACb,SAAK,oBAAoB;AACzB,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA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,SAAO;AACT;AAGK,MAAC,sBAAsB;AAAA,EAC1B,YAAY;AAAA,EACZ,KAAK;AAAA;AAAA,EACL,OAAO;AAAA,IACL,OAAO;AAAA,MACX,oBAAMF;AAAAA,IACN;AAAA,IACI,QAAQ;AAAA,MACZ,qBAAMD,qBAAAA;AAAAA,IACN;AAAA,IACI,YAAY;AAAA;AAAA,MAEhB,mBAAMI,kBAAAA;AAAAA;AAAAA,MAEN,kBAAMC,iBAAAA;AAAAA;AAAAA,MAEN,mBAAMC,kBAAAA;AAAAA,MACN,yBAAMC,wBAAAA;AAAAA;AAAAA,MAEN,eAAMC,cAAAA;AAAAA;AAAAA,MAEN,qBAAMC,oBAAAA;AAAAA,IACN;AAAA,EACA;AACA;;;;;;;;;"}
1
+ {"version":3,"file":"notifications.client.cjs","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { toRefs, watch } from 'vue';\n// Router import\nimport routerNotifications from './router/notifications.router.js';\n// Store\nimport * as storeNotifications from './store/notifications.store.js';\n// Auth store import\n// Global WebSocket import\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\n// Capacitor Preferences\nimport { Preferences } from '@capacitor/preferences';\n// Layouts\nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue';\n// Sections\nimport NotificationPreferences from './components/sections/NotificationPreferences.vue';\nimport NotificationsList from './components/sections/NotificationsList.vue';\n// Pages\nimport Notifications from './components/pages/Notifications.vue';\n// Components\nimport NotificationItem from './components/blocks/NotificationItem.vue';\nimport NotificationBadge from './components/elements/NotificationBadge.vue';\n\n/**\n * Capacitor Push Notification handler\n */\nclass CapacitorPushHandler {\n constructor(store) {\n this.store = store;\n this.pushNotifications = null;\n this.device = null;\n this.isInitialized = false;\n }\n\n /**\n * Initialize Capacitor plugins\n */\n async initialize() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n // Dynamic imports to prevent errors in web environment\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n\n this.capacitor = Capacitor;\n this.pushNotifications = PushNotifications;\n this.device = Device;\n\n // Only proceed if running on a native platform\n if (!this.capacitor.isNativePlatform()) {\n return false;\n }\n\n this.isInitialized = true;\n return true;\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n }\n\n /**\n * Request permission and register for push notifications\n */\n async requestPermissions() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n if (!this.isInitialized) {\n const initialized = await this.initialize();\n if (!initialized) return false;\n }\n\n try {\n // Request permission\n const permissionResult = await this.pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n\n // Set up event listeners\n this._setupListeners();\n\n // Register with Apple/Google\n await this.pushNotifications.register();\n return true;\n } catch (error) {\n console.error('Error requesting push notification permissions:', error);\n return false;\n }\n }\n\n /**\n * Setup push notification event listeners\n */\n _setupListeners() {\n // Registration event\n this.pushNotifications.addListener('registration', this._handleRegistration.bind(this));\n\n // Notification received event\n this.pushNotifications.addListener('pushNotificationReceived', this._handleNotificationReceived.bind(this));\n\n // Notification action performed event\n this.pushNotifications.addListener('pushNotificationActionPerformed', this._handleNotificationAction.bind(this));\n }\n\n /**\n * Handle registration token received\n */\n async _handleRegistration(token) {\n try {\n // Get device info\n const deviceInfo = await this.device.getInfo();\n const deviceId = await this.device.getId();\n\n // Prepare device data\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value,\n };\n\n // For anonymous users, add anonymousId\n if (!this.store.auth.state.user?._id) {\n let anonymousId = null;\n try {\n const result = await Preferences.get({ key: 'notifications_anonymous_id' });\n anonymousId = result.value;\n } catch (error) {\n console.warn('Could not get anonymous ID from preferences:', error);\n }\n \n if (!anonymousId) {\n anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n deviceData.anonymousId = anonymousId;\n }\n\n // Register device with backend\n await this.store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n }\n\n /**\n * Handle received notification\n */\n _handleNotificationReceived(notification) {\n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {},\n });\n }\n\n /**\n * Handle notification action (when user taps on notification)\n */\n _handleNotificationAction(actionData) {\n if (actionData.notification && actionData.notification.data) {\n this.store.notifications.actions.handleNotificationAction(actionData.notification.data);\n }\n }\n\n /**\n * Remove push notification listeners\n */\n removeListeners() {\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.pushNotifications) {\n this.pushNotifications.removeAllListeners();\n }\n }\n}\n\n/**\n * Notification Manager for coordinating WebSocket and Push notifications\n */\n\nclass NotificationManager {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.pushHandler = new CapacitorPushHandler(store);\n this.initialized = false;\n this.isServer = typeof window === 'undefined';\n }\n\n async registerWebPush(store) {\n if (!('Notification' in window) || !('serviceWorker' in navigator) || !('PushManager' in window)) {\n console.warn('Web Push не поддерживается в браузере');\n return;\n }\n\n const permission = await Notification.requestPermission();\n if (permission !== 'granted') {\n console.warn('Разрешение на уведомления не получено');\n return;\n }\n\n const registration = await navigator.serviceWorker.ready;\n const subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: 'BJtNnRrx05VQS0abnkHC-8gHJWpnmoqC_iQveENCmZOZIs-adWzqAiqFCdGVVd7CbiaLW-Q5iuIBDRgM9G-VnKg',\n });\n\n console.log('New subscription:', JSON.stringify(subscription));\n\n const deviceToken = JSON.stringify(subscription);\n const deviceId = await this.generateDeviceId();\n \n // Store device data for re-registration after login\n try {\n await Preferences.set({\n key: 'notifications_device_token',\n value: deviceToken\n });\n } catch (error) {\n console.warn('Could not save device token to preferences:', error);\n }\n\n const deviceData = {\n deviceToken,\n deviceType: 'web',\n deviceId\n };\n\n // For anonymous users, get or generate anonymousId\n if (!store.auth.state.user?._id) {\n let anonymousId = null;\n try {\n const result = await Preferences.get({ key: 'notifications_anonymous_id' });\n anonymousId = result.value;\n } catch (error) {\n console.warn('Could not get anonymous ID from preferences:', error);\n }\n \n if (!anonymousId) {\n anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n deviceData.anonymousId = anonymousId;\n }\n\n // Register device\n console.log('[Notifications] Registering device with data:', deviceData);\n await store.notifications.actions.registerDevice(deviceData);\n }\n\n async generateDeviceId() {\n // Try to get or generate a persistent device ID\n try {\n const result = await Preferences.get({ key: 'notifications_device_id' });\n let deviceId = result.value;\n \n if (!deviceId) {\n deviceId = 'web_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n await Preferences.set({\n key: 'notifications_device_id',\n value: deviceId\n });\n }\n return deviceId;\n } catch (error) {\n console.warn('Could not access preferences for device ID:', error);\n return 'web_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n }\n }\n\n async initialize() {\n if (this.initialized || this.isServer) return;\n\n const userId = this.store.auth.state.user?._id;\n \n // Connect WebSocket only for authenticated users\n if (userId) {\n console.log('Connecting to websockets via notifications');\n globalWebSocket.initialize({\n wsUrl: process.env.WSS_URL,\n maxReconnectAttempts: 10,\n reconnectDelay: 2000,\n });\n\n await globalWebSocket.connect(userId);\n\n globalWebSocket.removeModuleListeners('notification');\n\n await globalWebSocket.subscribeModule('notification');\n\n globalWebSocket.addEventListener(\n 'notification',\n data => {\n this.store.notifications.actions.addLocalNotification(data.data);\n },\n { module: 'notification' }\n );\n\n // Load notifications from API for authenticated users\n await this.store.notifications.actions.getNotifications(userId);\n } else {\n console.log('Initializing notifications for anonymous user');\n }\n\n // Enable push notifications for both authenticated and anonymous users\n // Skip auto-init for mobile apps - will be triggered manually from Walkthrough\n if (this.options.enablePush !== false && !process.env.MOBILE_APP) {\n await this.pushHandler.requestPermissions();\n await this.registerWebPush(this.store);\n }\n\n this.initialized = true;\n }\n\n disconnect() {\n if (this.isServer) return;\n\n globalWebSocket.removeModuleListeners('notification');\n this.pushHandler.removeListeners();\n this.initialized = false;\n }\n}\n\n/**\n * Server-side utility for pre-fetching notification data\n */\nconst SSRUtils = {\n /**\n * Pre-fetch notifications for SSR\n * @param {Object} store - Store instance\n * @param {Object} context - SSR context\n */\n async prefetchNotifications(store, context) {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n // Fetch notifications without WebSocket or push setup\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n },\n};\n\n/**\n * Function to initialize the notifications module\n * @param {Object} app - Vue app instance\n * @param {Object} store - Vuex/Pinia store\n * @param {Object} router - Vue Router instance\n * @param {Object} options - Configuration options\n */\nfunction initializeNotifications(app, store, router, options = {}) {\n // Add routes and store\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n \n console.log('[Notifications] Initializing, auth store exists:', !!store.auth);\n console.log('[Notifications] Auth state:', store.auth?.state);\n\n // Initialize global WebSocket if needed\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: process.env.WSS_URL });\n }\n\n // Create notification manager\n const notificationManager = new NotificationManager(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000,\n });\n\n // Attach notification manager to store for access in components\n store.notificationManager = notificationManager;\n\n // Don't auto-initialize on server\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n\n if (autoInit) {\n // Initialize immediately (supports both authenticated and anonymous users)\n notificationManager.initialize();\n\n // Watch for user login/logout using auth store\n console.log('[Notifications] Setting up auth watcher...');\n if (!store.auth) {\n console.error('[Notifications] Auth store not found! Cannot set up watcher.');\n return;\n }\n \n watch(\n () => store.auth.state.access.status,\n async (isAuthenticated) => {\n console.log('[Notifications] Auth status changed:', isAuthenticated);\n if (isAuthenticated) {\n // Re-register device for authenticated user\n console.log('[Notifications] User logged in, re-registering device...');\n await store.notifications.actions.reregisterDeviceAfterLogin();\n // Reinitialize notifications for authenticated user\n notificationManager.disconnect();\n await notificationManager.initialize();\n } else {\n // Keep notifications active for anonymous users, just reset user-specific data\n console.log('[Notifications] User logged out, resetting notifications...');\n store.notifications.mutations.resetNotifications();\n }\n }\n );\n }\n\n // Provide composable for components to access notification functionality\n app.provide('useNotifications', () => {\n return {\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: notificationManager.initialize.bind(notificationManager),\n disconnect: notificationManager.disconnect.bind(notificationManager),\n isServer,\n };\n });\n\n return notificationManager;\n}\n\n// Module export\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n SSR: SSRUtils, // Export SSR utilities\n views: {\n store: {\n storeNotifications,\n },\n router: {\n routerNotifications,\n },\n components: {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n },\n },\n};\n\n// Component exports\nexport {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n // Sections\n NotificationsList,\n // SSR Utilities\n SSRUtils,\n};\n\nexport default ModuleNotifications;\n"],"names":["Preferences","globalWebSocket","routerNotifications","storeNotifications","watch","toRefs","NotificationBadge","NotificationItem","NotificationsList","NotificationPreferences","Notifications","NotificationsLayout"],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,qBAAqB;AAAA,EACzB,YAAY,OAAO;AACjB,SAAK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;AAE5D,8BAAoB,WAAU;AAC9B,gBAAM,oBAAoB,WAAU;AAAA,QACtC,OAAO;AAEL,kBAAQ,IAAI,6DAA6D;AACzE,gBAAM,cAAc,UAAU,mBAAkB;AAAA,QAClD;AAAA,MACF;AAAA,IACN;AAAA,EACE;AAGA,MAAI,QAAQ,oBAAoB,MAAM;AACpC,WAAO;AAAA,MACL,GAAGC,WAAO,MAAM,cAAc,KAAK;AAAA,MACnC,GAAG,MAAM,cAAc;AAAA,MACvB,GAAG,MAAM,cAAc;AAAA,MACvB,MAAM,oBAAoB,WAAW,KAAK,mBAAmB;AAAA,MAC7D,YAAY,oBAAoB,WAAW,KAAK,mBAAmB;AAAA,MACnE;AAAA,IACN;AAAA,EACE,CAAC;AAED,SAAO;AACT;AAGK,MAAC,sBAAsB;AAAA,EAC1B,YAAY;AAAA,EACZ,KAAK;AAAA;AAAA,EACL,OAAO;AAAA,IACL,OAAO;AAAA,MACX,oBAAMF;AAAAA,IACN;AAAA,IACI,QAAQ;AAAA,MACZ,qBAAMD,qBAAAA;AAAAA,IACN;AAAA,IACI,YAAY;AAAA;AAAA,MAEhB,mBAAMI,kBAAAA;AAAAA;AAAAA,MAEN,kBAAMC,iBAAAA;AAAAA;AAAAA,MAEN,mBAAMC,kBAAAA;AAAAA,MACN,yBAAMC,wBAAAA;AAAAA;AAAAA,MAEN,eAAMC,cAAAA;AAAAA;AAAAA,MAEN,qBAAMC,oBAAAA;AAAAA,IACN;AAAA,EACA;AACA;;;;;;;;;"}
@@ -201,6 +201,7 @@ class NotificationManager {
201
201
  }
202
202
  deviceData.anonymousId = anonymousId;
203
203
  }
204
+ console.log("[Notifications] Registering device with data:", deviceData);
204
205
  await store.notifications.actions.registerDevice(deviceData);
205
206
  }
206
207
  async generateDeviceId() {
@@ -278,6 +279,8 @@ function initializeNotifications(app, store, router, options = {}) {
278
279
  const route = options.route || "User Profile Root";
279
280
  router.addRoute(route, nofitications);
280
281
  store.addStore("notifications", notifications_store);
282
+ console.log("[Notifications] Initializing, auth store exists:", !!store.auth);
283
+ console.log("[Notifications] Auth state:", store.auth?.state);
281
284
  if (options.wsUrl) {
282
285
  globalWebSocket.initialize({ wsUrl: process.env.WSS_URL });
283
286
  }
@@ -292,14 +295,22 @@ function initializeNotifications(app, store, router, options = {}) {
292
295
  const autoInit = !isServer && options.autoInit !== false;
293
296
  if (autoInit) {
294
297
  notificationManager.initialize();
298
+ console.log("[Notifications] Setting up auth watcher...");
299
+ if (!store.auth) {
300
+ console.error("[Notifications] Auth store not found! Cannot set up watcher.");
301
+ return;
302
+ }
295
303
  watch(
296
304
  () => store.auth.state.access.status,
297
- (isAuthenticated) => {
305
+ async (isAuthenticated) => {
306
+ console.log("[Notifications] Auth status changed:", isAuthenticated);
298
307
  if (isAuthenticated) {
299
- store.notifications.actions.reregisterDeviceAfterLogin();
308
+ console.log("[Notifications] User logged in, re-registering device...");
309
+ await store.notifications.actions.reregisterDeviceAfterLogin();
300
310
  notificationManager.disconnect();
301
- notificationManager.initialize();
311
+ await notificationManager.initialize();
302
312
  } else {
313
+ console.log("[Notifications] User logged out, resetting notifications...");
303
314
  store.notifications.mutations.resetNotifications();
304
315
  }
305
316
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.client.js","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { toRefs, watch } from 'vue';\n// Router import\nimport routerNotifications from './router/notifications.router.js';\n// Store\nimport * as storeNotifications from './store/notifications.store.js';\n// Auth store import\n// Global WebSocket import\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\n// Capacitor Preferences\nimport { Preferences } from '@capacitor/preferences';\n// Layouts\nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue';\n// Sections\nimport NotificationPreferences from './components/sections/NotificationPreferences.vue';\nimport NotificationsList from './components/sections/NotificationsList.vue';\n// Pages\nimport Notifications from './components/pages/Notifications.vue';\n// Components\nimport NotificationItem from './components/blocks/NotificationItem.vue';\nimport NotificationBadge from './components/elements/NotificationBadge.vue';\n\n/**\n * Capacitor Push Notification handler\n */\nclass CapacitorPushHandler {\n constructor(store) {\n this.store = store;\n this.pushNotifications = null;\n this.device = null;\n this.isInitialized = false;\n }\n\n /**\n * Initialize Capacitor plugins\n */\n async initialize() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n // Dynamic imports to prevent errors in web environment\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n\n this.capacitor = Capacitor;\n this.pushNotifications = PushNotifications;\n this.device = Device;\n\n // Only proceed if running on a native platform\n if (!this.capacitor.isNativePlatform()) {\n return false;\n }\n\n this.isInitialized = true;\n return true;\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n }\n\n /**\n * Request permission and register for push notifications\n */\n async requestPermissions() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n if (!this.isInitialized) {\n const initialized = await this.initialize();\n if (!initialized) return false;\n }\n\n try {\n // Request permission\n const permissionResult = await this.pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n\n // Set up event listeners\n this._setupListeners();\n\n // Register with Apple/Google\n await this.pushNotifications.register();\n return true;\n } catch (error) {\n console.error('Error requesting push notification permissions:', error);\n return false;\n }\n }\n\n /**\n * Setup push notification event listeners\n */\n _setupListeners() {\n // Registration event\n this.pushNotifications.addListener('registration', this._handleRegistration.bind(this));\n\n // Notification received event\n this.pushNotifications.addListener('pushNotificationReceived', this._handleNotificationReceived.bind(this));\n\n // Notification action performed event\n this.pushNotifications.addListener('pushNotificationActionPerformed', this._handleNotificationAction.bind(this));\n }\n\n /**\n * Handle registration token received\n */\n async _handleRegistration(token) {\n try {\n // Get device info\n const deviceInfo = await this.device.getInfo();\n const deviceId = await this.device.getId();\n\n // Prepare device data\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value,\n };\n\n // For anonymous users, add anonymousId\n if (!this.store.auth.state.user?._id) {\n let anonymousId = null;\n try {\n const result = await Preferences.get({ key: 'notifications_anonymous_id' });\n anonymousId = result.value;\n } catch (error) {\n console.warn('Could not get anonymous ID from preferences:', error);\n }\n \n if (!anonymousId) {\n anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n deviceData.anonymousId = anonymousId;\n }\n\n // Register device with backend\n await this.store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n }\n\n /**\n * Handle received notification\n */\n _handleNotificationReceived(notification) {\n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {},\n });\n }\n\n /**\n * Handle notification action (when user taps on notification)\n */\n _handleNotificationAction(actionData) {\n if (actionData.notification && actionData.notification.data) {\n this.store.notifications.actions.handleNotificationAction(actionData.notification.data);\n }\n }\n\n /**\n * Remove push notification listeners\n */\n removeListeners() {\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.pushNotifications) {\n this.pushNotifications.removeAllListeners();\n }\n }\n}\n\n/**\n * Notification Manager for coordinating WebSocket and Push notifications\n */\n\nclass NotificationManager {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.pushHandler = new CapacitorPushHandler(store);\n this.initialized = false;\n this.isServer = typeof window === 'undefined';\n }\n\n async registerWebPush(store) {\n if (!('Notification' in window) || !('serviceWorker' in navigator) || !('PushManager' in window)) {\n console.warn('Web Push не поддерживается в браузере');\n return;\n }\n\n const permission = await Notification.requestPermission();\n if (permission !== 'granted') {\n console.warn('Разрешение на уведомления не получено');\n return;\n }\n\n const registration = await navigator.serviceWorker.ready;\n const subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: 'BJtNnRrx05VQS0abnkHC-8gHJWpnmoqC_iQveENCmZOZIs-adWzqAiqFCdGVVd7CbiaLW-Q5iuIBDRgM9G-VnKg',\n });\n\n console.log('New subscription:', JSON.stringify(subscription));\n\n const deviceToken = JSON.stringify(subscription);\n const deviceId = await this.generateDeviceId();\n \n // Store device data for re-registration after login\n try {\n await Preferences.set({\n key: 'notifications_device_token',\n value: deviceToken\n });\n } catch (error) {\n console.warn('Could not save device token to preferences:', error);\n }\n\n const deviceData = {\n deviceToken,\n deviceType: 'web',\n deviceId\n };\n\n // For anonymous users, get or generate anonymousId\n if (!store.auth.state.user?._id) {\n let anonymousId = null;\n try {\n const result = await Preferences.get({ key: 'notifications_anonymous_id' });\n anonymousId = result.value;\n } catch (error) {\n console.warn('Could not get anonymous ID from preferences:', error);\n }\n \n if (!anonymousId) {\n anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n deviceData.anonymousId = anonymousId;\n }\n\n // Register device\n await store.notifications.actions.registerDevice(deviceData);\n }\n\n async generateDeviceId() {\n // Try to get or generate a persistent device ID\n try {\n const result = await Preferences.get({ key: 'notifications_device_id' });\n let deviceId = result.value;\n \n if (!deviceId) {\n deviceId = 'web_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n await Preferences.set({\n key: 'notifications_device_id',\n value: deviceId\n });\n }\n return deviceId;\n } catch (error) {\n console.warn('Could not access preferences for device ID:', error);\n return 'web_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n }\n }\n\n async initialize() {\n if (this.initialized || this.isServer) return;\n\n const userId = this.store.auth.state.user?._id;\n \n // Connect WebSocket only for authenticated users\n if (userId) {\n console.log('Connecting to websockets via notifications');\n globalWebSocket.initialize({\n wsUrl: process.env.WSS_URL,\n maxReconnectAttempts: 10,\n reconnectDelay: 2000,\n });\n\n await globalWebSocket.connect(userId);\n\n globalWebSocket.removeModuleListeners('notification');\n\n await globalWebSocket.subscribeModule('notification');\n\n globalWebSocket.addEventListener(\n 'notification',\n data => {\n this.store.notifications.actions.addLocalNotification(data.data);\n },\n { module: 'notification' }\n );\n\n // Load notifications from API for authenticated users\n await this.store.notifications.actions.getNotifications(userId);\n } else {\n console.log('Initializing notifications for anonymous user');\n }\n\n // Enable push notifications for both authenticated and anonymous users\n // Skip auto-init for mobile apps - will be triggered manually from Walkthrough\n if (this.options.enablePush !== false && !process.env.MOBILE_APP) {\n await this.pushHandler.requestPermissions();\n await this.registerWebPush(this.store);\n }\n\n this.initialized = true;\n }\n\n disconnect() {\n if (this.isServer) return;\n\n globalWebSocket.removeModuleListeners('notification');\n this.pushHandler.removeListeners();\n this.initialized = false;\n }\n}\n\n/**\n * Server-side utility for pre-fetching notification data\n */\nconst SSRUtils = {\n /**\n * Pre-fetch notifications for SSR\n * @param {Object} store - Store instance\n * @param {Object} context - SSR context\n */\n async prefetchNotifications(store, context) {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n // Fetch notifications without WebSocket or push setup\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n },\n};\n\n/**\n * Function to initialize the notifications module\n * @param {Object} app - Vue app instance\n * @param {Object} store - Vuex/Pinia store\n * @param {Object} router - Vue Router instance\n * @param {Object} options - Configuration options\n */\nfunction initializeNotifications(app, store, router, options = {}) {\n // Add routes and store\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n\n // Initialize global WebSocket if needed\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: process.env.WSS_URL });\n }\n\n // Create notification manager\n const notificationManager = new NotificationManager(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000,\n });\n\n // Attach notification manager to store for access in components\n store.notificationManager = notificationManager;\n\n // Don't auto-initialize on server\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n\n if (autoInit) {\n // Initialize immediately (supports both authenticated and anonymous users)\n notificationManager.initialize();\n\n // Watch for user login/logout using auth store\n watch(\n () => store.auth.state.access.status,\n isAuthenticated => {\n if (isAuthenticated) {\n // Re-register device for authenticated user\n store.notifications.actions.reregisterDeviceAfterLogin();\n // Reinitialize for authenticated user\n notificationManager.disconnect();\n notificationManager.initialize();\n } else {\n // Keep notifications active for anonymous users, just reset user-specific data\n store.notifications.mutations.resetNotifications();\n }\n }\n );\n }\n\n // Provide composable for components to access notification functionality\n app.provide('useNotifications', () => {\n return {\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: notificationManager.initialize.bind(notificationManager),\n disconnect: notificationManager.disconnect.bind(notificationManager),\n isServer,\n };\n });\n\n return notificationManager;\n}\n\n// Module export\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n SSR: SSRUtils, // Export SSR utilities\n views: {\n store: {\n storeNotifications,\n },\n router: {\n routerNotifications,\n },\n components: {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n },\n },\n};\n\n// Component exports\nexport {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n // Sections\n NotificationsList,\n // SSR Utilities\n SSRUtils,\n};\n\nexport default ModuleNotifications;\n"],"names":["routerNotifications","storeNotifications","Notifications","NotificationsLayout"],"mappings":";;;;;;;;;;;AAwBA,MAAM,qBAAqB;AAAA,EACzB,YAAY,OAAO;AACjB,SAAK,QAAQ;AACb,SAAK,oBAAoB;AACzB,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACvB;AAA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YAAY;AAAA;AAAA,MAEV;AAAA;AAAA,MAEA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA;AAAA,MAEN,eAAME;AAAAA;AAAAA,MAEN,qBAAMC;AAAAA,IACN;AAAA,EACA;AACA;"}
1
+ {"version":3,"file":"notifications.client.js","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { toRefs, watch } from 'vue';\n// Router import\nimport routerNotifications from './router/notifications.router.js';\n// Store\nimport * as storeNotifications from './store/notifications.store.js';\n// Auth store import\n// Global WebSocket import\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\n// Capacitor Preferences\nimport { Preferences } from '@capacitor/preferences';\n// Layouts\nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue';\n// Sections\nimport NotificationPreferences from './components/sections/NotificationPreferences.vue';\nimport NotificationsList from './components/sections/NotificationsList.vue';\n// Pages\nimport Notifications from './components/pages/Notifications.vue';\n// Components\nimport NotificationItem from './components/blocks/NotificationItem.vue';\nimport NotificationBadge from './components/elements/NotificationBadge.vue';\n\n/**\n * Capacitor Push Notification handler\n */\nclass CapacitorPushHandler {\n constructor(store) {\n this.store = store;\n this.pushNotifications = null;\n this.device = null;\n this.isInitialized = false;\n }\n\n /**\n * Initialize Capacitor plugins\n */\n async initialize() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n // Dynamic imports to prevent errors in web environment\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n\n this.capacitor = Capacitor;\n this.pushNotifications = PushNotifications;\n this.device = Device;\n\n // Only proceed if running on a native platform\n if (!this.capacitor.isNativePlatform()) {\n return false;\n }\n\n this.isInitialized = true;\n return true;\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n }\n\n /**\n * Request permission and register for push notifications\n */\n async requestPermissions() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n if (!this.isInitialized) {\n const initialized = await this.initialize();\n if (!initialized) return false;\n }\n\n try {\n // Request permission\n const permissionResult = await this.pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n\n // Set up event listeners\n this._setupListeners();\n\n // Register with Apple/Google\n await this.pushNotifications.register();\n return true;\n } catch (error) {\n console.error('Error requesting push notification permissions:', error);\n return false;\n }\n }\n\n /**\n * Setup push notification event listeners\n */\n _setupListeners() {\n // Registration event\n this.pushNotifications.addListener('registration', this._handleRegistration.bind(this));\n\n // Notification received event\n this.pushNotifications.addListener('pushNotificationReceived', this._handleNotificationReceived.bind(this));\n\n // Notification action performed event\n this.pushNotifications.addListener('pushNotificationActionPerformed', this._handleNotificationAction.bind(this));\n }\n\n /**\n * Handle registration token received\n */\n async _handleRegistration(token) {\n try {\n // Get device info\n const deviceInfo = await this.device.getInfo();\n const deviceId = await this.device.getId();\n\n // Prepare device data\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value,\n };\n\n // For anonymous users, add anonymousId\n if (!this.store.auth.state.user?._id) {\n let anonymousId = null;\n try {\n const result = await Preferences.get({ key: 'notifications_anonymous_id' });\n anonymousId = result.value;\n } catch (error) {\n console.warn('Could not get anonymous ID from preferences:', error);\n }\n \n if (!anonymousId) {\n anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n deviceData.anonymousId = anonymousId;\n }\n\n // Register device with backend\n await this.store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n }\n\n /**\n * Handle received notification\n */\n _handleNotificationReceived(notification) {\n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {},\n });\n }\n\n /**\n * Handle notification action (when user taps on notification)\n */\n _handleNotificationAction(actionData) {\n if (actionData.notification && actionData.notification.data) {\n this.store.notifications.actions.handleNotificationAction(actionData.notification.data);\n }\n }\n\n /**\n * Remove push notification listeners\n */\n removeListeners() {\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.pushNotifications) {\n this.pushNotifications.removeAllListeners();\n }\n }\n}\n\n/**\n * Notification Manager for coordinating WebSocket and Push notifications\n */\n\nclass NotificationManager {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.pushHandler = new CapacitorPushHandler(store);\n this.initialized = false;\n this.isServer = typeof window === 'undefined';\n }\n\n async registerWebPush(store) {\n if (!('Notification' in window) || !('serviceWorker' in navigator) || !('PushManager' in window)) {\n console.warn('Web Push не поддерживается в браузере');\n return;\n }\n\n const permission = await Notification.requestPermission();\n if (permission !== 'granted') {\n console.warn('Разрешение на уведомления не получено');\n return;\n }\n\n const registration = await navigator.serviceWorker.ready;\n const subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: 'BJtNnRrx05VQS0abnkHC-8gHJWpnmoqC_iQveENCmZOZIs-adWzqAiqFCdGVVd7CbiaLW-Q5iuIBDRgM9G-VnKg',\n });\n\n console.log('New subscription:', JSON.stringify(subscription));\n\n const deviceToken = JSON.stringify(subscription);\n const deviceId = await this.generateDeviceId();\n \n // Store device data for re-registration after login\n try {\n await Preferences.set({\n key: 'notifications_device_token',\n value: deviceToken\n });\n } catch (error) {\n console.warn('Could not save device token to preferences:', error);\n }\n\n const deviceData = {\n deviceToken,\n deviceType: 'web',\n deviceId\n };\n\n // For anonymous users, get or generate anonymousId\n if (!store.auth.state.user?._id) {\n let anonymousId = null;\n try {\n const result = await Preferences.get({ key: 'notifications_anonymous_id' });\n anonymousId = result.value;\n } catch (error) {\n console.warn('Could not get anonymous ID from preferences:', error);\n }\n \n if (!anonymousId) {\n anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n deviceData.anonymousId = anonymousId;\n }\n\n // Register device\n console.log('[Notifications] Registering device with data:', deviceData);\n await store.notifications.actions.registerDevice(deviceData);\n }\n\n async generateDeviceId() {\n // Try to get or generate a persistent device ID\n try {\n const result = await Preferences.get({ key: 'notifications_device_id' });\n let deviceId = result.value;\n \n if (!deviceId) {\n deviceId = 'web_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n await Preferences.set({\n key: 'notifications_device_id',\n value: deviceId\n });\n }\n return deviceId;\n } catch (error) {\n console.warn('Could not access preferences for device ID:', error);\n return 'web_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n }\n }\n\n async initialize() {\n if (this.initialized || this.isServer) return;\n\n const userId = this.store.auth.state.user?._id;\n \n // Connect WebSocket only for authenticated users\n if (userId) {\n console.log('Connecting to websockets via notifications');\n globalWebSocket.initialize({\n wsUrl: process.env.WSS_URL,\n maxReconnectAttempts: 10,\n reconnectDelay: 2000,\n });\n\n await globalWebSocket.connect(userId);\n\n globalWebSocket.removeModuleListeners('notification');\n\n await globalWebSocket.subscribeModule('notification');\n\n globalWebSocket.addEventListener(\n 'notification',\n data => {\n this.store.notifications.actions.addLocalNotification(data.data);\n },\n { module: 'notification' }\n );\n\n // Load notifications from API for authenticated users\n await this.store.notifications.actions.getNotifications(userId);\n } else {\n console.log('Initializing notifications for anonymous user');\n }\n\n // Enable push notifications for both authenticated and anonymous users\n // Skip auto-init for mobile apps - will be triggered manually from Walkthrough\n if (this.options.enablePush !== false && !process.env.MOBILE_APP) {\n await this.pushHandler.requestPermissions();\n await this.registerWebPush(this.store);\n }\n\n this.initialized = true;\n }\n\n disconnect() {\n if (this.isServer) return;\n\n globalWebSocket.removeModuleListeners('notification');\n this.pushHandler.removeListeners();\n this.initialized = false;\n }\n}\n\n/**\n * Server-side utility for pre-fetching notification data\n */\nconst SSRUtils = {\n /**\n * Pre-fetch notifications for SSR\n * @param {Object} store - Store instance\n * @param {Object} context - SSR context\n */\n async prefetchNotifications(store, context) {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n // Fetch notifications without WebSocket or push setup\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n },\n};\n\n/**\n * Function to initialize the notifications module\n * @param {Object} app - Vue app instance\n * @param {Object} store - Vuex/Pinia store\n * @param {Object} router - Vue Router instance\n * @param {Object} options - Configuration options\n */\nfunction initializeNotifications(app, store, router, options = {}) {\n // Add routes and store\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n \n console.log('[Notifications] Initializing, auth store exists:', !!store.auth);\n console.log('[Notifications] Auth state:', store.auth?.state);\n\n // Initialize global WebSocket if needed\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: process.env.WSS_URL });\n }\n\n // Create notification manager\n const notificationManager = new NotificationManager(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000,\n });\n\n // Attach notification manager to store for access in components\n store.notificationManager = notificationManager;\n\n // Don't auto-initialize on server\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n\n if (autoInit) {\n // Initialize immediately (supports both authenticated and anonymous users)\n notificationManager.initialize();\n\n // Watch for user login/logout using auth store\n console.log('[Notifications] Setting up auth watcher...');\n if (!store.auth) {\n console.error('[Notifications] Auth store not found! Cannot set up watcher.');\n return;\n }\n \n watch(\n () => store.auth.state.access.status,\n async (isAuthenticated) => {\n console.log('[Notifications] Auth status changed:', isAuthenticated);\n if (isAuthenticated) {\n // Re-register device for authenticated user\n console.log('[Notifications] User logged in, re-registering device...');\n await store.notifications.actions.reregisterDeviceAfterLogin();\n // Reinitialize notifications for authenticated user\n notificationManager.disconnect();\n await notificationManager.initialize();\n } else {\n // Keep notifications active for anonymous users, just reset user-specific data\n console.log('[Notifications] User logged out, resetting notifications...');\n store.notifications.mutations.resetNotifications();\n }\n }\n );\n }\n\n // Provide composable for components to access notification functionality\n app.provide('useNotifications', () => {\n return {\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: notificationManager.initialize.bind(notificationManager),\n disconnect: notificationManager.disconnect.bind(notificationManager),\n isServer,\n };\n });\n\n return notificationManager;\n}\n\n// Module export\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n SSR: SSRUtils, // Export SSR utilities\n views: {\n store: {\n storeNotifications,\n },\n router: {\n routerNotifications,\n },\n components: {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n },\n },\n};\n\n// Component exports\nexport {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n // Sections\n NotificationsList,\n // SSR Utilities\n SSRUtils,\n};\n\nexport default ModuleNotifications;\n"],"names":["routerNotifications","storeNotifications","Notifications","NotificationsLayout"],"mappings":";;;;;;;;;;;AAwBA,MAAM,qBAAqB;AAAA,EACzB,YAAY,OAAO;AACjB,SAAK,QAAQ;AACb,SAAK,oBAAoB;AACzB,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAAa;AAEjB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AAEA,QAAI;AAEF,YAAM,EAAE,UAAS,IAAK,MAAM,OAAO,8FAAiB;AACpD,YAAM,EAAE,kBAAiB,IAAK,MAAM,OAAO,uJAA+B;AAC1E,YAAM,EAAE,OAAM,IAAK,MAAM,OAAO,+HAAmB;AAEnD,WAAK,YAAY;AACjB,WAAK,oBAAoB;A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;AAAA,MACZ,qBAAMD;AAAAA,IACN;AAAA,IACI,YAAY;AAAA;AAAA,MAEV;AAAA;AAAA,MAEA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA;AAAA,MAEN,eAAME;AAAAA;AAAAA,MAEN,qBAAMC;AAAAA,IACN;AAAA,EACA;AACA;"}
@@ -109,7 +109,9 @@ const actions = {
109
109
  }
110
110
  }
111
111
  }
112
+ console.log("[Notifications Store] Registering device:", deviceData);
112
113
  const response = await axiosInstance.default.post("/api/notifications/devices/register", deviceData);
114
+ console.log("[Notifications Store] Device registered successfully:", response.data);
113
115
  state.deviceRegistered = true;
114
116
  return response.data;
115
117
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.store.cjs","sources":["../../../../../../src/modules/notifications/store/notifications.store.js"],"sourcesContent":["// Dependencies\nimport { computed, reactive, watch } from 'vue';\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals.js';\n// Auth\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n// Capacitor Preferences\nimport { Preferences } from '@capacitor/preferences';\n\n// Initial state for a notification\nconst notificationInitState = {\n _id: null,\n title: '',\n body: '',\n type: 'info',\n metadata: {},\n userId: null,\n status: 'pending',\n createdAt: null,\n updatedAt: null,\n};\n\n// Initial state for notification preferences\nconst preferencesInitState = {\n web: true,\n push: true,\n email: true,\n sms: true,\n telegram: false,\n whatsapp: false,\n};\n\n// State declaration\nconst state = reactive({\n notifications: [],\n unreadCount: 0,\n current: { ...notificationInitState },\n preferences: { ...preferencesInitState },\n deviceRegistered: false,\n loading: false,\n lastSync: null,\n});\n\nconst actions = {\n /**\n * Get user notifications from server\n */\n async getNotifications(userId = null) {\n try {\n // Use provided userId or get from auth store\n const userIdToUse = userId || auth.state.user._id;\n\n if (!userIdToUse) {\n console.warn('Cannot get notifications: No user ID found');\n return [];\n }\n\n state.loading = true;\n const response = await $axios.get(`/api/notifications/user/${userIdToUse}`);\n state.notifications = response.data;\n state.lastSync = new Date().toISOString();\n updateUnreadCount();\n state.loading = false;\n return response.data;\n } catch (error) {\n state.loading = false;\n setError(error);\n throw error;\n }\n },\n\n /**\n * Mark a notification as read\n */\n async markAsRead(notificationId) {\n try {\n const response = await $axios.put(`/api/notifications/${notificationId}/read`);\n\n // Update the notification in the local state\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index] = response.data;\n updateUnreadCount();\n }\n\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Synchronize notification status without API call\n * (For use with WebSocket updates)\n */\n syncNotificationStatus(notificationId, status) {\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index].status = status;\n state.notifications[index].updatedAt = new Date().toISOString();\n updateUnreadCount();\n }\n },\n\n /**\n * Register a device for push notifications\n */\n async registerDevice(deviceData) {\n try {\n const userId = auth.state.user?._id;\n \n if (userId) {\n // Registered user\n deviceData.userId = userId;\n } else {\n // Anonymous user - generate or use existing anonymousId\n if (!deviceData.anonymousId) {\n // Generate anonymous ID if not provided\n deviceData.anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n // Store in Capacitor Preferences for persistence\n if (typeof window !== 'undefined') {\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: deviceData.anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n }\n }\n\n const response = await $axios.post('/api/notifications/devices/register', deviceData);\n state.deviceRegistered = true;\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Re-register device after user login\n */\n async reregisterDeviceAfterLogin() {\n try {\n const deviceIdResult = await Preferences.get({ key: 'notifications_device_id' });\n const deviceTokenResult = await Preferences.get({ key: 'notifications_device_token' });\n \n const deviceId = deviceIdResult.value;\n const deviceToken = deviceTokenResult.value;\n \n if (deviceId && deviceToken) {\n await this.registerDevice({\n deviceId,\n deviceToken,\n deviceType: 'web'\n });\n }\n } catch (error) {\n console.error('Error re-registering device after login:', error);\n }\n },\n\n /**\n * Update notification preferences\n */\n async updatePreferences(preferences) {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot update preferences: No user ID found');\n return;\n }\n\n // Transform preferences object to array format expected by the API\n const preferencesArray = Object.entries(preferences).map(([channelType, isEnabled]) => {\n return {\n channelType,\n notificationType: 'all', // Default type, can be made more specific\n isEnabled,\n };\n });\n\n const response = await $axios.put('/api/notifications/preferences', {\n userId,\n preferences: preferencesArray,\n });\n\n // Update state with new preferences\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Get notification preferences\n */\n async getPreferences() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot get preferences: No user ID found');\n return;\n }\n\n // Assuming an endpoint exists to fetch preferences\n const response = await $axios.get(`/api/notifications/preferences/${userId}`);\n\n // Transform API response to our state format\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n // If API fails, use default preferences\n state.preferences = { ...preferencesInitState };\n throw error;\n }\n },\n\n /**\n * Add a local notification (for handling push notifications or WebSocket notifications)\n */\n addLocalNotification(notification) {\n // Check if notification already exists by ID to prevent duplicates\n if (notification._id) {\n const existingIndex = state.notifications.findIndex(n => n._id === notification._id);\n if (existingIndex !== -1) {\n // Update existing notification\n state.notifications[existingIndex] = {\n ...state.notifications[existingIndex],\n ...notification,\n updatedAt: new Date().toISOString(),\n };\n updateUnreadCount();\n return;\n }\n }\n\n // Create a notification object that matches our expected format\n const newNotification = {\n _id: notification._id || Date.now().toString(), // Use provided ID or generate temporary one\n title: notification.title,\n body: notification.body,\n type: notification.type || notification.data?.type || 'info',\n metadata: notification.data || notification.metadata || {},\n status: notification.status || 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString(),\n };\n\n // Add to local state\n state.notifications.unshift(newNotification);\n updateUnreadCount();\n },\n\n /**\n * Handle notification action (e.g., when user taps on push notification)\n */\n handleNotificationAction(data) {\n // Mark notification as read if ID is provided\n if (data.notificationId) {\n actions.markAsRead(data.notificationId);\n }\n\n return true\n\n // // Navigate based on notification type and metadata\n // if (data.route) {\n // // router.push(data.route);\n // alert('1');\n // } else if (data.type === 'order') {\n // // router.push(`/orders/${data.orderId}`);\n // alert('2');\n // } else if (data.type === 'message') {\n // // router.push('/messages');\n // alert('3');\n // } else {\n // // Default to notifications page\n // // router.push('/notifications');\n // alert('4');\n // }\n },\n\n /**\n * Mark all notifications as read\n */\n async markAllAsRead() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot mark all as read: No user ID found');\n return;\n }\n\n console.log('=== markAllAsRead API call ===');\n console.log('URL:', `/api/notifications/user/${userId}/read-all`);\n \n const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);\n \n console.log('markAllAsRead response status:', response.status);\n console.log('markAllAsRead response data:', response.data);\n\n // Update all notifications in local state\n state.notifications.forEach(notification => {\n notification.status = 'read';\n notification.updatedAt = new Date().toISOString();\n });\n\n updateUnreadCount();\n console.log('Local state updated, unread count:', state.unreadCount);\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n};\n\nconst mutations = {\n resetNotifications() {\n state.notifications = [];\n state.unreadCount = 0;\n state.lastSync = null;\n },\n\n resetCurrent() {\n state.current = { ...notificationInitState };\n },\n\n resetPreferences() {\n state.preferences = { ...preferencesInitState };\n },\n};\n\n// Helper functions\nfunction updateUnreadCount() {\n state.unreadCount = state.notifications.filter(n => n.status !== 'read').length;\n}\n\n// Track state changes\nconst history = [];\nhistory.push(state);\n\nwatch(state, newState => {\n history.push(newState);\n});\n\n// Computed properties\nconst getters = {\n unreadNotifications: computed(() => {\n return state.notifications.filter(n => n.status !== 'read');\n }),\n\n readNotifications: computed(() => {\n return state.notifications.filter(n => n.status === 'read');\n }),\n\n notificationsByType: computed(() => {\n const result = {};\n state.notifications.forEach(notification => {\n if (!result[notification.type]) {\n result[notification.type] = [];\n }\n result[notification.type].push(notification);\n });\n return result;\n }),\n};\n\nexport { actions, getters, mutations, state };\n"],"names":["reactive","auth.state","$axios","setError","index","Preferences","watch","computed"],"mappings":";;;;;;;AAYA,MAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,CAAA;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAGA,MAAM,uBAAuB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AACZ;AAGK,MAAC,QAAQA,IAAAA,SAAS;AAAA,EACrB,eAAe,CAAA;AAAA,EACf,aAAa;AAAA,EACb,SAAS,EAAE,GAAG,sBAAqB;AAAA,EACnC,aAAa,EAAE,GAAG,qBAAoB;AAAA,EACtC,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,UAAU;AACZ,CAAC;AAEI,MAAC,UAAU;AAAA;AAAA;AAAA;AAAA,EAId,MAAM,iBAAiB,SAAS,MAAM;AACpC,QAAI;AAEF,YAAM,cAAc,UAAUC,KAAAA,MAAW,KAAK;AAE9C,UAAI,CAAC,aAAa;AAChB,gBAAQ,KAAK,4CAA4C;AACzD,eAAO,CAAA;AAAA,MACT;AAEA,YAAM,UAAU;AAChB,YAAM,WAAW,MAAMC,sBAAO,IAAI,2BAA2B,WAAW,EAAE;AAC1E,YAAM,gBAAgB,SAAS;AAC/B,YAAM,YAA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,EAAE,GAAG,sBAAqB;AAAA,EAC5C;AAAA,EAEA,mBAAmB;AACjB,UAAM,cAAc,EAAE,GAAG,qBAAoB;AAAA,EAC/C;AACF;AAGA,SAAS,oBAAoB;AAC3B,QAAM,cAAc,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM,EAAE;AAC3E;AAMAG,IAAAA,MAAM,OAAO,cAAY;AAEzB,CAAC;AAGI,MAAC,UAAU;AAAA,EACd,qBAAqBC,IAAAA,SAAS,MAAM;AAClC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC5D,CAAC;AAAA,EAED,mBAAmBA,IAAAA,SAAS,MAAM;AAChC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC5D,CAAC;AAAA,EAED,qBAAqBA,IAAAA,SAAS,MAAM;AAClC,UAAM,SAAS,CAAA;AACf,UAAM,cAAc,QAAQ,kBAAgB;AAC1C,UAAI,CAAC,OAAO,aAAa,IAAI,GAAG;AAC9B,eAAO,aAAa,IAAI,IAAI,CAAA;AAAA,MAC9B;AACA,aAAO,aAAa,IAAI,EAAE,KAAK,YAAY;AAAA,IAC7C,CAAC;AACD,WAAO;AAAA,EACT,CAAC;AACH;;;;;"}
1
+ {"version":3,"file":"notifications.store.cjs","sources":["../../../../../../src/modules/notifications/store/notifications.store.js"],"sourcesContent":["// Dependencies\nimport { computed, reactive, watch } from 'vue';\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals.js';\n// Auth\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n// Capacitor Preferences\nimport { Preferences } from '@capacitor/preferences';\n\n// Initial state for a notification\nconst notificationInitState = {\n _id: null,\n title: '',\n body: '',\n type: 'info',\n metadata: {},\n userId: null,\n status: 'pending',\n createdAt: null,\n updatedAt: null,\n};\n\n// Initial state for notification preferences\nconst preferencesInitState = {\n web: true,\n push: true,\n email: true,\n sms: true,\n telegram: false,\n whatsapp: false,\n};\n\n// State declaration\nconst state = reactive({\n notifications: [],\n unreadCount: 0,\n current: { ...notificationInitState },\n preferences: { ...preferencesInitState },\n deviceRegistered: false,\n loading: false,\n lastSync: null,\n});\n\nconst actions = {\n /**\n * Get user notifications from server\n */\n async getNotifications(userId = null) {\n try {\n // Use provided userId or get from auth store\n const userIdToUse = userId || auth.state.user._id;\n\n if (!userIdToUse) {\n console.warn('Cannot get notifications: No user ID found');\n return [];\n }\n\n state.loading = true;\n const response = await $axios.get(`/api/notifications/user/${userIdToUse}`);\n state.notifications = response.data;\n state.lastSync = new Date().toISOString();\n updateUnreadCount();\n state.loading = false;\n return response.data;\n } catch (error) {\n state.loading = false;\n setError(error);\n throw error;\n }\n },\n\n /**\n * Mark a notification as read\n */\n async markAsRead(notificationId) {\n try {\n const response = await $axios.put(`/api/notifications/${notificationId}/read`);\n\n // Update the notification in the local state\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index] = response.data;\n updateUnreadCount();\n }\n\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Synchronize notification status without API call\n * (For use with WebSocket updates)\n */\n syncNotificationStatus(notificationId, status) {\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index].status = status;\n state.notifications[index].updatedAt = new Date().toISOString();\n updateUnreadCount();\n }\n },\n\n /**\n * Register a device for push notifications\n */\n async registerDevice(deviceData) {\n try {\n const userId = auth.state.user?._id;\n \n if (userId) {\n // Registered user\n deviceData.userId = userId;\n } else {\n // Anonymous user - generate or use existing anonymousId\n if (!deviceData.anonymousId) {\n // Generate anonymous ID if not provided\n deviceData.anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n // Store in Capacitor Preferences for persistence\n if (typeof window !== 'undefined') {\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: deviceData.anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n }\n }\n\n console.log('[Notifications Store] Registering device:', deviceData);\n const response = await $axios.post('/api/notifications/devices/register', deviceData);\n console.log('[Notifications Store] Device registered successfully:', response.data);\n state.deviceRegistered = true;\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Re-register device after user login\n */\n async reregisterDeviceAfterLogin() {\n try {\n const deviceIdResult = await Preferences.get({ key: 'notifications_device_id' });\n const deviceTokenResult = await Preferences.get({ key: 'notifications_device_token' });\n \n const deviceId = deviceIdResult.value;\n const deviceToken = deviceTokenResult.value;\n \n if (deviceId && deviceToken) {\n await this.registerDevice({\n deviceId,\n deviceToken,\n deviceType: 'web'\n });\n }\n } catch (error) {\n console.error('Error re-registering device after login:', error);\n }\n },\n\n /**\n * Update notification preferences\n */\n async updatePreferences(preferences) {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot update preferences: No user ID found');\n return;\n }\n\n // Transform preferences object to array format expected by the API\n const preferencesArray = Object.entries(preferences).map(([channelType, isEnabled]) => {\n return {\n channelType,\n notificationType: 'all', // Default type, can be made more specific\n isEnabled,\n };\n });\n\n const response = await $axios.put('/api/notifications/preferences', {\n userId,\n preferences: preferencesArray,\n });\n\n // Update state with new preferences\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Get notification preferences\n */\n async getPreferences() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot get preferences: No user ID found');\n return;\n }\n\n // Assuming an endpoint exists to fetch preferences\n const response = await $axios.get(`/api/notifications/preferences/${userId}`);\n\n // Transform API response to our state format\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n // If API fails, use default preferences\n state.preferences = { ...preferencesInitState };\n throw error;\n }\n },\n\n /**\n * Add a local notification (for handling push notifications or WebSocket notifications)\n */\n addLocalNotification(notification) {\n // Check if notification already exists by ID to prevent duplicates\n if (notification._id) {\n const existingIndex = state.notifications.findIndex(n => n._id === notification._id);\n if (existingIndex !== -1) {\n // Update existing notification\n state.notifications[existingIndex] = {\n ...state.notifications[existingIndex],\n ...notification,\n updatedAt: new Date().toISOString(),\n };\n updateUnreadCount();\n return;\n }\n }\n\n // Create a notification object that matches our expected format\n const newNotification = {\n _id: notification._id || Date.now().toString(), // Use provided ID or generate temporary one\n title: notification.title,\n body: notification.body,\n type: notification.type || notification.data?.type || 'info',\n metadata: notification.data || notification.metadata || {},\n status: notification.status || 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString(),\n };\n\n // Add to local state\n state.notifications.unshift(newNotification);\n updateUnreadCount();\n },\n\n /**\n * Handle notification action (e.g., when user taps on push notification)\n */\n handleNotificationAction(data) {\n // Mark notification as read if ID is provided\n if (data.notificationId) {\n actions.markAsRead(data.notificationId);\n }\n\n return true\n\n // // Navigate based on notification type and metadata\n // if (data.route) {\n // // router.push(data.route);\n // alert('1');\n // } else if (data.type === 'order') {\n // // router.push(`/orders/${data.orderId}`);\n // alert('2');\n // } else if (data.type === 'message') {\n // // router.push('/messages');\n // alert('3');\n // } else {\n // // Default to notifications page\n // // router.push('/notifications');\n // alert('4');\n // }\n },\n\n /**\n * Mark all notifications as read\n */\n async markAllAsRead() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot mark all as read: No user ID found');\n return;\n }\n\n console.log('=== markAllAsRead API call ===');\n console.log('URL:', `/api/notifications/user/${userId}/read-all`);\n \n const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);\n \n console.log('markAllAsRead response status:', response.status);\n console.log('markAllAsRead response data:', response.data);\n\n // Update all notifications in local state\n state.notifications.forEach(notification => {\n notification.status = 'read';\n notification.updatedAt = new Date().toISOString();\n });\n\n updateUnreadCount();\n console.log('Local state updated, unread count:', state.unreadCount);\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n};\n\nconst mutations = {\n resetNotifications() {\n state.notifications = [];\n state.unreadCount = 0;\n state.lastSync = null;\n },\n\n resetCurrent() {\n state.current = { ...notificationInitState };\n },\n\n resetPreferences() {\n state.preferences = { ...preferencesInitState };\n },\n};\n\n// Helper functions\nfunction updateUnreadCount() {\n state.unreadCount = state.notifications.filter(n => n.status !== 'read').length;\n}\n\n// Track state changes\nconst history = [];\nhistory.push(state);\n\nwatch(state, newState => {\n history.push(newState);\n});\n\n// Computed properties\nconst getters = {\n unreadNotifications: computed(() => {\n return state.notifications.filter(n => n.status !== 'read');\n }),\n\n readNotifications: computed(() => {\n return state.notifications.filter(n => n.status === 'read');\n }),\n\n notificationsByType: computed(() => {\n const result = {};\n state.notifications.forEach(notification => {\n if (!result[notification.type]) {\n result[notification.type] = [];\n }\n result[notification.type].push(notification);\n });\n return result;\n }),\n};\n\nexport { actions, getters, mutations, state };\n"],"names":["reactive","auth.state","$axios","setError","index","Preferences","watch","computed"],"mappings":";;;;;;;AAYA,MAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,CAAA;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAGA,MAAM,uBAAuB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AACZ;AAGK,MAAC,QAAQA,IAAAA,SAAS;AAAA,EACrB,eAAe,CAAA;AAAA,EACf,aAAa;AAAA,EACb,SAAS,EAAE,GAAG,sBAAqB;AAAA,EACnC,aAAa,EAA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,CAAC;AACD,WAAO;AAAA,EACT,CAAC;AACH;;;;;"}
@@ -107,7 +107,9 @@ const actions = {
107
107
  }
108
108
  }
109
109
  }
110
+ console.log("[Notifications Store] Registering device:", deviceData);
110
111
  const response = await $axios.post("/api/notifications/devices/register", deviceData);
112
+ console.log("[Notifications Store] Device registered successfully:", response.data);
111
113
  state.deviceRegistered = true;
112
114
  return response.data;
113
115
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.store.js","sources":["../../../../../../src/modules/notifications/store/notifications.store.js"],"sourcesContent":["// Dependencies\nimport { computed, reactive, watch } from 'vue';\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals.js';\n// Auth\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n// Capacitor Preferences\nimport { Preferences } from '@capacitor/preferences';\n\n// Initial state for a notification\nconst notificationInitState = {\n _id: null,\n title: '',\n body: '',\n type: 'info',\n metadata: {},\n userId: null,\n status: 'pending',\n createdAt: null,\n updatedAt: null,\n};\n\n// Initial state for notification preferences\nconst preferencesInitState = {\n web: true,\n push: true,\n email: true,\n sms: true,\n telegram: false,\n whatsapp: false,\n};\n\n// State declaration\nconst state = reactive({\n notifications: [],\n unreadCount: 0,\n current: { ...notificationInitState },\n preferences: { ...preferencesInitState },\n deviceRegistered: false,\n loading: false,\n lastSync: null,\n});\n\nconst actions = {\n /**\n * Get user notifications from server\n */\n async getNotifications(userId = null) {\n try {\n // Use provided userId or get from auth store\n const userIdToUse = userId || auth.state.user._id;\n\n if (!userIdToUse) {\n console.warn('Cannot get notifications: No user ID found');\n return [];\n }\n\n state.loading = true;\n const response = await $axios.get(`/api/notifications/user/${userIdToUse}`);\n state.notifications = response.data;\n state.lastSync = new Date().toISOString();\n updateUnreadCount();\n state.loading = false;\n return response.data;\n } catch (error) {\n state.loading = false;\n setError(error);\n throw error;\n }\n },\n\n /**\n * Mark a notification as read\n */\n async markAsRead(notificationId) {\n try {\n const response = await $axios.put(`/api/notifications/${notificationId}/read`);\n\n // Update the notification in the local state\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index] = response.data;\n updateUnreadCount();\n }\n\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Synchronize notification status without API call\n * (For use with WebSocket updates)\n */\n syncNotificationStatus(notificationId, status) {\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index].status = status;\n state.notifications[index].updatedAt = new Date().toISOString();\n updateUnreadCount();\n }\n },\n\n /**\n * Register a device for push notifications\n */\n async registerDevice(deviceData) {\n try {\n const userId = auth.state.user?._id;\n \n if (userId) {\n // Registered user\n deviceData.userId = userId;\n } else {\n // Anonymous user - generate or use existing anonymousId\n if (!deviceData.anonymousId) {\n // Generate anonymous ID if not provided\n deviceData.anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n // Store in Capacitor Preferences for persistence\n if (typeof window !== 'undefined') {\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: deviceData.anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n }\n }\n\n const response = await $axios.post('/api/notifications/devices/register', deviceData);\n state.deviceRegistered = true;\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Re-register device after user login\n */\n async reregisterDeviceAfterLogin() {\n try {\n const deviceIdResult = await Preferences.get({ key: 'notifications_device_id' });\n const deviceTokenResult = await Preferences.get({ key: 'notifications_device_token' });\n \n const deviceId = deviceIdResult.value;\n const deviceToken = deviceTokenResult.value;\n \n if (deviceId && deviceToken) {\n await this.registerDevice({\n deviceId,\n deviceToken,\n deviceType: 'web'\n });\n }\n } catch (error) {\n console.error('Error re-registering device after login:', error);\n }\n },\n\n /**\n * Update notification preferences\n */\n async updatePreferences(preferences) {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot update preferences: No user ID found');\n return;\n }\n\n // Transform preferences object to array format expected by the API\n const preferencesArray = Object.entries(preferences).map(([channelType, isEnabled]) => {\n return {\n channelType,\n notificationType: 'all', // Default type, can be made more specific\n isEnabled,\n };\n });\n\n const response = await $axios.put('/api/notifications/preferences', {\n userId,\n preferences: preferencesArray,\n });\n\n // Update state with new preferences\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Get notification preferences\n */\n async getPreferences() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot get preferences: No user ID found');\n return;\n }\n\n // Assuming an endpoint exists to fetch preferences\n const response = await $axios.get(`/api/notifications/preferences/${userId}`);\n\n // Transform API response to our state format\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n // If API fails, use default preferences\n state.preferences = { ...preferencesInitState };\n throw error;\n }\n },\n\n /**\n * Add a local notification (for handling push notifications or WebSocket notifications)\n */\n addLocalNotification(notification) {\n // Check if notification already exists by ID to prevent duplicates\n if (notification._id) {\n const existingIndex = state.notifications.findIndex(n => n._id === notification._id);\n if (existingIndex !== -1) {\n // Update existing notification\n state.notifications[existingIndex] = {\n ...state.notifications[existingIndex],\n ...notification,\n updatedAt: new Date().toISOString(),\n };\n updateUnreadCount();\n return;\n }\n }\n\n // Create a notification object that matches our expected format\n const newNotification = {\n _id: notification._id || Date.now().toString(), // Use provided ID or generate temporary one\n title: notification.title,\n body: notification.body,\n type: notification.type || notification.data?.type || 'info',\n metadata: notification.data || notification.metadata || {},\n status: notification.status || 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString(),\n };\n\n // Add to local state\n state.notifications.unshift(newNotification);\n updateUnreadCount();\n },\n\n /**\n * Handle notification action (e.g., when user taps on push notification)\n */\n handleNotificationAction(data) {\n // Mark notification as read if ID is provided\n if (data.notificationId) {\n actions.markAsRead(data.notificationId);\n }\n\n return true\n\n // // Navigate based on notification type and metadata\n // if (data.route) {\n // // router.push(data.route);\n // alert('1');\n // } else if (data.type === 'order') {\n // // router.push(`/orders/${data.orderId}`);\n // alert('2');\n // } else if (data.type === 'message') {\n // // router.push('/messages');\n // alert('3');\n // } else {\n // // Default to notifications page\n // // router.push('/notifications');\n // alert('4');\n // }\n },\n\n /**\n * Mark all notifications as read\n */\n async markAllAsRead() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot mark all as read: No user ID found');\n return;\n }\n\n console.log('=== markAllAsRead API call ===');\n console.log('URL:', `/api/notifications/user/${userId}/read-all`);\n \n const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);\n \n console.log('markAllAsRead response status:', response.status);\n console.log('markAllAsRead response data:', response.data);\n\n // Update all notifications in local state\n state.notifications.forEach(notification => {\n notification.status = 'read';\n notification.updatedAt = new Date().toISOString();\n });\n\n updateUnreadCount();\n console.log('Local state updated, unread count:', state.unreadCount);\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n};\n\nconst mutations = {\n resetNotifications() {\n state.notifications = [];\n state.unreadCount = 0;\n state.lastSync = null;\n },\n\n resetCurrent() {\n state.current = { ...notificationInitState };\n },\n\n resetPreferences() {\n state.preferences = { ...preferencesInitState };\n },\n};\n\n// Helper functions\nfunction updateUnreadCount() {\n state.unreadCount = state.notifications.filter(n => n.status !== 'read').length;\n}\n\n// Track state changes\nconst history = [];\nhistory.push(state);\n\nwatch(state, newState => {\n history.push(newState);\n});\n\n// Computed properties\nconst getters = {\n unreadNotifications: computed(() => {\n return state.notifications.filter(n => n.status !== 'read');\n }),\n\n readNotifications: computed(() => {\n return state.notifications.filter(n => n.status === 'read');\n }),\n\n notificationsByType: computed(() => {\n const result = {};\n state.notifications.forEach(notification => {\n if (!result[notification.type]) {\n result[notification.type] = [];\n }\n result[notification.type].push(notification);\n });\n return result;\n }),\n};\n\nexport { actions, getters, mutations, state };\n"],"names":["auth.state"],"mappings":";;;;;AAYA,MAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,CAAA;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAGA,MAAM,uBAAuB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AACZ;AAGK,MAAC,QAAQ,SAAS;AAAA,EACrB,eAAe,CAAA;AAAA,EACf,aAAa;AAAA,EACb,SAAS,EAAE,GAAG,sBAAqB;AAAA,EACnC,aAAa,EAAE,GAAG,qBAAoB;AAAA,EACtC,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,UAAU;AACZ,CAAC;AAEI,MAAC,UAAU;AAAA;AAAA;AAAA;AAAA,EAId,MAAM,iBAAiB,SAAS,MAAM;AACpC,QAAI;AAEF,YAAM,cAAc,UAAUA,QAAW,KAAK;AAE9C,UAAI,CAAC,aAAa;AAChB,gBAAQ,KAAK,4CAA4C;AACzD,eAAO,CAAA;AAAA,MACT;AAEA,YAAM,UAAU;AAChB,YAAM,WAAW,MAAM,OAAO,IAAI,2BAA2B,WAAW,EAAE;AAC1E,YAAM,gBAAgB,SAAS;AAC/B,YAAM,YAAW,oBAAI,KAAI,GAAG,YAAW;AACvC,wBAAiB;AACjB,YAAM,UAAU;AAChB,aAAO,SAAS;AAAA,IAClB,SAAS,OAAO;AACd,YAAM,UAAU;AAChB,eAAS,KAAK;AACd,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAA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,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC5D,CAAC;AAAA,EAED,mBAAmB,SAAS,MAAM;AAChC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC5D,CAAC;AAAA,EAED,qBAAqB,SAAS,MAAM;AAClC,UAAM,SAAS,CAAA;AACf,UAAM,cAAc,QAAQ,kBAAgB;AAC1C,UAAI,CAAC,OAAO,aAAa,IAAI,GAAG;AAC9B,eAAO,aAAa,IAAI,IAAI,CAAA;AAAA,MAC9B;AACA,aAAO,aAAa,IAAI,EAAE,KAAK,YAAY;AAAA,IAC7C,CAAC;AACD,WAAO;AAAA,EACT,CAAC;AACH;"}
1
+ {"version":3,"file":"notifications.store.js","sources":["../../../../../../src/modules/notifications/store/notifications.store.js"],"sourcesContent":["// Dependencies\nimport { computed, reactive, watch } from 'vue';\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals.js';\n// Auth\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n// Capacitor Preferences\nimport { Preferences } from '@capacitor/preferences';\n\n// Initial state for a notification\nconst notificationInitState = {\n _id: null,\n title: '',\n body: '',\n type: 'info',\n metadata: {},\n userId: null,\n status: 'pending',\n createdAt: null,\n updatedAt: null,\n};\n\n// Initial state for notification preferences\nconst preferencesInitState = {\n web: true,\n push: true,\n email: true,\n sms: true,\n telegram: false,\n whatsapp: false,\n};\n\n// State declaration\nconst state = reactive({\n notifications: [],\n unreadCount: 0,\n current: { ...notificationInitState },\n preferences: { ...preferencesInitState },\n deviceRegistered: false,\n loading: false,\n lastSync: null,\n});\n\nconst actions = {\n /**\n * Get user notifications from server\n */\n async getNotifications(userId = null) {\n try {\n // Use provided userId or get from auth store\n const userIdToUse = userId || auth.state.user._id;\n\n if (!userIdToUse) {\n console.warn('Cannot get notifications: No user ID found');\n return [];\n }\n\n state.loading = true;\n const response = await $axios.get(`/api/notifications/user/${userIdToUse}`);\n state.notifications = response.data;\n state.lastSync = new Date().toISOString();\n updateUnreadCount();\n state.loading = false;\n return response.data;\n } catch (error) {\n state.loading = false;\n setError(error);\n throw error;\n }\n },\n\n /**\n * Mark a notification as read\n */\n async markAsRead(notificationId) {\n try {\n const response = await $axios.put(`/api/notifications/${notificationId}/read`);\n\n // Update the notification in the local state\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index] = response.data;\n updateUnreadCount();\n }\n\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Synchronize notification status without API call\n * (For use with WebSocket updates)\n */\n syncNotificationStatus(notificationId, status) {\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index].status = status;\n state.notifications[index].updatedAt = new Date().toISOString();\n updateUnreadCount();\n }\n },\n\n /**\n * Register a device for push notifications\n */\n async registerDevice(deviceData) {\n try {\n const userId = auth.state.user?._id;\n \n if (userId) {\n // Registered user\n deviceData.userId = userId;\n } else {\n // Anonymous user - generate or use existing anonymousId\n if (!deviceData.anonymousId) {\n // Generate anonymous ID if not provided\n deviceData.anonymousId = 'anon_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);\n // Store in Capacitor Preferences for persistence\n if (typeof window !== 'undefined') {\n try {\n await Preferences.set({\n key: 'notifications_anonymous_id',\n value: deviceData.anonymousId\n });\n } catch (error) {\n console.warn('Could not save anonymous ID to preferences:', error);\n }\n }\n }\n }\n\n console.log('[Notifications Store] Registering device:', deviceData);\n const response = await $axios.post('/api/notifications/devices/register', deviceData);\n console.log('[Notifications Store] Device registered successfully:', response.data);\n state.deviceRegistered = true;\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Re-register device after user login\n */\n async reregisterDeviceAfterLogin() {\n try {\n const deviceIdResult = await Preferences.get({ key: 'notifications_device_id' });\n const deviceTokenResult = await Preferences.get({ key: 'notifications_device_token' });\n \n const deviceId = deviceIdResult.value;\n const deviceToken = deviceTokenResult.value;\n \n if (deviceId && deviceToken) {\n await this.registerDevice({\n deviceId,\n deviceToken,\n deviceType: 'web'\n });\n }\n } catch (error) {\n console.error('Error re-registering device after login:', error);\n }\n },\n\n /**\n * Update notification preferences\n */\n async updatePreferences(preferences) {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot update preferences: No user ID found');\n return;\n }\n\n // Transform preferences object to array format expected by the API\n const preferencesArray = Object.entries(preferences).map(([channelType, isEnabled]) => {\n return {\n channelType,\n notificationType: 'all', // Default type, can be made more specific\n isEnabled,\n };\n });\n\n const response = await $axios.put('/api/notifications/preferences', {\n userId,\n preferences: preferencesArray,\n });\n\n // Update state with new preferences\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Get notification preferences\n */\n async getPreferences() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot get preferences: No user ID found');\n return;\n }\n\n // Assuming an endpoint exists to fetch preferences\n const response = await $axios.get(`/api/notifications/preferences/${userId}`);\n\n // Transform API response to our state format\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n // If API fails, use default preferences\n state.preferences = { ...preferencesInitState };\n throw error;\n }\n },\n\n /**\n * Add a local notification (for handling push notifications or WebSocket notifications)\n */\n addLocalNotification(notification) {\n // Check if notification already exists by ID to prevent duplicates\n if (notification._id) {\n const existingIndex = state.notifications.findIndex(n => n._id === notification._id);\n if (existingIndex !== -1) {\n // Update existing notification\n state.notifications[existingIndex] = {\n ...state.notifications[existingIndex],\n ...notification,\n updatedAt: new Date().toISOString(),\n };\n updateUnreadCount();\n return;\n }\n }\n\n // Create a notification object that matches our expected format\n const newNotification = {\n _id: notification._id || Date.now().toString(), // Use provided ID or generate temporary one\n title: notification.title,\n body: notification.body,\n type: notification.type || notification.data?.type || 'info',\n metadata: notification.data || notification.metadata || {},\n status: notification.status || 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString(),\n };\n\n // Add to local state\n state.notifications.unshift(newNotification);\n updateUnreadCount();\n },\n\n /**\n * Handle notification action (e.g., when user taps on push notification)\n */\n handleNotificationAction(data) {\n // Mark notification as read if ID is provided\n if (data.notificationId) {\n actions.markAsRead(data.notificationId);\n }\n\n return true\n\n // // Navigate based on notification type and metadata\n // if (data.route) {\n // // router.push(data.route);\n // alert('1');\n // } else if (data.type === 'order') {\n // // router.push(`/orders/${data.orderId}`);\n // alert('2');\n // } else if (data.type === 'message') {\n // // router.push('/messages');\n // alert('3');\n // } else {\n // // Default to notifications page\n // // router.push('/notifications');\n // alert('4');\n // }\n },\n\n /**\n * Mark all notifications as read\n */\n async markAllAsRead() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot mark all as read: No user ID found');\n return;\n }\n\n console.log('=== markAllAsRead API call ===');\n console.log('URL:', `/api/notifications/user/${userId}/read-all`);\n \n const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);\n \n console.log('markAllAsRead response status:', response.status);\n console.log('markAllAsRead response data:', response.data);\n\n // Update all notifications in local state\n state.notifications.forEach(notification => {\n notification.status = 'read';\n notification.updatedAt = new Date().toISOString();\n });\n\n updateUnreadCount();\n console.log('Local state updated, unread count:', state.unreadCount);\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n};\n\nconst mutations = {\n resetNotifications() {\n state.notifications = [];\n state.unreadCount = 0;\n state.lastSync = null;\n },\n\n resetCurrent() {\n state.current = { ...notificationInitState };\n },\n\n resetPreferences() {\n state.preferences = { ...preferencesInitState };\n },\n};\n\n// Helper functions\nfunction updateUnreadCount() {\n state.unreadCount = state.notifications.filter(n => n.status !== 'read').length;\n}\n\n// Track state changes\nconst history = [];\nhistory.push(state);\n\nwatch(state, newState => {\n history.push(newState);\n});\n\n// Computed properties\nconst getters = {\n unreadNotifications: computed(() => {\n return state.notifications.filter(n => n.status !== 'read');\n }),\n\n readNotifications: computed(() => {\n return state.notifications.filter(n => n.status === 'read');\n }),\n\n notificationsByType: computed(() => {\n const result = {};\n state.notifications.forEach(notification => {\n if (!result[notification.type]) {\n result[notification.type] = [];\n }\n result[notification.type].push(notification);\n });\n return result;\n }),\n};\n\nexport { actions, getters, mutations, state };\n"],"names":["auth.state"],"mappings":";;;;;AAYA,MAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,CAAA;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAGA,MAAM,uBAAuB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AACZ;AAGK,MAAC,QAAQ,SAAS;AAAA,EACrB,eAAe,CAAA;AAAA,EACf,aAAa;AAAA,EACb,SAAS,EAAE,GAAG,sBAAqB;AAAA,EACnC,aAAa,EAAE,GAAG,qBAAoB;AAAA,EACtC,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,UAAU;AACZ,CAAC;AAEI,MAAC,UAAU;AAAA;AAAA;AAAA;AAAA,EAId,MAAM,iBAAiB,SAAS,MAAM;AACpC,QAAI;AAEF,YAAM,cAAc,UAAUA,QAAW,KAAK;AAE9C,UAAI,CAAC,aAAa;AAChB,gBAAQ,KAAK,4CAA4C;AACzD,eAAO,CAAA;AAAA,MACT;AAEA,YAAM,UAAU;AAChB,YAAM,WAAW,MAAM,OAAO,IAAI,2BAA2B,WAAW,EAAE;AAC1E,YAAM,gBAAgB,SAA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AAG,sBAAqB;AAAA,EAC5C;AAAA,EAEA,mBAAmB;AACjB,UAAM,cAAc,EAAE,GAAG,qBAAoB;AAAA,EAC/C;AACF;AAGA,SAAS,oBAAoB;AAC3B,QAAM,cAAc,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM,EAAE;AAC3E;AAMA,MAAM,OAAO,cAAY;AAEzB,CAAC;AAGI,MAAC,UAAU;AAAA,EACd,qBAAqB,SAAS,MAAM;AAClC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC5D,CAAC;AAAA,EAED,mBAAmB,SAAS,MAAM;AAChC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC5D,CAAC;AAAA,EAED,qBAAqB,SAAS,MAAM;AAClC,UAAM,SAAS,CAAA;AACf,UAAM,cAAc,QAAQ,kBAAgB;AAC1C,UAAI,CAAC,OAAO,aAAa,IAAI,GAAG;AAC9B,eAAO,aAAa,IAAI,IAAI,CAAA;AAAA,MAC9B;AACA,aAAO,aAAa,IAAI,EAAE,KAAK,YAAY;AAAA,IAC7C,CAAC;AACD,WAAO;AAAA,EACT,CAAC;AACH;"}
@@ -3,7 +3,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  const vue = require("vue");
4
4
  const Block = require("../../../../components/Block/Block.vue.cjs");
5
5
  const Field = require("../../../../components/Field/Field.vue.cjs");
6
- const Select = require("../../../../components/Select/Select.vue.cjs");
6
+ const Select = require("../../../../components/Select/Select.vue2.cjs");
7
7
  const Button = require("../../../../components/Button/Button.vue.cjs");
8
8
  const _hoisted_1 = { class: "gap-thin flex mn-t-small" };
9
9
  const _sfc_main = {
@@ -1,7 +1,7 @@
1
1
  import { mergeModels, useModel, ref, watch, createBlock, openBlock, withCtx, createVNode, createElementVNode, unref, isRef, createTextVNode, toDisplayString } from "vue";
2
2
  import _sfc_main$1 from "../../../../components/Block/Block.vue.js";
3
3
  import Field from "../../../../components/Field/Field.vue.js";
4
- import Select from "../../../../components/Select/Select.vue.js";
4
+ import Select from "../../../../components/Select/Select.vue2.js";
5
5
  import _sfc_main$2 from "../../../../components/Button/Button.vue.js";
6
6
  const _hoisted_1 = { class: "gap-thin flex mn-t-small" };
7
7
  const _sfc_main = {
@@ -4,7 +4,7 @@ const vue = require("vue");
4
4
  const Block = require("../../../../components/Block/Block.vue.cjs");
5
5
  const Field = require("../../../../components/Field/Field.vue.cjs");
6
6
  const FieldPhone = require("../../../../components/FieldPhone/FieldPhone.vue.cjs");
7
- const Select = require("../../../../components/Select/Select.vue.cjs");
7
+ const Select = require("../../../../components/Select/Select.vue2.cjs");
8
8
  const Button = require("../../../../components/Button/Button.vue.cjs");
9
9
  const _hoisted_1 = { class: "gap-thin mn-b-thin flex-justify-between flex-nowrap flex" };
10
10
  const _hoisted_2 = {
@@ -2,7 +2,7 @@ import { mergeModels, useModel, ref, watch, createBlock, openBlock, withCtx, cre
2
2
  import _sfc_main$1 from "../../../../components/Block/Block.vue.js";
3
3
  import Field from "../../../../components/Field/Field.vue.js";
4
4
  import _sfc_main$2 from "../../../../components/FieldPhone/FieldPhone.vue.js";
5
- import Select from "../../../../components/Select/Select.vue.js";
5
+ import Select from "../../../../components/Select/Select.vue2.js";
6
6
  import _sfc_main$3 from "../../../../components/Button/Button.vue.js";
7
7
  const _hoisted_1 = { class: "gap-thin mn-b-thin flex-justify-between flex-nowrap flex" };
8
8
  const _hoisted_2 = {
@@ -3,7 +3,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  const vue = require("vue");
4
4
  const vueRouter = require("vue-router");
5
5
  const Block = require("../../../../components/Block/Block.vue.cjs");
6
- ;/* empty css */
6
+ ;/* empty css */
7
7
  const IconCross = require("../../../icons/navigation/IconCross.vue.cjs");
8
8
  ;/* empty css */
9
9
  const Popup = require("../../../../components/Popup/Popup.vue.cjs");
@@ -1,7 +1,7 @@
1
1
  import { useModel, ref, createElementBlock, openBlock, Fragment, createVNode, withCtx, createBlock, unref, renderList } from "vue";
2
2
  import { useRoute } from "vue-router";
3
3
  import _sfc_main$1 from "../../../../components/Block/Block.vue.js";
4
- /* empty css */
4
+ /* empty css */
5
5
  import _sfc_main$3 from "../../../icons/navigation/IconCross.vue.js";
6
6
  /* empty css */
7
7
  import _sfc_main$6 from "../../../../components/Popup/Popup.vue.js";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  const vue = require("vue");
4
4
  const vueRouter = require("vue-router");
5
5
  const Button = require("../../../../components/Button/Button.vue.cjs");
6
- const Select = require("../../../../components/Select/Select.vue.cjs");
6
+ const Select = require("../../../../components/Select/Select.vue2.cjs");
7
7
  const Popup = require("../../../../components/Popup/Popup.vue.cjs");
8
8
  const IconTime = require("../../../icons/entities/IconTime.vue.cjs");
9
9
  const CardOrderItem = require("../blocks/CardOrderItem.vue.cjs");
@@ -1,7 +1,7 @@
1
1
  import { ref, onMounted, computed, createElementBlock, createCommentVNode, openBlock, createVNode, createElementVNode, createTextVNode, toDisplayString, Fragment, renderList, normalizeClass, withCtx, createBlock, unref } from "vue";
2
2
  import { useRouter, useRoute } from "vue-router";
3
3
  import _sfc_main$2 from "../../../../components/Button/Button.vue.js";
4
- import Select from "../../../../components/Select/Select.vue.js";
4
+ import Select from "../../../../components/Select/Select.vue2.js";
5
5
  import _sfc_main$1 from "../../../../components/Popup/Popup.vue.js";
6
6
  import IconClock from "../../../icons/entities/IconTime.vue.js";
7
7
  import _sfc_main$3 from "../blocks/CardOrderItem.vue.js";
@@ -4,7 +4,7 @@ const vue = require("vue");
4
4
  const vueRouter = require("vue-router");
5
5
  ;/* empty css */
6
6
  const Button = require("../../../../components/Button/Button.vue.cjs");
7
- const Tab = require("../../../../components/Tab/Tab.vue.cjs");
7
+ const Tab = require("../../../../components/Tab/Tab.vue2.cjs");
8
8
  const Popup = require("../../../../components/Popup/Popup.vue.cjs");
9
9
  const Block = require("../../../../components/Block/Block.vue.cjs");
10
10
  const Feed = require("../../../../components/Feed/Feed.vue.cjs");
@@ -2,7 +2,7 @@ import { getCurrentInstance, computed, ref, onMounted, createElementBlock, openB
2
2
  import { useRoute, useRouter } from "vue-router";
3
3
  /* empty css */
4
4
  import _sfc_main$2 from "../../../../components/Button/Button.vue.js";
5
- import _sfc_main$3 from "../../../../components/Tab/Tab.vue.js";
5
+ import _sfc_main$3 from "../../../../components/Tab/Tab.vue2.js";
6
6
  import _sfc_main$4 from "../../../../components/Popup/Popup.vue.js";
7
7
  import _sfc_main$1 from "../../../../components/Block/Block.vue.js";
8
8
  import _sfc_main$5 from "../../../../components/Feed/Feed.vue.js";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const vue = require("vue");
4
4
  const vueRouter = require("vue-router");
5
- ;/* empty css */
5
+ ;/* empty css */
6
6
  const Block = require("../../../../components/Block/Block.vue.cjs");
7
7
  const orders = require("../../store/orders.cjs");
8
8
  const auth = require("../../../auth/views/store/auth.cjs");
@@ -1,6 +1,6 @@
1
1
  import { ref, computed, onMounted, resolveComponent, createElementBlock, openBlock, createBlock, createCommentVNode, createVNode, unref, withCtx, createElementVNode, toDisplayString, Fragment, renderList } from "vue";
2
2
  import { useRoute, useRouter } from "vue-router";
3
- /* empty css */
3
+ /* empty css */
4
4
  import _sfc_main$2 from "../../../../components/Block/Block.vue.js";
5
5
  import { state, actions, getters } from "../../store/orders.js";
6
6
  import { state as state$1 } from "../../../auth/views/store/auth.js";