@vandenberghinc/volt 1.1.26 → 1.1.28

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 (502) hide show
  1. package/backend/dist/cjs/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
  2. package/backend/dist/cjs/{blacklist.js → backend/src/blacklist.js} +8 -5
  3. package/backend/dist/cjs/{cli.js → backend/src/cli.js} +29 -47
  4. package/backend/dist/cjs/backend/src/database/collection.d.ts +1543 -0
  5. package/backend/dist/cjs/backend/src/database/collection.js +3042 -0
  6. package/backend/dist/cjs/backend/src/database/database.d.ts +66 -0
  7. package/backend/dist/cjs/{database → backend/src/database}/database.js +48 -43
  8. package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +6 -0
  9. package/backend/dist/cjs/backend/src/database/filters/filters.js +15 -0
  10. package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +223 -0
  11. package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +15 -0
  12. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +443 -0
  13. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +15 -0
  14. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
  15. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +15 -0
  16. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
  17. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +15 -0
  18. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
  19. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +15 -0
  20. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
  21. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +15 -0
  22. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  23. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +15 -0
  24. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
  25. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +355 -0
  26. package/backend/dist/cjs/backend/src/database/flatten.d.ts +75 -0
  27. package/backend/dist/cjs/{logger.js → backend/src/database/flatten.js} +18 -7
  28. package/backend/dist/cjs/backend/src/database/flatten_test.js +175 -0
  29. package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +461 -0
  30. package/backend/dist/cjs/backend/src/database/quota/quota.js +1014 -0
  31. package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +534 -0
  32. package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +1087 -0
  33. package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +293 -0
  34. package/backend/dist/cjs/backend/src/database/quota/safe_int.js +573 -0
  35. package/backend/dist/{esm → cjs/backend/src}/endpoint.d.ts +69 -46
  36. package/backend/dist/cjs/{endpoint.js → backend/src/endpoint.js} +87 -101
  37. package/backend/dist/cjs/backend/src/errors/index.d.ts +7 -0
  38. package/backend/dist/cjs/backend/src/errors/index.js +25 -0
  39. package/backend/dist/{esm/utils.d.ts → cjs/backend/src/errors/internal_external.d.ts} +14 -22
  40. package/backend/dist/cjs/backend/src/errors/internal_external.js +85 -0
  41. package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +38 -0
  42. package/backend/dist/cjs/{mutex.js → backend/src/errors/invalid_usage_error.js} +20 -37
  43. package/backend/dist/cjs/backend/src/errors/system_error.d.ts +230 -0
  44. package/backend/dist/cjs/backend/src/errors/system_error.js +393 -0
  45. package/backend/dist/cjs/backend/src/events.d.ts +54 -0
  46. package/backend/dist/cjs/backend/src/events.js +15 -0
  47. package/backend/dist/cjs/{frontend.js → backend/src/frontend.js} +1 -1
  48. package/backend/dist/cjs/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
  49. package/backend/dist/cjs/{image_endpoint.js → backend/src/image_endpoint.js} +3 -5
  50. package/backend/dist/cjs/backend/src/logger.d.ts +5 -0
  51. package/backend/dist/cjs/backend/src/logger.js +15 -0
  52. package/backend/dist/cjs/backend/src/meta.d.ts +64 -0
  53. package/backend/dist/cjs/{meta.js → backend/src/meta.js} +9 -12
  54. package/backend/dist/cjs/backend/src/payments/paddle.d.ts +326 -0
  55. package/backend/dist/cjs/{payments → backend/src/payments}/paddle.js +377 -327
  56. package/backend/dist/cjs/backend/src/plugins/browser.d.ts +1 -0
  57. package/backend/dist/cjs/backend/src/plugins/browser.js +15 -0
  58. package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +248 -0
  59. package/backend/dist/cjs/backend/src/plugins/mail/mail.js +379 -0
  60. package/backend/dist/{esm → cjs/backend/src}/plugins/mail/ui.d.ts +23 -0
  61. package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +1 -0
  62. package/backend/dist/cjs/backend/src/rate_limit.d.ts +145 -0
  63. package/backend/dist/cjs/backend/src/rate_limit.js +549 -0
  64. package/backend/dist/cjs/{route.d.ts → backend/src/route.d.ts} +3 -10
  65. package/backend/dist/cjs/{route.js → backend/src/route.js} +23 -21
  66. package/backend/dist/cjs/backend/src/server.d.ts +485 -0
  67. package/backend/dist/cjs/{server.js → backend/src/server.js} +688 -873
  68. package/backend/dist/cjs/backend/src/splash_screen.d.ts +80 -0
  69. package/backend/dist/cjs/{splash_screen.js → backend/src/splash_screen.js} +24 -3
  70. package/backend/dist/cjs/backend/src/status.d.ts +74 -0
  71. package/backend/dist/cjs/{status.js → backend/src/status.js} +64 -64
  72. package/backend/dist/cjs/backend/src/stream.d.ts +376 -0
  73. package/backend/dist/cjs/{stream.js → backend/src/stream.js} +299 -276
  74. package/backend/dist/cjs/backend/src/users.d.ts +807 -0
  75. package/backend/dist/cjs/backend/src/users.js +1971 -0
  76. package/backend/dist/cjs/backend/src/utils.d.ts +16 -0
  77. package/backend/dist/cjs/{utils.js → backend/src/utils.js} +14 -77
  78. package/backend/dist/{esm → cjs/backend/src}/view.d.ts +33 -11
  79. package/backend/dist/cjs/backend/src/view.js +508 -0
  80. package/backend/dist/{esm → cjs/backend/src}/volt.d.ts +10 -1
  81. package/backend/dist/cjs/{volt.js → backend/src/volt.js} +8 -5
  82. package/backend/dist/cjs/frontend/src/modules/request.d.ts +70 -0
  83. package/backend/dist/cjs/frontend/src/modules/request.js +99 -0
  84. package/backend/dist/esm/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
  85. package/backend/dist/esm/{blacklist.js → backend/src/blacklist.js} +9 -6
  86. package/backend/dist/esm/{cli.js → backend/src/cli.js} +43 -60
  87. package/backend/dist/esm/backend/src/database/collection.d.ts +1543 -0
  88. package/backend/dist/esm/backend/src/database/collection.js +3510 -0
  89. package/backend/dist/esm/backend/src/database/database.d.ts +66 -0
  90. package/backend/dist/esm/{database → backend/src/database}/database.js +62 -103
  91. package/backend/dist/esm/backend/src/database/document.d.ts +1 -0
  92. package/backend/dist/esm/backend/src/database/document.js +558 -0
  93. package/backend/dist/esm/backend/src/database/filters/filters.d.ts +6 -0
  94. package/backend/dist/esm/backend/src/database/filters/filters.js +1 -0
  95. package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +223 -0
  96. package/backend/dist/esm/backend/src/database/filters/strict_filter.js +3 -0
  97. package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +1 -0
  98. package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +505 -0
  99. package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
  100. package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +712 -0
  101. package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
  102. package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +5 -0
  103. package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
  104. package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +44 -0
  105. package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
  106. package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +5 -0
  107. package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
  108. package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +1 -0
  109. package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  110. package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +5 -0
  111. package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
  112. package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +405 -0
  113. package/backend/dist/esm/backend/src/database/flatten.d.ts +75 -0
  114. package/backend/dist/esm/backend/src/database/flatten.js +22 -0
  115. package/backend/dist/esm/backend/src/database/flatten_test.d.ts +1 -0
  116. package/backend/dist/esm/backend/src/database/flatten_test.js +174 -0
  117. package/backend/dist/esm/backend/src/database/quota/quota.d.ts +461 -0
  118. package/backend/dist/esm/backend/src/database/quota/quota.js +1118 -0
  119. package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +534 -0
  120. package/backend/dist/esm/backend/src/database/quota/quota_v1.js +1242 -0
  121. package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +293 -0
  122. package/backend/dist/esm/backend/src/database/quota/safe_int.js +602 -0
  123. package/backend/dist/{cjs → esm/backend/src}/endpoint.d.ts +69 -46
  124. package/backend/dist/esm/{endpoint.js → backend/src/endpoint.js} +136 -127
  125. package/backend/dist/esm/backend/src/errors/index.d.ts +7 -0
  126. package/backend/dist/esm/backend/src/errors/index.js +7 -0
  127. package/backend/dist/{cjs/utils.d.ts → esm/backend/src/errors/internal_external.d.ts} +14 -22
  128. package/backend/dist/esm/backend/src/errors/internal_external.js +70 -0
  129. package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +38 -0
  130. package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +30 -0
  131. package/backend/dist/esm/backend/src/errors/system_error.d.ts +230 -0
  132. package/backend/dist/esm/backend/src/errors/system_error.js +402 -0
  133. package/backend/dist/esm/backend/src/events.d.ts +54 -0
  134. package/backend/dist/esm/backend/src/events.js +5 -0
  135. package/backend/dist/esm/{frontend.js → backend/src/frontend.js} +1 -1
  136. package/backend/dist/esm/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
  137. package/backend/dist/esm/{image_endpoint.js → backend/src/image_endpoint.js} +16 -20
  138. package/backend/dist/esm/backend/src/logger.d.ts +5 -0
  139. package/backend/dist/esm/backend/src/logger.js +8 -0
  140. package/backend/dist/esm/backend/src/meta.d.ts +64 -0
  141. package/backend/dist/esm/{meta.js → backend/src/meta.js} +15 -54
  142. package/backend/dist/esm/backend/src/payments/paddle.d.ts +326 -0
  143. package/backend/dist/esm/{payments → backend/src/payments}/paddle.js +417 -452
  144. package/backend/dist/esm/backend/src/plugins/browser.d.ts +1 -0
  145. package/backend/dist/esm/backend/src/plugins/browser.js +170 -0
  146. package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +248 -0
  147. package/backend/dist/esm/backend/src/plugins/mail/mail.js +389 -0
  148. package/backend/dist/{cjs → esm/backend/src}/plugins/mail/ui.d.ts +23 -0
  149. package/backend/dist/esm/{plugins → backend/src/plugins}/mail/ui.js +3 -6
  150. package/backend/dist/esm/backend/src/plugins/pdf.d.ts +1 -0
  151. package/backend/dist/esm/{plugins → backend/src/plugins}/pdf.js +3 -3
  152. package/backend/dist/esm/backend/src/rate_limit.d.ts +145 -0
  153. package/backend/dist/esm/backend/src/rate_limit.js +667 -0
  154. package/backend/dist/esm/{route.d.ts → backend/src/route.d.ts} +3 -10
  155. package/backend/dist/esm/{route.js → backend/src/route.js} +26 -21
  156. package/backend/dist/esm/backend/src/server.d.ts +485 -0
  157. package/backend/dist/esm/{server.js → backend/src/server.js} +891 -1441
  158. package/backend/dist/esm/backend/src/splash_screen.d.ts +80 -0
  159. package/backend/dist/esm/{splash_screen.js → backend/src/splash_screen.js} +42 -55
  160. package/backend/dist/esm/backend/src/status.d.ts +74 -0
  161. package/backend/dist/esm/backend/src/status.js +199 -0
  162. package/backend/dist/esm/backend/src/stream.d.ts +376 -0
  163. package/backend/dist/esm/{stream.js → backend/src/stream.js} +327 -292
  164. package/backend/dist/esm/backend/src/users.d.ts +809 -0
  165. package/backend/dist/esm/backend/src/users.js +2140 -0
  166. package/backend/dist/esm/backend/src/utils.d.ts +16 -0
  167. package/backend/dist/esm/{utils.js → backend/src/utils.js} +20 -81
  168. package/backend/dist/{cjs → esm/backend/src}/view.d.ts +33 -11
  169. package/backend/dist/esm/{view.js → backend/src/view.js} +266 -86
  170. package/backend/dist/{cjs → esm/backend/src}/volt.d.ts +10 -1
  171. package/backend/dist/esm/{volt.js → backend/src/volt.js} +7 -4
  172. package/backend/dist/esm/frontend/src/modules/request.d.ts +70 -0
  173. package/backend/dist/esm/frontend/src/modules/request.js +117 -0
  174. package/frontend/dist/backend/src/database/collection.d.ts +1543 -0
  175. package/frontend/dist/backend/src/database/collection.js +3510 -0
  176. package/frontend/dist/backend/src/database/database.d.ts +66 -0
  177. package/frontend/dist/backend/src/database/database.js +196 -0
  178. package/frontend/dist/backend/src/database/filters/filters.d.ts +6 -0
  179. package/frontend/dist/backend/src/database/filters/filters.js +1 -0
  180. package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +223 -0
  181. package/frontend/dist/backend/src/database/filters/strict_filter.js +3 -0
  182. package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  183. package/frontend/dist/backend/src/database/filters/strict_update_filter.js +5 -0
  184. package/frontend/dist/backend/src/database/flatten.d.ts +75 -0
  185. package/frontend/dist/backend/src/database/flatten.js +22 -0
  186. package/frontend/dist/backend/src/endpoint.d.ts +204 -0
  187. package/frontend/dist/backend/src/endpoint.js +570 -0
  188. package/frontend/dist/backend/src/errors/index.d.ts +7 -0
  189. package/frontend/dist/backend/src/errors/index.js +7 -0
  190. package/frontend/dist/backend/src/errors/internal_external.d.ts +38 -0
  191. package/frontend/dist/backend/src/errors/internal_external.js +70 -0
  192. package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +38 -0
  193. package/frontend/dist/backend/src/errors/invalid_usage_error.js +30 -0
  194. package/frontend/dist/backend/src/errors/system_error.d.ts +230 -0
  195. package/frontend/dist/backend/src/errors/system_error.js +402 -0
  196. package/frontend/dist/backend/src/events.d.ts +54 -0
  197. package/frontend/dist/backend/src/events.js +5 -0
  198. package/frontend/dist/backend/src/frontend.d.ts +11 -0
  199. package/frontend/dist/backend/src/frontend.js +12 -0
  200. package/frontend/dist/backend/src/image_endpoint.d.ts +39 -0
  201. package/frontend/dist/backend/src/image_endpoint.js +202 -0
  202. package/frontend/dist/backend/src/meta.d.ts +64 -0
  203. package/frontend/dist/backend/src/meta.js +110 -0
  204. package/frontend/dist/backend/src/payments/paddle.d.ts +326 -0
  205. package/frontend/dist/backend/src/payments/paddle.js +2256 -0
  206. package/frontend/dist/backend/src/plugins/mail/mail.d.ts +248 -0
  207. package/frontend/dist/backend/src/plugins/mail/mail.js +389 -0
  208. package/{backend/dist/esm/plugins/mail.d.ts → frontend/dist/backend/src/plugins/mail/ui.d.ts} +23 -0
  209. package/{backend/dist/esm/plugins/mail.js → frontend/dist/backend/src/plugins/mail/ui.js} +3 -6
  210. package/frontend/dist/backend/src/rate_limit.d.ts +145 -0
  211. package/frontend/dist/backend/src/rate_limit.js +673 -0
  212. package/frontend/dist/backend/src/route.d.ts +35 -0
  213. package/frontend/dist/backend/src/route.js +212 -0
  214. package/frontend/dist/backend/src/server.d.ts +485 -0
  215. package/frontend/dist/backend/src/server.js +2670 -0
  216. package/frontend/dist/backend/src/splash_screen.d.ts +80 -0
  217. package/frontend/dist/backend/src/splash_screen.js +135 -0
  218. package/frontend/dist/backend/src/status.d.ts +74 -0
  219. package/frontend/dist/backend/src/status.js +199 -0
  220. package/frontend/dist/backend/src/stream.d.ts +376 -0
  221. package/frontend/dist/backend/src/stream.js +1007 -0
  222. package/frontend/dist/backend/src/users.d.ts +807 -0
  223. package/frontend/dist/backend/src/users.js +2118 -0
  224. package/frontend/dist/backend/src/utils.d.ts +16 -0
  225. package/frontend/dist/backend/src/utils.js +241 -0
  226. package/frontend/dist/backend/src/view.d.ts +162 -0
  227. package/frontend/dist/backend/src/view.js +720 -0
  228. package/frontend/dist/frontend/src/elements/base.d.ts +4414 -0
  229. package/frontend/dist/{elements → frontend/src/elements}/base.js +3624 -260
  230. package/frontend/dist/frontend/src/elements/module.d.ts +95 -0
  231. package/frontend/dist/{elements → frontend/src/elements}/module.js +53 -52
  232. package/frontend/dist/frontend/src/elements/types.d.ts +52 -0
  233. package/frontend/dist/frontend/src/elements/types.js +5 -0
  234. package/frontend/dist/frontend/src/modules/attachment.d.ts +126 -0
  235. package/frontend/dist/frontend/src/modules/attachment.js +306 -0
  236. package/frontend/dist/frontend/src/modules/auth.d.ts +44 -0
  237. package/frontend/dist/frontend/src/modules/auth.js +80 -0
  238. package/frontend/dist/{modules → frontend/src/modules}/color.js +2 -2
  239. package/frontend/dist/frontend/src/modules/compression.d.ts +39 -0
  240. package/frontend/dist/frontend/src/modules/compression.js +102 -0
  241. package/frontend/dist/frontend/src/modules/cookies.d.ts +44 -0
  242. package/frontend/dist/frontend/src/modules/cookies.js +143 -0
  243. package/frontend/dist/frontend/src/modules/events.d.ts +31 -0
  244. package/frontend/dist/frontend/src/modules/events.js +74 -0
  245. package/frontend/dist/frontend/src/modules/google.d.ts +23 -0
  246. package/frontend/dist/frontend/src/modules/google.js +52 -0
  247. package/frontend/dist/frontend/src/modules/meta.d.ts +14 -0
  248. package/frontend/dist/{modules → frontend/src/modules}/meta.js +9 -7
  249. package/frontend/dist/{modules → frontend/src/modules}/paddle.d.ts +37 -134
  250. package/frontend/dist/{modules → frontend/src/modules}/paddle.js +620 -568
  251. package/frontend/dist/frontend/src/modules/request.d.ts +70 -0
  252. package/frontend/dist/frontend/src/modules/request.js +117 -0
  253. package/frontend/dist/frontend/src/modules/settings.d.ts +3 -0
  254. package/frontend/dist/frontend/src/modules/settings.js +5 -0
  255. package/frontend/dist/frontend/src/modules/statics.d.ts +21 -0
  256. package/frontend/dist/{modules → frontend/src/modules}/statics.js +15 -18
  257. package/frontend/dist/frontend/src/modules/support.d.ts +30 -0
  258. package/frontend/dist/frontend/src/modules/support.js +53 -0
  259. package/frontend/dist/{modules → frontend/src/modules}/theme.d.ts +67 -0
  260. package/frontend/dist/{modules → frontend/src/modules}/theme.js +68 -38
  261. package/frontend/dist/frontend/src/modules/themes.d.ts +12 -0
  262. package/frontend/dist/frontend/src/modules/themes.js +22 -0
  263. package/frontend/dist/frontend/src/modules/user.d.ts +164 -0
  264. package/frontend/dist/frontend/src/modules/user.js +268 -0
  265. package/frontend/dist/frontend/src/modules/utils.d.ts +176 -0
  266. package/frontend/dist/frontend/src/modules/utils.js +569 -0
  267. package/frontend/dist/frontend/src/types/gradient.d.ts +29 -0
  268. package/frontend/dist/{types → frontend/src/types}/gradient.js +14 -18
  269. package/frontend/dist/frontend/src/ui/border_button.d.ts +94 -0
  270. package/frontend/dist/{ui → frontend/src/ui}/border_button.js +7 -13
  271. package/frontend/dist/frontend/src/ui/button.d.ts +28 -0
  272. package/frontend/dist/{ui → frontend/src/ui}/button.js +21 -12
  273. package/frontend/dist/frontend/src/ui/canvas.d.ts +138 -0
  274. package/frontend/dist/{ui → frontend/src/ui}/canvas.js +88 -55
  275. package/frontend/dist/frontend/src/ui/checkbox.d.ts +74 -0
  276. package/frontend/dist/{ui → frontend/src/ui}/checkbox.js +80 -41
  277. package/frontend/dist/{ui → frontend/src/ui}/code.d.ts +73 -6
  278. package/frontend/dist/{ui → frontend/src/ui}/code.js +55 -52
  279. package/frontend/dist/{ui → frontend/src/ui}/context_menu.d.ts +4 -0
  280. package/frontend/dist/{ui → frontend/src/ui}/context_menu.js +12 -17
  281. package/frontend/dist/{ui → frontend/src/ui}/css.d.ts +4 -0
  282. package/frontend/dist/{ui → frontend/src/ui}/css.js +3 -3
  283. package/frontend/dist/{ui → frontend/src/ui}/divider.d.ts +4 -0
  284. package/frontend/dist/{ui → frontend/src/ui}/divider.js +3 -3
  285. package/frontend/dist/{ui → frontend/src/ui}/dropdown.d.ts +57 -2
  286. package/frontend/dist/{ui → frontend/src/ui}/dropdown.js +87 -94
  287. package/frontend/dist/{ui → frontend/src/ui}/for_each.d.ts +4 -0
  288. package/frontend/dist/{ui → frontend/src/ui}/for_each.js +3 -3
  289. package/frontend/dist/{ui → frontend/src/ui}/form.d.ts +6 -2
  290. package/frontend/dist/{ui → frontend/src/ui}/form.js +10 -7
  291. package/frontend/dist/frontend/src/ui/frame_modes.d.ts +37 -0
  292. package/frontend/dist/{ui → frontend/src/ui}/frame_modes.js +16 -22
  293. package/frontend/dist/{ui → frontend/src/ui}/google_map.d.ts +4 -0
  294. package/frontend/dist/{ui → frontend/src/ui}/google_map.js +4 -4
  295. package/frontend/dist/{ui → frontend/src/ui}/gradient.d.ts +4 -0
  296. package/frontend/dist/{ui → frontend/src/ui}/gradient.js +3 -3
  297. package/frontend/dist/{ui → frontend/src/ui}/image.d.ts +4 -0
  298. package/frontend/dist/{ui → frontend/src/ui}/image.js +5 -5
  299. package/frontend/dist/frontend/src/ui/input.d.ts +392 -0
  300. package/frontend/dist/{ui → frontend/src/ui}/input.js +346 -360
  301. package/frontend/dist/{ui → frontend/src/ui}/link.d.ts +4 -0
  302. package/frontend/dist/{ui → frontend/src/ui}/link.js +3 -3
  303. package/frontend/dist/{ui → frontend/src/ui}/list.d.ts +4 -0
  304. package/frontend/dist/{ui → frontend/src/ui}/list.js +12 -6
  305. package/frontend/dist/frontend/src/ui/loader_button.d.ts +80 -0
  306. package/frontend/dist/{ui → frontend/src/ui}/loader_button.js +35 -47
  307. package/frontend/dist/frontend/src/ui/loaders.d.ts +57 -0
  308. package/frontend/dist/{ui → frontend/src/ui}/loaders.js +11 -11
  309. package/frontend/dist/{ui → frontend/src/ui}/popup.d.ts +11 -6
  310. package/frontend/dist/{ui → frontend/src/ui}/popup.js +32 -18
  311. package/frontend/dist/frontend/src/ui/pseudo.d.ts +44 -0
  312. package/frontend/dist/{ui → frontend/src/ui}/pseudo.js +84 -8
  313. package/frontend/dist/{ui → frontend/src/ui}/scroller.d.ts +14 -2
  314. package/frontend/dist/{ui → frontend/src/ui}/scroller.js +37 -43
  315. package/frontend/dist/{ui → frontend/src/ui}/slider.d.ts +5 -1
  316. package/frontend/dist/{ui → frontend/src/ui}/slider.js +4 -4
  317. package/frontend/dist/{ui → frontend/src/ui}/spacer.d.ts +4 -0
  318. package/frontend/dist/{ui → frontend/src/ui}/spacer.js +3 -3
  319. package/frontend/dist/{ui → frontend/src/ui}/span.d.ts +4 -0
  320. package/frontend/dist/{ui → frontend/src/ui}/span.js +3 -3
  321. package/frontend/dist/{ui → frontend/src/ui}/stack.d.ts +4 -0
  322. package/frontend/dist/{ui → frontend/src/ui}/stack.js +3 -9
  323. package/frontend/dist/frontend/src/ui/steps.d.ts +131 -0
  324. package/frontend/dist/{ui → frontend/src/ui}/steps.js +30 -45
  325. package/frontend/dist/{ui → frontend/src/ui}/style.d.ts +4 -0
  326. package/frontend/dist/{ui → frontend/src/ui}/style.js +3 -3
  327. package/frontend/dist/{ui → frontend/src/ui}/switch.d.ts +5 -1
  328. package/frontend/dist/{ui → frontend/src/ui}/switch.js +4 -4
  329. package/frontend/dist/{ui → frontend/src/ui}/table.d.ts +4 -0
  330. package/frontend/dist/{ui → frontend/src/ui}/table.js +6 -6
  331. package/frontend/dist/{ui → frontend/src/ui}/tabs.d.ts +45 -3
  332. package/frontend/dist/{ui → frontend/src/ui}/tabs.js +65 -40
  333. package/frontend/dist/{ui → frontend/src/ui}/text.d.ts +4 -0
  334. package/frontend/dist/{ui → frontend/src/ui}/text.js +3 -3
  335. package/frontend/dist/frontend/src/ui/title.d.ts +91 -0
  336. package/frontend/dist/frontend/src/ui/title.js +272 -0
  337. package/frontend/dist/{ui → frontend/src/ui}/view.d.ts +4 -0
  338. package/frontend/dist/{ui → frontend/src/ui}/view.js +3 -3
  339. package/frontend/dist/{volt.d.ts → frontend/src/volt.d.ts} +3 -0
  340. package/frontend/dist/{volt.js → frontend/src/volt.js} +4 -0
  341. package/frontend/tools/bundle_d_ts.js +71 -0
  342. package/frontend/tools/convert_to_jsdoc_input.txt +9452 -0
  343. package/frontend/tools/convert_to_jsdoc_output.txt +7626 -0
  344. package/frontend/tools/convert_to_jsdoc_tmp.js +345 -0
  345. package/package.json +11 -12
  346. package/backend/dist/cjs/database/collection.d.ts +0 -160
  347. package/backend/dist/cjs/database/collection.js +0 -842
  348. package/backend/dist/cjs/database/database.d.ts +0 -121
  349. package/backend/dist/cjs/database/document.d.ts +0 -131
  350. package/backend/dist/cjs/database/document.js +0 -224
  351. package/backend/dist/cjs/database.d.ts +0 -502
  352. package/backend/dist/cjs/database.js +0 -2248
  353. package/backend/dist/cjs/logger.d.ts +0 -3
  354. package/backend/dist/cjs/meta.d.ts +0 -50
  355. package/backend/dist/cjs/mutex.d.ts +0 -24
  356. package/backend/dist/cjs/payments/paddle.d.ts +0 -160
  357. package/backend/dist/cjs/plugins/browser.d.ts +0 -36
  358. package/backend/dist/cjs/plugins/browser.js +0 -198
  359. package/backend/dist/cjs/plugins/css.d.ts +0 -11
  360. package/backend/dist/cjs/plugins/css.js +0 -80
  361. package/backend/dist/cjs/plugins/mail.d.ts +0 -277
  362. package/backend/dist/cjs/plugins/mail.js +0 -1370
  363. package/backend/dist/cjs/plugins/ts/compiler.d.ts +0 -139
  364. package/backend/dist/cjs/plugins/ts/compiler.js +0 -750
  365. package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +0 -14
  366. package/backend/dist/cjs/plugins/ts/preprocessing.js +0 -440
  367. package/backend/dist/cjs/rate_limit.d.ts +0 -63
  368. package/backend/dist/cjs/rate_limit.js +0 -348
  369. package/backend/dist/cjs/request.deprc.d.ts +0 -48
  370. package/backend/dist/cjs/request.deprc.js +0 -572
  371. package/backend/dist/cjs/response.deprc.d.ts +0 -55
  372. package/backend/dist/cjs/response.deprc.js +0 -275
  373. package/backend/dist/cjs/server.d.ts +0 -342
  374. package/backend/dist/cjs/splash_screen.d.ts +0 -35
  375. package/backend/dist/cjs/status.d.ts +0 -61
  376. package/backend/dist/cjs/stream.d.ts +0 -79
  377. package/backend/dist/cjs/users.d.ts +0 -111
  378. package/backend/dist/cjs/users.js +0 -1817
  379. package/backend/dist/cjs/view.js +0 -352
  380. package/backend/dist/cjs/vinc.dev.d.ts +0 -3
  381. package/backend/dist/cjs/vinc.dev.js +0 -7
  382. package/backend/dist/css/adyen.css +0 -92
  383. package/backend/dist/css/volt.css +0 -70
  384. package/backend/dist/esm/database/collection.d.ts +0 -160
  385. package/backend/dist/esm/database/collection.js +0 -1328
  386. package/backend/dist/esm/database/database.d.ts +0 -121
  387. package/backend/dist/esm/database/document.d.ts +0 -131
  388. package/backend/dist/esm/database/document.js +0 -247
  389. package/backend/dist/esm/database.d.ts +0 -502
  390. package/backend/dist/esm/database.js +0 -2423
  391. package/backend/dist/esm/file_watcher.js +0 -329
  392. package/backend/dist/esm/logger.d.ts +0 -3
  393. package/backend/dist/esm/logger.js +0 -11
  394. package/backend/dist/esm/meta.d.ts +0 -50
  395. package/backend/dist/esm/mutex.d.ts +0 -24
  396. package/backend/dist/esm/mutex.js +0 -48
  397. package/backend/dist/esm/payments/paddle.d.ts +0 -160
  398. package/backend/dist/esm/plugins/browser.d.ts +0 -36
  399. package/backend/dist/esm/plugins/browser.js +0 -176
  400. package/backend/dist/esm/plugins/css.d.ts +0 -11
  401. package/backend/dist/esm/plugins/css.js +0 -90
  402. package/backend/dist/esm/plugins/ts/compiler.d.ts +0 -139
  403. package/backend/dist/esm/plugins/ts/compiler.js +0 -1194
  404. package/backend/dist/esm/plugins/ts/preprocessing.d.ts +0 -14
  405. package/backend/dist/esm/plugins/ts/preprocessing.js +0 -726
  406. package/backend/dist/esm/rate_limit.d.ts +0 -63
  407. package/backend/dist/esm/rate_limit.js +0 -417
  408. package/backend/dist/esm/request.deprc.d.ts +0 -48
  409. package/backend/dist/esm/request.deprc.js +0 -572
  410. package/backend/dist/esm/response.deprc.d.ts +0 -55
  411. package/backend/dist/esm/response.deprc.js +0 -275
  412. package/backend/dist/esm/server.d.ts +0 -342
  413. package/backend/dist/esm/splash_screen.d.ts +0 -35
  414. package/backend/dist/esm/status.d.ts +0 -61
  415. package/backend/dist/esm/status.js +0 -197
  416. package/backend/dist/esm/stream.d.ts +0 -79
  417. package/backend/dist/esm/users.d.ts +0 -111
  418. package/backend/dist/esm/users.js +0 -1935
  419. package/backend/dist/esm/vinc.dev.d.ts +0 -3
  420. package/backend/dist/esm/vinc.dev.js +0 -7
  421. package/frontend/dist/elements/base.d.ts +0 -9889
  422. package/frontend/dist/elements/module.d.ts +0 -30
  423. package/frontend/dist/modules/array.d.ts +0 -94
  424. package/frontend/dist/modules/array.js +0 -634
  425. package/frontend/dist/modules/auth.d.ts +0 -46
  426. package/frontend/dist/modules/auth.js +0 -139
  427. package/frontend/dist/modules/colors.d.ts +0 -1
  428. package/frontend/dist/modules/colors.js +0 -417
  429. package/frontend/dist/modules/compression.d.ts +0 -6
  430. package/frontend/dist/modules/compression.js +0 -999
  431. package/frontend/dist/modules/cookies.d.ts +0 -18
  432. package/frontend/dist/modules/cookies.js +0 -167
  433. package/frontend/dist/modules/date.d.ts +0 -142
  434. package/frontend/dist/modules/date.js +0 -493
  435. package/frontend/dist/modules/events.d.ts +0 -8
  436. package/frontend/dist/modules/events.js +0 -91
  437. package/frontend/dist/modules/google.d.ts +0 -11
  438. package/frontend/dist/modules/google.js +0 -54
  439. package/frontend/dist/modules/meta.d.ts +0 -10
  440. package/frontend/dist/modules/mutex.d.ts +0 -7
  441. package/frontend/dist/modules/mutex.js +0 -51
  442. package/frontend/dist/modules/number.d.ts +0 -16
  443. package/frontend/dist/modules/number.js +0 -23
  444. package/frontend/dist/modules/object.d.ts +0 -52
  445. package/frontend/dist/modules/object.js +0 -383
  446. package/frontend/dist/modules/scheme.d.ts +0 -227
  447. package/frontend/dist/modules/scheme.js +0 -531
  448. package/frontend/dist/modules/settings.d.ts +0 -3
  449. package/frontend/dist/modules/settings.js +0 -4
  450. package/frontend/dist/modules/statics.d.ts +0 -5
  451. package/frontend/dist/modules/string.d.ts +0 -124
  452. package/frontend/dist/modules/string.js +0 -745
  453. package/frontend/dist/modules/support.d.ts +0 -19
  454. package/frontend/dist/modules/support.js +0 -103
  455. package/frontend/dist/modules/themes.d.ts +0 -8
  456. package/frontend/dist/modules/themes.js +0 -18
  457. package/frontend/dist/modules/user.d.ts +0 -59
  458. package/frontend/dist/modules/user.js +0 -280
  459. package/frontend/dist/modules/utils.d.ts +0 -87
  460. package/frontend/dist/modules/utils.js +0 -923
  461. package/frontend/dist/types/gradient.d.ts +0 -12
  462. package/frontend/dist/ui/border_button.d.ts +0 -152
  463. package/frontend/dist/ui/button.d.ts +0 -21
  464. package/frontend/dist/ui/canvas.d.ts +0 -56
  465. package/frontend/dist/ui/checkbox.d.ts +0 -52
  466. package/frontend/dist/ui/frame_modes.d.ts +0 -25
  467. package/frontend/dist/ui/input.d.ts +0 -241
  468. package/frontend/dist/ui/loader_button.d.ts +0 -93
  469. package/frontend/dist/ui/loaders.d.ts +0 -57
  470. package/frontend/dist/ui/pseudo.d.ts +0 -16
  471. package/frontend/dist/ui/steps.d.ts +0 -59
  472. package/frontend/dist/ui/title.d.ts +0 -21
  473. package/frontend/dist/ui/title.js +0 -121
  474. package/frontend/examples/dashboard/dashboard.ts +0 -776
  475. /package/backend/dist/cjs/{cli.d.ts → backend/src/cli.d.ts} +0 -0
  476. /package/backend/dist/cjs/{file_watcher.d.ts → backend/src/database/document.d.ts} +0 -0
  477. /package/backend/dist/cjs/{file_watcher.js → backend/src/database/document.js} +0 -0
  478. /package/backend/dist/cjs/{plugins/pdf.d.ts → backend/src/database/filters/strict_filter_test.d.ts} +0 -0
  479. /package/backend/dist/{esm/file_watcher.d.ts → cjs/backend/src/database/filters/strict_filter_test_v0.d.ts} +0 -0
  480. /package/backend/dist/{esm/plugins/pdf.d.ts → cjs/backend/src/database/flatten_test.d.ts} +0 -0
  481. /package/backend/dist/cjs/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
  482. /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.d.ts +0 -0
  483. /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.js +0 -0
  484. /package/backend/dist/cjs/{plugins → backend/src/plugins}/mail/ui.js +0 -0
  485. /package/backend/dist/cjs/{plugins → backend/src/plugins}/pdf.js +0 -0
  486. /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
  487. /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
  488. /package/backend/dist/cjs/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
  489. /package/backend/dist/cjs/{vinc.js → backend/src/vinc.js} +0 -0
  490. /package/backend/dist/esm/{cli.d.ts → backend/src/cli.d.ts} +0 -0
  491. /package/backend/dist/esm/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
  492. /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.d.ts +0 -0
  493. /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.js +0 -0
  494. /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
  495. /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
  496. /package/backend/dist/esm/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
  497. /package/backend/dist/esm/{vinc.js → backend/src/vinc.js} +0 -0
  498. /package/frontend/dist/{elements → frontend/src/elements}/register_element.d.ts +0 -0
  499. /package/frontend/dist/{elements → frontend/src/elements}/register_element.js +0 -0
  500. /package/frontend/dist/{modules → frontend/src/modules}/color.d.ts +0 -0
  501. /package/frontend/dist/{ui → frontend/src/ui}/ui.d.ts +0 -0
  502. /package/frontend/dist/{ui → frontend/src/ui}/ui.js +0 -0
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /*
2
3
  * @author: Daan van den Bergh
3
4
  * @copyright: © 2022 - 2024 Daan van den Bergh.
@@ -5,31 +6,36 @@
5
6
  // Imports.
6
7
  import { Utils } from "./utils.js";
7
8
  import { User } from "./user.js";
8
- import { HStack, VStack, } from "../ui/stack";
9
- import { Text } from "../ui/text";
10
- import { Title } from "../ui/title";
11
- import { ForEach } from "../ui/for_each";
12
- import { Image, ImageMask } from "../ui/image";
13
- import { RingLoader } from "../ui/loaders";
14
- import { BorderButton } from "../ui/border_button";
15
- import { LoaderButton } from "../ui/loader_button";
16
- import { Divider } from "../ui/divider";
17
- import { Input, ExtendedSelect, ExtendedInput } from "../ui/input";
18
- import { Spacer } from "../ui/spacer";
19
- import { Form } from "../ui/form";
20
- import { YesNoPopup } from "../ui/popup";
9
+ import { HStack, VStack, } from "../ui/stack.js";
10
+ import { Text } from "../ui/text.js";
11
+ import { Title } from "../ui/title.js";
12
+ import { ForEach } from "../ui/for_each.js";
13
+ import { Image, ImageMask } from "../ui/image.js";
14
+ import { RingLoader } from "../ui/loaders.js";
15
+ import { BorderButton } from "../ui/border_button.js";
16
+ import { LoaderButton } from "../ui/loader_button.js";
17
+ import { Divider } from "../ui/divider.js";
18
+ import { Input, ExtendedSelect, ExtendedInput } from "../ui/input.js";
19
+ import { Spacer } from "../ui/spacer.js";
20
+ import { Form } from "../ui/form.js";
21
+ import { YesNoPopup } from "../ui/popup.js";
21
22
  import { Span } from "../ui/span.js";
23
+ import { request } from "./request.js";
22
24
  // ---------------------------------------------------------
23
25
  // Payments Object.
24
- const Payments = {
26
+ /**
27
+ * @deprecated using stripe from now on.
28
+ */
29
+ export var Payments;
30
+ (function (Payments) {
25
31
  // ---------------------------------------------------------
26
32
  // Private Properties.
27
- client_key: "{{PADDLE_CLIENT_KEY}}",
33
+ const client_key = "{{PADDLE_CLIENT_KEY}}";
28
34
  // @ts-ignore
29
- sandbox: "{{PADDLE_SANDBOX}}" === "true",
35
+ Payments.sandbox = "{{PADDLE_SANDBOX}}" === "true";
30
36
  // @ts-ignore
31
- tax_inclusive: "{{PADDLE_INCLUSIVE_TAX}}" === "true",
32
- countries: {
37
+ Payments.tax_inclusive = "{{PADDLE_INCLUSIVE_TAX}}" === "true";
38
+ Payments.countries = {
33
39
  "AD": { name: "🇦🇩 Andorra", calling_code: "+376" },
34
40
  "AE": { name: "🇦🇪 United Arab Emirates", calling_code: "+971" },
35
41
  "AF": { name: "🇦🇫 Afghanistan", calling_code: "+93" },
@@ -279,34 +285,34 @@ const Payments = {
279
285
  "ZA": { name: "🇿🇦 South Africa", calling_code: "+27" },
280
286
  "ZM": { name: "🇿🇲 Zambia", calling_code: "+260" },
281
287
  "ZW": { name: "🇿🇼 Zimbabwe", calling_code: "+263" }
282
- },
283
- _paddle_initialized: false,
284
- _payment_element: undefined, // Replace 'any' with the actual type if known.
285
- _sign_in_redirect: undefined,
286
- _step: 0,
287
- _steps_element: undefined,
288
- _steps_container: undefined,
289
- _overview_container: undefined,
290
- _order_container: undefined,
291
- _billing_container: undefined,
292
- _payment_container: undefined,
293
- _processing_container: undefined,
294
- _checkout_button: undefined,
295
- _prev_step_button: undefined,
296
- _style: undefined,
297
- _currency_symbol: undefined,
298
- _render_payment_element_reject: undefined,
299
- _render_payment_element_resolve: undefined,
300
- _refunds_element: undefined,
301
- _refunds_container: undefined,
302
- _processing_element: undefined,
303
- _theme: undefined,
304
- _products: undefined,
305
- _days_refundable: 30, // **Added Property**
306
- on_error: (data) => { },
288
+ };
289
+ let _paddle_initialized = false;
290
+ let _payment_element = undefined; // Replace 'any' with the actual type if known.
291
+ let _sign_in_redirect = undefined;
292
+ let _payment_step = 0;
293
+ let _steps_element = undefined;
294
+ let _steps_container = undefined;
295
+ let _overview_container = undefined;
296
+ let _order_container = undefined;
297
+ let _billing_container = undefined;
298
+ let _payment_container = undefined;
299
+ let _processing_container = undefined;
300
+ let _checkout_button = undefined;
301
+ let _prev_step_button = undefined;
302
+ let _style = undefined;
303
+ let _currency_symbol = undefined;
304
+ let _render_payment_element_reject = undefined;
305
+ let _render_payment_element_resolve = undefined;
306
+ let _refunds_element = undefined;
307
+ let _refunds_container = undefined;
308
+ let _processing_element = undefined;
309
+ let _theme = undefined;
310
+ let _products = undefined;
311
+ let _days_refundable = 30; // **Added Property**
312
+ Payments.on_error = () => { };
307
313
  // Additional properties that might be inferred from function bodies:
308
- _refund_policy: undefined, // Used in commented code
309
- _cancellation_policy: undefined, // Used in commented code
314
+ let _refund_policy; // Used in commented code
315
+ let _cancellation_policy; // Used in commented code
310
316
  // cart: {
311
317
  // items: [] as any[], // Replace 'any' with the actual item type.
312
318
  // refresh: function() { /* Implement refresh logic */ },
@@ -314,93 +320,97 @@ const Payments = {
314
320
  // add: async function(productId: string, quantity: number) { /* Implement add logic */ },
315
321
  // remove: async function(productId: string, quantity: number | "all") { /* Implement remove logic */ },
316
322
  // },
317
- _billing_element: undefined, // Replace 'any' with the actual type if known.
318
- _billing_details: undefined, // Replace 'any' with the actual type if known.
319
- _overview_subtotal: undefined, // Replace 'any' with the actual type if known.
320
- _overview_total: undefined, // Replace 'any' with the actual type if known.
321
- _overview_subtotal_tax: undefined, // Replace 'any' with the actual type if known.
322
- _overview_tax_container: undefined, // Replace 'any' with the actual type if known.
323
- _overview_incl_excl_tax: undefined, // Replace 'any' with the actual type if known.
324
- _overview_element: undefined, // Replace 'any' with the actual type if known.
325
- _order_element: undefined, // Replace 'any' with the actual type if known.
323
+ let _billing_element; // Replace 'any' with the actual type if known.
324
+ let _billing_details; // Replace 'any' with the actual type if known.
325
+ let _overview_subtotal; // Replace 'any' with the actual type if known.
326
+ let _overview_total; // Replace 'any' with the actual type if known.
327
+ let _overview_subtotal_tax; // Replace 'any' with the actual type if known.
328
+ let _overview_tax_container; // Replace 'any' with the actual type if known.
329
+ let _overview_incl_excl_tax; // Replace 'any' with the actual type if known.
330
+ let _overview_element; // Replace 'any' with the actual type if known.
331
+ let _order_element; // Replace 'any' with the actual type if known.
326
332
  // ---------------------------------------------------------
327
333
  // Private Methods.
328
334
  /**
329
335
  * Initialize Paddle with the provided client key and set up event callbacks.
330
336
  */
331
- _initialize_paddle: function () {
332
- if (this._paddle_initialized !== true) {
333
- if (this.sandbox) {
337
+ function _initialize_paddle() {
338
+ if (_paddle_initialized !== true) {
339
+ if (Payments.sandbox) {
334
340
  Paddle.Environment.set("sandbox");
335
341
  }
336
342
  Paddle.Setup({
337
- token: this.client_key,
343
+ token: client_key,
338
344
  eventCallback: (data) => {
339
345
  if (data.name === "checkout.loaded") {
340
- this._render_payment_element_resolve();
346
+ _render_payment_element_resolve();
341
347
  }
342
348
  else if (data.name === "checkout.completed") {
343
- this._show_processing("success");
349
+ _show_processing("success");
344
350
  }
345
351
  else if (data.name === "checkout.payment.initiated") {
346
352
  // Uncomment and implement if needed.
347
- // this._show_processing("processing");
353
+ // _show_processing("processing");
348
354
  }
349
355
  else if (data.name === "checkout.payment.failed") {
350
- this._show_processing("error");
356
+ _show_processing("error");
351
357
  }
352
358
  else if (data.type === "checkout.error") {
353
359
  if (data.error?.detail) {
354
360
  console.error(data);
355
- this.on_error(data.error.detail);
361
+ Payments.on_error(data.error.detail);
356
362
  }
357
363
  else {
358
364
  console.error(data);
359
- this.on_error(new Error("Unknown error"));
365
+ Payments.on_error(new Error("Unknown error"));
360
366
  }
361
- this._render_payment_element_reject(data.detail.split("|")[0]);
367
+ _render_payment_element_reject(data.detail.split("|")[0]);
362
368
  }
363
369
  else if (data.type === "checkout.warning") {
364
- if (this.sandbox) {
370
+ if (Payments.sandbox) {
365
371
  console.log("Checkout warning:", data);
366
372
  }
367
373
  }
368
374
  else {
369
375
  // Handle other events if necessary.
370
376
  // Uncomment for debugging.
371
- // if (this.sandbox) {
377
+ // if (sandbox) {
372
378
  // console.log("Event", data);
373
379
  // }
374
380
  }
375
381
  }
376
382
  });
377
- this._paddle_initialized = true;
383
+ _paddle_initialized = true;
378
384
  }
379
- },
385
+ }
380
386
  /**
381
387
  * Reset the payment element by removing it if it exists.
382
388
  */
383
- _reset: function () {
384
- if (this._payment_element !== undefined) {
385
- this._payment_element.remove();
389
+ function _reset_payment_element() {
390
+ if (_payment_element !== undefined) {
391
+ _payment_element.remove();
386
392
  }
387
- this._payment_element = undefined;
388
- },
393
+ _payment_element = undefined;
394
+ }
389
395
  /**
390
396
  * Initialize the order by verifying authentication and making a POST request.
391
397
  */
392
- _init_order: async function () {
398
+ async function _init_order() {
393
399
  try {
394
- if (this._sign_in_redirect != null && !User.is_authenticated()) {
395
- Utils.redirect(this._sign_in_redirect);
400
+ if (_sign_in_redirect != null && !User.is_authenticated()) {
401
+ Utils.redirect(_sign_in_redirect);
396
402
  }
397
- const response = await Utils.request_v1({
403
+ const payload = {
404
+ items: Cart.items,
405
+ };
406
+ const response = await request({
398
407
  method: "POST",
399
- url: "/volt/payments/init",
400
- data: {
401
- items: this.cart.items,
402
- }
408
+ url: "/volt/api/v1/payments/init",
409
+ data: payload,
403
410
  });
411
+ if (response.error) {
412
+ throw new Error(response.error.message);
413
+ }
404
414
  // Handle response if necessary.
405
415
  }
406
416
  catch (err) {
@@ -409,26 +419,26 @@ const Payments = {
409
419
  }
410
420
  throw new Error(err);
411
421
  }
412
- },
422
+ }
413
423
  /**
414
424
  * Set the current step in the payment process.
415
425
  */
416
- _set_step: async function () {
426
+ async function _set_step() {
417
427
  // Switch step.
418
- switch (this._step) {
428
+ switch (_payment_step) {
419
429
  // Order.
420
430
  case 0: {
421
431
  // Select the current step.
422
- this._steps_element.select(this._step);
432
+ _steps_element.select(_payment_step);
423
433
  // Show and hide relevant containers.
424
- this._overview_container.show();
425
- this._order_container.show();
426
- this._billing_container.hide();
427
- this._payment_container.hide();
428
- this._processing_container.hide();
429
- this._checkout_button.nodes.text.text("Next");
430
- // this._policy_checkbox.hide();
431
- this._prev_step_button.hide();
434
+ _overview_container.show();
435
+ _order_container.show();
436
+ _billing_container.hide();
437
+ _payment_container.hide();
438
+ _processing_container.hide();
439
+ _checkout_button.nodes.text.text("Next");
440
+ // _policy_checkbox.hide();
441
+ _prev_step_button.hide();
432
442
  break;
433
443
  }
434
444
  // Address.
@@ -437,139 +447,139 @@ const Payments = {
437
447
  const min_duration = new Promise(resolve => setTimeout(resolve, 350));
438
448
  // Verify the order.
439
449
  try {
440
- await this._init_order();
450
+ await _init_order();
441
451
  }
442
452
  catch (err) {
443
- --this._step;
453
+ --_payment_step;
444
454
  console.error(err);
445
- this.on_error(err);
455
+ Payments.on_error(err);
446
456
  return null;
447
457
  }
448
458
  // Render billing element.
449
- this._render_billing_element();
459
+ _render_billing_element();
450
460
  // Await minimum duration.
451
461
  await min_duration;
452
462
  // Select the current step.
453
- this._steps_element.select(this._step);
463
+ _steps_element.select(_payment_step);
454
464
  // Show and hide relevant containers.
455
- this._overview_container.show();
456
- this._order_container.hide();
457
- this._billing_container.show();
458
- this._payment_container.hide();
459
- this._processing_container.hide();
460
- this._checkout_button.nodes.text.text("Next");
461
- // this._policy_checkbox.hide();
462
- this._prev_step_button.show();
465
+ _overview_container.show();
466
+ _order_container.hide();
467
+ _billing_container.show();
468
+ _payment_container.hide();
469
+ _processing_container.hide();
470
+ _checkout_button.nodes.text.text("Next");
471
+ // _policy_checkbox.hide();
472
+ _prev_step_button.show();
463
473
  break;
464
474
  }
465
475
  // Payment.
466
476
  case 2: {
467
477
  // Check if the billing details are entered correctly.
468
478
  try {
469
- this._billing_details = this._billing_element.data();
470
- this._billing_details.phone_number = this._billing_details.phone_country_code + this._billing_details.phone_number;
471
- delete this._billing_details.phone_country_code;
479
+ _billing_details = _billing_element.data();
480
+ _billing_details.phone_number = _billing_details.phone_country_code + _billing_details.phone_number;
481
+ delete _billing_details.phone_country_code;
472
482
  }
473
483
  catch (error) {
474
- --this._step;
484
+ --_payment_step;
475
485
  console.error(error);
476
- this.on_error(error);
486
+ Payments.on_error(error);
477
487
  return null;
478
488
  }
479
489
  // Render payment element.
480
490
  try {
481
- await this._render_payment_element();
491
+ await _render_payment_element();
482
492
  }
483
493
  catch (error) {
484
- --this._step;
494
+ --_payment_step;
485
495
  console.error(error);
486
- this.on_error(error);
496
+ Payments.on_error(error);
487
497
  return null;
488
498
  }
489
499
  // Select the current step.
490
- this._steps_element.select(this._step);
500
+ _steps_element.select(_payment_step);
491
501
  // Show and hide relevant containers.
492
- this._overview_container.hide();
493
- this._order_container.hide();
494
- this._billing_container.hide();
495
- this._payment_container.show();
496
- this._processing_container.hide();
497
- this._checkout_button.nodes.text.text("Checkout");
498
- // this._policy_checkbox.show();
499
- this._prev_step_button.show();
502
+ _overview_container.hide();
503
+ _order_container.hide();
504
+ _billing_container.hide();
505
+ _payment_container.show();
506
+ _processing_container.hide();
507
+ _checkout_button.nodes.text.text("Checkout");
508
+ // _policy_checkbox.show();
509
+ _prev_step_button.show();
500
510
  break;
501
511
  }
502
512
  }
503
- },
513
+ }
504
514
  /**
505
515
  * Navigate to the next step in the payment process.
506
516
  */
507
- _next: async function () {
508
- if (this._step < 3) {
509
- ++this._step;
510
- return this._set_step();
517
+ async function _next() {
518
+ if (_payment_step < 3) {
519
+ ++_payment_step;
520
+ return _set_step();
511
521
  }
512
- else if (this._step === 3) {
513
- return this._set_step();
522
+ else if (_payment_step === 3) {
523
+ return _set_step();
514
524
  }
515
- },
525
+ }
516
526
  /**
517
527
  * Navigate to the previous step in the payment process.
518
528
  */
519
- _prev: async function () {
520
- if (this._step > 0) {
521
- --this._step;
522
- return this._set_step();
529
+ async function _prev() {
530
+ if (_payment_step > 0) {
531
+ --_payment_step;
532
+ return _set_step();
523
533
  }
524
- },
534
+ }
525
535
  /**
526
536
  * Render the steps element in the UI.
527
537
  */
528
- _render_steps_element: function () {
538
+ function _render_steps_element() {
529
539
  // Shortcuts.
530
- const style = this._style;
540
+ const style = _style;
531
541
  // The previous step button.
532
- this._prev_step_button = HStack(ImageMask("/volt_static/payments/arrow.long.webp")
542
+ _prev_step_button = HStack(ImageMask("/volt_static/payments/arrow.long.webp")
533
543
  .frame(15, 15)
534
- .mask_color(this._style.fg_1)
544
+ .mask_color(_style.fg_1)
535
545
  .transition_mask("background 300ms ease-in-out")
536
546
  .transform("rotate(180deg)")
537
547
  .margin_right(10), Text("Previous Step")
538
- .color(this._style.fg_1)
548
+ .color(_style.fg_1)
539
549
  .transition("color 300ms ease-in-out")
540
550
  .padding(0)
541
551
  .margin(0)
542
552
  .font_size(14))
543
553
  .hide()
544
554
  .on_mouse_over_out((e) => {
545
- e.child(0).color(this._style.fg);
546
- e.child(1).color(this._style.fg);
555
+ e.child(0).color(_style.fg);
556
+ e.child(1).color(_style.fg);
547
557
  }, (e) => {
548
- e.child(0).color(this._style.fg_1);
549
- e.child(1).color(this._style.fg_1);
558
+ e.child(0).color(_style.fg_1);
559
+ e.child(1).color(_style.fg_1);
550
560
  })
551
561
  .on_click(() => {
552
- this._prev()
562
+ _prev()
553
563
  .catch((err) => console.error(err));
554
564
  })
555
565
  .center_vertical();
556
566
  // The steps element.
557
- this._steps_element = HStack(ForEach(["Order Details", "Billing Details", "Payment Details", "Processing Details"], (item, index) => {
567
+ _steps_element = HStack(ForEach(["Order Details", "Billing Details", "Payment Details", "Processing Details"], (item, index) => {
558
568
  const stack = HStack(VStack((index + 1).toString())
559
569
  .font_size(11)
560
570
  .padding(0)
561
571
  .margin(0)
562
- .color(index === 0 ? this._style.selected.fg : this._style.fg_1)
572
+ .color(index === 0 ? _style.selected.fg : _style.fg_1)
563
573
  .frame(17.5, 17.5)
564
- .background(index === 0 ? this._style.selected.bg : this._style.bg_1)
574
+ .background(index === 0 ? _style.selected.bg : _style.bg_1)
565
575
  .transition("color 300ms ease-in-out, background 300ms ease-in-out")
566
576
  .border_radius("50%")
567
577
  .margin_right(15)
568
578
  .flex_shrink(0)
569
579
  .center()
570
580
  .center_vertical()
571
- .border(1, this._style.divider_bg), Text(item)
572
- .color(index === 0 ? this._style.fg : this._style.fg_1)
581
+ .border(1, _style.divider_bg), Text(item)
582
+ .color(index === 0 ? _style.fg : _style.fg_1)
573
583
  .transition("color 300ms ease-in-out")
574
584
  .padding(0)
575
585
  .font_size(14)
@@ -577,9 +587,9 @@ const Payments = {
577
587
  .center_vertical()
578
588
  .margin_right(25);
579
589
  return stack;
580
- }), Spacer().min_frame(10, 1), this._prev_step_button)
590
+ }), Spacer().min_frame(10, 1), _prev_step_button)
581
591
  .overflow_x("scroll")
582
- .class("hide_scrollbar")
592
+ .class("volt_hide_scrollbar")
583
593
  .extend({
584
594
  selected_index: 0,
585
595
  /**
@@ -604,74 +614,74 @@ const Payments = {
604
614
  },
605
615
  });
606
616
  // Append the steps element to the steps container.
607
- this._steps_container.append(this._steps_element);
608
- },
617
+ _steps_container.append(_steps_element);
618
+ }
609
619
  /**
610
620
  * Render the overview element in the UI.
611
621
  */
612
- _render_overview_element: function () {
622
+ function _render_overview_element() {
613
623
  // The subtotal price from the overview.
614
- this._overview_subtotal = Text(`${this._currency_symbol == null ? "$" : this._currency_symbol} 0.00`)
615
- .color(this._style.fg)
616
- .font_size(this._style.font_size)
624
+ _overview_subtotal = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
625
+ .color(_style.fg)
626
+ .font_size(_style.font_size)
617
627
  .flex_shrink(0)
618
628
  .margin(0)
619
629
  .padding(0);
620
630
  // The total price from the overview.
621
- this._overview_total = Text(`${this._currency_symbol == null ? "$" : this._currency_symbol} 0.00`)
631
+ _overview_total = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
622
632
  .font_weight("bold")
623
- .color(this._style.fg)
624
- .font_size(this._style.font_size)
633
+ .color(_style.fg)
634
+ .font_size(_style.font_size)
625
635
  .flex_shrink(0)
626
636
  .margin(0)
627
637
  .padding(0);
628
638
  // The subtotal VAT price from the overview.
629
- this._overview_subtotal_tax = Text(`${this._currency_symbol == null ? "$" : this._currency_symbol} 0.00`)
630
- .color(this._style.fg)
631
- .font_size(this._style.font_size)
639
+ _overview_subtotal_tax = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
640
+ .color(_style.fg)
641
+ .font_size(_style.font_size)
632
642
  .flex_shrink(0)
633
643
  .margin(0)
634
644
  .padding(0);
635
645
  // The tax stack.
636
- this._overview_tax_container = HStack(Text("Tax:")
637
- .color(this._style.fg)
638
- .font_size(this._style.font_size)
646
+ _overview_tax_container = HStack(Text("Tax:")
647
+ .color(_style.fg)
648
+ .font_size(_style.font_size)
639
649
  .stretch(true)
640
650
  .flex_shrink(0)
641
651
  .margin(0, 5, 0, 0)
642
652
  .padding(0)
643
653
  .wrap(false)
644
654
  .overflow("hidden")
645
- .text_overflow("ellipsis"), this._overview_subtotal_tax)
655
+ .text_overflow("ellipsis"), _overview_subtotal_tax)
646
656
  .margin_top(5);
647
657
  // The incl/excl tax text.
648
- this._overview_incl_excl_tax = Text(this.tax_inclusive ? "incl. tax" : "excl. tax")
649
- .color(this._style.fg_2)
650
- .font_size(this._style.font_size - 6)
658
+ _overview_incl_excl_tax = Text(Payments.tax_inclusive ? "incl. tax" : "excl. tax")
659
+ .color(_style.fg_2)
660
+ .font_size(_style.font_size - 6)
651
661
  .margin(2.5, 0, 0, 0)
652
662
  .padding(0)
653
663
  .flex_shrink(0)
654
664
  .text_trailing();
655
665
  // The checkout button.
656
- this._checkout_button = LoaderButton("Next")
657
- .color(this._style.button.fg)
658
- .background(this._style.button.bg)
659
- .border_radius(this._style.button.border_radius)
660
- .border(this._style.button.border_inset ? `${this._style.button.border_width} inset ${this._style.button.border_color}` : `${this._style.button.border_width} solid ${this._style.button.border_color}`)
661
- .hover_brightness(...this._style.button.hover_brightness)
666
+ _checkout_button = LoaderButton("Next")
667
+ .color(_style.button.fg)
668
+ .background(_style.button.bg)
669
+ .border_radius(_style.button.border_radius)
670
+ .border(_style.button.border_inset ? `${_style.button.border_width} inset ${_style.button.border_color}` : `${_style.button.border_width} solid ${_style.button.border_color}`)
671
+ .hover_brightness(..._style.button.hover_brightness)
662
672
  .nodes.loader
663
- .background(this._style.button.fg)
673
+ .background(_style.button.fg)
664
674
  .update()
665
675
  .parent()
666
676
  .on_click(async () => {
667
- this._checkout_button.show_loader();
668
- Payments._next()
677
+ _checkout_button.show_loader();
678
+ _next()
669
679
  .then(() => {
670
- this._checkout_button.hide_loader();
680
+ _checkout_button.hide_loader();
671
681
  })
672
682
  .catch((err) => {
673
683
  console.error(err);
674
- this._checkout_button.hide_loader();
684
+ _checkout_button.hide_loader();
675
685
  });
676
686
  });
677
687
  // Accept agreements (currently commented out).
@@ -683,38 +693,38 @@ const Payments = {
683
693
  // " policy. I agree that my payment method may be used for recurring subscriptions.",
684
694
  // required: true
685
695
  // }) // @todo check text.
686
- // .color(this._style.fg_2)
687
- // .border_color(this._style.divider_bg)
688
- // .font_size(this._style.font_size - 6)
689
- // .focus_color(this._style.theme_fg)
690
- // .missing_color(this._style.missing_fg)
691
- // .inner_bg(this._style.bg)
696
+ // .color(_style.fg_2)
697
+ // .border_color(_style.divider_bg)
698
+ // .font_size(_style.font_size - 6)
699
+ // .focus_color(_style.theme_fg)
700
+ // .missing_color(_style.missing_fg)
701
+ // .inner_bg(_style.bg)
692
702
  // .margin_bottom(15)
693
703
  // .hide();
694
704
  // The overview element.
695
- this._overview_element = VStack(Title("Overview")
696
- .color(this._style.fg)
705
+ _overview_element = VStack(Title("Overview")
706
+ .color(_style.fg)
697
707
  .width("fit-content")
698
- .font_size(this._style.font_size - 2)
708
+ .font_size(_style.font_size - 2)
699
709
  .flex_shrink(0)
700
710
  .margin(0, 0, 15, 0)
701
711
  .letter_spacing("1px")
702
712
  .text_transform("uppercase")
703
713
  .ellipsis_overflow(true), HStack(Text("Subtotal:")
704
- .color(this._style.fg)
705
- .font_size(this._style.font_size)
714
+ .color(_style.fg)
715
+ .font_size(_style.font_size)
706
716
  .stretch(true)
707
717
  .flex_shrink(0)
708
718
  .margin(0, 5, 0, 0)
709
719
  .padding(0)
710
720
  .wrap(false)
711
721
  .overflow("hidden")
712
- .text_overflow("ellipsis"), this._overview_subtotal),
722
+ .text_overflow("ellipsis"), _overview_subtotal),
713
723
  // Uncomment and define Shipping if needed.
714
724
  // HStack(
715
725
  // Text("Shipping:")
716
- // .color(this._style.fg_1)
717
- // .font_size(this._style.font_size)
726
+ // .color(_style.fg_1)
727
+ // .font_size(_style.font_size)
718
728
  // .stretch(true)
719
729
  // .flex_shrink(0)
720
730
  // .margin(0, 5, 0, 0)
@@ -723,8 +733,8 @@ const Payments = {
723
733
  // .overflow("hidden")
724
734
  // .text_overflow("ellipsis"),
725
735
  // Text("free")
726
- // .color(this._style.fg_1)
727
- // .font_size(this._style.font_size)
736
+ // .color(_style.fg_1)
737
+ // .font_size(_style.font_size)
728
738
  // .flex_shrink(0)
729
739
  // .margin(0)
730
740
  // .padding(0)
@@ -733,104 +743,104 @@ const Payments = {
733
743
  // .text_overflow("ellipsis"),
734
744
  // )
735
745
  // .margin_top(5),
736
- this._overview_tax_container, Divider()
746
+ _overview_tax_container, Divider()
737
747
  .margin(20, 0, 20, 0)
738
- .background(this._style.divider_bg), HStack(Text("Total:")
748
+ .background(_style.divider_bg), HStack(Text("Total:")
739
749
  .font_weight("bold")
740
- .color(this._style.fg)
741
- .font_size(this._style.font_size)
750
+ .color(_style.fg)
751
+ .font_size(_style.font_size)
742
752
  .stretch(true)
743
753
  .flex_shrink(0)
744
754
  .margin(0, 5, 0, 0)
745
755
  .padding(0)
746
756
  .wrap(false)
747
757
  .overflow("hidden")
748
- .text_overflow("ellipsis"), VStack(this._overview_total, this._overview_incl_excl_tax))
758
+ .text_overflow("ellipsis"), VStack(_overview_total, _overview_incl_excl_tax))
749
759
  .margin_bottom(25),
750
760
  // this._policy_checkbox,
751
- this._checkout_button)
761
+ _checkout_button)
752
762
  .extend({
753
763
  total: 0,
754
764
  tax: 0,
755
765
  /**
756
766
  * Handle unknown tax scenarios by updating the UI accordingly.
757
767
  */
758
- unknown_tax: () => {
759
- this._overview_incl_excl_tax.text(this.tax_inclusive ? "incl. tax" : "excl. tax");
760
- this._overview_tax_container.hide();
761
- this._overview_element.tax = 0;
762
- this._overview_total.text(`${this._currency_symbol} ${this._overview_element.total.toFixed(2)}`);
768
+ unknown_tax() {
769
+ _overview_incl_excl_tax.text(Payments.tax_inclusive ? "incl. tax" : "excl. tax");
770
+ _overview_tax_container.hide();
771
+ _overview_element.tax = 0;
772
+ _overview_total.text(`${_currency_symbol} ${_overview_element.total.toFixed(2)}`);
763
773
  },
764
774
  /**
765
775
  * Calculate tax based on the provided country code.
766
776
  * @param country - The country code to calculate tax for.
767
777
  */
768
- calc_tax: async (country) => {
769
- this._initialize_paddle();
778
+ async calc_tax(country) {
779
+ _initialize_paddle();
770
780
  try {
771
781
  const result = await Paddle.PricePreview({
772
- items: this.cart.items.map((item) => {
782
+ items: Cart.items.map((item) => {
773
783
  return { priceId: item.product.price_id, quantity: item.quantity };
774
784
  }),
775
785
  address: { countryCode: country },
776
786
  });
777
- this._overview_element.tax = 0;
787
+ _overview_element.tax = 0;
778
788
  result.data.details.lineItems.forEach((item) => {
779
- this._overview_element.tax += parseInt(item.totals.tax) / 100;
789
+ _overview_element.tax += parseInt(item.totals.tax) / 100;
780
790
  });
781
- this._overview_tax_container.show();
782
- this._overview_incl_excl_tax.text("incl. tax");
783
- this._overview_subtotal_tax.text(`${this._currency_symbol} ${this._overview_element.tax.toFixed(2)}`);
784
- this._overview_total.text(`${this._currency_symbol} ${(this._overview_element.total + this._overview_element.tax).toFixed(2)}`);
791
+ _overview_tax_container.show();
792
+ _overview_incl_excl_tax.text("incl. tax");
793
+ _overview_subtotal_tax.text(`${_currency_symbol} ${_overview_element.tax.toFixed(2)}`);
794
+ _overview_total.text(`${_currency_symbol} ${(_overview_element.total + _overview_element.tax).toFixed(2)}`);
785
795
  }
786
796
  catch (error) {
787
797
  if (error?.error?.detail) {
788
- this.on_error(error.error.detail);
798
+ Payments.on_error(error.error.detail);
789
799
  console.error(error);
790
800
  }
791
801
  else {
792
802
  console.error(error);
793
803
  }
794
- this._overview_element.unknown_tax();
804
+ _overview_element.unknown_tax();
795
805
  }
796
806
  },
797
807
  });
798
808
  // Append the overview element to the overview container.
799
- this._overview_container.append(this._overview_element);
800
- },
809
+ _overview_container.append(_overview_element);
810
+ }
801
811
  /**
802
812
  * Render the order element in the UI.
803
813
  */
804
- _render_order_element: function () {
805
- this._order_element = VStack()
814
+ function _render_order_element() {
815
+ // Render.
816
+ _order_element = VStack()
806
817
  .extend({
807
818
  /**
808
819
  * Refresh the order element by updating the cart and UI elements.
809
820
  */
810
821
  refresh() {
811
822
  // Refresh the cart.
812
- Payments.cart.refresh();
823
+ Cart.refresh();
813
824
  // Shortcuts.
814
- const style = Payments._style;
815
- const cart = Payments.cart;
816
- const cart_items = Payments.cart.items;
825
+ const style = _style;
826
+ const cart_items = Cart.items;
817
827
  // Shopping cart view.
818
828
  let currency_symbol = null;
819
829
  let subtotal = 0;
820
830
  cart_items.forEach((item) => {
821
- if (currency_symbol === null) {
831
+ if (currency_symbol == null) {
822
832
  currency_symbol = Payments.get_currency_symbol(item.product.currency);
823
833
  }
824
834
  subtotal += item.product.price * item.quantity;
825
835
  });
826
- if (currency_symbol === null) {
836
+ if (currency_symbol == null) {
827
837
  currency_symbol = "$";
828
838
  }
829
- Payments._currency_symbol = currency_symbol;
839
+ _currency_symbol = currency_symbol;
830
840
  // Set the overview prices.
831
- Payments._overview_subtotal.text(`${currency_symbol} ${subtotal.toFixed(2)}`);
832
- Payments._overview_element.total = subtotal;
833
- Payments._overview_element.unknown_tax();
841
+ _overview_subtotal.text(`${currency_symbol} ${subtotal.toFixed(2)}`);
842
+ _overview_element.total = subtotal;
843
+ _overview_element.unknown_tax();
834
844
  // Add the products.
835
845
  this.remove_children();
836
846
  if (cart_items.length === 0) {
@@ -904,7 +914,7 @@ const Payments = {
904
914
  return null;
905
915
  }
906
916
  item.quantity = quantity;
907
- cart.save();
917
+ Cart.save();
908
918
  this.refresh();
909
919
  }, 500);
910
920
  })
@@ -983,11 +993,11 @@ const Payments = {
983
993
  .on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
984
994
  .on_click(async () => {
985
995
  if (item.quantity === 1) {
986
- await cart.remove(item.product.id, "all");
996
+ await Cart.remove(item.product.id, "all");
987
997
  this.refresh();
988
998
  }
989
999
  else {
990
- await cart.remove(item.product.id, 1);
1000
+ await Cart.remove(item.product.id, 1);
991
1001
  this.refresh();
992
1002
  }
993
1003
  }), ImageMask("/volt_static/payments/plus.webp")
@@ -1002,7 +1012,7 @@ const Payments = {
1002
1012
  .transition_mask("background 300ms ease-in-out")
1003
1013
  .on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
1004
1014
  .on_click(async () => {
1005
- await cart.add(item.product.id, 1);
1015
+ await Cart.add(item.product.id, 1);
1006
1016
  this.refresh();
1007
1017
  }), ImageMask("/volt_static/payments/trash.webp")
1008
1018
  .frame(20, 20)
@@ -1016,7 +1026,7 @@ const Payments = {
1016
1026
  .transition_mask("background 300ms ease-in-out")
1017
1027
  .on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
1018
1028
  .on_click(async () => {
1019
- await cart.remove(item.product.id, "all");
1029
+ await Cart.remove(item.product.id, "all");
1020
1030
  this.refresh();
1021
1031
  }))
1022
1032
  .center_vertical()
@@ -1042,7 +1052,7 @@ const Payments = {
1042
1052
  .padding(0)
1043
1053
  .flex_shrink(0)))
1044
1054
  .overflow_x("scroll")
1045
- .class("hide_scrollbar")
1055
+ .class("volt_hide_scrollbar")
1046
1056
  .width("100%")
1047
1057
  .media("width >= 800px", (e) => {
1048
1058
  e.wrap(false);
@@ -1066,13 +1076,13 @@ const Payments = {
1066
1076
  }
1067
1077
  });
1068
1078
  // Append the order element to the order container.
1069
- this._order_container.append(this._order_element.refresh());
1070
- },
1079
+ _order_container.append(_order_element.refresh());
1080
+ }
1071
1081
  // Render the refunds element.
1072
- _render_refunds_element: function () {
1082
+ function _render_refunds_element() {
1073
1083
  // Render.
1074
- const style = this._style;
1075
- this._refunds_element = VStack()
1084
+ const style = _style;
1085
+ _refunds_element = VStack()
1076
1086
  .extend({
1077
1087
  /**
1078
1088
  * Refresh the refunds element by fetching and displaying refundable, refunding, and refunded payments.
@@ -1081,29 +1091,56 @@ const Payments = {
1081
1091
  // Reset.
1082
1092
  this.inner_html("");
1083
1093
  // Create containers.
1084
- let payments = await Payments.get_refundable_payments({
1085
- days: Payments._days_refundable,
1094
+ const refundable_res = await Payments.get_refundable_payments({
1095
+ days: _days_refundable,
1086
1096
  });
1097
+ let refundable = [];
1098
+ if (refundable_res.error) {
1099
+ const e = new Error(refundable_res.error.message);
1100
+ console.error(e);
1101
+ Payments.on_error(e);
1102
+ }
1103
+ else {
1104
+ refundable = refundable_res.data;
1105
+ }
1087
1106
  const refundable_container = VStack()
1088
1107
  .extend({
1089
1108
  title: "Refundable Payments",
1090
- payments: payments,
1109
+ payments: refundable,
1091
1110
  is_refundable: true,
1092
1111
  });
1093
- payments = await Payments.get_refunding_payments();
1112
+ const refunding_res = await Payments.get_refunding_payments();
1113
+ let refunding = [];
1114
+ if (refunding_res.error) {
1115
+ const e = new Error(refunding_res.error.message);
1116
+ console.error(e);
1117
+ Payments.on_error(e);
1118
+ }
1119
+ else {
1120
+ refunding = refunding_res.data;
1121
+ }
1094
1122
  const refunding_container = VStack()
1095
1123
  .hide()
1096
1124
  .extend({
1097
1125
  title: "Processing Refunds",
1098
- payments: payments,
1126
+ payments: refunding,
1099
1127
  is_refunding: true,
1100
1128
  });
1101
- payments = await Payments.get_refunded_payments();
1129
+ const refunded_res = await Payments.get_refunded_payments();
1130
+ let refunded = [];
1131
+ if (refunded_res.error) {
1132
+ const e = new Error(refunded_res.error.message);
1133
+ console.error(e);
1134
+ Payments.on_error(e);
1135
+ }
1136
+ else {
1137
+ refunded = refunded_res.data;
1138
+ }
1102
1139
  const refunded_container = VStack()
1103
1140
  .hide()
1104
1141
  .extend({
1105
1142
  title: "Refunded Payments",
1106
- payments: payments,
1143
+ payments: refunded,
1107
1144
  is_refunded: true,
1108
1145
  });
1109
1146
  // Option bar.
@@ -1127,10 +1164,10 @@ const Payments = {
1127
1164
  }
1128
1165
  })
1129
1166
  .on_click((e) => {
1130
- e.color(Payments._style.fg_1);
1131
- e.background(Payments._style.bg_1);
1167
+ e.color(_style.fg_1);
1168
+ e.background(_style.bg_1);
1132
1169
  [e.parentElement.child(1), e.parentElement.child(2)].forEach((child) => {
1133
- child.color(Payments._style.fg_1);
1170
+ child.color(_style.fg_1);
1134
1171
  child.background("none");
1135
1172
  });
1136
1173
  refundable_container.show();
@@ -1156,10 +1193,10 @@ const Payments = {
1156
1193
  }
1157
1194
  })
1158
1195
  .on_click((e) => {
1159
- e.color(Payments._style.fg_1);
1160
- e.background(Payments._style.bg_1);
1196
+ e.color(_style.fg_1);
1197
+ e.background(_style.bg_1);
1161
1198
  [e.parentElement.child(0), e.parentElement.child(2)].forEach((child) => {
1162
- child.color(Payments._style.fg_1);
1199
+ child.color(_style.fg_1);
1163
1200
  child.background("none");
1164
1201
  });
1165
1202
  refundable_container.hide();
@@ -1185,10 +1222,10 @@ const Payments = {
1185
1222
  }
1186
1223
  })
1187
1224
  .on_click((e) => {
1188
- e.color(Payments._style.fg_1);
1189
- e.background(Payments._style.bg_1);
1225
+ e.color(_style.fg_1);
1226
+ e.background(_style.bg_1);
1190
1227
  [e.parentElement.child(0), e.parentElement.child(1)].forEach((child) => {
1191
- child.color(Payments._style.fg_1);
1228
+ child.color(_style.fg_1);
1192
1229
  child.background("none");
1193
1230
  });
1194
1231
  refundable_container.hide();
@@ -1240,7 +1277,11 @@ const Payments = {
1240
1277
  else {
1241
1278
  await Promise.all(container.payments.map(async (payment) => {
1242
1279
  await Promise.all(payment.line_items.map(async (item) => {
1243
- item.product = await Payments.get_product(item.product);
1280
+ const res = await Payments.get_product(item.product);
1281
+ if (res.error) {
1282
+ throw new Error(res.error.message);
1283
+ }
1284
+ item.product = res.data;
1244
1285
  }));
1245
1286
  }));
1246
1287
  container.append(Title(container.title)
@@ -1324,19 +1365,25 @@ const Payments = {
1324
1365
  animation_duration: 300,
1325
1366
  on_yes: async () => {
1326
1367
  try {
1327
- await Payments.create_refund(payment);
1368
+ const res = await Payments.create_refund(payment);
1369
+ if (res.error) {
1370
+ const e = new Error(res.error.message);
1371
+ console.error(e);
1372
+ Payments.on_error(e);
1373
+ return;
1374
+ }
1328
1375
  }
1329
1376
  catch (err) {
1330
1377
  console.error(err);
1331
1378
  Payments.on_error(err);
1332
- return null;
1379
+ return;
1333
1380
  }
1334
1381
  this.refresh().then(() => {
1335
1382
  refunding_option.click();
1336
1383
  });
1337
1384
  },
1338
1385
  })
1339
- .font(window.getComputedStyle(Payments._refunds_container).font)
1386
+ .font(window.getComputedStyle(_refunds_container).font)
1340
1387
  .widget
1341
1388
  .background(style.bg)
1342
1389
  .color(style.fg_1)
@@ -1419,65 +1466,65 @@ const Payments = {
1419
1466
  }
1420
1467
  });
1421
1468
  // Append.
1422
- this._refunds_element.refresh();
1423
- this._refunds_container.append(this._refunds_element);
1424
- },
1469
+ _refunds_element.refresh();
1470
+ _refunds_container.append(_refunds_element);
1471
+ }
1425
1472
  // Render the address element.
1426
- _render_billing_element: function () {
1427
- if (this._billing_element !== undefined) {
1473
+ function _render_billing_element() {
1474
+ if (_billing_element !== undefined) {
1428
1475
  return;
1429
1476
  }
1430
1477
  // Utils.
1431
1478
  const CreateInput = (args) => {
1432
1479
  return ExtendedInput(args)
1433
- .color(this._style.fg)
1434
- .font_size(this._style.font_size)
1435
- .missing_color(this._style.missing_fg)
1436
- .focus_color(this._style.theme_fg)
1437
- .border_color(this._style.divider_bg)
1438
- .border_radius(this._style.border_radius)
1480
+ .color(_style.fg)
1481
+ .font_size(_style.font_size)
1482
+ .missing_color(_style.missing_fg)
1483
+ .focus_color(_style.theme_fg)
1484
+ .border_color(_style.divider_bg)
1485
+ .border_radius(_style.border_radius)
1439
1486
  .input
1440
- .color(this._style.fg_1)
1487
+ .color(_style.fg_1)
1441
1488
  .parent();
1442
1489
  };
1443
1490
  const CreateSelect = (args) => {
1444
1491
  return ExtendedSelect(args)
1445
- .background(this._style.bg)
1446
- .color(this._style.fg)
1447
- .font_size(this._style.font_size)
1448
- .missing_color(this._style.missing_fg)
1449
- .focus_color(this._style.theme_fg)
1450
- .border_color(this._style.divider_bg)
1451
- .border_radius(this._style.border_radius)
1492
+ .background(_style.bg)
1493
+ .color(_style.fg)
1494
+ .font_size(_style.font_size)
1495
+ .error_color(_style.missing_fg)
1496
+ .focus_color(_style.theme_fg)
1497
+ .border_color(_style.divider_bg)
1498
+ .border_radius(_style.border_radius)
1452
1499
  .dropdown_height(150)
1453
1500
  .background("transparent")
1454
1501
  .dropdown
1455
- .background(this._style.bg_1)
1502
+ .background(_style.bg_1)
1456
1503
  .background_blur(20)
1457
1504
  .parent()
1458
1505
  .input
1459
1506
  .white_space("pre")
1460
1507
  // .border_radius(0)
1461
- .color(this._style.fg_1)
1508
+ .color(_style.fg_1)
1462
1509
  .parent();
1463
1510
  };
1464
1511
  // Create element.
1465
1512
  const input_spacing = 15;
1466
1513
  let country_code;
1467
- this._billing_element = Form(Title("Billing Details")
1468
- .color(this._style.fg)
1514
+ _billing_element = Form(Title("Billing Details")
1515
+ .color(_style.fg)
1469
1516
  .width("fit-content")
1470
- .font_size(this._style.font_size - 2)
1517
+ .font_size(_style.font_size - 2)
1471
1518
  .flex_shrink(0)
1472
1519
  .margin(0, 0, 0, 0)
1473
1520
  .letter_spacing("1px")
1474
1521
  .text_transform("uppercase")
1475
1522
  .ellipsis_overflow(true), Divider()
1476
- .background(this._style.divider_bg)
1523
+ .background(_style.divider_bg)
1477
1524
  .margin(10, 0, 10, 0), HStack(Text("Personal")
1478
- .font_size(this._style.font_size)
1479
- .color(this._style.fg)
1480
- .background(this._style.bg_1)
1525
+ .font_size(_style.font_size)
1526
+ .color(_style.fg)
1527
+ .background(_style.bg_1)
1481
1528
  .padding(8, 6)
1482
1529
  .margin(0)
1483
1530
  .stretch(true)
@@ -1485,29 +1532,29 @@ const Payments = {
1485
1532
  .transition("color 350ms ease, background 350ms ease")
1486
1533
  .on_mouse_over((e) => {
1487
1534
  if (e.background() === "transparent") {
1488
- e.color(this._style.fg);
1535
+ e.color(_style.fg);
1489
1536
  }
1490
1537
  })
1491
1538
  .on_mouse_out((e) => {
1492
1539
  if (e.background() === "transparent") {
1493
- e.color(this._style.fg_1);
1540
+ e.color(_style.fg_1);
1494
1541
  }
1495
1542
  })
1496
1543
  .on_click((e) => {
1497
- e.color(this._style.fg_1);
1498
- e.background(this._style.bg_1);
1544
+ e.color(_style.fg_1);
1545
+ e.background(_style.bg_1);
1499
1546
  const other = e.parentElement.child(1);
1500
- other.color(this._style.fg_1);
1547
+ other.color(_style.fg_1);
1501
1548
  other.background("none");
1502
- this._billing_element.name_input.show();
1503
- this._billing_element.name_input.required(true);
1504
- this._billing_element.business_input.hide();
1505
- this._billing_element.business_input.required(false);
1506
- this._billing_element.vat_id_input.hide();
1507
- this._billing_element.vat_id_input.required(false);
1549
+ _billing_element.name_input.show();
1550
+ _billing_element.name_input.required(true);
1551
+ _billing_element.business_input.hide();
1552
+ _billing_element.business_input.required(false);
1553
+ _billing_element.vat_id_input.hide();
1554
+ _billing_element.vat_id_input.required(false);
1508
1555
  }), Text("Business")
1509
- .font_size(this._style.font_size)
1510
- .color(this._style.fg_1)
1556
+ .font_size(_style.font_size)
1557
+ .color(_style.fg_1)
1511
1558
  .background("transparent")
1512
1559
  .padding(8, 6)
1513
1560
  .margin(0)
@@ -1516,30 +1563,30 @@ const Payments = {
1516
1563
  .transition("color 350ms ease, background 350ms ease")
1517
1564
  .on_mouse_over((e) => {
1518
1565
  if (e.background() === "transparent") {
1519
- e.color(this._style.fg);
1566
+ e.color(_style.fg);
1520
1567
  }
1521
1568
  })
1522
1569
  .on_mouse_out((e) => {
1523
1570
  if (e.background() === "transparent") {
1524
- e.color(this._style.fg_1);
1571
+ e.color(_style.fg_1);
1525
1572
  }
1526
1573
  })
1527
1574
  .on_click((e) => {
1528
- e.color(this._style.fg_1);
1529
- e.background(this._style.bg_1);
1575
+ e.color(_style.fg_1);
1576
+ e.background(_style.bg_1);
1530
1577
  const other = e.parentElement.child(0);
1531
- other.color(this._style.fg_1);
1578
+ other.color(_style.fg_1);
1532
1579
  other.background("transparent");
1533
- this._billing_element.name_input.hide();
1534
- this._billing_element.name_input.required(false);
1535
- this._billing_element.business_input.show();
1536
- this._billing_element.business_input.required(true);
1537
- this._billing_element.vat_id_input.show();
1538
- this._billing_element.vat_id_input.required(true);
1580
+ _billing_element.name_input.hide();
1581
+ _billing_element.name_input.required(false);
1582
+ _billing_element.business_input.show();
1583
+ _billing_element.business_input.required(true);
1584
+ _billing_element.vat_id_input.show();
1585
+ _billing_element.vat_id_input.required(true);
1539
1586
  }))
1540
1587
  .overflow("hidden")
1541
- .border(1, this._style.divider_bg)
1542
- .border_radius(this._style.border_radius)
1588
+ .border(1, _style.divider_bg)
1589
+ .border_radius(_style.border_radius)
1543
1590
  .margin_top(10)
1544
1591
  .margin_bottom(10)
1545
1592
  .flex_shrink(0), CreateInput({
@@ -1609,7 +1656,7 @@ const Payments = {
1609
1656
  items: Object.fromEntries(Object.entries(Payments.countries).map(([key, value]) => [key, value.name])),
1610
1657
  })
1611
1658
  .on_change((_, country) => {
1612
- this._overview_element.calc_tax(country);
1659
+ _overview_element.calc_tax(country);
1613
1660
  country_code.value(Payments.countries[country].calling_code);
1614
1661
  })
1615
1662
  .margin_top(input_spacing)
@@ -1637,58 +1684,63 @@ const Payments = {
1637
1684
  .id("phone_number"))
1638
1685
  .width("100%"));
1639
1686
  // Append.
1640
- this._billing_container.append(this._billing_element);
1641
- },
1687
+ _billing_container.append(_billing_element);
1688
+ }
1642
1689
  // Render the payment element.
1643
- _render_payment_element: async function () {
1690
+ async function _render_payment_element() {
1644
1691
  return new Promise((resolve, reject) => {
1645
- this._render_payment_element_resolve = resolve;
1646
- this._render_payment_element_reject = reject;
1692
+ _render_payment_element_resolve = resolve;
1693
+ _render_payment_element_reject = reject;
1647
1694
  // Already rendered.
1648
- if (this._payment_element !== undefined) {
1695
+ if (_payment_element !== undefined) {
1649
1696
  return resolve();
1650
1697
  }
1651
1698
  // Checks.
1652
- if (this.client_key == null) {
1699
+ if (client_key == null) {
1653
1700
  return reject(new Error(`No client key has been assigned to "Payments.client_key".`));
1654
1701
  }
1655
- if (this.cart.items.length === 0) {
1702
+ if (Cart.items.length === 0) {
1656
1703
  return reject(new Error("Shopping cart is empty."));
1657
1704
  }
1658
1705
  // Check subscription or one time payment.
1659
1706
  let is_subscription = false;
1660
- this.cart.items.forEach((item) => {
1707
+ Cart.items.forEach((item) => {
1661
1708
  if (item.is_subscription === true) {
1662
1709
  is_subscription = true;
1663
1710
  return false;
1664
1711
  }
1665
1712
  });
1666
1713
  // Initialize paddle.
1667
- this._initialize_paddle();
1714
+ _initialize_paddle();
1668
1715
  // Create element.
1669
- this._payment_element = VStack()
1716
+ _payment_element = VStack()
1670
1717
  .class("checkout-container");
1671
1718
  // Append.
1672
- this._payment_container.append(this._payment_element);
1719
+ _payment_container.append(_payment_element);
1720
+ if (!_billing_details) {
1721
+ const e = new Error("Billing details are not yet defined.");
1722
+ Payments.on_error(e);
1723
+ throw e;
1724
+ }
1673
1725
  // Initialize.
1674
1726
  let custom_data = {
1675
- customer_name: this._billing_details.name,
1727
+ customer_name: _billing_details.name,
1676
1728
  };
1677
1729
  if (User.is_authenticated()) {
1678
1730
  custom_data.uid = User.uid();
1679
1731
  }
1680
1732
  try {
1681
1733
  let business = undefined;
1682
- if (this._billing_details.business !== "") {
1734
+ if (_billing_details.business !== "") {
1683
1735
  business = {
1684
- name: this._billing_details.business,
1685
- taxIdentifier: this._billing_details.vat_id === "" ? undefined : this._billing_details.vat_id,
1736
+ name: _billing_details.business,
1737
+ taxIdentifier: _billing_details.vat_id === "" ? undefined : _billing_details.vat_id,
1686
1738
  };
1687
1739
  }
1688
1740
  Paddle.Checkout.open({
1689
1741
  settings: {
1690
1742
  displayMode: "inline",
1691
- theme: this._theme,
1743
+ theme: _theme,
1692
1744
  locale: "en",
1693
1745
  frameTarget: "checkout-container",
1694
1746
  frameInitialHeight: "450",
@@ -1696,15 +1748,15 @@ const Payments = {
1696
1748
  // successUrl: this.return_url,
1697
1749
  // successUrl: "http://test.vandenberghinc.com/checkout?payment_status=success",
1698
1750
  },
1699
- items: this.cart.items.map((item) => { return { priceId: item.product.price_id, quantity: item.quantity }; }),
1751
+ items: Cart.items.map((item) => { return { priceId: item.product.price_id, quantity: item.quantity }; }),
1700
1752
  customer: {
1701
- email: this._billing_details.email,
1753
+ email: _billing_details.email,
1702
1754
  address: {
1703
- countryCode: this._billing_details.country,
1704
- postalCode: this._billing_details.postal_code,
1705
- region: this._billing_details.province,
1706
- city: this._billing_details.city,
1707
- firstLine: `${this._billing_details.street} ${this._billing_details.house_number}`,
1755
+ countryCode: _billing_details.country,
1756
+ postalCode: _billing_details.postal_code,
1757
+ region: _billing_details.province,
1758
+ city: _billing_details.city,
1759
+ firstLine: `${_billing_details.street} ${_billing_details.house_number}`,
1708
1760
  },
1709
1761
  business,
1710
1762
  },
@@ -1714,7 +1766,7 @@ const Payments = {
1714
1766
  catch (err) {
1715
1767
  return reject(err);
1716
1768
  }
1717
- // const iframe = this._payment_element.children[0];
1769
+ // const iframe = _payment_element.children[0];
1718
1770
  // iframe.onload = () => {
1719
1771
  // console.log("ON LOAD");
1720
1772
  // let doc = iframe.contentDocument || iframe.contentWindow.document;
@@ -1722,18 +1774,18 @@ const Payments = {
1722
1774
  // elementInsideIframe.style.background = 'red'; // Example of editing an element
1723
1775
  // }
1724
1776
  });
1725
- },
1777
+ }
1726
1778
  // Render the processing element.
1727
- _render_processing_element: function () {
1779
+ function _render_processing_element() {
1728
1780
  // Already defined.
1729
- if (this._processing_element !== undefined) {
1730
- this._processing_element.set_processing();
1781
+ if (_processing_element !== undefined) {
1782
+ _processing_element.set_processing();
1731
1783
  return;
1732
1784
  }
1733
1785
  // Create element.
1734
- this._processing_element = VStack(Title("Processing")
1735
- .color(this._style.fg)
1736
- .font_size(this._style.font_size - 2)
1786
+ _processing_element = VStack(Title("Processing")
1787
+ .color(_style.fg)
1788
+ .font_size(_style.font_size - 2)
1737
1789
  .flex_shrink(0)
1738
1790
  .letter_spacing("1px")
1739
1791
  .text_transform("uppercase")
@@ -1741,9 +1793,9 @@ const Payments = {
1741
1793
  .margin(0)
1742
1794
  .padding(0)
1743
1795
  .assign_to_parent_as("title_e"), Text("Processing your payment, please wait.")
1744
- .color(this._style.fg_1)
1745
- .font_size(this._style.font_size - 2)
1746
- .line_height(this._style.font_size)
1796
+ .color(_style.fg_1)
1797
+ .font_size(_style.font_size - 2)
1798
+ .line_height(_style.font_size)
1747
1799
  .margin(5, 0, 0, 0)
1748
1800
  .padding(0)
1749
1801
  .assign_to_parent_as("text_e")
@@ -1753,14 +1805,14 @@ const Payments = {
1753
1805
  .hide()
1754
1806
  .frame(40, 40)
1755
1807
  .padding(5)
1756
- .mask_color(this._style.missing_fg)
1808
+ .mask_color(_style.missing_fg)
1757
1809
  .margin_top(15)
1758
1810
  .assign_to_parent_as("error_image_e"), Image("/volt_static/payments/party.webp")
1759
1811
  .hide()
1760
1812
  .frame(40, 40)
1761
1813
  .margin_top(15)
1762
1814
  .assign_to_parent_as("success_image_e"), RingLoader()
1763
- .background(this._style.theme_fg)
1815
+ .background(_style.theme_fg)
1764
1816
  .frame(40, 40)
1765
1817
  .update()
1766
1818
  .margin_top(15)
@@ -1818,51 +1870,51 @@ const Payments = {
1818
1870
  },
1819
1871
  });
1820
1872
  // Append.
1821
- this._processing_container.append(this._processing_element);
1822
- },
1873
+ _processing_container.append(_processing_element);
1874
+ }
1823
1875
  // Show the processing container.
1824
- _show_processing: async function (status = null) {
1876
+ async function _show_processing(status = null) {
1825
1877
  // Select step.
1826
- this._step = 3;
1827
- this._steps_element.select(this._step);
1878
+ _payment_step = 3;
1879
+ _steps_element.select(_payment_step);
1828
1880
  // Render the processing element.
1829
- this._render_processing_element();
1881
+ _render_processing_element();
1830
1882
  // Set elements.
1831
- this._order_container.hide();
1832
- this._billing_container.hide();
1833
- this._payment_container.hide();
1834
- this._processing_container.show();
1835
- this._overview_container.hide();
1836
- this._prev_step_button.hide();
1883
+ _order_container.hide();
1884
+ _billing_container.hide();
1885
+ _payment_container.hide();
1886
+ _processing_container.show();
1887
+ _overview_container.hide();
1888
+ _prev_step_button.hide();
1837
1889
  // Update.
1838
1890
  if (status != null) {
1839
- this._update_processing(status);
1891
+ _update_processing(status);
1840
1892
  }
1841
- },
1893
+ }
1842
1894
  // Update the processing container.
1843
- _update_processing: async function (status) {
1895
+ async function _update_processing(status) {
1844
1896
  // Handle result code.
1845
1897
  switch (status) {
1846
1898
  case "success":
1847
- this._processing_element.set_success();
1899
+ _processing_element.set_success();
1848
1900
  break;
1849
1901
  case "processing":
1850
- this._processing_element.set_processing();
1902
+ _processing_element.set_processing();
1851
1903
  break;
1852
1904
  case "cancelled":
1853
- this._processing_element.set_cancelled();
1905
+ _processing_element.set_cancelled();
1854
1906
  break;
1855
1907
  case "error":
1856
- this._processing_element.set_error();
1908
+ _processing_element.set_error();
1857
1909
  break;
1858
1910
  default:
1859
1911
  console.error(`Unknown session result code "${status}".`);
1860
- this._processing_element.set_error("An unknown error has occurred.");
1912
+ _processing_element.set_error("An unknown error has occurred.");
1861
1913
  break;
1862
1914
  }
1863
- },
1915
+ }
1864
1916
  // Initialize checkout page.
1865
- style: function ({ theme = "light", // light or dark
1917
+ function style({ theme = "light", // light or dark
1866
1918
  font_size = 16, border_radius = 10, bg = "#FFFFFF", bg_1 = "#00000099", divider_bg = "gray", fg = "#687282", fg_1 = "black", fg_2 = "#6D6E77", theme_fg = "#8EB8EB", missing_fg = "#E8454E", selected = {
1867
1919
  fg: null,
1868
1920
  bg: null,
@@ -1904,34 +1956,35 @@ const Payments = {
1904
1956
  button.border_width = `${button.border_width}px`;
1905
1957
  }
1906
1958
  // Save style.
1907
- this._style = {};
1908
- this._theme = theme;
1909
- this._style.font_size = font_size;
1910
- this._style.border_radius = border_radius;
1911
- this._style.bg = bg;
1912
- this._style.bg_1 = bg_1;
1913
- this._style.divider_bg = divider_bg;
1914
- this._style.fg = fg;
1915
- this._style.fg_1 = fg_1;
1916
- this._style.fg_2 = fg_2;
1917
- this._style.theme_fg = theme_fg;
1918
- this._style.missing_fg = missing_fg;
1919
- this._style.selected = selected;
1920
- this._style.button = button;
1959
+ _style = {};
1960
+ _theme = theme;
1961
+ _style.font_size = font_size;
1962
+ _style.border_radius = border_radius;
1963
+ _style.bg = bg;
1964
+ _style.bg_1 = bg_1;
1965
+ _style.divider_bg = divider_bg;
1966
+ _style.fg = fg;
1967
+ _style.fg_1 = fg_1;
1968
+ _style.fg_2 = fg_2;
1969
+ _style.theme_fg = theme_fg;
1970
+ _style.missing_fg = missing_fg;
1971
+ _style.selected = selected;
1972
+ _style.button = button;
1921
1973
  // Set CSS variables.
1922
- Object.keys(this._style).forEach((key) => {
1923
- if (typeof this._style[key] === "number") {
1924
- document.documentElement.style.setProperty(`--vpayments_${key}`, `${this._style[key]}px`);
1974
+ Object.keys(_style).forEach((key) => {
1975
+ if (typeof _style[key] === "number") {
1976
+ document.documentElement.style.setProperty(`--vpayments_${key}`, `${_style[key]}px`);
1925
1977
  }
1926
1978
  else {
1927
- document.documentElement.style.setProperty(`--vpayments_${key}`, this._style[key]);
1979
+ document.documentElement.style.setProperty(`--vpayments_${key}`, _style[key]);
1928
1980
  }
1929
1981
  });
1930
- document.documentElement.style.setProperty(`--vpayments_theme_fg_80`, `${this._style.theme_fg}80`);
1931
- document.documentElement.style.setProperty(`--vpayments_missing_fg_80`, `${this._style.missing_fg}80`);
1932
- },
1982
+ document.documentElement.style.setProperty(`--vpayments_theme_fg_80`, `${_style.theme_fg}80`);
1983
+ document.documentElement.style.setProperty(`--vpayments_missing_fg_80`, `${_style.missing_fg}80`);
1984
+ }
1985
+ Payments.style = style;
1933
1986
  // Initialize checkout page.
1934
- create_checkout_dropin: function ({ steps_container, order_container, billing_container, payment_container, processing_container, overview_container, sign_in_redirect = null, on_error = (error) => { }, }) {
1987
+ function create_checkout_dropin({ steps_container, order_container, billing_container, payment_container, processing_container, overview_container, sign_in_redirect = null, on_error = (error) => { }, }) {
1935
1988
  // Check args.
1936
1989
  if (!(steps_container instanceof Node)) {
1937
1990
  throw new Error('The "steps_container" must be assigned with a container node.');
@@ -1952,42 +2005,42 @@ const Payments = {
1952
2005
  throw new Error('The "overview_container" must be assigned with a container node.');
1953
2006
  }
1954
2007
  // Args.
1955
- this._steps_container = steps_container;
1956
- this._order_container = order_container;
2008
+ _steps_container = steps_container;
2009
+ _order_container = order_container;
1957
2010
  // @ts-ignore
1958
- this._billing_container = billing_container.hide();
2011
+ _billing_container = billing_container.hide();
1959
2012
  // @ts-ignore
1960
- this._payment_container = payment_container.hide();
2013
+ _payment_container = payment_container.hide();
1961
2014
  // @ts-ignore
1962
- this._processing_container = processing_container.hide();
1963
- this._overview_container = overview_container;
2015
+ _processing_container = processing_container.hide();
2016
+ _overview_container = overview_container;
1964
2017
  // Settings.
1965
- this._sign_in_redirect = sign_in_redirect;
2018
+ _sign_in_redirect = sign_in_redirect;
1966
2019
  // Events.
1967
- this.on_error = on_error;
2020
+ Payments.on_error = on_error;
1968
2021
  // Check style.
1969
- if (this._style === undefined) {
1970
- this.style();
2022
+ if (_style === undefined) {
2023
+ Payments.style();
1971
2024
  }
1972
2025
  // Other attributes.
1973
- this._step = 0;
2026
+ _payment_step = 0;
1974
2027
  // Render the steps element.
1975
- this._render_steps_element();
2028
+ _render_steps_element();
1976
2029
  // When the user was redirected the URL params are defined, if so only render the processing view.
1977
2030
  if (Utils.url_param("payment_status", null) != null) {
1978
- this._show_processing(Utils.url_param("payment_status", null));
2031
+ _show_processing(Utils.url_param("payment_status", null));
1979
2032
  }
1980
2033
  // No redirect.
1981
2034
  else {
1982
2035
  // Render the overview element.
1983
- this._render_overview_element();
2036
+ _render_overview_element();
1984
2037
  // Render the order element.
1985
2038
  // Must be rendered after the overview element is rendered.
1986
- this._render_order_element();
2039
+ _render_order_element();
1987
2040
  }
1988
- },
2041
+ }
1989
2042
  // Initialize refund page.
1990
- create_refunds_dropin: function ({
2043
+ function create_refunds_dropin({
1991
2044
  // The element containers.
1992
2045
  refunds_container,
1993
2046
  // Refundable settings.
@@ -1999,19 +2052,19 @@ const Payments = {
1999
2052
  throw new Error('The "refunds_container" must be assigned with a container node.');
2000
2053
  }
2001
2054
  // Args.
2002
- this._refunds_container = refunds_container;
2003
- this._days_refundable = days_refundable;
2055
+ _refunds_container = refunds_container;
2056
+ _days_refundable = days_refundable;
2004
2057
  // Events.
2005
- this.on_error = on_error;
2058
+ Payments.on_error = on_error;
2006
2059
  // Check style.
2007
- if (this._style === undefined) {
2008
- this.style();
2060
+ if (_style === undefined) {
2061
+ Payments.style();
2009
2062
  }
2010
2063
  // Other attributes.
2011
- this._step = 0;
2064
+ _payment_step = 0;
2012
2065
  // Render the refunds element.
2013
- this._render_refunds_element();
2014
- },
2066
+ _render_refunds_element();
2067
+ }
2015
2068
  // Backend API.
2016
2069
  // Get the currency symbol for a product currency.
2017
2070
  // Returns `null` when the currency is not supported.
@@ -2027,7 +2080,7 @@ const Payments = {
2027
2080
  * @name: currency
2028
2081
  * @description: The currency from the product object.
2029
2082
  */
2030
- get_currency_symbol: function (currency) {
2083
+ function get_currency_symbol(currency) {
2031
2084
  switch (currency.toLowerCase()) {
2032
2085
  case "aed": return "د.إ";
2033
2086
  case "afn": return "Af";
@@ -2184,7 +2237,8 @@ const Payments = {
2184
2237
  case "zmw": return "ZK";
2185
2238
  }
2186
2239
  return null;
2187
- },
2240
+ }
2241
+ Payments.get_currency_symbol = get_currency_symbol;
2188
2242
  // Fetch the payment products.
2189
2243
  /**
2190
2244
  * @docs:
@@ -2195,24 +2249,16 @@ const Payments = {
2195
2249
  * @type: array[object]
2196
2250
  * @return: Returns the backend defined payment products.
2197
2251
  */
2198
- get_products: async function () {
2199
- return new Promise((resolve, reject) => {
2200
- if (this._products !== undefined) {
2201
- return resolve(this._products);
2202
- }
2203
- Utils.request_v1({
2204
- method: "GET",
2205
- url: "/volt/payments/products",
2206
- })
2207
- .then((products) => {
2208
- this._products = products;
2209
- resolve(this._products);
2210
- })
2211
- .catch((err) => {
2212
- reject(err);
2213
- });
2252
+ function get_products() {
2253
+ if (_products !== undefined) {
2254
+ return _products;
2255
+ }
2256
+ return request({
2257
+ method: "GET",
2258
+ url: "/volt/api/v1/payments/products",
2214
2259
  });
2215
- },
2260
+ }
2261
+ Payments.get_products = get_products;
2216
2262
  // Fetch a payment product by id.
2217
2263
  /**
2218
2264
  * @docs:
@@ -2228,32 +2274,42 @@ const Payments = {
2228
2274
  * @type: string
2229
2275
  * @desc: The id of the payment product.
2230
2276
  */
2231
- get_product: async function (id) {
2232
- return new Promise(async (resolve, reject) => {
2233
- const products = await this.get_products();
2234
- let product = null;
2235
- for (const p of products) {
2236
- if (p.id === id) {
2237
- product = p;
2238
- break;
2239
- }
2240
- if (p.is_subscription) {
2241
- for (const plan of p.plans) {
2242
- if (plan.id === id) {
2243
- product = plan;
2244
- break;
2245
- }
2246
- }
2247
- if (product)
2277
+ async function get_product(id) {
2278
+ // APPLY_NEW_RESPONSE
2279
+ const products = await get_products();
2280
+ if (products.error)
2281
+ return products;
2282
+ let product = undefined;
2283
+ for (const p of products.data) {
2284
+ if (p.id === id) {
2285
+ product = p;
2286
+ break;
2287
+ }
2288
+ if (p.is_subscription && p.plans) {
2289
+ for (const plan of p.plans) {
2290
+ if (plan.id === id) {
2291
+ product = plan;
2248
2292
  break;
2293
+ }
2249
2294
  }
2295
+ if (product)
2296
+ break;
2250
2297
  }
2251
- if (product == null) {
2252
- return reject(new Error(`Product "${id}" does not exist.`));
2253
- }
2254
- resolve(product);
2255
- });
2256
- },
2298
+ }
2299
+ if (product == null) {
2300
+ return {
2301
+ error: {
2302
+ message: `Product "${id}" does not exist.`
2303
+ },
2304
+ status: 400,
2305
+ };
2306
+ }
2307
+ return {
2308
+ status: 200,
2309
+ data: product
2310
+ };
2311
+ }
2312
+ Payments.get_product = get_product;
2257
2313
  // Fetch a payment object by id.
2258
2314
  /**
2259
2315
  * @docs:
@@ -2267,15 +2323,14 @@ const Payments = {
2267
2323
  * @type: string
2268
2324
  * @desc: The id of the payment.
2269
2325
  */
2270
- get_payment: async function (id) {
2271
- return Utils.request_v1({
2326
+ function get_payment(payload) {
2327
+ return request({
2272
2328
  method: "GET",
2273
- url: "/volt/payments/payment",
2274
- data: {
2275
- id: id,
2276
- }
2329
+ url: "/volt/api/v1/payments/payment",
2330
+ data: payload,
2277
2331
  });
2278
- },
2332
+ }
2333
+ Payments.get_payment = get_payment;
2279
2334
  // Get all payments.
2280
2335
  /**
2281
2336
  * @docs:
@@ -2305,17 +2360,14 @@ const Payments = {
2305
2360
  * @value: "paid"
2306
2361
  * @desc: Payments that are paid.
2307
2362
  */
2308
- get_payments: async function ({ days = 30, limit = null, status = null, } = {}) {
2309
- return Utils.request_v1({
2363
+ function get_payments(payload) {
2364
+ return request({
2310
2365
  method: "GET",
2311
- url: "/volt/payments/payments",
2312
- data: {
2313
- days,
2314
- limit,
2315
- status,
2316
- }
2366
+ url: "/volt/api/v1/payments/payments",
2367
+ data: payload
2317
2368
  });
2318
- },
2369
+ }
2370
+ Payments.get_payments = get_payments;
2319
2371
  // Get refundable payments.
2320
2372
  /**
2321
2373
  * @docs:
@@ -2332,16 +2384,14 @@ const Payments = {
2332
2384
  * @type: number
2333
2385
  * @desc: Limit the amount of response payment objects.
2334
2386
  */
2335
- get_refundable_payments: async function ({ days = 30, limit = null, } = {}) {
2336
- return Utils.request_v1({
2387
+ function get_refundable_payments(payload) {
2388
+ return request({
2337
2389
  method: "GET",
2338
- url: "/volt/payments/payments/refundable",
2339
- data: {
2340
- days,
2341
- limit,
2342
- }
2390
+ url: "/volt/api/v1/payments/payments/refundable",
2391
+ data: payload
2343
2392
  });
2344
- },
2393
+ }
2394
+ Payments.get_refundable_payments = get_refundable_payments;
2345
2395
  // Get refunded payments.
2346
2396
  /**
2347
2397
  * @docs:
@@ -2358,16 +2408,14 @@ const Payments = {
2358
2408
  * @type: number
2359
2409
  * @desc: Limit the amount of response payment objects.
2360
2410
  */
2361
- get_refunded_payments: async function ({ days = 30, limit = null, } = {}) {
2362
- return Utils.request_v1({
2411
+ function get_refunded_payments(payload) {
2412
+ return request({
2363
2413
  method: "GET",
2364
- url: "/volt/payments/payments/refunded",
2365
- data: {
2366
- days,
2367
- limit,
2368
- }
2414
+ url: "/volt/api/v1/payments/payments/refunded",
2415
+ data: payload
2369
2416
  });
2370
- },
2417
+ }
2418
+ Payments.get_refunded_payments = get_refunded_payments;
2371
2419
  // Get refunding payments.
2372
2420
  /**
2373
2421
  * @docs:
@@ -2384,16 +2432,14 @@ const Payments = {
2384
2432
  * @type: number
2385
2433
  * @desc: Limit the amount of response payment objects.
2386
2434
  */
2387
- get_refunding_payments: async function ({ days = null, limit = null, } = {}) {
2388
- return Utils.request_v1({
2435
+ function get_refunding_payments(payload) {
2436
+ return request({
2389
2437
  method: "GET",
2390
- url: "/volt/payments/payments/refunding",
2391
- data: {
2392
- days,
2393
- limit,
2394
- }
2438
+ url: "/volt/api/v1/payments/payments/refunding",
2439
+ data: payload
2395
2440
  });
2396
- },
2441
+ }
2442
+ Payments.get_refunding_payments = get_refunding_payments;
2397
2443
  // Create refund.
2398
2444
  /**
2399
2445
  * @docs:
@@ -2417,17 +2463,14 @@ const Payments = {
2417
2463
  * @type: string
2418
2464
  * @desc: The refund reason.
2419
2465
  */
2420
- create_refund: async function (payment, line_items = null, reason = "refund") {
2421
- return Utils.request_v1({
2466
+ function create_refund(payload) {
2467
+ return request({
2422
2468
  method: "POST",
2423
- url: "/volt/payments/refund",
2424
- data: {
2425
- payment,
2426
- line_items,
2427
- reason,
2428
- }
2469
+ url: "/volt/api/v1/payments/refund",
2470
+ data: payload
2429
2471
  });
2430
- },
2472
+ }
2473
+ Payments.create_refund = create_refund;
2431
2474
  // Cancel subscription.
2432
2475
  /**
2433
2476
  * @docs:
@@ -2442,15 +2485,14 @@ const Payments = {
2442
2485
  * @type: string
2443
2486
  * @desc: The product id.
2444
2487
  */
2445
- cancel_subscription: async function (product) {
2446
- return Utils.request_v1({
2488
+ function cancel_subscription(payload) {
2489
+ return request({
2447
2490
  method: "DELETE",
2448
- url: "/volt/payments/subscription",
2449
- data: {
2450
- product,
2451
- }
2491
+ url: "/volt/api/v1/payments/subscription",
2492
+ data: payload
2452
2493
  });
2453
- },
2494
+ }
2495
+ Payments.cancel_subscription = cancel_subscription;
2454
2496
  // Is subscribed.
2455
2497
  /**
2456
2498
  * @docs:
@@ -2464,15 +2506,14 @@ const Payments = {
2464
2506
  * @type: string
2465
2507
  * @desc: The product id.
2466
2508
  */
2467
- is_subscribed: async function (product) {
2468
- return Utils.request_v1({
2509
+ function is_subscribed(payload) {
2510
+ return request({
2469
2511
  method: "GET",
2470
- url: "/volt/payments/subscribed",
2471
- data: {
2472
- product,
2473
- }
2512
+ url: "/volt/api/v1/payments/subscribed",
2513
+ data: payload
2474
2514
  });
2475
- },
2515
+ }
2516
+ Payments.is_subscribed = is_subscribed;
2476
2517
  // Get active subscriptions.
2477
2518
  /**
2478
2519
  * @docs:
@@ -2481,16 +2522,18 @@ const Payments = {
2481
2522
  * @title: Get active subscriptions
2482
2523
  * @desc: Get the active subscriptions of the authenticated user.
2483
2524
  */
2484
- get_active_subscriptions: async function () {
2485
- return Utils.request_v1({
2525
+ function get_active_subscriptions() {
2526
+ return request({
2486
2527
  method: "GET",
2487
- url: "/volt/payments/active_subscriptions",
2528
+ url: "/volt/api/v1/payments/active_subscriptions",
2488
2529
  });
2489
- },
2530
+ }
2531
+ Payments.get_active_subscriptions = get_active_subscriptions;
2490
2532
  // Shopping cart.
2491
2533
  // The shopping cart object.
2492
- cart: {
2493
- items: [],
2534
+ let Cart;
2535
+ (function (Cart) {
2536
+ Cart.items = [];
2494
2537
  // Refresh the shopping cart.
2495
2538
  /**
2496
2539
  * @docs:
@@ -2502,17 +2545,18 @@ const Payments = {
2502
2545
  *
2503
2546
  * The current cart items are accessible as `Payments.cart.items`.
2504
2547
  */
2505
- refresh: function () {
2548
+ function refresh() {
2506
2549
  // Load from local storage.
2507
2550
  try {
2508
- this.items = JSON.parse(localStorage.getItem("volt_shopping_cart")) || [];
2551
+ Cart.items = JSON.parse(localStorage.getItem("volt_shopping_cart")) || [];
2509
2552
  }
2510
2553
  catch (err) {
2511
- this.items = [];
2554
+ Cart.items = [];
2512
2555
  }
2513
2556
  // Reset the charge objects.
2514
- Payments._reset();
2515
- },
2557
+ _reset_payment_element();
2558
+ }
2559
+ Cart.refresh = refresh;
2516
2560
  // Save the shopping cart.
2517
2561
  /**
2518
2562
  * @docs:
@@ -2524,12 +2568,13 @@ const Payments = {
2524
2568
  *
2525
2569
  * The current cart items are accessible as `Payments.cart.items`.
2526
2570
  */
2527
- save: function () {
2571
+ function save() {
2528
2572
  // Save to local storage.
2529
- localStorage.setItem("volt_shopping_cart", JSON.stringify(this.items));
2573
+ localStorage.setItem("volt_shopping_cart", JSON.stringify(Cart.items));
2530
2574
  // Reset the charge objects.
2531
- Payments._reset();
2532
- },
2575
+ _reset_payment_element();
2576
+ }
2577
+ Cart.save = save;
2533
2578
  // Add a product to the shopping cart.
2534
2579
  /**
2535
2580
  * @docs:
@@ -2553,9 +2598,9 @@ const Payments = {
2553
2598
  * @description: The quantity to add.
2554
2599
  * @type: number
2555
2600
  */
2556
- add: async function (id, quantity = 1) {
2557
- this.refresh(); // Update in case another window has updated the cart.
2558
- const found = this.items.some((item) => {
2601
+ async function add(id, quantity = 1) {
2602
+ Cart.refresh(); // Update in case another window has updated the cart.
2603
+ const found = Cart.items.some((item) => {
2559
2604
  if (item.product.id === id) {
2560
2605
  item.quantity += quantity;
2561
2606
  return true;
@@ -2565,8 +2610,10 @@ const Payments = {
2565
2610
  if (!found) {
2566
2611
  try {
2567
2612
  const product = await Payments.get_product(id);
2568
- this.items.push({
2569
- product: product,
2613
+ if (product.error)
2614
+ throw new Error(product.error.message);
2615
+ Cart.items.push({
2616
+ product: product.data,
2570
2617
  quantity: quantity,
2571
2618
  });
2572
2619
  }
@@ -2576,8 +2623,9 @@ const Payments = {
2576
2623
  throw new Error(`Failed to add product with id "${id}" to the cart.`);
2577
2624
  }
2578
2625
  }
2579
- this.save();
2580
- },
2626
+ Cart.save();
2627
+ }
2628
+ Cart.add = add;
2581
2629
  // Remove a product from the shopping cart.
2582
2630
  /**
2583
2631
  * @docs:
@@ -2599,10 +2647,10 @@ const Payments = {
2599
2647
  * @description: The quantity to remove. When the quantity value is "all", the entire product will be removed from the shopping cart.
2600
2648
  * @type: number | "all"
2601
2649
  */
2602
- remove: async function (id, quantity = 1) {
2603
- this.refresh(); // Update in case another window has updated the cart.
2650
+ async function remove(id, quantity = 1) {
2651
+ Cart.refresh(); // Update in case another window has updated the cart.
2604
2652
  let new_cart = [];
2605
- this.items.forEach((item) => {
2653
+ Cart.items.forEach((item) => {
2606
2654
  if (item.product.id === id) {
2607
2655
  if (quantity === "all") {
2608
2656
  item.quantity = 0;
@@ -2615,9 +2663,10 @@ const Payments = {
2615
2663
  new_cart.push(item);
2616
2664
  }
2617
2665
  });
2618
- this.items = new_cart;
2619
- this.save();
2620
- },
2666
+ Cart.items = new_cart;
2667
+ Cart.save();
2668
+ }
2669
+ Cart.remove = remove;
2621
2670
  // Clear the shopping cart.
2622
2671
  /**
2623
2672
  * @docs:
@@ -2631,12 +2680,15 @@ const Payments = {
2631
2680
  *
2632
2681
  * The current cart items are accessible as `Payments.cart.items`.
2633
2682
  */
2634
- clear: async function () {
2635
- this.items = [];
2636
- this.save();
2683
+ async function clear() {
2684
+ Cart.items = [];
2685
+ Cart.save();
2637
2686
  }
2638
- },
2639
- };
2640
- // Exports.
2641
- export { Payments };
2687
+ Cart.clear = clear;
2688
+ })(Cart = Payments.Cart || (Payments.Cart = {}));
2689
+ })(Payments || (Payments = {}));
2690
+ ;
2642
2691
  export { Payments as payments }; // also export as lowercase for compatibility.
2692
+ // APPLY_FIX // @todo if undeprecate: convert to namespace
2693
+ // APPLY_FIX // @todo if undeprecate: audit by claude
2694
+ // APPLY_FIX // @todo if undeprecate: remove request_v1 everywhere in volt, return Utils.RequestResult instead