@wix/himalaya-cli 0.1794.0 → 0.1795.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 (350) hide show
  1. package/dist/browser-plane/assets.json +5 -5
  2. package/dist/browser-plane/preview-deferred/{83e211fe9fba65cca1fac7a0d552fbd3ba2873496f1c6117d5ac561d489ac839.bin → 11bd915805d61287157c1beca36b2d642d15e8107049a7d0fed28468d2965395.bin} +1 -1
  3. package/dist/browser-plane/sw.js +8 -8
  4. package/dist/cli.mjs +75 -44
  5. package/dist/preview-assets.generated.bin +0 -0
  6. package/package.json +2 -2
  7. package/templates/beauty-salon/config.ts +16 -1
  8. package/templates/beauty-salon/l10n/ar.json +6 -5
  9. package/templates/beauty-salon/l10n/cs.json +6 -5
  10. package/templates/beauty-salon/l10n/da.json +6 -5
  11. package/templates/beauty-salon/l10n/de.json +6 -5
  12. package/templates/beauty-salon/l10n/el.json +6 -5
  13. package/templates/beauty-salon/l10n/en.json +8 -1
  14. package/templates/beauty-salon/l10n/es.json +6 -5
  15. package/templates/beauty-salon/l10n/fi.json +6 -5
  16. package/templates/beauty-salon/l10n/fr.json +6 -5
  17. package/templates/beauty-salon/l10n/he.json +5 -4
  18. package/templates/beauty-salon/l10n/hu.json +6 -5
  19. package/templates/beauty-salon/l10n/id.json +6 -5
  20. package/templates/beauty-salon/l10n/it.json +6 -5
  21. package/templates/beauty-salon/l10n/ja.json +6 -5
  22. package/templates/beauty-salon/l10n/ko.json +6 -5
  23. package/templates/beauty-salon/l10n/lt.json +6 -5
  24. package/templates/beauty-salon/l10n/nl.json +6 -5
  25. package/templates/beauty-salon/l10n/no.json +6 -5
  26. package/templates/beauty-salon/l10n/pl.json +6 -5
  27. package/templates/beauty-salon/l10n/pt.json +6 -5
  28. package/templates/beauty-salon/l10n/ru.json +6 -5
  29. package/templates/beauty-salon/l10n/sv.json +6 -5
  30. package/templates/beauty-salon/l10n/th.json +6 -5
  31. package/templates/beauty-salon/l10n/tr.json +6 -5
  32. package/templates/beauty-salon/l10n/uk.json +6 -5
  33. package/templates/beauty-salon/l10n/vi.json +6 -5
  34. package/templates/beauty-salon/l10n/zh.json +6 -5
  35. package/templates/beauty-salon/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  36. package/templates/branded-lite/config.ts +26 -1
  37. package/templates/branded-lite/dev/index.ts +955 -1
  38. package/templates/branded-lite/himalaya.content.json +3 -0
  39. package/templates/branded-lite/l10n/ar.json +106 -5
  40. package/templates/branded-lite/l10n/cs.json +106 -5
  41. package/templates/branded-lite/l10n/da.json +106 -5
  42. package/templates/branded-lite/l10n/de.json +106 -5
  43. package/templates/branded-lite/l10n/el.json +106 -5
  44. package/templates/branded-lite/l10n/en.json +43 -1
  45. package/templates/branded-lite/l10n/es.json +106 -5
  46. package/templates/branded-lite/l10n/fi.json +106 -5
  47. package/templates/branded-lite/l10n/fr.json +106 -5
  48. package/templates/branded-lite/l10n/he.json +86 -4
  49. package/templates/branded-lite/l10n/hu.json +106 -5
  50. package/templates/branded-lite/l10n/id.json +106 -5
  51. package/templates/branded-lite/l10n/it.json +106 -5
  52. package/templates/branded-lite/l10n/ja.json +106 -5
  53. package/templates/branded-lite/l10n/ko.json +106 -5
  54. package/templates/branded-lite/l10n/lt.json +106 -5
  55. package/templates/branded-lite/l10n/nl.json +106 -5
  56. package/templates/branded-lite/l10n/no.json +106 -5
  57. package/templates/branded-lite/l10n/pl.json +106 -5
  58. package/templates/branded-lite/l10n/pt.json +106 -5
  59. package/templates/branded-lite/l10n/ru.json +106 -5
  60. package/templates/branded-lite/l10n/sv.json +106 -5
  61. package/templates/branded-lite/l10n/th.json +106 -5
  62. package/templates/branded-lite/l10n/tr.json +106 -5
  63. package/templates/branded-lite/l10n/uk.json +106 -5
  64. package/templates/branded-lite/l10n/vi.json +106 -5
  65. package/templates/branded-lite/l10n/zh.json +106 -5
  66. package/templates/branded-lite/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  67. package/templates/branded-lite/tier5-src/_shared/program-content.ts +94 -0
  68. package/templates/branded-lite/tier5-src/_shared/program-progress-mark.ts +22 -0
  69. package/templates/branded-lite/tier5-src/_shared/program-reads.ts +72 -0
  70. package/templates/branded-lite/tier5-src/himi-branded-lite-program-participant/index.ts +46 -62
  71. package/templates/branded-lite/tier5-src/himi-branded-lite-program-participant/model.ts +12 -76
  72. package/templates/branded-lite/tier5-src/himi-branded-lite-program-step/index.ts +520 -0
  73. package/templates/branded-lite/tier5-src/himi-branded-lite-program-step/model.ts +69 -0
  74. package/templates/brandy/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  75. package/templates/community-club/config.ts +16 -1
  76. package/templates/community-club/l10n/ar.json +6 -5
  77. package/templates/community-club/l10n/cs.json +6 -5
  78. package/templates/community-club/l10n/da.json +6 -5
  79. package/templates/community-club/l10n/de.json +6 -5
  80. package/templates/community-club/l10n/el.json +6 -5
  81. package/templates/community-club/l10n/en.json +8 -1
  82. package/templates/community-club/l10n/es.json +6 -5
  83. package/templates/community-club/l10n/fi.json +6 -5
  84. package/templates/community-club/l10n/fr.json +6 -5
  85. package/templates/community-club/l10n/he.json +5 -4
  86. package/templates/community-club/l10n/hu.json +6 -5
  87. package/templates/community-club/l10n/id.json +6 -5
  88. package/templates/community-club/l10n/it.json +6 -5
  89. package/templates/community-club/l10n/ja.json +6 -5
  90. package/templates/community-club/l10n/ko.json +6 -5
  91. package/templates/community-club/l10n/lt.json +6 -5
  92. package/templates/community-club/l10n/nl.json +6 -5
  93. package/templates/community-club/l10n/no.json +6 -5
  94. package/templates/community-club/l10n/pl.json +6 -5
  95. package/templates/community-club/l10n/pt.json +6 -5
  96. package/templates/community-club/l10n/ru.json +6 -5
  97. package/templates/community-club/l10n/sv.json +6 -5
  98. package/templates/community-club/l10n/th.json +6 -5
  99. package/templates/community-club/l10n/tr.json +6 -5
  100. package/templates/community-club/l10n/uk.json +6 -5
  101. package/templates/community-club/l10n/vi.json +6 -5
  102. package/templates/community-club/l10n/zh.json +6 -5
  103. package/templates/community-club/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  104. package/templates/conference/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  105. package/templates/events-meetups/config.ts +16 -1
  106. package/templates/events-meetups/l10n/ar.json +6 -5
  107. package/templates/events-meetups/l10n/cs.json +6 -5
  108. package/templates/events-meetups/l10n/da.json +6 -5
  109. package/templates/events-meetups/l10n/de.json +6 -5
  110. package/templates/events-meetups/l10n/el.json +6 -5
  111. package/templates/events-meetups/l10n/en.json +8 -1
  112. package/templates/events-meetups/l10n/es.json +6 -5
  113. package/templates/events-meetups/l10n/fi.json +6 -5
  114. package/templates/events-meetups/l10n/fr.json +6 -5
  115. package/templates/events-meetups/l10n/he.json +5 -4
  116. package/templates/events-meetups/l10n/hu.json +6 -5
  117. package/templates/events-meetups/l10n/id.json +6 -5
  118. package/templates/events-meetups/l10n/it.json +6 -5
  119. package/templates/events-meetups/l10n/ja.json +6 -5
  120. package/templates/events-meetups/l10n/ko.json +6 -5
  121. package/templates/events-meetups/l10n/lt.json +6 -5
  122. package/templates/events-meetups/l10n/nl.json +6 -5
  123. package/templates/events-meetups/l10n/no.json +6 -5
  124. package/templates/events-meetups/l10n/pl.json +6 -5
  125. package/templates/events-meetups/l10n/pt.json +6 -5
  126. package/templates/events-meetups/l10n/ru.json +6 -5
  127. package/templates/events-meetups/l10n/sv.json +6 -5
  128. package/templates/events-meetups/l10n/th.json +6 -5
  129. package/templates/events-meetups/l10n/tr.json +6 -5
  130. package/templates/events-meetups/l10n/uk.json +6 -5
  131. package/templates/events-meetups/l10n/vi.json +6 -5
  132. package/templates/events-meetups/l10n/zh.json +6 -5
  133. package/templates/events-meetups/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  134. package/templates/fitness-gym/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  135. package/templates/gym-fitness/config.ts +16 -1
  136. package/templates/gym-fitness/l10n/ar.json +6 -5
  137. package/templates/gym-fitness/l10n/cs.json +6 -5
  138. package/templates/gym-fitness/l10n/da.json +6 -5
  139. package/templates/gym-fitness/l10n/de.json +6 -5
  140. package/templates/gym-fitness/l10n/el.json +6 -5
  141. package/templates/gym-fitness/l10n/en.json +8 -1
  142. package/templates/gym-fitness/l10n/es.json +6 -5
  143. package/templates/gym-fitness/l10n/fi.json +6 -5
  144. package/templates/gym-fitness/l10n/fr.json +6 -5
  145. package/templates/gym-fitness/l10n/he.json +5 -4
  146. package/templates/gym-fitness/l10n/hu.json +6 -5
  147. package/templates/gym-fitness/l10n/id.json +6 -5
  148. package/templates/gym-fitness/l10n/it.json +6 -5
  149. package/templates/gym-fitness/l10n/ja.json +6 -5
  150. package/templates/gym-fitness/l10n/ko.json +6 -5
  151. package/templates/gym-fitness/l10n/lt.json +6 -5
  152. package/templates/gym-fitness/l10n/nl.json +6 -5
  153. package/templates/gym-fitness/l10n/no.json +6 -5
  154. package/templates/gym-fitness/l10n/pl.json +6 -5
  155. package/templates/gym-fitness/l10n/pt.json +6 -5
  156. package/templates/gym-fitness/l10n/ru.json +6 -5
  157. package/templates/gym-fitness/l10n/sv.json +6 -5
  158. package/templates/gym-fitness/l10n/th.json +6 -5
  159. package/templates/gym-fitness/l10n/tr.json +6 -5
  160. package/templates/gym-fitness/l10n/uk.json +6 -5
  161. package/templates/gym-fitness/l10n/vi.json +6 -5
  162. package/templates/gym-fitness/l10n/zh.json +6 -5
  163. package/templates/gym-fitness/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  164. package/templates/medical-services/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  165. package/templates/nonprofit-cause/config.ts +16 -1
  166. package/templates/nonprofit-cause/l10n/ar.json +6 -5
  167. package/templates/nonprofit-cause/l10n/cs.json +6 -5
  168. package/templates/nonprofit-cause/l10n/da.json +6 -5
  169. package/templates/nonprofit-cause/l10n/de.json +6 -5
  170. package/templates/nonprofit-cause/l10n/el.json +6 -5
  171. package/templates/nonprofit-cause/l10n/en.json +8 -1
  172. package/templates/nonprofit-cause/l10n/es.json +6 -5
  173. package/templates/nonprofit-cause/l10n/fi.json +6 -5
  174. package/templates/nonprofit-cause/l10n/fr.json +6 -5
  175. package/templates/nonprofit-cause/l10n/he.json +5 -4
  176. package/templates/nonprofit-cause/l10n/hu.json +6 -5
  177. package/templates/nonprofit-cause/l10n/id.json +6 -5
  178. package/templates/nonprofit-cause/l10n/it.json +6 -5
  179. package/templates/nonprofit-cause/l10n/ja.json +6 -5
  180. package/templates/nonprofit-cause/l10n/ko.json +6 -5
  181. package/templates/nonprofit-cause/l10n/lt.json +6 -5
  182. package/templates/nonprofit-cause/l10n/nl.json +6 -5
  183. package/templates/nonprofit-cause/l10n/no.json +6 -5
  184. package/templates/nonprofit-cause/l10n/pl.json +6 -5
  185. package/templates/nonprofit-cause/l10n/pt.json +6 -5
  186. package/templates/nonprofit-cause/l10n/ru.json +6 -5
  187. package/templates/nonprofit-cause/l10n/sv.json +6 -5
  188. package/templates/nonprofit-cause/l10n/th.json +6 -5
  189. package/templates/nonprofit-cause/l10n/tr.json +6 -5
  190. package/templates/nonprofit-cause/l10n/uk.json +6 -5
  191. package/templates/nonprofit-cause/l10n/vi.json +6 -5
  192. package/templates/nonprofit-cause/l10n/zh.json +6 -5
  193. package/templates/nonprofit-cause/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  194. package/templates/personal-fitness-trainer/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  195. package/templates/podcast-creator/config.ts +16 -1
  196. package/templates/podcast-creator/l10n/ar.json +6 -5
  197. package/templates/podcast-creator/l10n/cs.json +6 -5
  198. package/templates/podcast-creator/l10n/da.json +6 -5
  199. package/templates/podcast-creator/l10n/de.json +6 -5
  200. package/templates/podcast-creator/l10n/el.json +6 -5
  201. package/templates/podcast-creator/l10n/en.json +8 -1
  202. package/templates/podcast-creator/l10n/es.json +6 -5
  203. package/templates/podcast-creator/l10n/fi.json +6 -5
  204. package/templates/podcast-creator/l10n/fr.json +6 -5
  205. package/templates/podcast-creator/l10n/he.json +5 -4
  206. package/templates/podcast-creator/l10n/hu.json +6 -5
  207. package/templates/podcast-creator/l10n/id.json +6 -5
  208. package/templates/podcast-creator/l10n/it.json +6 -5
  209. package/templates/podcast-creator/l10n/ja.json +6 -5
  210. package/templates/podcast-creator/l10n/ko.json +6 -5
  211. package/templates/podcast-creator/l10n/lt.json +6 -5
  212. package/templates/podcast-creator/l10n/nl.json +6 -5
  213. package/templates/podcast-creator/l10n/no.json +6 -5
  214. package/templates/podcast-creator/l10n/pl.json +6 -5
  215. package/templates/podcast-creator/l10n/pt.json +6 -5
  216. package/templates/podcast-creator/l10n/ru.json +6 -5
  217. package/templates/podcast-creator/l10n/sv.json +6 -5
  218. package/templates/podcast-creator/l10n/th.json +6 -5
  219. package/templates/podcast-creator/l10n/tr.json +6 -5
  220. package/templates/podcast-creator/l10n/uk.json +6 -5
  221. package/templates/podcast-creator/l10n/vi.json +6 -5
  222. package/templates/podcast-creator/l10n/zh.json +6 -5
  223. package/templates/podcast-creator/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  224. package/templates/portfolio-creative/config.ts +16 -1
  225. package/templates/portfolio-creative/l10n/ar.json +6 -5
  226. package/templates/portfolio-creative/l10n/cs.json +6 -5
  227. package/templates/portfolio-creative/l10n/da.json +6 -5
  228. package/templates/portfolio-creative/l10n/de.json +6 -5
  229. package/templates/portfolio-creative/l10n/el.json +6 -5
  230. package/templates/portfolio-creative/l10n/en.json +8 -1
  231. package/templates/portfolio-creative/l10n/es.json +6 -5
  232. package/templates/portfolio-creative/l10n/fi.json +6 -5
  233. package/templates/portfolio-creative/l10n/fr.json +6 -5
  234. package/templates/portfolio-creative/l10n/he.json +5 -4
  235. package/templates/portfolio-creative/l10n/hu.json +6 -5
  236. package/templates/portfolio-creative/l10n/id.json +6 -5
  237. package/templates/portfolio-creative/l10n/it.json +6 -5
  238. package/templates/portfolio-creative/l10n/ja.json +6 -5
  239. package/templates/portfolio-creative/l10n/ko.json +6 -5
  240. package/templates/portfolio-creative/l10n/lt.json +6 -5
  241. package/templates/portfolio-creative/l10n/nl.json +6 -5
  242. package/templates/portfolio-creative/l10n/no.json +6 -5
  243. package/templates/portfolio-creative/l10n/pl.json +6 -5
  244. package/templates/portfolio-creative/l10n/pt.json +6 -5
  245. package/templates/portfolio-creative/l10n/ru.json +6 -5
  246. package/templates/portfolio-creative/l10n/sv.json +6 -5
  247. package/templates/portfolio-creative/l10n/th.json +6 -5
  248. package/templates/portfolio-creative/l10n/tr.json +6 -5
  249. package/templates/portfolio-creative/l10n/uk.json +6 -5
  250. package/templates/portfolio-creative/l10n/vi.json +6 -5
  251. package/templates/portfolio-creative/l10n/zh.json +6 -5
  252. package/templates/portfolio-creative/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  253. package/templates/restaurant/config.ts +16 -1
  254. package/templates/restaurant/l10n/ar.json +6 -5
  255. package/templates/restaurant/l10n/cs.json +6 -5
  256. package/templates/restaurant/l10n/da.json +6 -5
  257. package/templates/restaurant/l10n/de.json +6 -5
  258. package/templates/restaurant/l10n/el.json +6 -5
  259. package/templates/restaurant/l10n/en.json +8 -1
  260. package/templates/restaurant/l10n/es.json +6 -5
  261. package/templates/restaurant/l10n/fi.json +6 -5
  262. package/templates/restaurant/l10n/fr.json +6 -5
  263. package/templates/restaurant/l10n/he.json +5 -4
  264. package/templates/restaurant/l10n/hu.json +6 -5
  265. package/templates/restaurant/l10n/id.json +6 -5
  266. package/templates/restaurant/l10n/it.json +6 -5
  267. package/templates/restaurant/l10n/ja.json +6 -5
  268. package/templates/restaurant/l10n/ko.json +6 -5
  269. package/templates/restaurant/l10n/lt.json +6 -5
  270. package/templates/restaurant/l10n/nl.json +6 -5
  271. package/templates/restaurant/l10n/no.json +6 -5
  272. package/templates/restaurant/l10n/pl.json +6 -5
  273. package/templates/restaurant/l10n/pt.json +6 -5
  274. package/templates/restaurant/l10n/ru.json +6 -5
  275. package/templates/restaurant/l10n/sv.json +6 -5
  276. package/templates/restaurant/l10n/th.json +6 -5
  277. package/templates/restaurant/l10n/tr.json +6 -5
  278. package/templates/restaurant/l10n/uk.json +6 -5
  279. package/templates/restaurant/l10n/vi.json +6 -5
  280. package/templates/restaurant/l10n/zh.json +6 -5
  281. package/templates/restaurant/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  282. package/templates/retail-store/config.ts +16 -1
  283. package/templates/retail-store/l10n/ar.json +6 -5
  284. package/templates/retail-store/l10n/cs.json +6 -5
  285. package/templates/retail-store/l10n/da.json +6 -5
  286. package/templates/retail-store/l10n/de.json +6 -5
  287. package/templates/retail-store/l10n/el.json +6 -5
  288. package/templates/retail-store/l10n/en.json +8 -1
  289. package/templates/retail-store/l10n/es.json +6 -5
  290. package/templates/retail-store/l10n/fi.json +6 -5
  291. package/templates/retail-store/l10n/fr.json +6 -5
  292. package/templates/retail-store/l10n/he.json +5 -4
  293. package/templates/retail-store/l10n/hu.json +6 -5
  294. package/templates/retail-store/l10n/id.json +6 -5
  295. package/templates/retail-store/l10n/it.json +6 -5
  296. package/templates/retail-store/l10n/ja.json +6 -5
  297. package/templates/retail-store/l10n/ko.json +6 -5
  298. package/templates/retail-store/l10n/lt.json +6 -5
  299. package/templates/retail-store/l10n/nl.json +6 -5
  300. package/templates/retail-store/l10n/no.json +6 -5
  301. package/templates/retail-store/l10n/pl.json +6 -5
  302. package/templates/retail-store/l10n/pt.json +6 -5
  303. package/templates/retail-store/l10n/ru.json +6 -5
  304. package/templates/retail-store/l10n/sv.json +6 -5
  305. package/templates/retail-store/l10n/th.json +6 -5
  306. package/templates/retail-store/l10n/tr.json +6 -5
  307. package/templates/retail-store/l10n/uk.json +6 -5
  308. package/templates/retail-store/l10n/vi.json +6 -5
  309. package/templates/retail-store/l10n/zh.json +6 -5
  310. package/templates/retail-store/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  311. package/templates/salon-spa/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  312. package/templates/wholesale-store/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  313. package/templates/yoga-studio/config.ts +27 -2
  314. package/templates/yoga-studio/dev/index.ts +958 -2
  315. package/templates/yoga-studio/himalaya.content.json +3 -0
  316. package/templates/yoga-studio/l10n/ar.json +106 -5
  317. package/templates/yoga-studio/l10n/cs.json +106 -5
  318. package/templates/yoga-studio/l10n/da.json +106 -5
  319. package/templates/yoga-studio/l10n/de.json +106 -5
  320. package/templates/yoga-studio/l10n/el.json +106 -5
  321. package/templates/yoga-studio/l10n/en.json +43 -1
  322. package/templates/yoga-studio/l10n/es.json +106 -5
  323. package/templates/yoga-studio/l10n/fi.json +106 -5
  324. package/templates/yoga-studio/l10n/fr.json +106 -5
  325. package/templates/yoga-studio/l10n/he.json +86 -4
  326. package/templates/yoga-studio/l10n/hu.json +106 -5
  327. package/templates/yoga-studio/l10n/id.json +106 -5
  328. package/templates/yoga-studio/l10n/it.json +106 -5
  329. package/templates/yoga-studio/l10n/ja.json +106 -5
  330. package/templates/yoga-studio/l10n/ko.json +106 -5
  331. package/templates/yoga-studio/l10n/lt.json +106 -5
  332. package/templates/yoga-studio/l10n/nl.json +106 -5
  333. package/templates/yoga-studio/l10n/no.json +106 -5
  334. package/templates/yoga-studio/l10n/pl.json +106 -5
  335. package/templates/yoga-studio/l10n/pt.json +106 -5
  336. package/templates/yoga-studio/l10n/ru.json +106 -5
  337. package/templates/yoga-studio/l10n/sv.json +106 -5
  338. package/templates/yoga-studio/l10n/th.json +106 -5
  339. package/templates/yoga-studio/l10n/tr.json +106 -5
  340. package/templates/yoga-studio/l10n/uk.json +106 -5
  341. package/templates/yoga-studio/l10n/vi.json +106 -5
  342. package/templates/yoga-studio/l10n/zh.json +106 -5
  343. package/templates/yoga-studio/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  344. package/templates/yoga-studio/tier5-src/_shared/program-content.ts +94 -0
  345. package/templates/yoga-studio/tier5-src/_shared/program-progress-mark.ts +22 -0
  346. package/templates/yoga-studio/tier5-src/_shared/program-reads.ts +72 -0
  347. package/templates/yoga-studio/tier5-src/himi-branded-lite-program-participant/index.ts +46 -62
  348. package/templates/yoga-studio/tier5-src/himi-branded-lite-program-participant/model.ts +12 -76
  349. package/templates/yoga-studio/tier5-src/himi-branded-lite-program-step/index.ts +520 -0
  350. package/templates/yoga-studio/tier5-src/himi-branded-lite-program-step/model.ts +69 -0
