@wix/himalaya-cli 0.1748.0 → 0.1750.0

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 (327) hide show
  1. package/bin/himi +16 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +9 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +2 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/l10n.mjs +1 -1
  6. package/dist/browser-plane/assets.json +7 -7
  7. package/dist/browser-plane/preview-deferred/{63821bbb8f637899037252154a5587f0596e4b537173c7f50551f9e44f7c22c0.bin → b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin} +1 -1
  8. package/dist/browser-plane/sw.js +6 -6
  9. package/dist/browser-plane/t5-frame.html +1 -1
  10. package/dist/browser-plane/t5-worker-frame.html +1 -1
  11. package/dist/cli.mjs +13464 -8217
  12. package/dist/preview-assets.generated.bin +0 -0
  13. package/guides/component-reference.json +1 -1
  14. package/guides/component-reference.md +9 -0
  15. package/guides/getting-started.md +3 -1
  16. package/guides/himi-json-output.md +54 -1
  17. package/guides/himi-skill.md +3 -1
  18. package/guides/one-app-to-himi-app.md +31 -8
  19. package/guides/skill.md +3 -1
  20. package/guides/store-submission.md +149 -34
  21. package/guides/wix-business-context.md +14 -0
  22. package/package.json +10 -10
  23. package/template-icons/medical-services.png +0 -0
  24. package/template-icons/personal-fitness-trainer.png +0 -0
  25. package/templates/beauty-salon/config.ts +12 -0
  26. package/templates/beauty-salon/dev/index.ts +1 -0
  27. package/templates/beauty-salon/l10n/en.json +6 -0
  28. package/templates/beauty-salon/l10n/fr.json +11 -0
  29. package/templates/beauty-salon/l10n/he.json +9 -0
  30. package/templates/beauty-salon/tier5-src/_shared/booking-session.ts +3 -1
  31. package/templates/beauty-salon/tier5-src/_shared/business-chat-transport.ts +148 -0
  32. package/templates/beauty-salon/tier5-src/_shared/header-badges.ts +113 -0
  33. package/templates/beauty-salon/tier5-src/_shared/location-pin.ts +97 -0
  34. package/templates/beauty-salon/tier5-src/_shared/member-access.ts +17 -6
  35. package/templates/beauty-salon/tier5-src/_shared/member-bookings.ts +17 -4
  36. package/templates/beauty-salon/tier5-src/_shared/source-badges.ts +72 -0
  37. package/templates/beauty-salon/tier5-src/_shared/staff-name.ts +18 -0
  38. package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +6 -2
  39. package/templates/beauty-salon/tier5-src/himi-booking-service/index.ts +7 -2
  40. package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +6 -4
  41. package/templates/beauty-salon/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  42. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +13 -4
  43. package/templates/beauty-salon/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  44. package/templates/beauty-salon-owner/dev/index.ts +54 -0
  45. package/templates/beauty-salon-owner/tier5-src/_shared/aria-chat.ts +30 -4
  46. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  47. package/templates/branded-lite/config.ts +12 -0
  48. package/templates/branded-lite/dev/index.ts +1 -0
  49. package/templates/branded-lite/l10n/fr.json +10 -0
  50. package/templates/branded-lite/l10n/he.json +8 -0
  51. package/templates/branded-lite/tier5-src/_shared/booking-session.ts +3 -1
  52. package/templates/branded-lite/tier5-src/_shared/location-pin.ts +97 -0
  53. package/templates/branded-lite/tier5-src/_shared/member-access.ts +17 -6
  54. package/templates/branded-lite/tier5-src/_shared/member-bookings.ts +17 -4
  55. package/templates/branded-lite/tier5-src/_shared/staff-name.ts +18 -0
  56. package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +6 -2
  57. package/templates/branded-lite/tier5-src/himi-booking-service/index.ts +7 -2
  58. package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +6 -4
  59. package/templates/branded-lite/tier5-src/himi-branded-lite-access-nav/index.ts +10 -5
  60. package/templates/branded-lite/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  61. package/templates/branded-lite/tier5-src/himi-branded-lite-video/index.ts +12 -1
  62. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +13 -4
  63. package/templates/branded-lite/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  64. package/templates/community-club/dev/index.ts +1 -0
  65. package/templates/community-club/tier5-src/_shared/member-access.ts +17 -6
  66. package/templates/community-club/tier5-src/_shared/member-bookings.ts +17 -4
  67. package/templates/community-club/tier5-src/himi-store-account/index.ts +13 -4
  68. package/templates/community-club/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  69. package/templates/community-club-owner/dev/index.ts +54 -0
  70. package/templates/community-club-owner/tier5-src/_shared/aria-chat.ts +30 -4
  71. package/templates/community-club-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  72. package/templates/conference/dev/index.ts +1 -0
  73. package/templates/conference/tier5-src/_shared/member-access.ts +17 -6
  74. package/templates/conference/tier5-src/himi-store-account/index.ts +13 -4
  75. package/templates/events-meetups/dev/index.ts +1 -0
  76. package/templates/events-meetups/tier5-src/_shared/member-access.ts +17 -6
  77. package/templates/events-meetups/tier5-src/_shared/member-bookings.ts +17 -4
  78. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +13 -4
  79. package/templates/events-meetups/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  80. package/templates/events-meetups-owner/dev/index.ts +54 -0
  81. package/templates/events-meetups-owner/tier5-src/_shared/aria-chat.ts +30 -4
  82. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  83. package/templates/gym-fitness/config.ts +12 -0
  84. package/templates/gym-fitness/dev/index.ts +1 -0
  85. package/templates/gym-fitness/l10n/en.json +6 -0
  86. package/templates/gym-fitness/l10n/fr.json +11 -0
  87. package/templates/gym-fitness/l10n/he.json +9 -0
  88. package/templates/gym-fitness/tier5-src/_shared/booking-session.ts +3 -1
  89. package/templates/gym-fitness/tier5-src/_shared/business-chat-transport.ts +148 -0
  90. package/templates/gym-fitness/tier5-src/_shared/header-badges.ts +113 -0
  91. package/templates/gym-fitness/tier5-src/_shared/location-pin.ts +97 -0
  92. package/templates/gym-fitness/tier5-src/_shared/member-access.ts +17 -6
  93. package/templates/gym-fitness/tier5-src/_shared/member-bookings.ts +17 -4
  94. package/templates/gym-fitness/tier5-src/_shared/source-badges.ts +72 -0
  95. package/templates/gym-fitness/tier5-src/_shared/staff-name.ts +18 -0
  96. package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +6 -2
  97. package/templates/gym-fitness/tier5-src/himi-booking-service/index.ts +7 -2
  98. package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +6 -4
  99. package/templates/gym-fitness/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  100. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +13 -4
  101. package/templates/gym-fitness/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  102. package/templates/gym-fitness-owner/dev/index.ts +54 -0
  103. package/templates/gym-fitness-owner/tier5-src/_shared/aria-chat.ts +30 -4
  104. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  105. package/templates/medical-services/README.md +53 -0
  106. package/templates/medical-services/config.ts +320 -0
  107. package/templates/medical-services/dev/index.ts +17783 -0
  108. package/templates/medical-services/himalaya.content.json +46 -0
  109. package/templates/medical-services/himalaya.template.json +14 -0
  110. package/templates/medical-services/icon.png +0 -0
  111. package/templates/medical-services/platforms.json +1 -0
  112. package/templates/medical-services/tier5-src/_shared/app-locale.ts +61 -0
  113. package/templates/medical-services/tier5-src/_shared/booking-location.ts +147 -0
  114. package/templates/medical-services/tier5-src/_shared/booking-session.ts +224 -0
  115. package/templates/medical-services/tier5-src/_shared/branded-lite-hosted.ts +280 -0
  116. package/templates/medical-services/tier5-src/_shared/branded-load-state.ts +109 -0
  117. package/templates/medical-services/tier5-src/_shared/business-chat-copy.ts +40 -0
  118. package/templates/medical-services/tier5-src/_shared/business-chat-history.ts +51 -0
  119. package/templates/medical-services/tier5-src/_shared/business-chat-message-model.ts +177 -0
  120. package/templates/medical-services/tier5-src/_shared/business-chat-model.ts +56 -0
  121. package/templates/medical-services/tier5-src/_shared/business-chat-presenter.ts +576 -0
  122. package/templates/medical-services/tier5-src/_shared/business-chat-transport.ts +148 -0
  123. package/templates/medical-services/tier5-src/_shared/collection-contract.ts +228 -0
  124. package/templates/medical-services/tier5-src/_shared/collection-query.ts +193 -0
  125. package/templates/medical-services/tier5-src/_shared/collection-service.ts +400 -0
  126. package/templates/medical-services/tier5-src/_shared/engine-intl.ts +523 -0
  127. package/templates/medical-services/tier5-src/_shared/faq-list.ts +405 -0
  128. package/templates/medical-services/tier5-src/_shared/himi-account.ts +194 -0
  129. package/templates/medical-services/tier5-src/_shared/himi-booking-saved.ts +88 -0
  130. package/templates/medical-services/tier5-src/_shared/himi-bookings.ts +318 -0
  131. package/templates/medical-services/tier5-src/_shared/himi-copy.ts +116 -0
  132. package/templates/medical-services/tier5-src/_shared/himi-store.ts +7 -0
  133. package/templates/medical-services/tier5-src/_shared/himi-text.ts +24 -0
  134. package/templates/medical-services/tier5-src/_shared/host-events.ts +66 -0
  135. package/templates/medical-services/tier5-src/_shared/hosted-checkout.ts +70 -0
  136. package/templates/medical-services/tier5-src/_shared/iap-attendance-form.ts +106 -0
  137. package/templates/medical-services/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
  138. package/templates/medical-services/tier5-src/_shared/iap-attendance.ts +38 -0
  139. package/templates/medical-services/tier5-src/_shared/iap-worker.ts +127 -0
  140. package/templates/medical-services/tier5-src/_shared/inbox-rooms.ts +68 -0
  141. package/templates/medical-services/tier5-src/_shared/local-preferences.ts +38 -0
  142. package/templates/medical-services/tier5-src/_shared/member-access.ts +63 -0
  143. package/templates/medical-services/tier5-src/_shared/member-account-routes.ts +52 -0
  144. package/templates/medical-services/tier5-src/_shared/member-bookings.ts +107 -0
  145. package/templates/medical-services/tier5-src/_shared/member-screen.ts +99 -0
  146. package/templates/medical-services/tier5-src/_shared/notification-target.ts +141 -0
  147. package/templates/medical-services/tier5-src/_shared/offset-page.ts +10 -0
  148. package/templates/medical-services/tier5-src/_shared/online-actions.ts +76 -0
  149. package/templates/medical-services/tier5-src/_shared/owner-load-error.ts +348 -0
  150. package/templates/medical-services/tier5-src/_shared/payment-setup.ts +6 -0
  151. package/templates/medical-services/tier5-src/_shared/rich-body.ts +78 -0
  152. package/templates/medical-services/tier5-src/_shared/rich-content-link.ts +34 -0
  153. package/templates/medical-services/tier5-src/_shared/sign-in-sheet.ts +18 -0
  154. package/templates/medical-services/tier5-src/_shared/staff-name.ts +18 -0
  155. package/templates/medical-services/tier5-src/_shared/weekly-goal.ts +107 -0
  156. package/templates/medical-services/tier5-src/_shared/wix-bi.ts +85 -0
  157. package/templates/medical-services/tier5-src/_shared/wix-member-links.ts +114 -0
  158. package/templates/medical-services/tier5-src/_shared/wix-service-price.ts +146 -0
  159. package/templates/medical-services/tier5-src/business-chat/index.ts +732 -0
  160. package/templates/medical-services/tier5-src/himi-booking-account/index.ts +252 -0
  161. package/templates/medical-services/tier5-src/himi-booking-bookings/index.ts +468 -0
  162. package/templates/medical-services/tier5-src/himi-booking-service/index.ts +1190 -0
  163. package/templates/medical-services/tier5-src/himi-booking-services/index.ts +791 -0
  164. package/templates/medical-services/tier5-src/himi-booking-time/index.ts +1729 -0
  165. package/templates/medical-services/tier5-src/himi-branded-lite-faq/index.ts +6 -0
  166. package/templates/medical-services/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
  167. package/templates/medical-services/tier5-src/himi-clinic-home/index.ts +389 -0
  168. package/templates/medical-services/tier5-src/himi-store-account/index.ts +1007 -0
  169. package/templates/medical-services/tokens.json +418 -0
  170. package/templates/nonprofit-cause/dev/index.ts +1 -0
  171. package/templates/nonprofit-cause/tier5-src/_shared/member-access.ts +17 -6
  172. package/templates/nonprofit-cause/tier5-src/_shared/member-bookings.ts +17 -4
  173. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +13 -4
  174. package/templates/nonprofit-cause/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  175. package/templates/nonprofit-cause-owner/dev/index.ts +54 -0
  176. package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-chat.ts +30 -4
  177. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  178. package/templates/owner-lite/dev/index.ts +54 -0
  179. package/templates/owner-lite/tier5-src/_shared/aria-chat.ts +30 -4
  180. package/templates/owner-lite/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  181. package/templates/personal-fitness-trainer/README.md +51 -0
  182. package/templates/personal-fitness-trainer/config.ts +343 -0
  183. package/templates/personal-fitness-trainer/dev/index.ts +24813 -0
  184. package/templates/personal-fitness-trainer/himalaya.content.json +79 -0
  185. package/templates/personal-fitness-trainer/himalaya.template.json +14 -0
  186. package/templates/personal-fitness-trainer/icon.png +0 -0
  187. package/templates/personal-fitness-trainer/platforms.json +3 -0
  188. package/templates/personal-fitness-trainer/splash.json +3 -0
  189. package/templates/personal-fitness-trainer/tier5-src/_shared/app-locale.ts +61 -0
  190. package/templates/personal-fitness-trainer/tier5-src/_shared/booking-location.ts +147 -0
  191. package/templates/personal-fitness-trainer/tier5-src/_shared/booking-session.ts +224 -0
  192. package/templates/personal-fitness-trainer/tier5-src/_shared/branded-lite-hosted.ts +280 -0
  193. package/templates/personal-fitness-trainer/tier5-src/_shared/branded-load-state.ts +109 -0
  194. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-copy.ts +40 -0
  195. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-history.ts +51 -0
  196. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-message-model.ts +177 -0
  197. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-model.ts +56 -0
  198. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-presenter.ts +576 -0
  199. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-transport.ts +148 -0
  200. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-contract.ts +228 -0
  201. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-query.ts +193 -0
  202. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-service.ts +400 -0
  203. package/templates/personal-fitness-trainer/tier5-src/_shared/detail-presence.ts +51 -0
  204. package/templates/personal-fitness-trainer/tier5-src/_shared/empty-flags.ts +33 -0
  205. package/templates/personal-fitness-trainer/tier5-src/_shared/engine-intl.ts +523 -0
  206. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-account.ts +194 -0
  207. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-booking-saved.ts +88 -0
  208. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-bookings.ts +318 -0
  209. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-copy.ts +116 -0
  210. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-layouts.ts +142 -0
  211. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-store.ts +7 -0
  212. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-text.ts +24 -0
  213. package/templates/personal-fitness-trainer/tier5-src/_shared/host-events.ts +66 -0
  214. package/templates/personal-fitness-trainer/tier5-src/_shared/hosted-checkout.ts +70 -0
  215. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance-form.ts +106 -0
  216. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
  217. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance.ts +38 -0
  218. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-worker.ts +127 -0
  219. package/templates/personal-fitness-trainer/tier5-src/_shared/inbox-rooms.ts +68 -0
  220. package/templates/personal-fitness-trainer/tier5-src/_shared/local-preferences.ts +38 -0
  221. package/templates/personal-fitness-trainer/tier5-src/_shared/member-access.ts +63 -0
  222. package/templates/personal-fitness-trainer/tier5-src/_shared/member-account-routes.ts +52 -0
  223. package/templates/personal-fitness-trainer/tier5-src/_shared/member-bookings.ts +107 -0
  224. package/templates/personal-fitness-trainer/tier5-src/_shared/member-screen.ts +99 -0
  225. package/templates/personal-fitness-trainer/tier5-src/_shared/offset-page.ts +10 -0
  226. package/templates/personal-fitness-trainer/tier5-src/_shared/online-actions.ts +76 -0
  227. package/templates/personal-fitness-trainer/tier5-src/_shared/owner-load-error.ts +348 -0
  228. package/templates/personal-fitness-trainer/tier5-src/_shared/payment-setup.ts +6 -0
  229. package/templates/personal-fitness-trainer/tier5-src/_shared/pricing-plan-display.ts +64 -0
  230. package/templates/personal-fitness-trainer/tier5-src/_shared/rich-body.ts +78 -0
  231. package/templates/personal-fitness-trainer/tier5-src/_shared/rich-content-link.ts +34 -0
  232. package/templates/personal-fitness-trainer/tier5-src/_shared/sign-in-sheet.ts +18 -0
  233. package/templates/personal-fitness-trainer/tier5-src/_shared/staff-name.ts +18 -0
  234. package/templates/personal-fitness-trainer/tier5-src/_shared/video-caption.ts +21 -0
  235. package/templates/personal-fitness-trainer/tier5-src/_shared/weekly-goal.ts +107 -0
  236. package/templates/personal-fitness-trainer/tier5-src/_shared/wix-bi.ts +85 -0
  237. package/templates/personal-fitness-trainer/tier5-src/_shared/wix-service-price.ts +146 -0
  238. package/templates/personal-fitness-trainer/tier5-src/business-chat/index.ts +732 -0
  239. package/templates/personal-fitness-trainer/tier5-src/business-contact/index.ts +6 -0
  240. package/templates/personal-fitness-trainer/tier5-src/himi-booking-bookings/index.ts +468 -0
  241. package/templates/personal-fitness-trainer/tier5-src/himi-booking-service/index.ts +1190 -0
  242. package/templates/personal-fitness-trainer/tier5-src/himi-booking-services/index.ts +791 -0
  243. package/templates/personal-fitness-trainer/tier5-src/himi-booking-time/index.ts +1729 -0
  244. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
  245. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/index.ts +1094 -0
  246. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-agenda/index.ts +955 -0
  247. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-appearance/index.ts +94 -0
  248. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-notifsettings/index.ts +173 -0
  249. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-plans/index.ts +495 -0
  250. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-splash/index.ts +35 -0
  251. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-video/index.ts +226 -0
  252. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-videos/index.ts +145 -0
  253. package/templates/personal-fitness-trainer/tier5-src/himi-fitness-trainer-home/index.ts +70 -0
  254. package/templates/personal-fitness-trainer/tier5-src/himi-fitness-trainer-profile/index.ts +53 -0
  255. package/templates/personal-fitness-trainer/tier5-src/himi-store-account/index.ts +1007 -0
  256. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-app-language/index.ts +73 -0
  257. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  258. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
  259. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
  260. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-view-profile/index.ts +119 -0
  261. package/templates/personal-fitness-trainer/tokens.json +381 -0
  262. package/templates/podcast-creator/dev/index.ts +1 -0
  263. package/templates/podcast-creator/tier5-src/_shared/member-access.ts +17 -6
  264. package/templates/podcast-creator/tier5-src/_shared/member-bookings.ts +17 -4
  265. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +13 -4
  266. package/templates/podcast-creator/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  267. package/templates/podcast-creator-owner/dev/index.ts +54 -0
  268. package/templates/podcast-creator-owner/tier5-src/_shared/aria-chat.ts +30 -4
  269. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  270. package/templates/portfolio-creative/dev/index.ts +1 -0
  271. package/templates/portfolio-creative/tier5-src/_shared/member-access.ts +17 -6
  272. package/templates/portfolio-creative/tier5-src/_shared/member-bookings.ts +17 -4
  273. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +13 -4
  274. package/templates/portfolio-creative/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  275. package/templates/portfolio-creative-owner/dev/index.ts +54 -0
  276. package/templates/portfolio-creative-owner/tier5-src/_shared/aria-chat.ts +30 -4
  277. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  278. package/templates/restaurant/dev/index.ts +1 -0
  279. package/templates/restaurant/tier5-src/_shared/member-access.ts +17 -6
  280. package/templates/restaurant/tier5-src/_shared/member-bookings.ts +17 -4
  281. package/templates/restaurant/tier5-src/himi-store-account/index.ts +13 -4
  282. package/templates/restaurant/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  283. package/templates/restaurant-owner/dev/index.ts +54 -0
  284. package/templates/restaurant-owner/tier5-src/_shared/aria-chat.ts +30 -4
  285. package/templates/restaurant-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  286. package/templates/retail-store/dev/index.ts +1 -0
  287. package/templates/retail-store/tier5-src/_shared/member-access.ts +17 -6
  288. package/templates/retail-store/tier5-src/_shared/member-bookings.ts +17 -4
  289. package/templates/retail-store/tier5-src/himi-store-account/index.ts +13 -4
  290. package/templates/retail-store/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  291. package/templates/retail-store-owner/dev/index.ts +54 -0
  292. package/templates/retail-store-owner/tier5-src/_shared/aria-chat.ts +30 -4
  293. package/templates/retail-store-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  294. package/templates/salon-spa/dev/index.ts +1 -0
  295. package/templates/salon-spa/tier5-src/_shared/booking-session.ts +3 -1
  296. package/templates/salon-spa/tier5-src/_shared/member-access.ts +17 -6
  297. package/templates/salon-spa/tier5-src/_shared/member-bookings.ts +17 -4
  298. package/templates/salon-spa/tier5-src/_shared/staff-name.ts +18 -0
  299. package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +6 -2
  300. package/templates/salon-spa/tier5-src/himi-booking-service/index.ts +7 -2
  301. package/templates/salon-spa/tier5-src/himi-booking-time/index.ts +6 -4
  302. package/templates/salon-spa/tier5-src/himi-store-account/index.ts +13 -4
  303. package/templates/wholesale-store/dev/index.ts +1 -0
  304. package/templates/wholesale-store/tier5-src/_shared/member-access.ts +17 -6
  305. package/templates/wholesale-store/tier5-src/himi-store-account/index.ts +13 -4
  306. package/templates/yoga-studio/config.ts +12 -0
  307. package/templates/yoga-studio/dev/index.ts +1 -0
  308. package/templates/yoga-studio/l10n/en.json +6 -0
  309. package/templates/yoga-studio/l10n/fr.json +11 -0
  310. package/templates/yoga-studio/l10n/he.json +9 -0
  311. package/templates/yoga-studio/tier5-src/_shared/booking-session.ts +3 -1
  312. package/templates/yoga-studio/tier5-src/_shared/business-chat-transport.ts +148 -0
  313. package/templates/yoga-studio/tier5-src/_shared/header-badges.ts +113 -0
  314. package/templates/yoga-studio/tier5-src/_shared/location-pin.ts +97 -0
  315. package/templates/yoga-studio/tier5-src/_shared/member-access.ts +17 -6
  316. package/templates/yoga-studio/tier5-src/_shared/member-bookings.ts +17 -4
  317. package/templates/yoga-studio/tier5-src/_shared/source-badges.ts +72 -0
  318. package/templates/yoga-studio/tier5-src/_shared/staff-name.ts +18 -0
  319. package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +6 -2
  320. package/templates/yoga-studio/tier5-src/himi-booking-service/index.ts +7 -2
  321. package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +6 -4
  322. package/templates/yoga-studio/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  323. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +13 -4
  324. package/templates/yoga-studio/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  325. package/templates/yoga-studio-owner/dev/index.ts +54 -0
  326. package/templates/yoga-studio-owner/tier5-src/_shared/aria-chat.ts +30 -4
  327. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
@@ -0,0 +1,6 @@
1
+ // The himi_faq screen's worker: the shared FAQ service under the screen's own service name. The whole worker lives in
2
+ // `_shared/faq-list.ts` so a migrated page can host the same FAQ next to other sections.
3
+ import { registerFaqList } from "../_shared/faq-list.js";
4
+
5
+ export const svc = registerFaqList("himiBrandedFaq");
6
+ export { sectionsFor, httpStatus, parseStaticFaq } from "../_shared/faq-list.js";
@@ -0,0 +1,256 @@
1
+ import { withOnlineWrites } from "../_shared/online-actions.js";
2
+ // himi-branded-lite-notifications — reads the member's notifications via Members Feed Viewer (queryNotifications).
3
+ // a failed query is an error with Retry (or Sign in when Wix refuses the
4
+ // visitor) and an empty one is a real empty state — never sample rows presented as
5
+ // the customer's own. Samples appear only in the host's explicit sample preview
6
+ // (_shared/branded-load-state.ts).
7
+ // mark-one-read / mark-all-read stay wired: they update state optimistically and
8
+ // best-effort the real write (a no-op on sample rows).
9
+ import { defineService as registerService } from "../_shared/collection-service.js";
10
+ import { LOADING, loaded, loadFailed, type LoadCopy, type LoadFlags } from "../_shared/branded-load-state.js";
11
+ import { queryNotifications, markRead, markAllRead, type MfvNotification } from "@himalaya/wix-members-feed-viewer";
12
+ import { assertMemberAccess, memberAccess, type MemberAccess } from "../_shared/member-access.js";
13
+ import { navigate } from "@himalaya/state";
14
+ import { notificationOpen, urlHost, type NotificationOpen } from "../_shared/notification-target.js";
15
+ import { openRichLink } from "../_shared/rich-content-link.js";
16
+ import { copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
+
18
+ interface Row {
19
+ id: string;
20
+ name: string;
21
+ subtitle: string;
22
+ unread: boolean;
23
+ /** "●" when unread, "" when read — bound to an accent dot that collapses when
24
+ * empty (per-item render is parity-safe; item-scoped hiddenWhen is not). */
25
+ unreadDot: string;
26
+ photo: string;
27
+ initial: string;
28
+ dest: string;
29
+ /** What a tap does (a screen, a web link or nothing). Absent on the preview samples, which open nothing. */
30
+ open?: NotificationOpen;
31
+ }
32
+ interface S extends LoadFlags {
33
+ items: Row[]; emptyText: string; actionMessage: string;
34
+ /** The web link the last tap named and is waiting for a second tap to open (see `open`). */
35
+ pendingUrl: string;
36
+ /** Ownership travels with the rows, including a state captured by an async write. */
37
+ inboxMember: MemberAccess | null;
38
+ isMock: boolean; notMock: boolean;
39
+ /** #2849 — hiddenWhen() hides on TRUE, so these are inverted: the empty-state banner
40
+ * shows only when the site really has none, and the unavailable one only when the
41
+ * query failed. A failed query must never render the sentence that claims the
42
+ * customer has no content. */
43
+ notMockEmpty: boolean; notMockUnavailable: boolean;
44
+ }
45
+
46
+ /** Human "2h ago" / "Yesterday" from an ISO date. */
47
+ function relativeTime(iso?: string): string {
48
+ if (!iso) return "";
49
+ const then = Date.parse(iso);
50
+ if (isNaN(then)) return "";
51
+ const diff = Date.now() - then;
52
+ if (diff < 0) return "Just now";
53
+ const min = Math.floor(diff / 60000);
54
+ if (min < 1) return "Just now";
55
+ if (min < 60) return `${min}m ago`;
56
+ const hr = Math.floor(min / 60);
57
+ if (hr < 24) return `${hr}h ago`;
58
+ const day = Math.floor(hr / 24);
59
+ if (day === 1) return "Yesterday";
60
+ if (day < 7) return `${day}d ago`;
61
+ const wk = Math.floor(day / 7);
62
+ if (wk < 5) return `${wk}w ago`;
63
+ return new Date(then).toLocaleDateString();
64
+ }
65
+
66
+ function isUnread(status?: string): boolean {
67
+ return status === "UNSEEN" || status === "SEEN_BUT_UNREAD";
68
+ }
69
+
70
+ function dest(n: MfvNotification): string {
71
+ return n.deeplink?.mobileData?.data || n.deeplink?.webUrlData?.webUrl || "";
72
+ }
73
+
74
+ function photo(n: MfvNotification): string {
75
+ return n.icon?.personAvatarData?.data || n.icon?.webUrlData?.webUrl || "";
76
+ }
77
+
78
+ /** The screens the Notifications screen says its app serves, or undefined when it did not say. */
79
+ function servedScreens(arg: unknown): ReadonlySet<string> | undefined {
80
+ const served = (arg as { served?: unknown } | null | undefined)?.served;
81
+ // A Retry reaches `load` with no params (the collection layer re-dispatches the action bare), so the list the screen
82
+ // last named is kept: dropping it would let every catalog link be tried again.
83
+ if (typeof served === "string") lastServed = new Set(served.split(",").filter(Boolean));
84
+ return lastServed;
85
+ }
86
+ let lastServed: ReadonlySet<string> | undefined;
87
+
88
+ function norm(n: MfvNotification, served?: ReadonlySet<string>): Row {
89
+ const name = (n.title || n.message || "Notification").trim() || "Notification";
90
+ const rel = relativeTime(n.sentDate);
91
+ const lead = n.title && n.message ? n.message.trim() : "";
92
+ const subtitle = [lead, rel].filter(Boolean).join(" · ");
93
+ const p = photo(n);
94
+ const unread = isUnread(n.status);
95
+ return {
96
+ id: n.id || "",
97
+ name,
98
+ subtitle,
99
+ unread,
100
+ unreadDot: unread ? "●" : "",
101
+ photo: p,
102
+ initial: (name[0] || "#").toUpperCase(),
103
+ dest: dest(n),
104
+ open: notificationOpen(n.deeplink, served),
105
+ };
106
+ }
107
+
108
+ const MOCK: Row[] = [
109
+ { id: "sample-like", name: "Maya Levin liked your post", subtitle: "“Weekend pop-up” · 2h ago", unread: true, unreadDot: "●", photo: "", initial: "M", dest: "" },
110
+ { id: "sample-comment", name: "Daniel Cohen commented on your post", subtitle: "“Love this — count me in!” · 5h ago", unread: true, unreadDot: "●", photo: "", initial: "D", dest: "" },
111
+ { id: "sample-booking", name: "Booking reminder", subtitle: "Yoga Flow tomorrow at 9:00 AM · Yesterday", unread: false, unreadDot: "", photo: "", initial: "B", dest: "" },
112
+ { id: "sample-follow", name: "Noa Bar started following you", subtitle: "2d ago", unread: false, unreadDot: "", photo: "", initial: "N", dest: "" },
113
+ { id: "sample-offer", name: "New offer just for you", subtitle: "15% off your next order · 3d ago", unread: false, unreadDot: "", photo: "", initial: "%", dest: "" },
114
+ ];
115
+
116
+ /** sample rows reach the screen ONLY in the host's explicit sample preview;
117
+ * a failed or empty query is an honest error / empty state (branded-load-state.ts). */
118
+ const COPY: LoadCopy<Row> = {
119
+ prefix: "notifications",
120
+ empty: "You're all caught up — no notifications yet.",
121
+ error: "Notifications couldn't be loaded.",
122
+ signIn: "Sign in to see your notifications.",
123
+ sample: () => MOCK.map((r) => ({ ...r })),
124
+ };
125
+
126
+ const signInRequired = () => new Error("Unauthenticated: sign in to see notifications");
127
+
128
+ async function requireMember(): Promise<MemberAccess> {
129
+ const member = await memberAccess();
130
+ if (!member.email) throw signInRequired();
131
+ return member;
132
+ }
133
+
134
+ async function requireInboxMember(s: S): Promise<void> {
135
+ const member = await requireMember();
136
+ if (!s.inboxMember || member.email !== s.inboxMember.email || member.scope !== s.inboxMember.scope) {
137
+ throw new Error("Member access changed: reload notifications");
138
+ }
139
+ }
140
+
141
+ /** Each successful load owns a fresh member object. Presentation changes and
142
+ * other read marks keep it; a newer inbox replaces it even for the same member. */
143
+ function currentInbox(s: S): S | undefined {
144
+ const current: S = svc.getState();
145
+ return current.inboxMember === s.inboxMember && (s.inboxMember !== null || current.items === s.items)
146
+ ? current : undefined;
147
+ }
148
+
149
+ const defineService = withOnlineWrites(registerService, ["markOneRead","markAll"], { messageFields: ["actionMessage"] });
150
+ const INITIAL = { ...LOADING, items: [] as Row[], emptyText: "", actionMessage: "", pendingUrl: "", inboxMember: null };
151
+ const svc = defineService<S, {
152
+ prepare: (s: S) => S;
153
+ load: (s: S, arg?: unknown) => Promise<S>;
154
+ markOneRead: (s: S, id: string) => Promise<S | undefined>;
155
+ markAll: (s: S) => Promise<S | undefined>;
156
+ open: (s: S, arg?: unknown) => Promise<S | undefined>;
157
+ }>("himiBrandedNotifications", {
158
+ state: INITIAL,
159
+ actions: {
160
+ // Clear worker-restored state before this worker starts its member probe.
161
+ // Native hosts may already cold-paint their account-scoped snapshot; this
162
+ // reducer does not control that earlier host phase.
163
+ prepare: (s) => ({ ...s, ...INITIAL }),
164
+ load: async (s, arg) => {
165
+ // The screen names which of the link targets this app serves (a comma list); none given means any may be tried.
166
+ const served = servedScreens(arg);
167
+ try {
168
+ const member = await requireMember();
169
+ const items = (await queryNotifications(25)).map((n) => norm(n, served));
170
+ await assertMemberAccess(member);
171
+ return { ...s, ...loaded("items", items, COPY), inboxMember: member, actionMessage: "", pendingUrl: "" };
172
+ } catch (err) {
173
+ return { ...s, ...loadFailed("items", (await memberAccess()).email ? err : signInRequired(), COPY), inboxMember: null, actionMessage: "", pendingUrl: "" };
174
+ }
175
+ },
176
+ // Mark one read; optimistically clear its dot. Real write is best-effort and
177
+ // a no-op on sample rows.
178
+ markOneRead: async (s, id): Promise<S | undefined> => {
179
+ if (!id || s.busy) return undefined;
180
+ if (!s.isMock) {
181
+ try {
182
+ await requireInboxMember(s);
183
+ if (!currentInbox(s)) return undefined;
184
+ if (!id.startsWith("sample-")) { try { await markRead([id]); } catch { /* keep optimistic */ } }
185
+ // Embedded workers may survive a host account/tenant change while
186
+ // Wix is acknowledging the write. Recheck the live identity too.
187
+ await requireInboxMember(s);
188
+ } catch (err) {
189
+ // The read may have finished while identity was checked. An obsolete
190
+ // write must not clear the freshly published inbox with its error.
191
+ const current = currentInbox(s);
192
+ return current ? { ...current, ...loadFailed("items", err, COPY), inboxMember: null } : undefined;
193
+ }
194
+ }
195
+ // A refresh can also finish while Wix acknowledges the write.
196
+ const current = currentInbox(s);
197
+ return current ? { ...current, items: current.items.map((r) => (r.id === id ? { ...r, unread: false, unreadDot: "" } : r)) } : undefined;
198
+ },
199
+ // A tap on a row opens what the notification points at, like the One App: a Himi screen when its link names
200
+ // one of ours (see _shared/notification-target.ts), else its https link, else a visible "can't open".
201
+ // A web link is written by the site, so it needs a SECOND tap on the same row, after the first tap has
202
+ // shown where it goes. It never replaces the inbox, and an unknown link never guesses a screen.
203
+ open: async (s, arg): Promise<S | undefined> => {
204
+ const id = String((arg as { id?: unknown } | null | undefined)?.id ?? "");
205
+ const row = s.items.find((r) => r.id === id);
206
+ if (!row || s.busy) return undefined;
207
+ if (!s.isMock) {
208
+ try { await requireInboxMember(s); } catch (err) {
209
+ const current = currentInbox(s);
210
+ return current ? { ...current, ...loadFailed("items", err, COPY), inboxMember: null } : undefined;
211
+ }
212
+ }
213
+ const current = currentInbox(s);
214
+ if (!current) return undefined;
215
+ const action = row.open ?? { kind: "none" as const };
216
+ if (action.kind === "url") {
217
+ if (current.pendingUrl !== action.url) {
218
+ return { ...current, pendingUrl: action.url, actionMessage: copyTemplate("notifications.openLinkText", "Tap again to open {host}.", { host: urlHost(action.url) }) };
219
+ }
220
+ const opened = await openRichLink(action.url);
221
+ const now = currentInbox(s);
222
+ return now ? { ...now, pendingUrl: "", actionMessage: opened ? "" : copyParam("notifications.cantOpenText", "This notification can't be opened here.") } : undefined;
223
+ }
224
+ if (action.kind === "none") {
225
+ return { ...current, pendingUrl: "", actionMessage: copyParam("notifications.cantOpenText", "This notification can't be opened here.") };
226
+ }
227
+ // Read on open: the dot clears at once, the write is best effort and never holds the navigation.
228
+ if (!id.startsWith("sample-") && row.unread) markRead([id]).catch(() => undefined);
229
+ const read = { ...current, pendingUrl: "", actionMessage: "", items: current.items.map((r) => (r.id === id ? { ...r, unread: false, unreadDot: "" } : r)) };
230
+ return navigate(read, { screenId: action.target.screenId, args: action.target.args });
231
+ },
232
+ // Mark everything read; optimistically clear all dots.
233
+ markAll: async (s): Promise<S | undefined> => {
234
+ if (s.busy) return undefined;
235
+ if (!s.isMock) {
236
+ try {
237
+ await requireInboxMember(s);
238
+ if (!currentInbox(s)) return undefined;
239
+ try { await markAllRead(); } catch { /* keep optimistic */ }
240
+ await requireInboxMember(s);
241
+ } catch (err) {
242
+ // The read may have finished while identity was checked. An obsolete
243
+ // write must not clear the freshly published inbox with its error.
244
+ const current = currentInbox(s);
245
+ return current ? { ...current, ...loadFailed("items", err, COPY), inboxMember: null } : undefined;
246
+ }
247
+ }
248
+ // A refresh can also finish while Wix acknowledges the write.
249
+ const current = currentInbox(s);
250
+ return current ? { ...current, items: current.items.map((r) => (r.unread ? { ...r, unread: false, unreadDot: "" } : r)) } : undefined;
251
+ },
252
+ },
253
+ });
254
+ svc.prepare();
255
+ svc.load();
256
+ export { svc };
@@ -0,0 +1,389 @@
1
+ // Tier-5 bundle: himi-clinic-home — the medical-services template's Home, The clinic, Our team
2
+ // and Contact us screens.
3
+ //
4
+ // Home shows a signed-in member's next appointments directly under the cover (the brief's "My
5
+ // appointments"): the same read as My Bookings' Upcoming tab (_shared/member-bookings.ts), the
6
+ // nearest first, at most three. A visitor never sees the section — not even an empty frame —
7
+ // because it stays hidden until the member read says there is a member. Our team is the site's
8
+ // Wix Bookings staff (the doctors): a failed read is an error with Retry, an empty team an empty
9
+ // state, never sample rows. The clinic and Contact us read nothing: their words are the copy
10
+ // pack's, and their call, email, WhatsApp and maps links leave the app through `openLink`.
11
+ //
12
+ // Nothing here reads a clock at boot: the release build hashes the boot state, so a time read
13
+ // there would make every build differ. Times are read in the actions.
14
+ import { defineService, navigate } from "@himalaya/state";
15
+ import { wixMediaUrl } from "@himalaya/wix-media";
16
+ import { open as openUrl } from "@himalaya/open-url";
17
+ import { memberAccess, assertMemberAccess } from "../_shared/member-access.js";
18
+ import { fetchMemberBookings, type MemberBookingRow } from "../_shared/member-bookings.js";
19
+ import { memberScreenOpener } from "../_shared/member-screen.js";
20
+ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
21
+ import { nameWords } from "../_shared/staff-name.js";
22
+
23
+ export interface AppointmentRow {
24
+ id: string;
25
+ title: string;
26
+ /** "Tue, Nov 18, 10:00 AM" — the booking's start, as My Bookings words it. */
27
+ when: string;
28
+ /** "with Dr. John Wang"; "" when the booking names no staff member. */
29
+ staff: string;
30
+ hasStaff: boolean;
31
+ noStaff: boolean;
32
+ a11y: string;
33
+ }
34
+ export interface DoctorRow {
35
+ id: string;
36
+ name: string;
37
+ /** "Family Doctor" — the first sentence of the staff member's description. */
38
+ role: string;
39
+ image: string;
40
+ hasImage: boolean;
41
+ noImage: boolean;
42
+ initials: string;
43
+ a11y: string;
44
+ }
45
+ type ReadStatus = "idle" | "loading" | "ready" | "error";
46
+ export interface S {
47
+ isMember: boolean;
48
+ notMember: boolean;
49
+ /** My appointments on Home. */
50
+ appointmentsStatus: ReadStatus;
51
+ appointments: AppointmentRow[];
52
+ /** Whose appointments the list holds: the member's email and account scope, the identity the
53
+ * shared member check compares. A list is revalidated quietly only for that same identity,
54
+ * never shown to the next member or another account. */
55
+ appointmentsFor: string;
56
+ /** The whole section: hidden for a visitor, and while the member is not known yet. */
57
+ hideAppointments: boolean;
58
+ appointmentsLoadingHidden: boolean;
59
+ appointmentsErrorHidden: boolean;
60
+ appointmentsEmptyHidden: boolean;
61
+ appointmentsListHidden: boolean;
62
+ /** Our team. */
63
+ teamStatus: ReadStatus;
64
+ team: DoctorRow[];
65
+ teamLoadingHidden: boolean;
66
+ teamErrorHidden: boolean;
67
+ teamEmptyHidden: boolean;
68
+ teamListHidden: boolean;
69
+ /** The Snackbar of a link that did not open ("" when none shows). It hides itself after
70
+ * SNACKBAR_MS through the `_poll` tick (`tick`); `snackbarAt` is when it showed. */
71
+ snackbar: string;
72
+ snackbarHidden: boolean;
73
+ snackbarAt: number;
74
+ }
75
+
76
+ export const APPOINTMENTS_MAX = 3;
77
+ export const SNACKBAR_MS = 3000;
78
+ /** The tick that hides the Snackbar: armed when one shows, stopped (`stop: true`) by the tick that
79
+ * hides it, so an idle screen never ticks. */
80
+ const SNACKBAR_POLL = { id: "clinic-snackbar", intervalMs: 1000, action: "himiClinicHome.tick", immediate: false };
81
+ const SNACKBAR_POLL_STOP = { id: "clinic-snackbar", stop: true as const };
82
+ const TEAM_MAX = 24;
83
+
84
+ type WixApi = { call: (method: string, path: string, body?: unknown) => Promise<unknown> };
85
+ function wixApi(): WixApi | null {
86
+ return (globalThis as { himalaya?: { wixApi?: WixApi } }).himalaya?.wixApi ?? null;
87
+ }
88
+
89
+ const clean = (value: unknown): string => (typeof value === "string" ? value.replace(/\s+/g, " ").trim() : "");
90
+
91
+ function mediaUrl(value: unknown): string {
92
+ if (typeof value === "string") return wixMediaUrl(value);
93
+ if (!value || typeof value !== "object") return "";
94
+ const node = value as Record<string, unknown>;
95
+ for (const direct of [node.url, node.src, node.imageUrl]) {
96
+ const url = wixMediaUrl(direct);
97
+ if (url) return url;
98
+ }
99
+ for (const nested of [node.image, node.mainMedia, node.media]) {
100
+ const url = mediaUrl(nested);
101
+ if (url) return url;
102
+ }
103
+ return "";
104
+ }
105
+
106
+ export function appointmentRow(row: MemberBookingRow): AppointmentRow {
107
+ const title = clean(row.title) || copyParam("clinic.bookingFallback", "Appointment");
108
+ const staff = row.staff ? copyTemplate("clinic.withStaff", "with {name}", { name: row.staff }) : "";
109
+ return {
110
+ id: row.id,
111
+ title,
112
+ when: row.subtitle,
113
+ staff,
114
+ hasStaff: !!staff,
115
+ noStaff: !staff,
116
+ a11y: [title, row.subtitle, staff].filter(Boolean).join(", "),
117
+ };
118
+ }
119
+
120
+ /** The member's next appointments: still ahead of `now`, the nearest first, at most three. */
121
+ export function upcomingOf(rows: MemberBookingRow[], now: number): AppointmentRow[] {
122
+ return rows
123
+ .filter((row) => Date.parse(row.start) > now)
124
+ .sort((a, b) => Date.parse(a.start) - Date.parse(b.start))
125
+ .slice(0, APPOINTMENTS_MAX)
126
+ .map(appointmentRow);
127
+ }
128
+
129
+ interface RawStaff { id?: unknown; name?: unknown; description?: unknown; mainMedia?: unknown }
130
+
131
+ /** "Family Doctor" from "Family Doctor. Ten years of…": the description's first sentence. */
132
+ function roleOf(description: unknown): string {
133
+ const text = clean(description);
134
+ if (!text) return "";
135
+ const first = text.split(/(?<=[.!?])\s/)[0] ?? text;
136
+ return first.replace(/[.!?]$/, "").slice(0, 60);
137
+ }
138
+
139
+ export function doctorRow(raw: RawStaff): DoctorRow {
140
+ const name = clean(raw.name);
141
+ const image = mediaUrl(raw.mainMedia);
142
+ const role = roleOf(raw.description);
143
+ const { words } = nameWords(name);
144
+ return {
145
+ id: String(raw.id ?? ""),
146
+ name,
147
+ role,
148
+ image,
149
+ hasImage: !!image,
150
+ noImage: !image,
151
+ initials: ((words[0]?.[0] ?? "") + (words.length > 1 ? words[words.length - 1]?.[0] ?? "" : "")).toUpperCase(),
152
+ a11y: [name, role].filter(Boolean).join(", "),
153
+ };
154
+ }
155
+
156
+ /** The Bookings staff with a real name ("Staff Member #1" is Wix's unnamed default), pictured
157
+ * first, in the site's own order within. */
158
+ export function teamOf(staff: RawStaff[]): DoctorRow[] {
159
+ const rows = staff.map(doctorRow).filter((row) => row.id && row.name && !/^staff member\b/i.test(row.name));
160
+ return [...rows.filter((row) => row.hasImage), ...rows.filter((row) => !row.hasImage)].slice(0, TEAM_MAX);
161
+ }
162
+
163
+ export function derive(s: S): S {
164
+ const a = s.appointmentsStatus;
165
+ const t = s.teamStatus;
166
+ return {
167
+ ...s,
168
+ notMember: !s.isMember,
169
+ hideAppointments: !s.isMember,
170
+ appointmentsLoadingHidden: a !== "loading",
171
+ appointmentsErrorHidden: a !== "error",
172
+ appointmentsEmptyHidden: a !== "ready" || s.appointments.length > 0,
173
+ appointmentsListHidden: a !== "ready" || s.appointments.length === 0,
174
+ teamLoadingHidden: t !== "loading" && t !== "idle",
175
+ teamErrorHidden: t !== "error",
176
+ teamEmptyHidden: t !== "ready" || s.team.length > 0,
177
+ teamListHidden: t !== "ready" || s.team.length === 0,
178
+ snackbarHidden: !s.snackbar,
179
+ };
180
+ }
181
+
182
+ export const BOOT: S = derive({
183
+ isMember: false,
184
+ notMember: true,
185
+ appointmentsStatus: "idle",
186
+ appointments: [],
187
+ appointmentsFor: "",
188
+ hideAppointments: true,
189
+ appointmentsLoadingHidden: true,
190
+ appointmentsErrorHidden: true,
191
+ appointmentsEmptyHidden: true,
192
+ appointmentsListHidden: true,
193
+ teamStatus: "idle",
194
+ team: [],
195
+ teamLoadingHidden: false,
196
+ teamErrorHidden: true,
197
+ teamEmptyHidden: true,
198
+ teamListHidden: true,
199
+ snackbar: "",
200
+ snackbarHidden: true,
201
+ snackbarAt: 0,
202
+ });
203
+
204
+ /** Directions, a call, an email or a WhatsApp chat: only these leave the app, and a web link only
205
+ * to a maps host or wa.me. A link the descriptor did not mean to send is refused, never opened. */
206
+ export function allowedLink(raw: string): string {
207
+ const url = raw.trim();
208
+ if (/^tel:\+?[0-9][0-9().\- ]*$/i.test(url)) return url;
209
+ if (/^mailto:[^\s@]+@[^\s@]+$/i.test(url)) return url;
210
+ // No `URL`: a bare iOS JSContext (the worker engine floor) has none. The host is read by hand —
211
+ // https only, no `user@` part and no backslash (a parser reads "\" as "/"), then an optional
212
+ // port and a path.
213
+ const match = /^https:\/\/([^/?#:@\s\\]+)(?::\d+)?(?:[/?#]\S*)?$/i.exec(url);
214
+ // Google Maps share links come from maps.google.com and maps.app.goo.gl as well as google.com.
215
+ if (match && /^(wa\.me|maps\.apple\.com|(www\.|maps\.)?google\.com|maps\.app\.goo\.gl)$/i.test(match[1])) return url;
216
+ return "";
217
+ }
218
+
219
+ /** `https://wa.me/<digits>` for a phone number as people write it ("+1 (555) 010-2030"), or ""
220
+ * when it holds no digits. */
221
+ export function whatsappUrl(phone: string): string {
222
+ const digits = phone.replace(/\D/g, "");
223
+ return digits ? `https://wa.me/${digits}` : "";
224
+ }
225
+
226
+ // The newest state an action returned — what a slow action answers from after its await.
227
+ let latest: S = BOOT;
228
+ const commit = (next: S): S => (latest = next);
229
+ /** The state as it is now: the runtime's, which also holds a state a host restored (hydrated). */
230
+ const now = (): S => (svc.getState?.() as S | undefined) ?? latest;
231
+
232
+ // Each read's number: a screen re-entered while its first read still runs starts a second one, and
233
+ // only the newest may commit.
234
+ let homeSeq = 0;
235
+ let teamSeq = 0;
236
+ // Each link tap's number: only the newest tap's answer sets the message.
237
+ let linkTaps = 0;
238
+ const openMemberScreen = memberScreenOpener();
239
+
240
+ /** `fresh`: read with the skeleton, never quietly — the reload after the member changed. */
241
+ async function loadHome(fresh = false): Promise<S> {
242
+ const mine = ++homeSeq;
243
+ let member;
244
+ try {
245
+ member = await memberAccess();
246
+ } catch {
247
+ member = { email: "", scope: "" };
248
+ }
249
+ if (mine !== homeSeq) return now();
250
+ if (!member.email) return commit(derive({ ...now(), isMember: false, appointmentsStatus: "idle", appointments: [], appointmentsFor: "" }));
251
+ // A member: PUBLISH the section in its loading state (through an action — only what an action
252
+ // returns reaches the screen), then the read. Retry from the error card shows the skeleton too.
253
+ // A list already on screen revalidates QUIETLY: coming Back to Home must not collapse it to the
254
+ // skeleton and replay the stagger.
255
+ // Only the SAME member's list (email and account scope): another member's or another account's
256
+ // appointments are never left on screen.
257
+ const who = JSON.stringify([member.email, member.scope]);
258
+ const shown = now();
259
+ const quiet = !fresh && shown.isMember && shown.appointmentsStatus === "ready" && shown.appointmentsFor === who;
260
+ if (!quiet) {
261
+ await svc.setLoading({ part: "appointments" });
262
+ if (mine !== homeSeq) return now();
263
+ }
264
+ const at = Date.now();
265
+ try {
266
+ const page = await fetchMemberBookings({ query: "", filter: "value:Upcoming", sort: "default", savedIds: [] }, "", new Date(at).toISOString(), member);
267
+ if (mine !== homeSeq) return now();
268
+ return commit(derive({ ...now(), isMember: true, appointmentsStatus: "ready", appointments: upcomingOf(page.items, at), appointmentsFor: who }));
269
+ } catch {
270
+ if (mine !== homeSeq) return now();
271
+ // A failed quiet re-read keeps the list only while the same member is signed in. When the
272
+ // member signed out or switched account, Home reloads, with the skeleton, for whoever is
273
+ // signed in now. A failed check counts as a change: the list is never kept on a guess.
274
+ if (quiet) {
275
+ let same = true;
276
+ try { await assertMemberAccess(member); } catch { same = false; }
277
+ if (mine !== homeSeq) return now();
278
+ return same ? now() : loadHome(true);
279
+ }
280
+ return commit(derive({ ...now(), isMember: true, appointmentsStatus: "error", appointments: [], appointmentsFor: "" }));
281
+ }
282
+ }
283
+
284
+ async function loadTeam(): Promise<S> {
285
+ const mine = ++teamSeq;
286
+ const api = wixApi();
287
+ // Published through an action, so Retry from the error card shows the skeleton while it reads.
288
+ // A team already on screen revalidates quietly (each sidebar visit re-reads it).
289
+ const quiet = now().teamStatus === "ready";
290
+ if (!quiet) {
291
+ await svc.setLoading({ part: "team" });
292
+ if (mine !== teamSeq) return now();
293
+ }
294
+ if (!api) return quiet ? now() : commit(derive({ ...now(), teamStatus: "error", team: [] }));
295
+ try {
296
+ const res = await api.call("POST", "/bookings/v1/staff-members/query", { query: { cursorPaging: { limit: 100 } } }) as { staffMembers?: RawStaff[] } | null;
297
+ if (mine !== teamSeq) return now();
298
+ return commit(derive({ ...now(), teamStatus: "ready", team: teamOf(res?.staffMembers ?? []) }));
299
+ } catch {
300
+ if (mine !== teamSeq) return now();
301
+ if (quiet) return now();
302
+ return commit(derive({ ...now(), teamStatus: "error", team: [] }));
303
+ }
304
+ }
305
+
306
+ /** Member data: kept out of a restored snapshot, so it boots as BOOT has it (section hidden). */
307
+ const MEMBER_FIELDS = ["isMember", "notMember", "appointmentsStatus", "appointments", "appointmentsFor", "hideAppointments",
308
+ "appointmentsLoadingHidden", "appointmentsErrorHidden", "appointmentsEmptyHidden", "appointmentsListHidden"] as const satisfies readonly (keyof S)[];
309
+
310
+ const svc = defineService<S, {
311
+ /** Home: who is signed in, and a member's next appointments. */
312
+ loadHome: (s: S, arg?: unknown) => Promise<S>;
313
+ /** Our team: the Bookings staff. */
314
+ loadTeam: (s: S, arg?: unknown) => Promise<S>;
315
+ /** The clinic and Contact us: no read, only this screen's words for the link messages. */
316
+ ready: (s: S, arg?: unknown) => S;
317
+ /** Publish a read's loading state (`part`: "appointments" or "team") before the read starts. */
318
+ setLoading: (s: S, arg?: unknown) => S;
319
+ openLink: (s: S, arg?: unknown) => Promise<S | undefined>;
320
+ /** WhatsApp from a phone number as written (`phone`), so the descriptor never builds the URL. */
321
+ openWhatsApp: (s: S, arg?: unknown) => Promise<S | undefined>;
322
+ openForMember: (s: S, arg?: unknown) => Promise<S>;
323
+ tick: (s: S) => S | undefined;
324
+ }>("himiClinicHome", {
325
+ // A Snackbar belongs to the visit it showed on: a restored screen must not show it again.
326
+ // The member's appointments and identity are never written to the saved snapshot, nor restored
327
+ // from one (no private disk cache): a cold launch after a sign-out must not show the last
328
+ // member's appointments. Home reads them again for whoever is signed in.
329
+ notHydrated: ["snackbar", "snackbarHidden", "snackbarAt", ...MEMBER_FIELDS],
330
+ notPersisted: MEMBER_FIELDS,
331
+ state: BOOT,
332
+ actions: {
333
+ loadHome: (_s, arg) => { stashCopy(arg); return loadHome(); },
334
+ loadTeam: (_s, arg) => { stashCopy(arg); return loadTeam(); },
335
+ ready: (s, arg) => { stashCopy(arg); return commit(derive({ ...s, snackbar: "", snackbarAt: 0 })); },
336
+ setLoading: (s, arg) => {
337
+ const part = String((arg as { part?: unknown } | undefined)?.part ?? "");
338
+ if (part === "appointments") return commit(derive({ ...s, isMember: true, appointmentsStatus: "loading" }));
339
+ if (part === "team") return commit(derive({ ...s, teamStatus: "loading" }));
340
+ return s;
341
+ },
342
+ openLink: (_s, arg) => openAllowed(String((arg as { url?: unknown } | undefined)?.url ?? "")),
343
+ openWhatsApp: (_s, arg) => openAllowed(whatsappUrl(String((arg as { phone?: unknown } | undefined)?.phone ?? ""))),
344
+ // A member screen (the chat): a member goes there; a guest gets the sign-in sheet first
345
+ // (_shared/member-screen.ts).
346
+ openForMember: async (_s, arg) => {
347
+ const nav = await openMemberScreen(arg);
348
+ return nav ? navigate(now(), nav) : now();
349
+ },
350
+ // The `_poll` tick: hide a Snackbar that has shown for SNACKBAR_MS; otherwise change nothing.
351
+ tick: (s) => {
352
+ if (s.snackbar && Date.now() - s.snackbarAt < SNACKBAR_MS) return undefined;
353
+ // Hide it (or there is none: a restored screen's leftover poll) and stop the poll.
354
+ return commit({ ...derive({ ...s, snackbar: "", snackbarAt: 0 }), _poll: { ...SNACKBAR_POLL_STOP } } as S);
355
+ },
356
+ },
357
+ });
358
+
359
+ /** Show `message` as the Snackbar, and arm the tick that hides it. */
360
+ function showSnackbar(message: string): S {
361
+ const next = derive({ ...now(), snackbar: message, snackbarAt: Date.now() });
362
+ return commit({ ...next, _poll: { ...SNACKBAR_POLL } } as S);
363
+ }
364
+
365
+ async function openAllowed(raw: string): Promise<S | undefined> {
366
+ const url = allowedLink(raw);
367
+ const failed = copyParam("clinic.linkFailed", "This link could not be opened.");
368
+ const tap = ++linkTaps;
369
+ if (!url) return showSnackbar(failed);
370
+ let opened = false;
371
+ // A wa.me or maps link goes to the system, which hands it to WhatsApp or the maps app (on web, a
372
+ // new tab); the in-app browser would show WhatsApp's web page. tel and mailto keep the default.
373
+ const mode = /^https:/i.test(url) ? "system_browser" : undefined;
374
+ try { opened = (await openUrl(url, mode)).opened === true; } catch { opened = false; }
375
+ // A newer tap has answered, or this one opened: nothing to show.
376
+ if (tap !== linkTaps || opened) return undefined;
377
+ return showSnackbar(failed);
378
+ }
379
+
380
+ // A runtime that predates the hydration opt-outs has already laid the saved snapshot over the
381
+ // state, and may have written the member fields to it: put this boot's member fields back in place
382
+ // before any action runs. In place, because on those runtimes getState() IS the stored state.
383
+ if ((globalThis as { himalaya?: { hydrationOptOut?: unknown } }).himalaya?.hydrationOptOut !== true) {
384
+ const live = (svc as { getState?: () => S | undefined }).getState?.();
385
+ if (live && typeof live === "object") for (const key of MEMBER_FIELDS) (live as unknown as Record<string, unknown>)[key] = BOOT[key];
386
+ }
387
+
388
+ // No read at boot: each screen loads on appear, with its copy.
389
+ export { svc };