@@ -0,0 +1,520 @@
1
+ // Tier-5 bundle: himi-branded-lite — one step of an online program (`himi_program_step`), what a
2
+ // JOINED member opens from the participant page (its next step, or a step row of its Content tab).
3
+ //
4
+ // The step's title, section and place ("Step 2 of 3"), then its content: an article is its rich
5
+ // description; a video plays in the core Video player above it, and a video with no public address
6
+ // (a Wix Video, a deleted one) opens the program on the website instead, as does a quiz until the app
7
+ // takes quizzes (B5). The member completes the step, or undoes it, and walks to the previous or the
8
+ // next step in place. A completion says what it finished: the step, its whole section, or the program.
9
+ //
10
+ // Reads (member identity): getProgram → getMyMember → the member's participation (Search
11
+ // Participants) → in parallel the program's sections, its steps (EXTENDED: the description and the
12
+ // video address) and the participant's resolved steps. Writes: Upsert Resolved Step (complete) and
13
+ // Delete Resolved Step (undo). Undo stops once the participation is COMPLETED: on amit1 an undo after
14
+ // the last step left the participation COMPLETED at 2 of 3 steps (2026-11-18), as the One App knows.
15
+ import { connectivity, defineService as registerService, navigate } from "@himalaya/state";
16
+ import {
17
+ completeStep,
18
+ listSections,
19
+ participationsByProgram,
20
+ searchMemberParticipation,
21
+ undoStep,
22
+ type WixParticipant,
23
+ type WixResolvedStep,
24
+ type WixStep,
25
+ } from "@himalaya/wix-online-programs";
26
+ import { getMyMember } from "@himalaya/wix-members";
27
+ import { i18n } from "@himalaya/wix-platform";
28
+ import { open, defaultMode } from "@himalaya/open-url";
29
+ import { descriptionBody } from "../_shared/rich-body.js";
30
+ import { openRichLink } from "../_shared/rich-content-link.js";
31
+ import { isProgramEnded, programName } from "../_shared/program-fields.js";
32
+ import { inProgram, standingOf, type Standing } from "../_shared/program-standing.js";
33
+ import { assertMemberAccess, memberAccess, memberChanged, type MemberAccess } from "../_shared/member-access.js";
34
+ import { offlineWriteMessage, withOnlineWrites } from "../_shared/online-actions.js";
35
+ import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
36
+ import { formatDateMedium } from "../_shared/engine-intl.js";
37
+ import { contentReadability, sectionTitle, stepKind, stepTitle } from "../_shared/program-content.js";
38
+ import { allResolved, allSteps, fetchProgram, gateTextOf, isRefused } from "../_shared/program-reads.js";
39
+ import { markProgress } from "../_shared/program-progress-mark.js";
40
+ import { completionOf, placeSteps, programWebUrl, videoUrlOf, type Completion, type PlacedStep } from "./model.js";
41
+
42
+ export const SERVICE = "himiBrandedProgramStep";
43
+
44
+ type Access = "member" | "signIn" | "notJoined";
45
+
46
+ interface State {
47
+ status: "loading" | "ready" | "error";
48
+ /** ErrorState variant: "offline" or "server". */
49
+ errorKind: string;
50
+ programId: string;
51
+ /** The step on screen: the screen's `stepId` until the member walks to another one. */
52
+ stepId: string;
53
+ programName: string;
54
+ sectionTitle: string;
55
+ title: string;
56
+ /** "Article" / "Video" / "Quiz". */
57
+ kindLabel: string;
58
+ kindIcon: string;
59
+ /** "Step 2 of 3". */
60
+ positionLabel: string;
61
+ bodyText: string;
62
+ bodyJson: string;
63
+ hideBodyText: boolean;
64
+ videoUrl: string;
65
+ hideVideo: boolean;
66
+ /** A video step whose video has no public address, or a quiz step: it opens on the website. */
67
+ webText: string;
68
+ hideWeb: boolean;
69
+ /** The program has no website address: the card says the step can't be shown, with no button. */
70
+ hideWebButton: boolean;
71
+ /** "This step opens Dec 4, 2026." while its section has not opened. */
72
+ lockedLine: string;
73
+ done: boolean;
74
+ hideComplete: boolean;
75
+ hideDone: boolean;
76
+ hideUndo: boolean;
77
+ busy: boolean;
78
+ /** A failed (or offline) complete or undo. */
79
+ writeError: string;
80
+ /** Why the step cannot be changed (the program ended); empty otherwise. */
81
+ frozenLine: string;
82
+ hidePrevious: boolean;
83
+ hideNext: boolean;
84
+ hideNav: boolean;
85
+ /** The completion sheet: which completion, and its copy. */
86
+ sheetOpen: boolean;
87
+ sheetIcon: string;
88
+ sheetTitle: string;
89
+ sheetBody: string;
90
+ hideSheetNext: boolean;
91
+ hideSheetBack: boolean;
92
+ /** Why a member who is not in the program sees no step. */
93
+ gateText: string;
94
+ /** The step is not in the program (removed, or another program's), or the steps cannot be read. */
95
+ missingText: string;
96
+ hideMissing: boolean;
97
+ isLoading: boolean;
98
+ notLoading: boolean;
99
+ hideError: boolean;
100
+ needsSignIn: boolean;
101
+ noSignIn: boolean;
102
+ hideNotJoined: boolean;
103
+ /** Hides the step (header, content, actions) while loading, on an error, for a non-participant and for a missing step. */
104
+ hideBody: boolean;
105
+ }
106
+
107
+ /** What the member's last load read; the screen re-derives from it when the member walks or writes. */
108
+ interface Loaded {
109
+ member: MemberAccess;
110
+ participant: WixParticipant;
111
+ standing: Standing;
112
+ placed: PlacedStep[];
113
+ done: Map<string, WixResolvedStep>;
114
+ /** The participation's own step count: a completion is the program's only when no step is missing from the list. */
115
+ reportedTotal: number;
116
+ /** The program has ended: its steps can't be changed, whatever the participation says. */
117
+ ended: boolean;
118
+ name: string;
119
+ webUrl: string;
120
+ locale: string;
121
+ }
122
+
123
+ let loaded: Loaded | undefined;
124
+ let access: Access = "member";
125
+ /** The completion just made; cleared when the sheet closes. */
126
+ let completion: Completion | undefined;
127
+ let busy = false;
128
+ let loadSeq = 0;
129
+ /** Counts the loads that start a new page (a push, another program or step); a refresh of the page keeps it. */
130
+ let pageSeq = 0;
131
+ /** Writes Wix accepted so far: a load that started before one read the progress without it. */
132
+ let writes = 0;
133
+ /** The step the screen was opened with on the last load; a new one replaces the step the member walked to. */
134
+ let askedStep = "";
135
+
136
+ function input(): { id: string; stepId: string } {
137
+ const value = (globalThis as { himalaya?: { input?: { id?: unknown; stepId?: unknown } } }).himalaya?.input;
138
+ return { id: typeof value?.id === "string" ? value.id : "", stepId: typeof value?.stepId === "string" ? value.stepId : "" };
139
+ }
140
+
141
+ function derive(state: State): State {
142
+ const ready = state.status === "ready";
143
+ const member = ready && access === "member";
144
+ return {
145
+ ...state,
146
+ hideBodyText: state.bodyJson !== "" || state.bodyText === "",
147
+ hideVideo: state.videoUrl === "",
148
+ isLoading: state.status === "loading",
149
+ notLoading: state.status !== "loading",
150
+ hideError: state.status !== "error",
151
+ needsSignIn: ready && access === "signIn",
152
+ noSignIn: !(ready && access === "signIn"),
153
+ hideNotJoined: !(ready && access === "notJoined"),
154
+ hideMissing: !member || state.missingText === "",
155
+ hideBody: !member || state.missingText !== "",
156
+ };
157
+ }
158
+
159
+ const EMPTY_STEP = {
160
+ sectionTitle: "", title: "", kindLabel: "", kindIcon: "", positionLabel: "", bodyText: "", bodyJson: "", hideBodyText: true,
161
+ videoUrl: "", hideVideo: true, webText: "", hideWeb: true, hideWebButton: true, lockedLine: "", done: false, hideComplete: true, hideDone: true, hideUndo: true,
162
+ frozenLine: "", hidePrevious: true, hideNext: true, hideNav: true,
163
+ };
164
+ const CLOSED_SHEET = { sheetOpen: false, sheetIcon: "success", sheetTitle: "", sheetBody: "", hideSheetNext: true, hideSheetBack: true };
165
+
166
+ const INITIAL_STATE: State = derive({
167
+ status: "loading", errorKind: "server", programId: "", stepId: "", programName: "", ...EMPTY_STEP, busy: false, writeError: "",
168
+ ...CLOSED_SHEET, gateText: "", missingText: "", hideMissing: true, isLoading: true, notLoading: false, hideError: true,
169
+ needsSignIn: false, noSignIn: true, hideNotJoined: true, hideBody: true,
170
+ });
171
+
172
+ /** The fields that draw one step, from what the last load read. */
173
+ function stepView(data: Loaded, stepId: string): Partial<State> {
174
+ const index = data.placed.findIndex((p) => p.step.id === stepId);
175
+ if (index < 0) return { ...EMPTY_STEP, stepId, missingText: copyParam("programStep.notFoundText", "This step isn't part of the program anymore.") };
176
+ const { step, section, locked, opens } = data.placed[index];
177
+ const type = String(step.stepType ?? "").toUpperCase();
178
+ const kind = stepKind(step);
179
+ const body = descriptionBody(step.description?.details, "");
180
+ const videoUrl = type === "VIDEO" ? videoUrlOf(step) : "";
181
+ // A quiz is taken on the website until the app takes quizzes, and so is a video the app cannot play.
182
+ // With no website address the card still says why the step has no action.
183
+ const onWeb = !locked && (type === "QUIZ" || (type === "VIDEO" && !videoUrl));
184
+ const done = data.done.has(stepId);
185
+ const ended = data.ended;
186
+ const quiz = type === "QUIZ";
187
+ // A video the app cannot play on a program with no website: the member has no way to see it, so it cannot be completed here.
188
+ const unviewable = unviewableStep(step, data);
189
+ // A COMPLETED participation stays COMPLETED after an undo (amit1), and the One App never undoes a FAILED one.
190
+ const programDone = ["COMPLETED", "FAILED"].includes(String(data.participant.progressStatus ?? "").toUpperCase());
191
+ const nav = data.placed.length > 1;
192
+ return {
193
+ stepId,
194
+ missingText: "",
195
+ sectionTitle: section ? sectionTitle(section) : "",
196
+ title: stepTitle(step),
197
+ kindLabel: kind.label,
198
+ kindIcon: locked ? "lock" : kind.icon,
199
+ positionLabel: copyTemplate("programStep.position", "Step {index} of {total}", { index: index + 1, total: data.placed.length }),
200
+ // A locked step shows its title and when it opens, never its content.
201
+ bodyText: locked ? "" : body.bodyText,
202
+ bodyJson: locked ? "" : body.bodyJson,
203
+ videoUrl: locked ? "" : videoUrl,
204
+ webText: !onWeb ? ""
205
+ : !data.webUrl ? copyParam("programStep.unavailableText", "This step can't be shown in the app right now.")
206
+ : type === "QUIZ" ? copyParam("programStep.quizOnWebText", "Take this quiz on the program's website.")
207
+ : copyParam("programStep.videoOnWebText", "This video plays on the program's website."),
208
+ hideWeb: !onWeb,
209
+ hideWebButton: !onWeb || !data.webUrl,
210
+ lockedLine: locked && Number.isFinite(opens)
211
+ ? copyTemplate("programStep.lockedLine", "This step opens {date}.", { date: formatDateMedium(new Date(opens), data.locale) })
212
+ : "",
213
+ done,
214
+ // A quiz completes with its submission (B5), never with a plain Complete.
215
+ hideComplete: done || locked || ended || quiz || unviewable,
216
+ hideDone: !done,
217
+ // A quiz's resolved step comes from its submission, and an unviewable video cannot be completed here:
218
+ // undoing either would leave a step no Complete can redo.
219
+ hideUndo: !done || ended || programDone || quiz || unviewable,
220
+ frozenLine: ended ? copyParam("programStep.endedText", "This program has ended, so its steps can't be changed.") : "",
221
+ hidePrevious: index === 0,
222
+ hideNext: index === data.placed.length - 1,
223
+ hideNav: !nav,
224
+ };
225
+ }
226
+
227
+ /** A video step with no address the app can play, on a program with no website to watch it on. */
228
+ function unviewableStep(step: WixStep, data: Loaded): boolean {
229
+ return String(step.stepType ?? "").toUpperCase() === "VIDEO" && !videoUrlOf(step) && !data.webUrl;
230
+ }
231
+
232
+ /** The completion sheet for `kind`, about the step on screen. */
233
+ function sheetView(data: Loaded, kind: Completion | undefined, stepId: string): Partial<State> {
234
+ if (!kind) return CLOSED_SHEET;
235
+ const index = data.placed.findIndex((p) => p.step.id === stepId);
236
+ const own = data.placed[index];
237
+ const hasNext = index >= 0 && index < data.placed.length - 1;
238
+ if (kind === "program") {
239
+ return {
240
+ sheetOpen: true, sheetIcon: "star_fill",
241
+ sheetTitle: copyParam("programStep.programDoneTitle", "Program complete"),
242
+ sheetBody: copyTemplate("programStep.programDoneBody", "You completed every step of {program}.", { program: data.name }),
243
+ hideSheetNext: true, hideSheetBack: false,
244
+ };
245
+ }
246
+ return {
247
+ sheetOpen: true, sheetIcon: "success",
248
+ sheetTitle: kind === "section" ? copyParam("programStep.sectionDoneTitle", "Section complete") : copyParam("programStep.stepDoneTitle", "Step complete"),
249
+ sheetBody: kind === "section" && own?.section
250
+ ? copyTemplate("programStep.sectionDoneBody", "You finished {section}.", { section: sectionTitle(own.section) })
251
+ : copyParam("programStep.stepDoneBody", "Nice work. Keep going."),
252
+ hideSheetNext: !hasNext, hideSheetBack: hasNext,
253
+ };
254
+ }
255
+
256
+ async function load(state: State, arg?: unknown): Promise<undefined> {
257
+ stashCopy(arg);
258
+ const { id, stepId: asked } = input();
259
+ const seq = ++loadSeq;
260
+ const current = () => seq === loadSeq && input().id === id;
261
+ // A refresh (the module boot, a Back that re-mounts the screen) keeps the step the member walked to;
262
+ // a push of the screen, another program or another step starts at the screen's step with no
263
+ // completion sheet left over. A pooled worker comes back with the last visit's state: `push` says so.
264
+ const pushed = (arg as { appearReason?: unknown } | undefined)?.appearReason === "push";
265
+ const samePage = !pushed && state.status === "ready" && state.programId === id && asked === askedStep;
266
+ const stepId = samePage && state.stepId ? state.stepId : asked;
267
+ askedStep = asked;
268
+ if (!samePage) {
269
+ pageSeq += 1;
270
+ completion = undefined;
271
+ void svc.publish({ status: "loading", programId: id, stepId, ...CLOSED_SHEET });
272
+ }
273
+ let member: MemberAccess | undefined;
274
+ const writesAtStart = writes;
275
+ try {
276
+ // No step id lands on the next step to take (below), never the error page.
277
+ if (!id) throw new Error("Program id missing");
278
+ const [found, identity, locale, memberId] = await Promise.all([
279
+ fetchProgram(id).then((program) => ({ program }), (error: unknown) => ({ error })),
280
+ memberAccess(),
281
+ i18n.locale().catch(() => "en"),
282
+ // A visitor has no member: the read fails, and the sign-in check below decides.
283
+ getMyMember().then((response) => response.member?.id, () => undefined),
284
+ ]);
285
+ member = identity;
286
+ if (!current()) return undefined;
287
+ if (!member.email) {
288
+ access = "signIn";
289
+ loaded = undefined;
290
+ completion = undefined;
291
+ void svc.publish({ programId: id, stepId, status: "ready", ...CLOSED_SHEET });
292
+ return undefined;
293
+ }
294
+ if ("error" in found) throw found.error;
295
+ const program = found.program;
296
+ if (!program) throw new Error("Program unavailable");
297
+ const name = programName(program) || copyParam("program.programFallbackName", "Program");
298
+ if (!memberId) throw new Error("Current member unavailable");
299
+ const participation = await searchMemberParticipation(id, memberId);
300
+ await assertMemberAccess(member);
301
+ if (!current()) return undefined;
302
+ const scoped = (participation.participants ?? []).filter((row) => row.memberId === memberId && row.programId === id);
303
+ const participant: WixParticipant | undefined = participationsByProgram(scoped).get(id);
304
+ const standing = standingOf(isProgramEnded(program), participant, undefined);
305
+ if (!participant || !inProgram(standing, participant)) {
306
+ access = "notJoined";
307
+ loaded = undefined;
308
+ completion = undefined;
309
+ void svc.publish({ programId: id, stepId, programName: name, status: "ready", gateText: gateTextOf(standing, participant), missingText: "", ...CLOSED_SHEET });
310
+ return undefined;
311
+ }
312
+ // The lock lists only the app identity for sections and steps, so a real site may refuse a member
313
+ // (403): the step then says it can't be shown here. Any other failure is the error page with Retry.
314
+ const refused = (error: unknown): undefined => {
315
+ if (isRefused(error)) return undefined;
316
+ throw error;
317
+ };
318
+ const [sections, steps, resolved] = await Promise.all([
319
+ listSections(id).then((response) => response.sections ?? []).catch(refused),
320
+ // EXTENDED: the default field set leaves out the description and the video address.
321
+ allSteps(id, "EXTENDED").catch(refused),
322
+ allResolved(participant.id).catch(refused),
323
+ ]);
324
+ await assertMemberAccess(member);
325
+ if (!current()) return undefined;
326
+ access = "member";
327
+ const webUrl = programWebUrl(program);
328
+ // An empty read can also mean "not allowed": the participation's own counts decide, as on the participant page.
329
+ const readable = contentReadability({ sections, steps, resolved, participant });
330
+ if (!steps || !readable.contentAvailable || !readable.marksKnown) {
331
+ loaded = undefined;
332
+ completion = undefined;
333
+ void svc.publish({
334
+ ...EMPTY_STEP, ...CLOSED_SHEET, programId: id, stepId, programName: name, status: "ready", writeError: "",
335
+ missingText: copyParam("programStep.unavailableText", "This step can't be shown in the app right now."),
336
+ });
337
+ return undefined;
338
+ }
339
+ // A complete or an undo landed while these reads ran: they predate it, so read again.
340
+ if (writes !== writesAtStart) { void svc.load(); return undefined; }
341
+ const placed = placeSteps(sections ?? [], steps, participant, Date.now());
342
+ loaded = { member, participant, standing, placed, done: readable.done,
343
+ reportedTotal: readable.reportedTotal, ended: isProgramEnded(program), name, webUrl, locale };
344
+ // A refresh lands on the step the member is on NOW: they may have walked while it ran. A screen
345
+ // opened with no step (a link with only the program) lands on the next step to take, else the first.
346
+ const fallback = stepId || (placed.find((p) => !p.locked && !readable.done.has(p.step.id!)) ?? placed[0])?.step.id || "";
347
+ const shown = samePage ? svc.getState().stepId || fallback : fallback;
348
+ void svc.publish({ programId: id, programName: name, status: "ready", writeError: "", ...stepView(loaded, shown), ...sheetView(loaded, completion, shown) });
349
+ } catch (error) {
350
+ if (!current()) return undefined;
351
+ const changed = await memberChanged(member, error);
352
+ if (!current()) return undefined;
353
+ if (changed) {
354
+ // Another member (or a signed-out one) never sees the previous member's step marks: start over.
355
+ loaded = undefined;
356
+ completion = undefined;
357
+ access = "member";
358
+ void svc.publish({ status: "loading", programId: "", ...EMPTY_STEP, ...CLOSED_SHEET });
359
+ void svc.load();
360
+ return undefined;
361
+ }
362
+ // A failed refresh keeps the step the member already sees, and only for the member it was built for.
363
+ if (samePage && loaded && member && loaded.member.email === member.email && loaded.member.scope === member.scope) return undefined;
364
+ completion = undefined;
365
+ void svc.publish({ status: "error", errorKind: connectivity().online ? "server" : "offline", ...CLOSED_SHEET });
366
+ }
367
+ return undefined;
368
+ }
369
+
370
+ /** Where a write that just landed shows: this page's data, even when a refresh of the page replaced it
371
+ * while the write ran (that refresh may have read before the write). A load of another page owns the
372
+ * screen, and the write is read again. */
373
+ function writeTarget(data: Loaded, page: number): Loaded | undefined {
374
+ const now = loaded;
375
+ return page === pageSeq && now && now.participant.id === data.participant.id ? now : undefined;
376
+ }
377
+
378
+ /** A write's precondition: the page is a member's step, nothing else is writing, and the member is still the same. */
379
+ async function writable(state: State): Promise<Loaded | undefined> {
380
+ const data = loaded;
381
+ if (busy || !data || access !== "member" || state.status !== "ready" || !state.stepId) return undefined;
382
+ busy = true;
383
+ void svc.publish({ busy: true, writeError: "" });
384
+ try {
385
+ await assertMemberAccess(data.member);
386
+ return data;
387
+ } catch {
388
+ // Another member is signed in: start over for them, after the busy flag is down.
389
+ busy = false;
390
+ loaded = undefined;
391
+ void svc.publish({ busy: false }).then(() => svc.load());
392
+ return undefined;
393
+ }
394
+ }
395
+
396
+ async function complete(state: State): Promise<undefined> {
397
+ const data = await writable(state);
398
+ if (!data) return undefined;
399
+ const stepId = state.stepId;
400
+ // A load of another page that starts while the write runs (Back, then another step) owns the screen from then on.
401
+ const page = pageSeq;
402
+ const own = data.placed.find((p) => p.step.id === stepId);
403
+ // One publish when the write settles: two publishes in one turn both start from the same state.
404
+ let patch: Partial<State> = {};
405
+ try {
406
+ if (!own || own.locked || data.done.has(stepId) || data.ended || String(own.step.stepType ?? "").toUpperCase() === "QUIZ" || unviewableStep(own.step, data)) return undefined;
407
+ // No status: the spec lists none, and the upsert answers COMPLETED for a plain completion (amit1, 2026-11-18).
408
+ const response = await completeStep(data.participant.id, stepId);
409
+ writes += 1;
410
+ await markProgress(state.programId);
411
+ const target = writeTarget(data, page);
412
+ // Another page replaced this one while the write ran: Wix has the change, so read it again.
413
+ if (!target) { void svc.load(); return undefined; }
414
+ target.done.set(stepId, response.resolvedStep ?? { programStepId: stepId, participantId: target.participant.id, status: "COMPLETED" });
415
+ completion = completionOf(target.placed, new Set(target.done.keys()), stepId, target.reportedTotal);
416
+ // The site marks the participation COMPLETED with its last step: from here no step is undone.
417
+ if (completion === "program") target.participant = { ...target.participant, progressStatus: "COMPLETED" };
418
+ patch = { ...stepView(target, svc.getState().stepId), ...sheetView(target, completion, stepId) };
419
+ } catch (error) {
420
+ // A failed write belongs to the page it was made on: a page pushed since then shows no error for it.
421
+ if (page === pageSeq) patch = { writeError: writeErrorOf(error, copyParam("programStep.completeFailed", "This step couldn't be saved. Try again.")) };
422
+ } finally {
423
+ busy = false;
424
+ void svc.publish({ ...patch, busy: false });
425
+ }
426
+ return undefined;
427
+ }
428
+
429
+ async function undo(state: State): Promise<undefined> {
430
+ const data = await writable(state);
431
+ if (!data) return undefined;
432
+ const stepId = state.stepId;
433
+ const page = pageSeq;
434
+ let patch: Partial<State> = {};
435
+ try {
436
+ const record = data.done.get(stepId);
437
+ const own = data.placed.find((p) => p.step.id === stepId);
438
+ if (!record || data.ended || ["COMPLETED", "FAILED"].includes(String(data.participant.progressStatus ?? "").toUpperCase()) || String(own?.step.stepType ?? "").toUpperCase() === "QUIZ" || (own && unviewableStep(own.step, data))) return undefined;
439
+ // The upsert answer carries the record's id; a record read without one is found again.
440
+ const resolvedId = record.id || (await allResolved(data.participant.id)).find((r) => r.programStepId === stepId)?.id;
441
+ if (!resolvedId) throw new Error("Resolved step unavailable");
442
+ await undoStep(resolvedId);
443
+ writes += 1;
444
+ await markProgress(state.programId);
445
+ const target = writeTarget(data, page);
446
+ if (!target) { void svc.load(); return undefined; }
447
+ target.done.delete(stepId);
448
+ patch = stepView(target, svc.getState().stepId);
449
+ } catch (error) {
450
+ if (page === pageSeq) patch = { writeError: writeErrorOf(error, copyParam("programStep.undoFailed", "This step couldn't be undone. Try again.")) };
451
+ } finally {
452
+ busy = false;
453
+ void svc.publish({ ...patch, busy: false });
454
+ }
455
+ return undefined;
456
+ }
457
+
458
+ function writeErrorOf(error: unknown, fallback: string): string {
459
+ return !connectivity().online || String(error).includes(offlineWriteMessage) ? offlineWriteMessage : fallback;
460
+ }
461
+
462
+ /** Walk `by` steps from the one on screen; the walk stays inside the program. */
463
+ function walk(state: State, by: number): State {
464
+ const data = loaded;
465
+ if (!data || busy) return state;
466
+ const index = data.placed.findIndex((p) => p.step.id === state.stepId);
467
+ const target = data.placed[index + by];
468
+ if (index < 0 || !target?.step.id) return state;
469
+ completion = undefined;
470
+ return derive({ ...state, ...stepView(data, target.step.id), ...CLOSED_SHEET, writeError: "" });
471
+ }
472
+
473
+ type Actions = {
474
+ load: (state: State, arg?: unknown) => Promise<undefined>;
475
+ refresh: (state: State) => Promise<undefined>;
476
+ publish: (state: State, patch: Partial<State>) => State;
477
+ complete: (state: State) => Promise<undefined>;
478
+ undo: (state: State) => Promise<undefined>;
479
+ previous: (state: State) => State;
480
+ next: (state: State) => State;
481
+ closeSheet: (state: State) => State;
482
+ backToProgram: (state: State) => State;
483
+ openWeb: (state: State) => Promise<undefined>;
484
+ openLink: (state: State, arg?: unknown) => Promise<undefined>;
485
+ };
486
+
487
+ // Complete and undo need the network: offline, they say so and change nothing.
488
+ const defineService = withOnlineWrites<State>(registerService, ["complete", "undo"], { derive, messageFields: ["writeError"] });
489
+
490
+ const svc = defineService<State, Actions>(SERVICE, {
491
+ state: INITIAL_STATE,
492
+ // Nothing is written to the on-device snapshot: every field is this member's progress or derives from it.
493
+ notPersisted: Object.keys(INITIAL_STATE) as (keyof State & string)[],
494
+ actions: {
495
+ load,
496
+ refresh: (state) => load(state),
497
+ publish: (state, patch) => derive({ ...state, ...patch }),
498
+ complete,
499
+ undo,
500
+ previous: (state) => walk(state, -1),
501
+ next: (state) => walk(state, 1),
502
+ closeSheet: (state) => {
503
+ completion = undefined;
504
+ return derive({ ...state, ...CLOSED_SHEET });
505
+ },
506
+ backToProgram: (state) => {
507
+ completion = undefined;
508
+ return navigate(derive({ ...state, ...CLOSED_SHEET }), { presentation: "back" });
509
+ },
510
+ openWeb: async () => {
511
+ const url = loaded?.webUrl ?? "";
512
+ if (url) await open(url, defaultMode(url)).catch(() => undefined);
513
+ return undefined;
514
+ },
515
+ openLink: async (_state, arg) => { await openRichLink(arg); return undefined; },
516
+ },
517
+ });
518
+
519
+ svc.load();
520
+ export { svc };
@@ -0,0 +1,69 @@
1
+ // The step screen's content model: where one step sits in its program (its section, the previous and
2
+ // the next step, whether its section has opened), what it plays, and which completion a newly done
3
+ // step is. Pure — the worker reads the program, the participation and the content; this file only
4
+ // decides what the member sees. The order is the participant page's own (`contentGroups`), so the
5
+ // Content tab and the step screen never disagree on what comes next.
6
+ import type { WixParticipant, WixSection, WixStep } from "@himalaya/wix-online-programs";
7
+ import { contentGroups, opensAt } from "../_shared/program-content.js";
8
+
9
+ /** One step in program order, with its section and its section's opening. */
10
+ export interface PlacedStep {
11
+ step: WixStep;
12
+ section: WixSection | undefined;
13
+ /** The section has not opened for this member yet. */
14
+ locked: boolean;
15
+ /** When it opens (epoch ms); NaN when it has no delay or the start date is unknown. */
16
+ opens: number;
17
+ }
18
+
19
+ /** Every step of the program in the participant page's order, sections first, each with its lock. */
20
+ export function placeSteps(sections: readonly WixSection[], steps: readonly WixStep[], participant: WixParticipant | undefined, now: number): PlacedStep[] {
21
+ const placed: PlacedStep[] = [];
22
+ for (const { section, steps: list } of contentGroups(sections, steps)) {
23
+ const opens = opensAt(section, participant);
24
+ const locked = Number.isFinite(opens) && opens > now;
25
+ for (const step of list) placed.push({ step, section, locked, opens });
26
+ }
27
+ return placed;
28
+ }
29
+
30
+ const HTTPS = /^https:\/\/[^\s/?#]\S*$/i;
31
+
32
+ /** The public address a video step plays: `videoOptions.video.url`, else its largest MP4 rendition.
33
+ * "" for a Wix Video (`videoOptions.wixVideo`, streamed through a site-only service), a deleted video,
34
+ * or one with no https address: the screen then opens the step on the website instead. */
35
+ export function videoUrlOf(step: WixStep | undefined): string {
36
+ const options = step?.videoOptions as { deleted?: unknown; video?: { url?: unknown; resolutions?: unknown } } | undefined;
37
+ if (!options || options.deleted === true) return "";
38
+ const direct = typeof options.video?.url === "string" ? options.video.url.trim() : "";
39
+ if (HTTPS.test(direct)) return direct;
40
+ const renditions = Array.isArray(options.video?.resolutions) ? options.video.resolutions as Array<{ url?: unknown; height?: unknown; format?: unknown }> : [];
41
+ const playable = renditions
42
+ // `format` is "mp4" on some sites and a quality label ("720p") on Wix Media, so an .mp4 address counts too (as in the galleries worker).
43
+ .filter((r) => typeof r.url === "string" && HTTPS.test(r.url) && (!r.format || /mp4/i.test(String(r.format)) || /\.mp4(?:[?#]|$)/i.test(r.url)))
44
+ .sort((a, b) => (Number(b.height) || 0) - (Number(a.height) || 0));
45
+ return playable.length ? String(playable[0].url) : "";
46
+ }
47
+
48
+ /** The program's page on the site (`seo.url`), where the member can take a step the app cannot show.
49
+ * "" when the program carries no https address. */
50
+ export function programWebUrl(program: unknown): string {
51
+ const url = (program as { seo?: { url?: { base?: unknown; path?: unknown } } } | undefined)?.seo?.url;
52
+ const base = typeof url?.base === "string" ? url.base.trim().replace(/\/+$/, "") : "";
53
+ const path = typeof url?.path === "string" ? url.path.trim() : "";
54
+ if (!base) return "";
55
+ const full = path ? `${base}${path.startsWith("/") ? "" : "/"}${path}` : base;
56
+ return HTTPS.test(full) ? full : "";
57
+ }
58
+
59
+ export type Completion = "step" | "section" | "program";
60
+
61
+ /** Which completion `stepId` just made, given every step now done (it included): the whole program,
62
+ * its section (every step of that section done), or only the step. The program is complete only when
63
+ * the list holds every step the participation counts (`reportedTotal`): a partial list never ends it. */
64
+ export function completionOf(placed: readonly PlacedStep[], done: ReadonlySet<string>, stepId: string, reportedTotal = 0): Completion {
65
+ if (placed.length > 0 && placed.length >= reportedTotal && placed.every((p) => done.has(p.step.id!))) return "program";
66
+ const own = placed.find((p) => p.step.id === stepId);
67
+ if (own?.section?.id && placed.filter((p) => p.section?.id === own.section!.id).every((p) => done.has(p.step.id!))) return "section";
68
+ return "step";
69
+ }
@@ -124,6 +124,7 @@ export const HOSTED_SCREEN_VERTICALS: Readonly<Record<string, readonly BrandedLi
124
124
  himi_programs: ["programs"],
125
125
  himi_member_programs: ["programs"],
126
126
  himi_program_participant: ["programs"],
127
+ himi_program_step: ["programs"],
127
128
  himi_reservations: ["reservations"],
128
129
  himi_reserve: ["restaurants"],
129
130
  himi_review: ["reviews"],
@@ -427,7 +427,7 @@ export default defineApp({
427
427
  // Your on-device database. It must declare every entity a worker reads or writes,
428
428
  // or those calls fail closed — keep it in step with `local_database` above.
429
429
  dataSchema: {
430
- "version": 4,
430
+ "version": 5,
431
431
  "entities": [
432
432
  {
433
433
  "name": "products",
@@ -626,6 +626,21 @@ export default defineApp({
626
626
  "type": "string"
627
627
  }
628
628
  ]
629
+ },
630
+ {
631
+ "name": "program_progress",
632
+ "encrypted": true,
633
+ "fields": [
634
+ {
635
+ "name": "id",
636
+ "type": "string",
637
+ "required": true
638
+ },
639
+ {
640
+ "name": "at",
641
+ "type": "string"
642
+ }
643
+ ]
629
644
  }
630
645
  ]
631
646
  },
@@ -1112,6 +1112,12 @@
1112
1112
  "translation": "مثبّت",
1113
1113
  "origin": "machine"
1114
1114
  },
1115
+ "h_39fc72124884": {
1116
+ "key": "blogCommon.undoCta",
1117
+ "source": "Undo",
1118
+ "translation": "تراجع",
1119
+ "origin": "one-app:mobile-apps-inbox:CONFIRMATION_UNDO_BUTTON_TITLE"
1120
+ },
1115
1121
  "h_d01f3a6fc64b": {
1116
1122
  "key": "blog.categoriesLabel",
1117
1123
  "source": "Post categories",
@@ -2294,11 +2300,6 @@
2294
2300
  "translation": "مزيد من الإجراءات",
2295
2301
  "origin": "one-app:wix-one-app-pos:pos.home.topBar.actions.accessibility"
2296
2302
  },
2297
- "h_39fc72124884": {
2298
- "source": "Undo",
2299
- "translation": "تراجع",
2300
- "origin": "one-app:mobile-apps-inbox:CONFIRMATION_UNDO_BUTTON_TITLE"
2301
- },
2302
2303
  "h_83087836c0d0": {
2303
2304
  "source": "Updated {date}",
2304
2305
  "translation": "تم التحديث في {date}",