@shopify/hydrogen-react 0.0.0-next-5c16c78 → 0.0.0-next-ea3959b

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 (410) hide show
  1. package/dist/browser-dev/AddToCartButton.mjs +43 -40
  2. package/dist/browser-dev/AddToCartButton.mjs.map +1 -1
  3. package/dist/browser-dev/BaseButton.mjs +13 -15
  4. package/dist/browser-dev/BaseButton.mjs.map +1 -1
  5. package/dist/browser-dev/BuyNowButton.mjs +19 -17
  6. package/dist/browser-dev/BuyNowButton.mjs.map +1 -1
  7. package/dist/browser-dev/CartCheckoutButton.mjs +12 -15
  8. package/dist/browser-dev/CartCheckoutButton.mjs.map +1 -1
  9. package/dist/browser-dev/CartProvider.mjs +73 -67
  10. package/dist/browser-dev/CartProvider.mjs.map +1 -1
  11. package/dist/browser-dev/ExternalVideo.mjs +13 -11
  12. package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
  13. package/dist/browser-dev/Image.mjs +41 -30
  14. package/dist/browser-dev/Image.mjs.map +1 -1
  15. package/dist/browser-dev/MediaFile.mjs +29 -21
  16. package/dist/browser-dev/MediaFile.mjs.map +1 -1
  17. package/dist/browser-dev/ModelViewer.mjs +138 -76
  18. package/dist/browser-dev/ModelViewer.mjs.map +1 -1
  19. package/dist/browser-dev/Money.mjs +12 -9
  20. package/dist/browser-dev/Money.mjs.map +1 -1
  21. package/dist/browser-dev/ProductPrice.mjs +12 -17
  22. package/dist/browser-dev/ProductPrice.mjs.map +1 -1
  23. package/dist/browser-dev/ProductProvider.mjs +102 -73
  24. package/dist/browser-dev/ProductProvider.mjs.map +1 -1
  25. package/dist/browser-dev/ShopPayButton.mjs +4 -14
  26. package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
  27. package/dist/browser-dev/ShopifyProvider.mjs +20 -15
  28. package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
  29. package/dist/browser-dev/Video.mjs +30 -21
  30. package/dist/browser-dev/Video.mjs.map +1 -1
  31. package/dist/browser-dev/_virtual/index.mjs +11 -2
  32. package/dist/browser-dev/_virtual/index.mjs.map +1 -1
  33. package/dist/browser-dev/_virtual/with-selector.mjs +11 -2
  34. package/dist/browser-dev/_virtual/with-selector.mjs.map +1 -1
  35. package/dist/browser-dev/cart-hooks.mjs +31 -34
  36. package/dist/browser-dev/cart-hooks.mjs.map +1 -1
  37. package/dist/browser-dev/cart-queries.mjs +50 -20
  38. package/dist/browser-dev/cart-queries.mjs.map +1 -1
  39. package/dist/browser-dev/codegen.helpers.mjs +1 -0
  40. package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
  41. package/dist/browser-dev/image-size.mjs +8 -8
  42. package/dist/browser-dev/image-size.mjs.map +1 -1
  43. package/dist/browser-dev/load-script.mjs.map +1 -1
  44. package/dist/browser-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  45. package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs +2 -2
  46. package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  47. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
  48. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  49. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
  50. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
  51. package/dist/browser-dev/node_modules/use-sync-external-store/shim/index.mjs +3 -3
  52. package/dist/browser-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  53. package/dist/browser-dev/parse-metafield.mjs +4 -5
  54. package/dist/browser-dev/parse-metafield.mjs.map +1 -1
  55. package/dist/browser-dev/storefront-client.mjs +8 -10
  56. package/dist/browser-dev/storefront-client.mjs.map +1 -1
  57. package/dist/browser-dev/useCartAPIStateMachine.mjs +111 -80
  58. package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
  59. package/dist/browser-dev/useCartActions.mjs +150 -109
  60. package/dist/browser-dev/useCartActions.mjs.map +1 -1
  61. package/dist/browser-dev/useMoney.mjs +61 -36
  62. package/dist/browser-dev/useMoney.mjs.map +1 -1
  63. package/dist/browser-prod/AddToCartButton.mjs +43 -40
  64. package/dist/browser-prod/AddToCartButton.mjs.map +1 -1
  65. package/dist/browser-prod/BaseButton.mjs +13 -15
  66. package/dist/browser-prod/BaseButton.mjs.map +1 -1
  67. package/dist/browser-prod/BuyNowButton.mjs +19 -17
  68. package/dist/browser-prod/BuyNowButton.mjs.map +1 -1
  69. package/dist/browser-prod/CartCheckoutButton.mjs +12 -15
  70. package/dist/browser-prod/CartCheckoutButton.mjs.map +1 -1
  71. package/dist/browser-prod/CartProvider.mjs +73 -67
  72. package/dist/browser-prod/CartProvider.mjs.map +1 -1
  73. package/dist/browser-prod/ExternalVideo.mjs +13 -11
  74. package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
  75. package/dist/browser-prod/Image.mjs +35 -28
  76. package/dist/browser-prod/Image.mjs.map +1 -1
  77. package/dist/browser-prod/MediaFile.mjs +29 -21
  78. package/dist/browser-prod/MediaFile.mjs.map +1 -1
  79. package/dist/browser-prod/ModelViewer.mjs +135 -75
  80. package/dist/browser-prod/ModelViewer.mjs.map +1 -1
  81. package/dist/browser-prod/Money.mjs +12 -9
  82. package/dist/browser-prod/Money.mjs.map +1 -1
  83. package/dist/browser-prod/ProductPrice.mjs +12 -17
  84. package/dist/browser-prod/ProductPrice.mjs.map +1 -1
  85. package/dist/browser-prod/ProductProvider.mjs +102 -73
  86. package/dist/browser-prod/ProductProvider.mjs.map +1 -1
  87. package/dist/browser-prod/ShopPayButton.mjs +4 -14
  88. package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
  89. package/dist/browser-prod/ShopifyProvider.mjs +17 -14
  90. package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
  91. package/dist/browser-prod/Video.mjs +30 -21
  92. package/dist/browser-prod/Video.mjs.map +1 -1
  93. package/dist/browser-prod/_virtual/index.mjs +11 -2
  94. package/dist/browser-prod/_virtual/index.mjs.map +1 -1
  95. package/dist/browser-prod/_virtual/with-selector.mjs +11 -2
  96. package/dist/browser-prod/_virtual/with-selector.mjs.map +1 -1
  97. package/dist/browser-prod/cart-hooks.mjs +31 -34
  98. package/dist/browser-prod/cart-hooks.mjs.map +1 -1
  99. package/dist/browser-prod/cart-queries.mjs +50 -20
  100. package/dist/browser-prod/cart-queries.mjs.map +1 -1
  101. package/dist/browser-prod/codegen.helpers.mjs +1 -0
  102. package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
  103. package/dist/browser-prod/image-size.mjs +8 -8
  104. package/dist/browser-prod/image-size.mjs.map +1 -1
  105. package/dist/browser-prod/load-script.mjs.map +1 -1
  106. package/dist/browser-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  107. package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs +2 -2
  108. package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  109. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
  110. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  111. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
  112. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
  113. package/dist/browser-prod/node_modules/use-sync-external-store/shim/index.mjs +3 -3
  114. package/dist/browser-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  115. package/dist/browser-prod/parse-metafield.mjs +4 -5
  116. package/dist/browser-prod/parse-metafield.mjs.map +1 -1
  117. package/dist/browser-prod/storefront-client.mjs +8 -10
  118. package/dist/browser-prod/storefront-client.mjs.map +1 -1
  119. package/dist/browser-prod/useCartAPIStateMachine.mjs +111 -80
  120. package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
  121. package/dist/browser-prod/useCartActions.mjs +150 -109
  122. package/dist/browser-prod/useCartActions.mjs.map +1 -1
  123. package/dist/browser-prod/useMoney.mjs +61 -36
  124. package/dist/browser-prod/useMoney.mjs.map +1 -1
  125. package/dist/node-dev/AddToCartButton.js +44 -41
  126. package/dist/node-dev/AddToCartButton.js.map +1 -1
  127. package/dist/node-dev/AddToCartButton.mjs +43 -40
  128. package/dist/node-dev/AddToCartButton.mjs.map +1 -1
  129. package/dist/node-dev/BaseButton.js +14 -16
  130. package/dist/node-dev/BaseButton.js.map +1 -1
  131. package/dist/node-dev/BaseButton.mjs +13 -15
  132. package/dist/node-dev/BaseButton.mjs.map +1 -1
  133. package/dist/node-dev/BuyNowButton.js +20 -18
  134. package/dist/node-dev/BuyNowButton.js.map +1 -1
  135. package/dist/node-dev/BuyNowButton.mjs +19 -17
  136. package/dist/node-dev/BuyNowButton.mjs.map +1 -1
  137. package/dist/node-dev/CartCheckoutButton.js +13 -16
  138. package/dist/node-dev/CartCheckoutButton.js.map +1 -1
  139. package/dist/node-dev/CartCheckoutButton.mjs +12 -15
  140. package/dist/node-dev/CartCheckoutButton.mjs.map +1 -1
  141. package/dist/node-dev/CartProvider.js +74 -68
  142. package/dist/node-dev/CartProvider.js.map +1 -1
  143. package/dist/node-dev/CartProvider.mjs +73 -67
  144. package/dist/node-dev/CartProvider.mjs.map +1 -1
  145. package/dist/node-dev/ExternalVideo.js +14 -12
  146. package/dist/node-dev/ExternalVideo.js.map +1 -1
  147. package/dist/node-dev/ExternalVideo.mjs +13 -11
  148. package/dist/node-dev/ExternalVideo.mjs.map +1 -1
  149. package/dist/node-dev/Image.js +42 -31
  150. package/dist/node-dev/Image.js.map +1 -1
  151. package/dist/node-dev/Image.mjs +41 -30
  152. package/dist/node-dev/Image.mjs.map +1 -1
  153. package/dist/node-dev/MediaFile.js +30 -22
  154. package/dist/node-dev/MediaFile.js.map +1 -1
  155. package/dist/node-dev/MediaFile.mjs +29 -21
  156. package/dist/node-dev/MediaFile.mjs.map +1 -1
  157. package/dist/node-dev/ModelViewer.js +139 -77
  158. package/dist/node-dev/ModelViewer.js.map +1 -1
  159. package/dist/node-dev/ModelViewer.mjs +138 -76
  160. package/dist/node-dev/ModelViewer.mjs.map +1 -1
  161. package/dist/node-dev/Money.js +13 -10
  162. package/dist/node-dev/Money.js.map +1 -1
  163. package/dist/node-dev/Money.mjs +12 -9
  164. package/dist/node-dev/Money.mjs.map +1 -1
  165. package/dist/node-dev/ProductPrice.js +13 -18
  166. package/dist/node-dev/ProductPrice.js.map +1 -1
  167. package/dist/node-dev/ProductPrice.mjs +12 -17
  168. package/dist/node-dev/ProductPrice.mjs.map +1 -1
  169. package/dist/node-dev/ProductProvider.js +103 -74
  170. package/dist/node-dev/ProductProvider.js.map +1 -1
  171. package/dist/node-dev/ProductProvider.mjs +102 -73
  172. package/dist/node-dev/ProductProvider.mjs.map +1 -1
  173. package/dist/node-dev/ShopPayButton.js +5 -15
  174. package/dist/node-dev/ShopPayButton.js.map +1 -1
  175. package/dist/node-dev/ShopPayButton.mjs +4 -14
  176. package/dist/node-dev/ShopPayButton.mjs.map +1 -1
  177. package/dist/node-dev/ShopifyProvider.js +21 -16
  178. package/dist/node-dev/ShopifyProvider.js.map +1 -1
  179. package/dist/node-dev/ShopifyProvider.mjs +20 -15
  180. package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
  181. package/dist/node-dev/Video.js +31 -22
  182. package/dist/node-dev/Video.js.map +1 -1
  183. package/dist/node-dev/Video.mjs +30 -21
  184. package/dist/node-dev/Video.mjs.map +1 -1
  185. package/dist/node-dev/_virtual/index.js +11 -3
  186. package/dist/node-dev/_virtual/index.js.map +1 -1
  187. package/dist/node-dev/_virtual/index.mjs +11 -2
  188. package/dist/node-dev/_virtual/index.mjs.map +1 -1
  189. package/dist/node-dev/_virtual/use-sync-external-store-shim.development.js +1 -1
  190. package/dist/node-dev/_virtual/use-sync-external-store-shim.production.min.js +1 -1
  191. package/dist/node-dev/_virtual/with-selector.development.js +1 -1
  192. package/dist/node-dev/_virtual/with-selector.js +11 -3
  193. package/dist/node-dev/_virtual/with-selector.js.map +1 -1
  194. package/dist/node-dev/_virtual/with-selector.mjs +11 -2
  195. package/dist/node-dev/_virtual/with-selector.mjs.map +1 -1
  196. package/dist/node-dev/_virtual/with-selector.production.min.js +1 -1
  197. package/dist/node-dev/cart-constants.js +1 -1
  198. package/dist/node-dev/cart-hooks.js +32 -35
  199. package/dist/node-dev/cart-hooks.js.map +1 -1
  200. package/dist/node-dev/cart-hooks.mjs +31 -34
  201. package/dist/node-dev/cart-hooks.mjs.map +1 -1
  202. package/dist/node-dev/cart-queries.js +51 -21
  203. package/dist/node-dev/cart-queries.js.map +1 -1
  204. package/dist/node-dev/cart-queries.mjs +50 -20
  205. package/dist/node-dev/cart-queries.mjs.map +1 -1
  206. package/dist/node-dev/codegen.helpers.js +2 -1
  207. package/dist/node-dev/codegen.helpers.js.map +1 -1
  208. package/dist/node-dev/codegen.helpers.mjs +1 -0
  209. package/dist/node-dev/codegen.helpers.mjs.map +1 -1
  210. package/dist/node-dev/flatten-connection.js +1 -1
  211. package/dist/node-dev/image-size.js +9 -9
  212. package/dist/node-dev/image-size.js.map +1 -1
  213. package/dist/node-dev/image-size.mjs +8 -8
  214. package/dist/node-dev/image-size.mjs.map +1 -1
  215. package/dist/node-dev/index.js +1 -1
  216. package/dist/node-dev/load-script.js +1 -1
  217. package/dist/node-dev/load-script.js.map +1 -1
  218. package/dist/node-dev/load-script.mjs.map +1 -1
  219. package/dist/node-dev/node_modules/@xstate/fsm/es/index.js +1 -1
  220. package/dist/node-dev/node_modules/@xstate/fsm/es/index.js.map +1 -1
  221. package/dist/node-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  222. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +2 -2
  223. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
  224. package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs +2 -2
  225. package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  226. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js +2 -4
  227. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  228. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +2 -4
  229. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  230. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
  231. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -4
  232. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  233. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  234. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +2 -4
  235. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  236. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
  237. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -4
  238. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  239. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
  240. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.js +4 -4
  241. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs +3 -3
  242. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
  243. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  244. package/dist/node-dev/parse-metafield.js +5 -6
  245. package/dist/node-dev/parse-metafield.js.map +1 -1
  246. package/dist/node-dev/parse-metafield.mjs +4 -5
  247. package/dist/node-dev/parse-metafield.mjs.map +1 -1
  248. package/dist/node-dev/storefront-api-constants.js +1 -1
  249. package/dist/node-dev/storefront-client.js +9 -11
  250. package/dist/node-dev/storefront-client.js.map +1 -1
  251. package/dist/node-dev/storefront-client.mjs +8 -10
  252. package/dist/node-dev/storefront-client.mjs.map +1 -1
  253. package/dist/node-dev/useCartAPIStateMachine.js +112 -81
  254. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
  255. package/dist/node-dev/useCartAPIStateMachine.mjs +111 -80
  256. package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
  257. package/dist/node-dev/useCartActions.js +151 -110
  258. package/dist/node-dev/useCartActions.js.map +1 -1
  259. package/dist/node-dev/useCartActions.mjs +150 -109
  260. package/dist/node-dev/useCartActions.mjs.map +1 -1
  261. package/dist/node-dev/useMoney.js +62 -37
  262. package/dist/node-dev/useMoney.js.map +1 -1
  263. package/dist/node-dev/useMoney.mjs +61 -36
  264. package/dist/node-dev/useMoney.mjs.map +1 -1
  265. package/dist/node-prod/AddToCartButton.js +44 -41
  266. package/dist/node-prod/AddToCartButton.js.map +1 -1
  267. package/dist/node-prod/AddToCartButton.mjs +43 -40
  268. package/dist/node-prod/AddToCartButton.mjs.map +1 -1
  269. package/dist/node-prod/BaseButton.js +14 -16
  270. package/dist/node-prod/BaseButton.js.map +1 -1
  271. package/dist/node-prod/BaseButton.mjs +13 -15
  272. package/dist/node-prod/BaseButton.mjs.map +1 -1
  273. package/dist/node-prod/BuyNowButton.js +20 -18
  274. package/dist/node-prod/BuyNowButton.js.map +1 -1
  275. package/dist/node-prod/BuyNowButton.mjs +19 -17
  276. package/dist/node-prod/BuyNowButton.mjs.map +1 -1
  277. package/dist/node-prod/CartCheckoutButton.js +13 -16
  278. package/dist/node-prod/CartCheckoutButton.js.map +1 -1
  279. package/dist/node-prod/CartCheckoutButton.mjs +12 -15
  280. package/dist/node-prod/CartCheckoutButton.mjs.map +1 -1
  281. package/dist/node-prod/CartProvider.js +74 -68
  282. package/dist/node-prod/CartProvider.js.map +1 -1
  283. package/dist/node-prod/CartProvider.mjs +73 -67
  284. package/dist/node-prod/CartProvider.mjs.map +1 -1
  285. package/dist/node-prod/ExternalVideo.js +14 -12
  286. package/dist/node-prod/ExternalVideo.js.map +1 -1
  287. package/dist/node-prod/ExternalVideo.mjs +13 -11
  288. package/dist/node-prod/ExternalVideo.mjs.map +1 -1
  289. package/dist/node-prod/Image.js +36 -29
  290. package/dist/node-prod/Image.js.map +1 -1
  291. package/dist/node-prod/Image.mjs +35 -28
  292. package/dist/node-prod/Image.mjs.map +1 -1
  293. package/dist/node-prod/MediaFile.js +30 -22
  294. package/dist/node-prod/MediaFile.js.map +1 -1
  295. package/dist/node-prod/MediaFile.mjs +29 -21
  296. package/dist/node-prod/MediaFile.mjs.map +1 -1
  297. package/dist/node-prod/ModelViewer.js +136 -76
  298. package/dist/node-prod/ModelViewer.js.map +1 -1
  299. package/dist/node-prod/ModelViewer.mjs +135 -75
  300. package/dist/node-prod/ModelViewer.mjs.map +1 -1
  301. package/dist/node-prod/Money.js +13 -10
  302. package/dist/node-prod/Money.js.map +1 -1
  303. package/dist/node-prod/Money.mjs +12 -9
  304. package/dist/node-prod/Money.mjs.map +1 -1
  305. package/dist/node-prod/ProductPrice.js +13 -18
  306. package/dist/node-prod/ProductPrice.js.map +1 -1
  307. package/dist/node-prod/ProductPrice.mjs +12 -17
  308. package/dist/node-prod/ProductPrice.mjs.map +1 -1
  309. package/dist/node-prod/ProductProvider.js +103 -74
  310. package/dist/node-prod/ProductProvider.js.map +1 -1
  311. package/dist/node-prod/ProductProvider.mjs +102 -73
  312. package/dist/node-prod/ProductProvider.mjs.map +1 -1
  313. package/dist/node-prod/ShopPayButton.js +5 -15
  314. package/dist/node-prod/ShopPayButton.js.map +1 -1
  315. package/dist/node-prod/ShopPayButton.mjs +4 -14
  316. package/dist/node-prod/ShopPayButton.mjs.map +1 -1
  317. package/dist/node-prod/ShopifyProvider.js +18 -15
  318. package/dist/node-prod/ShopifyProvider.js.map +1 -1
  319. package/dist/node-prod/ShopifyProvider.mjs +17 -14
  320. package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
  321. package/dist/node-prod/Video.js +31 -22
  322. package/dist/node-prod/Video.js.map +1 -1
  323. package/dist/node-prod/Video.mjs +30 -21
  324. package/dist/node-prod/Video.mjs.map +1 -1
  325. package/dist/node-prod/_virtual/index.js +11 -3
  326. package/dist/node-prod/_virtual/index.js.map +1 -1
  327. package/dist/node-prod/_virtual/index.mjs +11 -2
  328. package/dist/node-prod/_virtual/index.mjs.map +1 -1
  329. package/dist/node-prod/_virtual/use-sync-external-store-shim.development.js +1 -1
  330. package/dist/node-prod/_virtual/use-sync-external-store-shim.production.min.js +1 -1
  331. package/dist/node-prod/_virtual/with-selector.development.js +1 -1
  332. package/dist/node-prod/_virtual/with-selector.js +11 -3
  333. package/dist/node-prod/_virtual/with-selector.js.map +1 -1
  334. package/dist/node-prod/_virtual/with-selector.mjs +11 -2
  335. package/dist/node-prod/_virtual/with-selector.mjs.map +1 -1
  336. package/dist/node-prod/_virtual/with-selector.production.min.js +1 -1
  337. package/dist/node-prod/cart-constants.js +1 -1
  338. package/dist/node-prod/cart-hooks.js +32 -35
  339. package/dist/node-prod/cart-hooks.js.map +1 -1
  340. package/dist/node-prod/cart-hooks.mjs +31 -34
  341. package/dist/node-prod/cart-hooks.mjs.map +1 -1
  342. package/dist/node-prod/cart-queries.js +51 -21
  343. package/dist/node-prod/cart-queries.js.map +1 -1
  344. package/dist/node-prod/cart-queries.mjs +50 -20
  345. package/dist/node-prod/cart-queries.mjs.map +1 -1
  346. package/dist/node-prod/codegen.helpers.js +2 -1
  347. package/dist/node-prod/codegen.helpers.js.map +1 -1
  348. package/dist/node-prod/codegen.helpers.mjs +1 -0
  349. package/dist/node-prod/codegen.helpers.mjs.map +1 -1
  350. package/dist/node-prod/flatten-connection.js +1 -1
  351. package/dist/node-prod/image-size.js +9 -9
  352. package/dist/node-prod/image-size.js.map +1 -1
  353. package/dist/node-prod/image-size.mjs +8 -8
  354. package/dist/node-prod/image-size.mjs.map +1 -1
  355. package/dist/node-prod/index.js +1 -1
  356. package/dist/node-prod/load-script.js +1 -1
  357. package/dist/node-prod/load-script.js.map +1 -1
  358. package/dist/node-prod/load-script.mjs.map +1 -1
  359. package/dist/node-prod/node_modules/@xstate/fsm/es/index.js +1 -1
  360. package/dist/node-prod/node_modules/@xstate/fsm/es/index.js.map +1 -1
  361. package/dist/node-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  362. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +2 -2
  363. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
  364. package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs +2 -2
  365. package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  366. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js +2 -4
  367. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  368. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +2 -4
  369. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  370. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
  371. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -4
  372. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  373. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  374. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +2 -4
  375. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  376. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
  377. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -4
  378. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  379. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
  380. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.js +4 -4
  381. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs +3 -3
  382. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
  383. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  384. package/dist/node-prod/parse-metafield.js +5 -6
  385. package/dist/node-prod/parse-metafield.js.map +1 -1
  386. package/dist/node-prod/parse-metafield.mjs +4 -5
  387. package/dist/node-prod/parse-metafield.mjs.map +1 -1
  388. package/dist/node-prod/storefront-api-constants.js +1 -1
  389. package/dist/node-prod/storefront-client.js +9 -11
  390. package/dist/node-prod/storefront-client.js.map +1 -1
  391. package/dist/node-prod/storefront-client.mjs +8 -10
  392. package/dist/node-prod/storefront-client.mjs.map +1 -1
  393. package/dist/node-prod/useCartAPIStateMachine.js +112 -81
  394. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
  395. package/dist/node-prod/useCartAPIStateMachine.mjs +111 -80
  396. package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
  397. package/dist/node-prod/useCartActions.js +151 -110
  398. package/dist/node-prod/useCartActions.js.map +1 -1
  399. package/dist/node-prod/useCartActions.mjs +150 -109
  400. package/dist/node-prod/useCartActions.mjs.map +1 -1
  401. package/dist/node-prod/useMoney.js +62 -37
  402. package/dist/node-prod/useMoney.js.map +1 -1
  403. package/dist/node-prod/useMoney.mjs +61 -36
  404. package/dist/node-prod/useMoney.mjs.map +1 -1
  405. package/dist/types/parse-metafield.d.ts +1 -1
  406. package/dist/umd/hydrogen-react.dev.js +994 -880
  407. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  408. package/dist/umd/hydrogen-react.prod.js +16 -16
  409. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  410. package/package.json +13 -13
@@ -2,10 +2,7 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.hydrogenreact = {}, global.React));
3
3
  })(this, function(exports2, React) {
4
4
  "use strict";
5
- const _interopDefaultLegacy = (e2) => e2 && typeof e2 === "object" && "default" in e2 ? e2 : { default: e2 };
6
- function _interopNamespace(e2) {
7
- if (e2 && e2.__esModule)
8
- return e2;
5
+ function _interopNamespaceDefault(e2) {
9
6
  const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
7
  if (e2) {
11
8
  for (const k in e2) {
@@ -21,8 +18,7 @@
21
18
  n2.default = e2;
22
19
  return Object.freeze(n2);
23
20
  }
24
- const React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
25
- const React__namespace = /* @__PURE__ */ _interopNamespace(React);
21
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
26
22
  /*! *****************************************************************************
27
23
  Copyright (c) Microsoft Corporation.
28
24
 
@@ -176,9 +172,25 @@
176
172
  return c2;
177
173
  }
178
174
  var index = React.useLayoutEffect;
179
- var withSelector = { exports: {} };
175
+ var withSelectorExports = {};
176
+ var withSelector = {
177
+ get exports() {
178
+ return withSelectorExports;
179
+ },
180
+ set exports(v2) {
181
+ withSelectorExports = v2;
182
+ }
183
+ };
180
184
  var withSelector_production_min = {};
181
- var shim = { exports: {} };
185
+ var shimExports = {};
186
+ var shim = {
187
+ get exports() {
188
+ return shimExports;
189
+ },
190
+ set exports(v2) {
191
+ shimExports = v2;
192
+ }
193
+ };
182
194
  var useSyncExternalStoreShim_production_min = {};
183
195
  /**
184
196
  * @license React
@@ -194,7 +206,7 @@
194
206
  if (hasRequiredUseSyncExternalStoreShim_production_min)
195
207
  return useSyncExternalStoreShim_production_min;
196
208
  hasRequiredUseSyncExternalStoreShim_production_min = 1;
197
- var e2 = React__default.default;
209
+ var e2 = React;
198
210
  function h(a2, b) {
199
211
  return a2 === b && (0 !== a2 || 1 / a2 === 1 / b) || a2 !== a2 && b !== b;
200
212
  }
@@ -252,8 +264,8 @@
252
264
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
253
265
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
254
266
  }
255
- var React2 = React__default.default;
256
- var ReactSharedInternals = React2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
267
+ var React$1 = React;
268
+ var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
257
269
  function error(format) {
258
270
  {
259
271
  {
@@ -283,13 +295,13 @@
283
295
  return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
284
296
  }
285
297
  var objectIs = typeof Object.is === "function" ? Object.is : is;
286
- var useState = React2.useState, useEffect = React2.useEffect, useLayoutEffect = React2.useLayoutEffect, useDebugValue = React2.useDebugValue;
298
+ var useState = React$1.useState, useEffect = React$1.useEffect, useLayoutEffect = React$1.useLayoutEffect, useDebugValue = React$1.useDebugValue;
287
299
  var didWarnOld18Alpha = false;
288
300
  var didWarnUncachedGetSnapshot = false;
289
301
  function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
290
302
  {
291
303
  if (!didWarnOld18Alpha) {
292
- if (React2.startTransition !== void 0) {
304
+ if (React$1.startTransition !== void 0) {
293
305
  didWarnOld18Alpha = true;
294
306
  error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
295
307
  }
@@ -354,7 +366,7 @@
354
366
  var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
355
367
  var isServerEnvironment = !canUseDOM;
356
368
  var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
357
- var useSyncExternalStore$2 = React2.useSyncExternalStore !== void 0 ? React2.useSyncExternalStore : shim2;
369
+ var useSyncExternalStore$2 = React$1.useSyncExternalStore !== void 0 ? React$1.useSyncExternalStore : shim2;
358
370
  useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
359
371
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
360
372
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
@@ -366,7 +378,7 @@
366
378
  var hasRequiredShim;
367
379
  function requireShim() {
368
380
  if (hasRequiredShim)
369
- return shim.exports;
381
+ return shimExports;
370
382
  hasRequiredShim = 1;
371
383
  (function(module2) {
372
384
  if (process.env.NODE_ENV === "production") {
@@ -375,7 +387,7 @@
375
387
  module2.exports = requireUseSyncExternalStoreShim_development();
376
388
  }
377
389
  })(shim);
378
- return shim.exports;
390
+ return shimExports;
379
391
  }
380
392
  /**
381
393
  * @license React
@@ -391,7 +403,7 @@
391
403
  if (hasRequiredWithSelector_production_min)
392
404
  return withSelector_production_min;
393
405
  hasRequiredWithSelector_production_min = 1;
394
- var h = React__default.default, n2 = requireShim();
406
+ var h = React, n2 = requireShim();
395
407
  function p(a2, b) {
396
408
  return a2 === b && (0 !== a2 || 1 / a2 === 1 / b) || a2 !== a2 && b !== b;
397
409
  }
@@ -462,14 +474,14 @@
462
474
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
463
475
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
464
476
  }
465
- var React2 = React__default.default;
477
+ var React$1 = React;
466
478
  var shim2 = requireShim();
467
479
  function is(x, y) {
468
480
  return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
469
481
  }
470
482
  var objectIs = typeof Object.is === "function" ? Object.is : is;
471
483
  var useSyncExternalStore = shim2.useSyncExternalStore;
472
- var useRef = React2.useRef, useEffect = React2.useEffect, useMemo = React2.useMemo, useDebugValue = React2.useDebugValue;
484
+ var useRef = React$1.useRef, useEffect = React$1.useEffect, useMemo = React$1.useMemo, useDebugValue = React$1.useDebugValue;
473
485
  function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual2) {
474
486
  var instRef = useRef(null);
475
487
  var inst;
@@ -635,7 +647,7 @@
635
647
  var unsubscribe = service.subscribe(handleStoreChange).unsubscribe;
636
648
  return unsubscribe;
637
649
  }, [service]);
638
- var storeSnapshot = withSelector.exports.useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, identity, isEqual);
650
+ var storeSnapshot = withSelectorExports.useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, identity, isEqual);
639
651
  return [storeSnapshot, service.send, service];
640
652
  }
641
653
  function flattenConnection(connection) {
@@ -665,7 +677,9 @@
665
677
  }
666
678
  return [];
667
679
  }
668
- const CartLineAdd = (cartFragment) => `
680
+ const CartLineAdd = (cartFragment) => (
681
+ /* GraphQL */
682
+ `
669
683
  mutation CartLineAdd(
670
684
  $cartId: ID!
671
685
  $lines: [CartLineInput!]!
@@ -680,8 +694,11 @@
680
694
  }
681
695
 
682
696
  ${cartFragment}
683
- `;
684
- const CartCreate = (cartFragment) => `
697
+ `
698
+ );
699
+ const CartCreate = (cartFragment) => (
700
+ /* GraphQL */
701
+ `
685
702
  mutation CartCreate(
686
703
  $input: CartInput!
687
704
  $numCartLines: Int = 250
@@ -695,8 +712,11 @@
695
712
  }
696
713
 
697
714
  ${cartFragment}
698
- `;
699
- const CartLineRemove = (cartFragment) => `
715
+ `
716
+ );
717
+ const CartLineRemove = (cartFragment) => (
718
+ /* GraphQL */
719
+ `
700
720
  mutation CartLineRemove(
701
721
  $cartId: ID!
702
722
  $lines: [ID!]!
@@ -711,8 +731,11 @@
711
731
  }
712
732
 
713
733
  ${cartFragment}
714
- `;
715
- const CartLineUpdate = (cartFragment) => `
734
+ `
735
+ );
736
+ const CartLineUpdate = (cartFragment) => (
737
+ /* GraphQL */
738
+ `
716
739
  mutation CartLineUpdate(
717
740
  $cartId: ID!
718
741
  $lines: [CartLineUpdateInput!]!
@@ -727,8 +750,11 @@
727
750
  }
728
751
 
729
752
  ${cartFragment}
730
- `;
731
- const CartNoteUpdate = (cartFragment) => `
753
+ `
754
+ );
755
+ const CartNoteUpdate = (cartFragment) => (
756
+ /* GraphQL */
757
+ `
732
758
  mutation CartNoteUpdate(
733
759
  $cartId: ID!
734
760
  $note: String
@@ -743,8 +769,11 @@
743
769
  }
744
770
 
745
771
  ${cartFragment}
746
- `;
747
- const CartBuyerIdentityUpdate = (cartFragment) => `
772
+ `
773
+ );
774
+ const CartBuyerIdentityUpdate = (cartFragment) => (
775
+ /* GraphQL */
776
+ `
748
777
  mutation CartBuyerIdentityUpdate(
749
778
  $cartId: ID!
750
779
  $buyerIdentity: CartBuyerIdentityInput!
@@ -759,8 +788,11 @@
759
788
  }
760
789
 
761
790
  ${cartFragment}
762
- `;
763
- const CartAttributesUpdate = (cartFragment) => `
791
+ `
792
+ );
793
+ const CartAttributesUpdate = (cartFragment) => (
794
+ /* GraphQL */
795
+ `
764
796
  mutation CartAttributesUpdate(
765
797
  $attributes: [AttributeInput!]!
766
798
  $cartId: ID!
@@ -775,8 +807,11 @@
775
807
  }
776
808
 
777
809
  ${cartFragment}
778
- `;
779
- const CartDiscountCodesUpdate = (cartFragment) => `
810
+ `
811
+ );
812
+ const CartDiscountCodesUpdate = (cartFragment) => (
813
+ /* GraphQL */
814
+ `
780
815
  mutation CartDiscountCodesUpdate(
781
816
  $cartId: ID!
782
817
  $discountCodes: [String!]
@@ -791,8 +826,11 @@
791
826
  }
792
827
 
793
828
  ${cartFragment}
794
- `;
795
- const CartQuery = (cartFragment) => `
829
+ `
830
+ );
831
+ const CartQuery = (cartFragment) => (
832
+ /* GraphQL */
833
+ `
796
834
  query CartQuery(
797
835
  $id: ID!
798
836
  $numCartLines: Int = 250
@@ -804,8 +842,11 @@
804
842
  }
805
843
 
806
844
  ${cartFragment}
807
- `;
808
- const defaultCartFragment = `
845
+ `
846
+ );
847
+ const defaultCartFragment = (
848
+ /* GraphQL */
849
+ `
809
850
  fragment CartFragment on Cart {
810
851
  id
811
852
  checkoutUrl
@@ -905,7 +946,8 @@
905
946
  width
906
947
  height
907
948
  }
908
- `;
949
+ `
950
+ );
909
951
  const SFAPI_VERSION = "2023-01";
910
952
  const warnings = /* @__PURE__ */ new Set();
911
953
  const warnOnce = (string) => {
@@ -938,15 +980,12 @@
938
980
  }
939
981
  return {
940
982
  getShopifyDomain(overrideProps) {
941
- var _a;
942
- return `https://${(_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain}.myshopify.com`;
983
+ return `https://${(overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain}.myshopify.com`;
943
984
  },
944
985
  getStorefrontApiUrl(overrideProps) {
945
- var _a, _b;
946
- return `https://${(_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain}.myshopify.com/api/${(_b = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _b : storefrontApiVersion}/graphql.json`;
986
+ return `https://${(overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain}.myshopify.com/api/${(overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) ?? storefrontApiVersion}/graphql.json`;
947
987
  },
948
988
  getPrivateTokenHeaders(overrideProps) {
949
- var _a, _b, _c;
950
989
  if (!privateStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.privateStorefrontToken)) {
951
990
  throw new Error(
952
991
  `StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`
@@ -957,34 +996,35 @@
957
996
  `StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`
958
997
  );
959
998
  }
960
- const finalContentType = (_a = overrideProps == null ? void 0 : overrideProps.contentType) != null ? _a : contentType;
999
+ const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType;
961
1000
  return {
1001
+ // default to json
962
1002
  "content-type": finalContentType === "graphql" ? "application/graphql" : "application/json",
963
1003
  "X-SDK-Variant": "hydrogen-ui",
964
1004
  "X-SDK-Variant-Source": "react",
965
1005
  "X-SDK-Version": storefrontApiVersion,
966
- "Shopify-Storefront-Private-Token": (_c = (_b = overrideProps == null ? void 0 : overrideProps.privateStorefrontToken) != null ? _b : privateStorefrontToken) != null ? _c : "",
1006
+ "Shopify-Storefront-Private-Token": (overrideProps == null ? void 0 : overrideProps.privateStorefrontToken) ?? privateStorefrontToken ?? "",
967
1007
  ...(overrideProps == null ? void 0 : overrideProps.buyerIp) ? { "Shopify-Storefront-Buyer-IP": overrideProps.buyerIp } : {}
968
1008
  };
969
1009
  },
970
1010
  getPublicTokenHeaders(overrideProps) {
971
- var _a, _b, _c, _d;
972
1011
  if (!publicStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken)) {
973
1012
  throw new Error(
974
1013
  `StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`
975
1014
  );
976
1015
  }
977
- const finalContentType = (_b = (_a = overrideProps == null ? void 0 : overrideProps.contentType) != null ? _a : contentType) != null ? _b : "json";
1016
+ const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType ?? "json";
978
1017
  return getPublicTokenHeadersRaw(
979
1018
  finalContentType,
980
1019
  storefrontApiVersion,
981
- (_d = (_c = overrideProps == null ? void 0 : overrideProps.publicStorefrontToken) != null ? _c : publicStorefrontToken) != null ? _d : ""
1020
+ (overrideProps == null ? void 0 : overrideProps.publicStorefrontToken) ?? publicStorefrontToken ?? ""
982
1021
  );
983
1022
  }
984
1023
  };
985
1024
  }
986
1025
  function getPublicTokenHeadersRaw(contentType, storefrontApiVersion, accessToken) {
987
1026
  return {
1027
+ // default to json
988
1028
  "content-type": contentType === "graphql" ? "application/graphql" : "application/json",
989
1029
  "X-SDK-Variant": "hydrogen-ui",
990
1030
  "X-SDK-Variant-Source": "react",
@@ -992,7 +1032,6 @@
992
1032
  "X-Shopify-Storefront-Access-Token": accessToken
993
1033
  };
994
1034
  }
995
- var _jsxFileName$e = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";
996
1035
  const ShopifyContext = React.createContext({
997
1036
  storeDomain: "test",
998
1037
  storefrontToken: "abc123",
@@ -1019,45 +1058,45 @@
1019
1058
  shopifyConfig
1020
1059
  }) {
1021
1060
  if (!shopifyConfig) {
1022
- throw new Error(`The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`);
1061
+ throw new Error(
1062
+ `The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`
1063
+ );
1023
1064
  }
1024
1065
  if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {
1025
- console.warn(`<ShopifyProvider/>: This version of Hydrogen-UI is built for Shopify's Storefront API version ${SFAPI_VERSION}, but it looks like you're using version ${shopifyConfig.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen-UI and the Storefront API.`);
1066
+ console.warn(
1067
+ `<ShopifyProvider/>: This version of Hydrogen-UI is built for Shopify's Storefront API version ${SFAPI_VERSION}, but it looks like you're using version ${shopifyConfig.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen-UI and the Storefront API.`
1068
+ );
1026
1069
  }
1027
1070
  const finalConfig = React.useMemo(() => {
1028
1071
  function getShopifyDomain(overrideProps) {
1029
- var _a;
1030
- return (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : shopifyConfig.storeDomain;
1072
+ return (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? shopifyConfig.storeDomain;
1031
1073
  }
1032
1074
  return {
1033
1075
  ...shopifyConfig,
1034
1076
  getPublicTokenHeaders(overrideProps) {
1035
- var _a;
1036
- return getPublicTokenHeadersRaw(overrideProps.contentType, shopifyConfig.storefrontApiVersion, (_a = overrideProps.storefrontToken) != null ? _a : shopifyConfig.storefrontToken);
1077
+ return getPublicTokenHeadersRaw(
1078
+ overrideProps.contentType,
1079
+ shopifyConfig.storefrontApiVersion,
1080
+ overrideProps.storefrontToken ?? shopifyConfig.storefrontToken
1081
+ );
1037
1082
  },
1038
1083
  getShopifyDomain,
1039
1084
  getStorefrontApiUrl(overrideProps) {
1040
- var _a, _b, _c;
1085
+ var _a;
1041
1086
  if ((_a = overrideProps == null ? void 0 : overrideProps.storeDomain) == null ? void 0 : _a.includes(".myshopify.com")) {
1042
1087
  {
1043
- console.warn(`<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`);
1088
+ console.warn(
1089
+ `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`
1090
+ );
1044
1091
  }
1045
1092
  }
1046
1093
  return `${getShopifyDomain({
1047
- storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : shopifyConfig.storeDomain
1048
- })}/api/${(_c = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _c : shopifyConfig.storefrontApiVersion}/graphql.json`;
1094
+ storeDomain: (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? shopifyConfig.storeDomain
1095
+ })}/api/${(overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) ?? shopifyConfig.storefrontApiVersion}/graphql.json`;
1049
1096
  }
1050
1097
  };
1051
1098
  }, [shopifyConfig]);
1052
- return /* @__PURE__ */ React__default.default.createElement(ShopifyContext.Provider, {
1053
- value: finalConfig,
1054
- __self: this,
1055
- __source: {
1056
- fileName: _jsxFileName$e,
1057
- lineNumber: 84,
1058
- columnNumber: 5
1059
- }
1060
- }, children);
1099
+ return /* @__PURE__ */ React.createElement(ShopifyContext.Provider, { value: finalConfig }, children);
1061
1100
  }
1062
1101
  function useShop() {
1063
1102
  const shopContext = React.useContext(ShopifyContext);
@@ -1096,40 +1135,37 @@
1096
1135
  return r2;
1097
1136
  }
1098
1137
  function useCartFetch() {
1099
- const {
1100
- storefrontId,
1101
- getPublicTokenHeaders,
1102
- getStorefrontApiUrl
1103
- } = useShop();
1104
- return React.useCallback(({
1105
- query,
1106
- variables
1107
- }) => {
1108
- const headers = getPublicTokenHeaders({
1109
- contentType: "json"
1110
- });
1111
- if (storefrontId) {
1112
- headers[SHOPIFY_STOREFRONT_ID_HEADER] = storefrontId;
1113
- }
1114
- const cookieData = u(document.cookie);
1115
- if (cookieData[SHOPIFY_Y] && cookieData[SHOPIFY_S]) {
1116
- headers[SHOPIFY_STOREFRONT_Y_HEADER] = cookieData[SHOPIFY_Y];
1117
- headers[SHOPIFY_STOREFRONT_S_HEADER] = cookieData[SHOPIFY_S];
1118
- }
1119
- return fetch(getStorefrontApiUrl(), {
1120
- method: "POST",
1121
- headers,
1122
- body: JSON.stringify({
1123
- query: query.toString(),
1124
- variables
1125
- })
1126
- }).then((res) => res.json()).catch((error) => {
1127
- return {
1128
- data: void 0,
1129
- errors: error.toString()
1130
- };
1131
- });
1132
- }, [getPublicTokenHeaders, storefrontId, getStorefrontApiUrl]);
1138
+ const { storefrontId, getPublicTokenHeaders, getStorefrontApiUrl } = useShop();
1139
+ return React.useCallback(
1140
+ ({
1141
+ query,
1142
+ variables
1143
+ }) => {
1144
+ const headers = getPublicTokenHeaders({ contentType: "json" });
1145
+ if (storefrontId) {
1146
+ headers[SHOPIFY_STOREFRONT_ID_HEADER] = storefrontId;
1147
+ }
1148
+ const cookieData = u(document.cookie);
1149
+ if (cookieData[SHOPIFY_Y] && cookieData[SHOPIFY_S]) {
1150
+ headers[SHOPIFY_STOREFRONT_Y_HEADER] = cookieData[SHOPIFY_Y];
1151
+ headers[SHOPIFY_STOREFRONT_S_HEADER] = cookieData[SHOPIFY_S];
1152
+ }
1153
+ return fetch(getStorefrontApiUrl(), {
1154
+ method: "POST",
1155
+ headers,
1156
+ body: JSON.stringify({
1157
+ query: query.toString(),
1158
+ variables
1159
+ })
1160
+ }).then((res) => res.json()).catch((error) => {
1161
+ return {
1162
+ data: void 0,
1163
+ errors: error.toString()
1164
+ };
1165
+ });
1166
+ },
1167
+ [getPublicTokenHeaders, storefrontId, getStorefrontApiUrl]
1168
+ );
1133
1169
  }
1134
1170
  function useCartActions({
1135
1171
  numCartLines,
@@ -1137,155 +1173,212 @@
1137
1173
  countryCode = "US"
1138
1174
  }) {
1139
1175
  const fetchCart = useCartFetch();
1140
- const cartFetch = React.useCallback((cartId) => {
1141
- return fetchCart({
1142
- query: CartQuery(cartFragment),
1143
- variables: {
1144
- id: cartId,
1145
- numCartLines,
1146
- country: countryCode
1147
- }
1148
- });
1149
- }, [fetchCart, cartFragment, numCartLines, countryCode]);
1150
- const cartCreate = React.useCallback((cart) => {
1151
- return fetchCart({
1152
- query: CartCreate(cartFragment),
1153
- variables: {
1154
- input: cart,
1155
- numCartLines,
1156
- country: countryCode
1157
- }
1158
- });
1159
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
1160
- const cartLineAdd = React.useCallback((cartId, lines) => {
1161
- return fetchCart({
1162
- query: CartLineAdd(cartFragment),
1163
- variables: {
1164
- cartId,
1165
- lines,
1166
- numCartLines,
1167
- country: countryCode
1168
- }
1169
- });
1170
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
1171
- const cartLineUpdate = React.useCallback((cartId, lines) => {
1172
- return fetchCart({
1173
- query: CartLineUpdate(cartFragment),
1174
- variables: {
1175
- cartId,
1176
- lines,
1177
- numCartLines,
1178
- country: countryCode
1179
- }
1180
- });
1181
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
1182
- const cartLineRemove = React.useCallback((cartId, lines) => {
1183
- return fetchCart({
1184
- query: CartLineRemove(cartFragment),
1185
- variables: {
1186
- cartId,
1187
- lines,
1188
- numCartLines,
1189
- country: countryCode
1190
- }
1191
- });
1192
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
1193
- const noteUpdate = React.useCallback((cartId, note) => {
1194
- return fetchCart({
1195
- query: CartNoteUpdate(cartFragment),
1196
- variables: {
1197
- cartId,
1198
- note,
1199
- numCartLines,
1200
- country: countryCode
1201
- }
1202
- });
1203
- }, [fetchCart, cartFragment, numCartLines, countryCode]);
1204
- const buyerIdentityUpdate = React.useCallback((cartId, buyerIdentity) => {
1205
- return fetchCart({
1206
- query: CartBuyerIdentityUpdate(cartFragment),
1207
- variables: {
1208
- cartId,
1209
- buyerIdentity,
1210
- numCartLines,
1211
- country: countryCode
1212
- }
1213
- });
1214
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
1215
- const cartAttributesUpdate = React.useCallback((cartId, attributes) => {
1216
- return fetchCart({
1217
- query: CartAttributesUpdate(cartFragment),
1218
- variables: {
1219
- cartId,
1220
- attributes,
1221
- numCartLines,
1222
- country: countryCode
1223
- }
1224
- });
1225
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
1226
- const discountCodesUpdate = React.useCallback((cartId, discountCodes) => {
1227
- return fetchCart({
1228
- query: CartDiscountCodesUpdate(cartFragment),
1229
- variables: {
1230
- cartId,
1231
- discountCodes,
1232
- numCartLines,
1233
- country: countryCode
1234
- }
1235
- });
1236
- }, [cartFragment, countryCode, fetchCart, numCartLines]);
1237
- return React.useMemo(() => ({
1238
- cartFetch,
1239
- cartCreate,
1240
- cartLineAdd,
1241
- cartLineUpdate,
1242
- cartLineRemove,
1243
- noteUpdate,
1244
- buyerIdentityUpdate,
1245
- cartAttributesUpdate,
1246
- discountCodesUpdate,
1247
- cartFragment
1248
- }), [cartFetch, cartCreate, cartLineAdd, cartLineUpdate, cartLineRemove, noteUpdate, buyerIdentityUpdate, cartAttributesUpdate, discountCodesUpdate, cartFragment]);
1176
+ const cartFetch = React.useCallback(
1177
+ (cartId) => {
1178
+ return fetchCart({
1179
+ query: CartQuery(cartFragment),
1180
+ variables: {
1181
+ id: cartId,
1182
+ numCartLines,
1183
+ country: countryCode
1184
+ }
1185
+ });
1186
+ },
1187
+ [fetchCart, cartFragment, numCartLines, countryCode]
1188
+ );
1189
+ const cartCreate = React.useCallback(
1190
+ (cart) => {
1191
+ return fetchCart({
1192
+ query: CartCreate(cartFragment),
1193
+ variables: {
1194
+ input: cart,
1195
+ numCartLines,
1196
+ country: countryCode
1197
+ }
1198
+ });
1199
+ },
1200
+ [cartFragment, countryCode, fetchCart, numCartLines]
1201
+ );
1202
+ const cartLineAdd = React.useCallback(
1203
+ (cartId, lines) => {
1204
+ return fetchCart({
1205
+ query: CartLineAdd(cartFragment),
1206
+ variables: {
1207
+ cartId,
1208
+ lines,
1209
+ numCartLines,
1210
+ country: countryCode
1211
+ }
1212
+ });
1213
+ },
1214
+ [cartFragment, countryCode, fetchCart, numCartLines]
1215
+ );
1216
+ const cartLineUpdate = React.useCallback(
1217
+ (cartId, lines) => {
1218
+ return fetchCart({
1219
+ query: CartLineUpdate(cartFragment),
1220
+ variables: {
1221
+ cartId,
1222
+ lines,
1223
+ numCartLines,
1224
+ country: countryCode
1225
+ }
1226
+ });
1227
+ },
1228
+ [cartFragment, countryCode, fetchCart, numCartLines]
1229
+ );
1230
+ const cartLineRemove = React.useCallback(
1231
+ (cartId, lines) => {
1232
+ return fetchCart({
1233
+ query: CartLineRemove(cartFragment),
1234
+ variables: {
1235
+ cartId,
1236
+ lines,
1237
+ numCartLines,
1238
+ country: countryCode
1239
+ }
1240
+ });
1241
+ },
1242
+ [cartFragment, countryCode, fetchCart, numCartLines]
1243
+ );
1244
+ const noteUpdate = React.useCallback(
1245
+ (cartId, note) => {
1246
+ return fetchCart({
1247
+ query: CartNoteUpdate(cartFragment),
1248
+ variables: {
1249
+ cartId,
1250
+ note,
1251
+ numCartLines,
1252
+ country: countryCode
1253
+ }
1254
+ });
1255
+ },
1256
+ [fetchCart, cartFragment, numCartLines, countryCode]
1257
+ );
1258
+ const buyerIdentityUpdate = React.useCallback(
1259
+ (cartId, buyerIdentity) => {
1260
+ return fetchCart({
1261
+ query: CartBuyerIdentityUpdate(cartFragment),
1262
+ variables: {
1263
+ cartId,
1264
+ buyerIdentity,
1265
+ numCartLines,
1266
+ country: countryCode
1267
+ }
1268
+ });
1269
+ },
1270
+ [cartFragment, countryCode, fetchCart, numCartLines]
1271
+ );
1272
+ const cartAttributesUpdate = React.useCallback(
1273
+ (cartId, attributes) => {
1274
+ return fetchCart({
1275
+ query: CartAttributesUpdate(cartFragment),
1276
+ variables: {
1277
+ cartId,
1278
+ attributes,
1279
+ numCartLines,
1280
+ country: countryCode
1281
+ }
1282
+ });
1283
+ },
1284
+ [cartFragment, countryCode, fetchCart, numCartLines]
1285
+ );
1286
+ const discountCodesUpdate = React.useCallback(
1287
+ (cartId, discountCodes) => {
1288
+ return fetchCart({
1289
+ query: CartDiscountCodesUpdate(cartFragment),
1290
+ variables: {
1291
+ cartId,
1292
+ discountCodes,
1293
+ numCartLines,
1294
+ country: countryCode
1295
+ }
1296
+ });
1297
+ },
1298
+ [cartFragment, countryCode, fetchCart, numCartLines]
1299
+ );
1300
+ return React.useMemo(
1301
+ () => ({
1302
+ cartFetch,
1303
+ cartCreate,
1304
+ cartLineAdd,
1305
+ cartLineUpdate,
1306
+ cartLineRemove,
1307
+ noteUpdate,
1308
+ buyerIdentityUpdate,
1309
+ cartAttributesUpdate,
1310
+ discountCodesUpdate,
1311
+ cartFragment
1312
+ }),
1313
+ [
1314
+ cartFetch,
1315
+ cartCreate,
1316
+ cartLineAdd,
1317
+ cartLineUpdate,
1318
+ cartLineRemove,
1319
+ noteUpdate,
1320
+ buyerIdentityUpdate,
1321
+ cartAttributesUpdate,
1322
+ discountCodesUpdate,
1323
+ cartFragment
1324
+ ]
1325
+ );
1249
1326
  }
1250
1327
  function invokeCart(action, options) {
1251
1328
  return {
1252
- entry: [...(options == null ? void 0 : options.entryActions) || [], i({
1253
- lastValidCart: (context) => context == null ? void 0 : context.cart
1254
- }), "onCartActionEntry", "onCartActionOptimisticUI", action],
1329
+ entry: [
1330
+ ...(options == null ? void 0 : options.entryActions) || [],
1331
+ i({
1332
+ lastValidCart: (context) => context == null ? void 0 : context.cart
1333
+ }),
1334
+ "onCartActionEntry",
1335
+ "onCartActionOptimisticUI",
1336
+ action
1337
+ ],
1255
1338
  on: {
1256
1339
  RESOLVE: {
1257
1340
  target: (options == null ? void 0 : options.resolveTarget) || "idle",
1258
- actions: [i({
1259
- prevCart: (context) => context == null ? void 0 : context.lastValidCart,
1260
- cart: (_, event) => {
1261
- var _a;
1262
- return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cart;
1263
- },
1264
- rawCartResult: (_, event) => {
1265
- var _a;
1266
- return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.rawCartResult;
1267
- },
1268
- errors: (_) => void 0
1269
- })]
1341
+ actions: [
1342
+ i({
1343
+ prevCart: (context) => context == null ? void 0 : context.lastValidCart,
1344
+ cart: (_, event) => {
1345
+ var _a;
1346
+ return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cart;
1347
+ },
1348
+ rawCartResult: (_, event) => {
1349
+ var _a;
1350
+ return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.rawCartResult;
1351
+ },
1352
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1353
+ errors: (_) => void 0
1354
+ })
1355
+ ]
1270
1356
  },
1271
1357
  ERROR: {
1272
1358
  target: (options == null ? void 0 : options.errorTarget) || "error",
1273
- actions: [i({
1274
- prevCart: (context) => context == null ? void 0 : context.lastValidCart,
1275
- cart: (context) => context == null ? void 0 : context.lastValidCart,
1276
- errors: (_, event) => {
1277
- var _a;
1278
- return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.errors;
1279
- }
1280
- })]
1359
+ actions: [
1360
+ i({
1361
+ prevCart: (context) => context == null ? void 0 : context.lastValidCart,
1362
+ cart: (context) => context == null ? void 0 : context.lastValidCart,
1363
+ errors: (_, event) => {
1364
+ var _a;
1365
+ return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.errors;
1366
+ }
1367
+ })
1368
+ ]
1281
1369
  },
1282
1370
  CART_COMPLETED: {
1283
1371
  target: "cartCompleted",
1284
1372
  actions: i({
1373
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1285
1374
  prevCart: (_) => void 0,
1375
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1286
1376
  cart: (_) => void 0,
1377
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1287
1378
  lastValidCart: (_) => void 0,
1379
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1288
1380
  rawCartResult: (_) => void 0,
1381
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1289
1382
  errors: (_) => void 0
1290
1383
  })
1291
1384
  }
@@ -1302,10 +1395,12 @@
1302
1395
  },
1303
1396
  CART_SET: {
1304
1397
  target: "idle",
1305
- actions: [i({
1306
- rawCartResult: (_, event) => event.payload.cart,
1307
- cart: (_, event) => cartFromGraphQL(event.payload.cart)
1308
- })]
1398
+ actions: [
1399
+ i({
1400
+ rawCartResult: (_, event) => event.payload.cart,
1401
+ cart: (_, event) => cartFromGraphQL(event.payload.cart)
1402
+ })
1403
+ ]
1309
1404
  }
1310
1405
  };
1311
1406
  const UPDATING_CART_EVENTS = {
@@ -1349,16 +1444,10 @@
1349
1444
  on: INITIALIZING_CART_EVENTS
1350
1445
  },
1351
1446
  idle: {
1352
- on: {
1353
- ...INITIALIZING_CART_EVENTS,
1354
- ...UPDATING_CART_EVENTS
1355
- }
1447
+ on: { ...INITIALIZING_CART_EVENTS, ...UPDATING_CART_EVENTS }
1356
1448
  },
1357
1449
  error: {
1358
- on: {
1359
- ...INITIALIZING_CART_EVENTS,
1360
- ...UPDATING_CART_EVENTS
1361
- }
1450
+ on: { ...INITIALIZING_CART_EVENTS, ...UPDATING_CART_EVENTS }
1362
1451
  },
1363
1452
  cartFetching: invokeCart("cartFetchAction", {
1364
1453
  errorTarget: "initializationError"
@@ -1407,10 +1496,7 @@
1407
1496
  var _a;
1408
1497
  if (event.type !== "CART_FETCH")
1409
1498
  return;
1410
- const {
1411
- data,
1412
- errors
1413
- } = await cartFetch((_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cartId);
1499
+ const { data, errors } = await cartFetch((_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cartId);
1414
1500
  const resultEvent = eventFromFetchResult(event, data == null ? void 0 : data.cart, errors);
1415
1501
  send(resultEvent);
1416
1502
  },
@@ -1418,88 +1504,117 @@
1418
1504
  var _a;
1419
1505
  if (event.type !== "CART_CREATE")
1420
1506
  return;
1421
- const {
1422
- data,
1507
+ const { data, errors } = await cartCreate(event == null ? void 0 : event.payload);
1508
+ const resultEvent = eventFromFetchResult(
1509
+ event,
1510
+ (_a = data == null ? void 0 : data.cartCreate) == null ? void 0 : _a.cart,
1423
1511
  errors
1424
- } = await cartCreate(event == null ? void 0 : event.payload);
1425
- const resultEvent = eventFromFetchResult(event, (_a = data == null ? void 0 : data.cartCreate) == null ? void 0 : _a.cart, errors);
1512
+ );
1426
1513
  send(resultEvent);
1427
1514
  },
1428
1515
  cartLineAddAction: async (context, event) => {
1429
1516
  var _a, _b;
1430
1517
  if (event.type !== "CARTLINE_ADD" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
1431
1518
  return;
1432
- const {
1433
- data,
1519
+ const { data, errors } = await cartLineAdd(
1520
+ context.cart.id,
1521
+ event.payload.lines
1522
+ );
1523
+ const resultEvent = eventFromFetchResult(
1524
+ event,
1525
+ (_b = data == null ? void 0 : data.cartLinesAdd) == null ? void 0 : _b.cart,
1434
1526
  errors
1435
- } = await cartLineAdd(context.cart.id, event.payload.lines);
1436
- const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesAdd) == null ? void 0 : _b.cart, errors);
1527
+ );
1437
1528
  send(resultEvent);
1438
1529
  },
1439
1530
  cartLineUpdateAction: async (context, event) => {
1440
1531
  var _a, _b;
1441
1532
  if (event.type !== "CARTLINE_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
1442
1533
  return;
1443
- const {
1444
- data,
1534
+ const { data, errors } = await cartLineUpdate(
1535
+ context.cart.id,
1536
+ event.payload.lines
1537
+ );
1538
+ const resultEvent = eventFromFetchResult(
1539
+ event,
1540
+ (_b = data == null ? void 0 : data.cartLinesUpdate) == null ? void 0 : _b.cart,
1445
1541
  errors
1446
- } = await cartLineUpdate(context.cart.id, event.payload.lines);
1447
- const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesUpdate) == null ? void 0 : _b.cart, errors);
1542
+ );
1448
1543
  send(resultEvent);
1449
1544
  },
1450
1545
  cartLineRemoveAction: async (context, event) => {
1451
1546
  var _a, _b;
1452
1547
  if (event.type !== "CARTLINE_REMOVE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
1453
1548
  return;
1454
- const {
1455
- data,
1549
+ const { data, errors } = await cartLineRemove(
1550
+ context.cart.id,
1551
+ event.payload.lines
1552
+ );
1553
+ const resultEvent = eventFromFetchResult(
1554
+ event,
1555
+ (_b = data == null ? void 0 : data.cartLinesRemove) == null ? void 0 : _b.cart,
1456
1556
  errors
1457
- } = await cartLineRemove(context.cart.id, event.payload.lines);
1458
- const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesRemove) == null ? void 0 : _b.cart, errors);
1557
+ );
1459
1558
  send(resultEvent);
1460
1559
  },
1461
1560
  noteUpdateAction: async (context, event) => {
1462
1561
  var _a, _b;
1463
1562
  if (event.type !== "NOTE_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
1464
1563
  return;
1465
- const {
1466
- data,
1564
+ const { data, errors } = await noteUpdate(
1565
+ context.cart.id,
1566
+ event.payload.note
1567
+ );
1568
+ const resultEvent = eventFromFetchResult(
1569
+ event,
1570
+ (_b = data == null ? void 0 : data.cartNoteUpdate) == null ? void 0 : _b.cart,
1467
1571
  errors
1468
- } = await noteUpdate(context.cart.id, event.payload.note);
1469
- const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartNoteUpdate) == null ? void 0 : _b.cart, errors);
1572
+ );
1470
1573
  send(resultEvent);
1471
1574
  },
1472
1575
  buyerIdentityUpdateAction: async (context, event) => {
1473
1576
  var _a, _b;
1474
1577
  if (event.type !== "BUYER_IDENTITY_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
1475
1578
  return;
1476
- const {
1477
- data,
1579
+ const { data, errors } = await buyerIdentityUpdate(
1580
+ context.cart.id,
1581
+ event.payload.buyerIdentity
1582
+ );
1583
+ const resultEvent = eventFromFetchResult(
1584
+ event,
1585
+ (_b = data == null ? void 0 : data.cartBuyerIdentityUpdate) == null ? void 0 : _b.cart,
1478
1586
  errors
1479
- } = await buyerIdentityUpdate(context.cart.id, event.payload.buyerIdentity);
1480
- const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartBuyerIdentityUpdate) == null ? void 0 : _b.cart, errors);
1587
+ );
1481
1588
  send(resultEvent);
1482
1589
  },
1483
1590
  cartAttributesUpdateAction: async (context, event) => {
1484
1591
  var _a, _b;
1485
1592
  if (event.type !== "CART_ATTRIBUTES_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
1486
1593
  return;
1487
- const {
1488
- data,
1594
+ const { data, errors } = await cartAttributesUpdate(
1595
+ context.cart.id,
1596
+ event.payload.attributes
1597
+ );
1598
+ const resultEvent = eventFromFetchResult(
1599
+ event,
1600
+ (_b = data == null ? void 0 : data.cartAttributesUpdate) == null ? void 0 : _b.cart,
1489
1601
  errors
1490
- } = await cartAttributesUpdate(context.cart.id, event.payload.attributes);
1491
- const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartAttributesUpdate) == null ? void 0 : _b.cart, errors);
1602
+ );
1492
1603
  send(resultEvent);
1493
1604
  },
1494
1605
  discountCodesUpdateAction: async (context, event) => {
1495
1606
  var _a, _b;
1496
1607
  if (event.type !== "DISCOUNT_CODES_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
1497
1608
  return;
1498
- const {
1499
- data,
1609
+ const { data, errors } = await discountCodesUpdate(
1610
+ context.cart.id,
1611
+ event.payload.discountCodes
1612
+ );
1613
+ const resultEvent = eventFromFetchResult(
1614
+ event,
1615
+ (_b = data == null ? void 0 : data.cartDiscountCodesUpdate) == null ? void 0 : _b.cart,
1500
1616
  errors
1501
- } = await discountCodesUpdate(context.cart.id, event.payload.discountCodes);
1502
- const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartDiscountCodesUpdate) == null ? void 0 : _b.cart, errors);
1617
+ );
1503
1618
  send(resultEvent);
1504
1619
  },
1505
1620
  ...onCartActionEntry && {
@@ -1526,22 +1641,15 @@
1526
1641
  return React.useMemo(() => [state, send, service], [state, send, service]);
1527
1642
  }
1528
1643
  function cartFromGraphQL(cart) {
1529
- var _a;
1530
1644
  return {
1531
1645
  ...cart,
1532
1646
  lines: flattenConnection(cart == null ? void 0 : cart.lines),
1533
- note: (_a = cart.note) != null ? _a : void 0
1647
+ note: cart.note ?? void 0
1534
1648
  };
1535
1649
  }
1536
1650
  function eventFromFetchResult(cartActionEvent, cart, errors) {
1537
1651
  if (errors) {
1538
- return {
1539
- type: "ERROR",
1540
- payload: {
1541
- errors,
1542
- cartActionEvent
1543
- }
1544
- };
1652
+ return { type: "ERROR", payload: { errors, cartActionEvent } };
1545
1653
  }
1546
1654
  if (!cart) {
1547
1655
  return {
@@ -1566,7 +1674,6 @@
1566
1674
  function isCartFetchResultEvent(event) {
1567
1675
  return event.type === "RESOLVE" || event.type === "ERROR" || event.type === "CART_COMPLETED";
1568
1676
  }
1569
- var _jsxFileName$d = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartProvider.tsx";
1570
1677
  const CartContext = React.createContext(null);
1571
1678
  function useCart() {
1572
1679
  const context = React.useContext(CartContext);
@@ -1642,16 +1749,16 @@
1642
1749
  onCartActionOptimisticUI(context, event) {
1643
1750
  var _a2, _b2, _c2, _d2;
1644
1751
  if (!context.cart)
1645
- return {
1646
- ...context
1647
- };
1752
+ return { ...context };
1648
1753
  switch (event.type) {
1649
1754
  case "CARTLINE_REMOVE":
1650
1755
  return {
1651
1756
  ...context,
1652
1757
  cart: {
1653
1758
  ...context.cart,
1654
- lines: (_b2 = (_a2 = context == null ? void 0 : context.cart) == null ? void 0 : _a2.lines) == null ? void 0 : _b2.filter((line) => (line == null ? void 0 : line.id) && !event.payload.lines.includes(line == null ? void 0 : line.id))
1759
+ lines: (_b2 = (_a2 = context == null ? void 0 : context.cart) == null ? void 0 : _a2.lines) == null ? void 0 : _b2.filter(
1760
+ (line) => (line == null ? void 0 : line.id) && !event.payload.lines.includes(line == null ? void 0 : line.id)
1761
+ )
1655
1762
  }
1656
1763
  };
1657
1764
  case "CARTLINE_UPDATE":
@@ -1660,9 +1767,9 @@
1660
1767
  cart: {
1661
1768
  ...context.cart,
1662
1769
  lines: (_d2 = (_c2 = context == null ? void 0 : context.cart) == null ? void 0 : _c2.lines) == null ? void 0 : _d2.map((line) => {
1663
- const updatedLine = event.payload.lines.find(({
1664
- id
1665
- }) => id === (line == null ? void 0 : line.id));
1770
+ const updatedLine = event.payload.lines.find(
1771
+ ({ id }) => id === (line == null ? void 0 : line.id)
1772
+ );
1666
1773
  if (updatedLine && updatedLine.quantity) {
1667
1774
  return {
1668
1775
  ...line,
@@ -1674,9 +1781,7 @@
1674
1781
  }
1675
1782
  };
1676
1783
  }
1677
- return {
1678
- ...context
1679
- };
1784
+ return { ...context };
1680
1785
  },
1681
1786
  onCartActionComplete(context, event) {
1682
1787
  const cartActionEvent = event.payload.cartActionEvent;
@@ -1721,12 +1826,7 @@
1721
1826
  try {
1722
1827
  const cartId = window.localStorage.getItem(CART_ID_STORAGE_KEY);
1723
1828
  if (cartId) {
1724
- cartSend({
1725
- type: "CART_FETCH",
1726
- payload: {
1727
- cartId
1728
- }
1729
- });
1829
+ cartSend({ type: "CART_FETCH", payload: { cartId } });
1730
1830
  }
1731
1831
  } catch (error) {
1732
1832
  console.warn("error fetching cartId");
@@ -1741,25 +1841,32 @@
1741
1841
  return;
1742
1842
  cartSend({
1743
1843
  type: "BUYER_IDENTITY_UPDATE",
1744
- payload: {
1745
- buyerIdentity: {
1746
- countryCode,
1747
- customerAccessToken
1748
- }
1749
- }
1844
+ payload: { buyerIdentity: { countryCode, customerAccessToken } }
1750
1845
  });
1751
- }, [countryCode, customerAccessToken, countryChanged, customerOverridesCountryCode, cartSend]);
1752
- const onCartReadySend = React.useCallback((cartEvent) => {
1753
- if (!cartReady.current) {
1754
- return console.warn("Cart isn't ready yet");
1755
- }
1756
- cartSend(cartEvent);
1757
- }, [cartSend]);
1846
+ }, [
1847
+ countryCode,
1848
+ customerAccessToken,
1849
+ countryChanged,
1850
+ customerOverridesCountryCode,
1851
+ cartSend
1852
+ ]);
1853
+ const onCartReadySend = React.useCallback(
1854
+ (cartEvent) => {
1855
+ if (!cartReady.current) {
1856
+ return console.warn("Cart isn't ready yet");
1857
+ }
1858
+ cartSend(cartEvent);
1859
+ },
1860
+ [cartSend]
1861
+ );
1758
1862
  React.useEffect(() => {
1759
1863
  var _a2, _b2, _c2;
1760
1864
  if (((_b2 = (_a2 = cartState == null ? void 0 : cartState.context) == null ? void 0 : _a2.cart) == null ? void 0 : _b2.id) && storageAvailable("localStorage")) {
1761
1865
  try {
1762
- window.localStorage.setItem(CART_ID_STORAGE_KEY, (_c2 = cartState.context.cart) == null ? void 0 : _c2.id);
1866
+ window.localStorage.setItem(
1867
+ CART_ID_STORAGE_KEY,
1868
+ (_c2 = cartState.context.cart) == null ? void 0 : _c2.id
1869
+ );
1763
1870
  } catch (error) {
1764
1871
  console.warn("Failed to save cartId to localStorage", error);
1765
1872
  }
@@ -1774,50 +1881,46 @@
1774
1881
  }
1775
1882
  }
1776
1883
  }, [cartCompleted]);
1777
- const cartCreate = React.useCallback((cartInput) => {
1778
- var _a2, _b2;
1779
- if (countryCode && !((_a2 = cartInput.buyerIdentity) == null ? void 0 : _a2.countryCode)) {
1780
- if (cartInput.buyerIdentity == null) {
1781
- cartInput.buyerIdentity = {};
1884
+ const cartCreate = React.useCallback(
1885
+ (cartInput) => {
1886
+ var _a2, _b2;
1887
+ if (countryCode && !((_a2 = cartInput.buyerIdentity) == null ? void 0 : _a2.countryCode)) {
1888
+ if (cartInput.buyerIdentity == null) {
1889
+ cartInput.buyerIdentity = {};
1890
+ }
1891
+ cartInput.buyerIdentity.countryCode = countryCode;
1782
1892
  }
1783
- cartInput.buyerIdentity.countryCode = countryCode;
1784
- }
1785
- if (customerAccessToken && !((_b2 = cartInput.buyerIdentity) == null ? void 0 : _b2.customerAccessToken)) {
1786
- if (cartInput.buyerIdentity == null) {
1787
- cartInput.buyerIdentity = {};
1893
+ if (customerAccessToken && !((_b2 = cartInput.buyerIdentity) == null ? void 0 : _b2.customerAccessToken)) {
1894
+ if (cartInput.buyerIdentity == null) {
1895
+ cartInput.buyerIdentity = {};
1896
+ }
1897
+ cartInput.buyerIdentity.customerAccessToken = customerAccessToken;
1788
1898
  }
1789
- cartInput.buyerIdentity.customerAccessToken = customerAccessToken;
1790
- }
1791
- onCartReadySend({
1792
- type: "CART_CREATE",
1793
- payload: cartInput
1794
- });
1795
- }, [countryCode, customerAccessToken, onCartReadySend]);
1899
+ onCartReadySend({
1900
+ type: "CART_CREATE",
1901
+ payload: cartInput
1902
+ });
1903
+ },
1904
+ [countryCode, customerAccessToken, onCartReadySend]
1905
+ );
1796
1906
  const cartDisplayState = useDelayedStateUntilHydration(cartState);
1797
1907
  const cartContextValue = React.useMemo(() => {
1798
- var _a2, _b2, _c2, _d2, _e2, _f2;
1908
+ var _a2, _b2, _c2, _d2;
1799
1909
  return {
1800
- ...(_b2 = (_a2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _a2.cart) != null ? _b2 : {
1801
- lines: [],
1802
- attributes: []
1803
- },
1910
+ ...((_a2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _a2.cart) ?? { lines: [], attributes: [] },
1804
1911
  status: transposeStatus(cartDisplayState.value),
1805
- error: (_c2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _c2.errors,
1806
- totalQuantity: (_f2 = (_e2 = (_d2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _d2.cart) == null ? void 0 : _e2.totalQuantity) != null ? _f2 : 0,
1912
+ error: (_b2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _b2.errors,
1913
+ totalQuantity: ((_d2 = (_c2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _c2.cart) == null ? void 0 : _d2.totalQuantity) ?? 0,
1807
1914
  cartCreate,
1808
1915
  linesAdd(lines) {
1809
1916
  var _a3, _b3;
1810
1917
  if ((_b3 = (_a3 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _a3.cart) == null ? void 0 : _b3.id) {
1811
1918
  onCartReadySend({
1812
1919
  type: "CARTLINE_ADD",
1813
- payload: {
1814
- lines
1815
- }
1920
+ payload: { lines }
1816
1921
  });
1817
1922
  } else {
1818
- cartCreate({
1819
- lines
1820
- });
1923
+ cartCreate({ lines });
1821
1924
  }
1822
1925
  },
1823
1926
  linesRemove(lines) {
@@ -1870,16 +1973,15 @@
1870
1973
  },
1871
1974
  cartFragment
1872
1975
  };
1873
- }, [cartCreate, (_f = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _f.cart, (_g = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _g.errors, cartDisplayState.value, cartFragment, onCartReadySend]);
1874
- return /* @__PURE__ */ React__default.default.createElement(CartContext.Provider, {
1875
- value: cartContextValue,
1876
- __self: this,
1877
- __source: {
1878
- fileName: _jsxFileName$d,
1879
- lineNumber: 424,
1880
- columnNumber: 5
1881
- }
1882
- }, children);
1976
+ }, [
1977
+ cartCreate,
1978
+ (_f = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _f.cart,
1979
+ (_g = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _g.errors,
1980
+ cartDisplayState.value,
1981
+ cartFragment,
1982
+ onCartReadySend
1983
+ ]);
1984
+ return /* @__PURE__ */ React.createElement(CartContext.Provider, { value: cartContextValue }, children);
1883
1985
  }
1884
1986
  function transposeStatus(status) {
1885
1987
  switch (status) {
@@ -1934,65 +2036,76 @@
1934
2036
  storage.removeItem(x);
1935
2037
  return true;
1936
2038
  } catch (e2) {
1937
- return e2 instanceof DOMException && (e2.code === 22 || e2.code === 1014 || e2.name === "QuotaExceededError" || e2.name === "NS_ERROR_DOM_QUOTA_REACHED") && storage && storage.length !== 0;
2039
+ return e2 instanceof DOMException && // everything except Firefox
2040
+ (e2.code === 22 || // Firefox
2041
+ e2.code === 1014 || // test name field too, because code might not be present
2042
+ // everything except Firefox
2043
+ e2.name === "QuotaExceededError" || // Firefox
2044
+ e2.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored
2045
+ storage && storage.length !== 0;
1938
2046
  }
1939
2047
  }
1940
2048
  function countryCodeNotUpdated(context, event) {
1941
2049
  var _a, _b;
1942
2050
  return event.payload.buyerIdentity.countryCode && ((_b = (_a = context.cart) == null ? void 0 : _a.buyerIdentity) == null ? void 0 : _b.countryCode) !== event.payload.buyerIdentity.countryCode;
1943
2051
  }
1944
- var _jsxFileName$c = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";
1945
2052
  const ProductOptionsContext = React.createContext(null);
1946
2053
  function ProductProvider({
1947
2054
  children,
1948
2055
  data: product,
1949
2056
  initialVariantId: explicitVariantId
1950
2057
  }) {
1951
- const variants = React.useMemo(() => {
1952
- var _a;
1953
- return flattenConnection((_a = product.variants) != null ? _a : {});
1954
- }, [product.variants]);
2058
+ const variants = React.useMemo(
2059
+ () => flattenConnection(product.variants ?? {}),
2060
+ [product.variants]
2061
+ );
1955
2062
  if (!isProductVariantArray(variants)) {
1956
- throw new Error(`<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'`);
2063
+ throw new Error(
2064
+ `<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'`
2065
+ );
1957
2066
  }
1958
2067
  const options = React.useMemo(() => getOptions(variants), [variants]);
1959
2068
  const [selectedVariant, setSelectedVariant] = React.useState(() => getVariantBasedOnIdProp(explicitVariantId, variants));
1960
- const [selectedOptions, setSelectedOptions] = React.useState(() => getSelectedOptions(selectedVariant));
2069
+ const [selectedOptions, setSelectedOptions] = React.useState(
2070
+ () => getSelectedOptions(selectedVariant)
2071
+ );
1961
2072
  React.useEffect(() => {
1962
- const newSelectedVariant = getVariantBasedOnIdProp(explicitVariantId, variants);
2073
+ const newSelectedVariant = getVariantBasedOnIdProp(
2074
+ explicitVariantId,
2075
+ variants
2076
+ );
1963
2077
  setSelectedVariant(newSelectedVariant);
1964
2078
  setSelectedOptions(getSelectedOptions(newSelectedVariant));
1965
2079
  }, [explicitVariantId, variants]);
1966
- const setSelectedOption = React.useCallback((name, value2) => {
1967
- setSelectedOptions((selectedOptions2) => {
1968
- const opts = {
1969
- ...selectedOptions2,
1970
- [name]: value2
1971
- };
1972
- setSelectedVariant(getSelectedVariant(variants, opts));
1973
- return opts;
1974
- });
1975
- }, [setSelectedOptions, variants]);
1976
- const isOptionInStock = React.useCallback((option, value2) => {
1977
- var _a;
1978
- const proposedVariant = getSelectedVariant(variants, {
1979
- ...selectedOptions,
1980
- ...{
1981
- [option]: value2
1982
- }
1983
- });
1984
- return (_a = proposedVariant == null ? void 0 : proposedVariant.availableForSale) != null ? _a : true;
1985
- }, [selectedOptions, variants]);
1986
- const sellingPlanGroups = React.useMemo(() => {
1987
- var _a;
1988
- return flattenConnection((_a = product.sellingPlanGroups) != null ? _a : {}).map((sellingPlanGroup) => {
1989
- var _a2;
1990
- return {
2080
+ const setSelectedOption = React.useCallback(
2081
+ (name, value2) => {
2082
+ setSelectedOptions((selectedOptions2) => {
2083
+ const opts = { ...selectedOptions2, [name]: value2 };
2084
+ setSelectedVariant(getSelectedVariant(variants, opts));
2085
+ return opts;
2086
+ });
2087
+ },
2088
+ [setSelectedOptions, variants]
2089
+ );
2090
+ const isOptionInStock = React.useCallback(
2091
+ (option, value2) => {
2092
+ const proposedVariant = getSelectedVariant(variants, {
2093
+ ...selectedOptions,
2094
+ ...{ [option]: value2 }
2095
+ });
2096
+ return (proposedVariant == null ? void 0 : proposedVariant.availableForSale) ?? true;
2097
+ },
2098
+ [selectedOptions, variants]
2099
+ );
2100
+ const sellingPlanGroups = React.useMemo(
2101
+ () => flattenConnection(product.sellingPlanGroups ?? {}).map(
2102
+ (sellingPlanGroup) => ({
1991
2103
  ...sellingPlanGroup,
1992
- sellingPlans: flattenConnection((_a2 = sellingPlanGroup == null ? void 0 : sellingPlanGroup.sellingPlans) != null ? _a2 : {})
1993
- };
1994
- });
1995
- }, [product.sellingPlanGroups]);
2104
+ sellingPlans: flattenConnection((sellingPlanGroup == null ? void 0 : sellingPlanGroup.sellingPlans) ?? {})
2105
+ })
2106
+ ),
2107
+ [product.sellingPlanGroups]
2108
+ );
1996
2109
  const [selectedSellingPlan, setSelectedSellingPlan] = React.useState(void 0);
1997
2110
  const selectedSellingPlanAllocation = React.useMemo(() => {
1998
2111
  var _a, _b;
@@ -2000,38 +2113,49 @@
2000
2113
  return;
2001
2114
  }
2002
2115
  if (!((_a = selectedVariant.sellingPlanAllocations) == null ? void 0 : _a.nodes) && !((_b = selectedVariant.sellingPlanAllocations) == null ? void 0 : _b.edges)) {
2003
- throw new Error(`<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation`);
2116
+ throw new Error(
2117
+ `<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation`
2118
+ );
2004
2119
  }
2005
- return flattenConnection(selectedVariant.sellingPlanAllocations).find((allocation) => {
2006
- var _a2;
2007
- return ((_a2 = allocation == null ? void 0 : allocation.sellingPlan) == null ? void 0 : _a2.id) === selectedSellingPlan.id;
2008
- });
2120
+ return flattenConnection(selectedVariant.sellingPlanAllocations).find(
2121
+ (allocation) => {
2122
+ var _a2;
2123
+ return ((_a2 = allocation == null ? void 0 : allocation.sellingPlan) == null ? void 0 : _a2.id) === selectedSellingPlan.id;
2124
+ }
2125
+ );
2009
2126
  }, [selectedVariant, selectedSellingPlan]);
2010
- const value = React.useMemo(() => ({
2011
- variants,
2012
- variantsConnection: product.variants,
2013
- options,
2014
- selectedVariant,
2015
- setSelectedVariant,
2016
- selectedOptions,
2017
- setSelectedOption,
2018
- setSelectedOptions,
2019
- isOptionInStock,
2020
- selectedSellingPlan,
2021
- setSelectedSellingPlan,
2022
- selectedSellingPlanAllocation,
2023
- sellingPlanGroups,
2024
- sellingPlanGroupsConnection: product.sellingPlanGroups
2025
- }), [isOptionInStock, options, product.sellingPlanGroups, product.variants, selectedOptions, selectedSellingPlan, selectedSellingPlanAllocation, selectedVariant, sellingPlanGroups, setSelectedOption, variants]);
2026
- return /* @__PURE__ */ React__default.default.createElement(ProductOptionsContext.Provider, {
2027
- value,
2028
- __self: this,
2029
- __source: {
2030
- fileName: _jsxFileName$c,
2031
- lineNumber: 201,
2032
- columnNumber: 5
2033
- }
2034
- }, children);
2127
+ const value = React.useMemo(
2128
+ () => ({
2129
+ variants,
2130
+ variantsConnection: product.variants,
2131
+ options,
2132
+ selectedVariant,
2133
+ setSelectedVariant,
2134
+ selectedOptions,
2135
+ setSelectedOption,
2136
+ setSelectedOptions,
2137
+ isOptionInStock,
2138
+ selectedSellingPlan,
2139
+ setSelectedSellingPlan,
2140
+ selectedSellingPlanAllocation,
2141
+ sellingPlanGroups,
2142
+ sellingPlanGroupsConnection: product.sellingPlanGroups
2143
+ }),
2144
+ [
2145
+ isOptionInStock,
2146
+ options,
2147
+ product.sellingPlanGroups,
2148
+ product.variants,
2149
+ selectedOptions,
2150
+ selectedSellingPlan,
2151
+ selectedSellingPlanAllocation,
2152
+ selectedVariant,
2153
+ sellingPlanGroups,
2154
+ setSelectedOption,
2155
+ variants
2156
+ ]
2157
+ );
2158
+ return /* @__PURE__ */ React.createElement(ProductOptionsContext.Provider, { value }, children);
2035
2159
  }
2036
2160
  function useProduct() {
2037
2161
  const context = React.useContext(ProductOptionsContext);
@@ -2048,7 +2172,9 @@
2048
2172
  return variants == null ? void 0 : variants.find((variant) => {
2049
2173
  return Object.entries(choices).every(([name, value]) => {
2050
2174
  var _a2;
2051
- return (_a2 = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a2.some((option) => (option == null ? void 0 : option.name) === name && (option == null ? void 0 : option.value) === value);
2175
+ return (_a2 = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a2.some(
2176
+ (option) => (option == null ? void 0 : option.name) === name && (option == null ? void 0 : option.value) === value
2177
+ );
2052
2178
  });
2053
2179
  });
2054
2180
  }
@@ -2059,9 +2185,8 @@
2059
2185
  throw new Error(`'getOptions' requires 'variant.selectedOptions'`);
2060
2186
  }
2061
2187
  (_a = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a.forEach((opt) => {
2062
- var _a2, _b, _c, _d;
2063
- memo[(_a2 = opt == null ? void 0 : opt.name) != null ? _a2 : ""] = memo[(_b = opt == null ? void 0 : opt.name) != null ? _b : ""] || /* @__PURE__ */ new Set();
2064
- memo[(_c = opt == null ? void 0 : opt.name) != null ? _c : ""].add((_d = opt == null ? void 0 : opt.value) != null ? _d : "");
2188
+ memo[(opt == null ? void 0 : opt.name) ?? ""] = memo[(opt == null ? void 0 : opt.name) ?? ""] || /* @__PURE__ */ new Set();
2189
+ memo[(opt == null ? void 0 : opt.name) ?? ""].add((opt == null ? void 0 : opt.value) ?? "");
2065
2190
  });
2066
2191
  return memo;
2067
2192
  }, {});
@@ -2074,9 +2199,13 @@
2074
2199
  }
2075
2200
  function getVariantBasedOnIdProp(explicitVariantId, variants) {
2076
2201
  if (explicitVariantId) {
2077
- const foundVariant = variants.find((variant) => (variant == null ? void 0 : variant.id) === explicitVariantId);
2202
+ const foundVariant = variants.find(
2203
+ (variant) => (variant == null ? void 0 : variant.id) === explicitVariantId
2204
+ );
2078
2205
  if (!foundVariant) {
2079
- console.warn(`<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID`);
2206
+ console.warn(
2207
+ `<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID`
2208
+ );
2080
2209
  }
2081
2210
  return foundVariant;
2082
2211
  }
@@ -2088,11 +2217,13 @@
2088
2217
  }
2089
2218
  }
2090
2219
  function getSelectedOptions(selectedVariant) {
2091
- return (selectedVariant == null ? void 0 : selectedVariant.selectedOptions) ? selectedVariant.selectedOptions.reduce((memo, optionSet) => {
2092
- var _a, _b;
2093
- memo[(_a = optionSet == null ? void 0 : optionSet.name) != null ? _a : ""] = (_b = optionSet == null ? void 0 : optionSet.value) != null ? _b : "";
2094
- return memo;
2095
- }, {}) : {};
2220
+ return (selectedVariant == null ? void 0 : selectedVariant.selectedOptions) ? selectedVariant.selectedOptions.reduce(
2221
+ (memo, optionSet) => {
2222
+ memo[(optionSet == null ? void 0 : optionSet.name) ?? ""] = (optionSet == null ? void 0 : optionSet.value) ?? "";
2223
+ return memo;
2224
+ },
2225
+ {}
2226
+ ) : {};
2096
2227
  }
2097
2228
  function isProductVariantArray(maybeVariantArray) {
2098
2229
  if (!maybeVariantArray || !Array.isArray(maybeVariantArray)) {
@@ -2100,7 +2231,6 @@
2100
2231
  }
2101
2232
  return true;
2102
2233
  }
2103
- var _jsxFileName$b = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BaseButton.tsx";
2104
2234
  function BaseButton(props) {
2105
2235
  const {
2106
2236
  as,
@@ -2110,30 +2240,21 @@
2110
2240
  buttonRef,
2111
2241
  ...passthroughProps
2112
2242
  } = props;
2113
- const handleOnClick = React.useCallback((event) => {
2114
- if (onClick) {
2115
- const clickShouldContinue = onClick(event);
2116
- if (typeof clickShouldContinue === "boolean" && clickShouldContinue === false || (event == null ? void 0 : event.defaultPrevented))
2117
- return;
2118
- }
2119
- defaultOnClick == null ? void 0 : defaultOnClick(event);
2120
- }, [defaultOnClick, onClick]);
2243
+ const handleOnClick = React.useCallback(
2244
+ (event) => {
2245
+ if (onClick) {
2246
+ const clickShouldContinue = onClick(event);
2247
+ if (typeof clickShouldContinue === "boolean" && clickShouldContinue === false || (event == null ? void 0 : event.defaultPrevented))
2248
+ return;
2249
+ }
2250
+ defaultOnClick == null ? void 0 : defaultOnClick(event);
2251
+ },
2252
+ [defaultOnClick, onClick]
2253
+ );
2121
2254
  const Component = as || "button";
2122
- return /* @__PURE__ */ React__default.default.createElement(Component, {
2123
- ref: buttonRef,
2124
- onClick: handleOnClick,
2125
- ...passthroughProps,
2126
- __self: this,
2127
- __source: {
2128
- fileName: _jsxFileName$b,
2129
- lineNumber: 59,
2130
- columnNumber: 5
2131
- }
2132
- }, children);
2133
- }
2134
- var _jsxFileName$a = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/AddToCartButton.tsx";
2255
+ return /* @__PURE__ */ React.createElement(Component, { ref: buttonRef, onClick: handleOnClick, ...passthroughProps }, children);
2256
+ }
2135
2257
  function AddToCartButton(props) {
2136
- var _a;
2137
2258
  const [addingItem, setAddingItem] = React.useState(false);
2138
2259
  const {
2139
2260
  variantId: explicitVariantId,
@@ -2145,14 +2266,9 @@
2145
2266
  accessibleAddingToCartLabel,
2146
2267
  ...passthroughProps
2147
2268
  } = props;
2148
- const {
2149
- status,
2150
- linesAdd
2151
- } = useCart();
2152
- const {
2153
- selectedVariant
2154
- } = useProduct();
2155
- const variantId = (_a = explicitVariantId != null ? explicitVariantId : selectedVariant == null ? void 0 : selectedVariant.id) != null ? _a : "";
2269
+ const { status, linesAdd } = useCart();
2270
+ const { selectedVariant } = useProduct();
2271
+ const variantId = explicitVariantId ?? (selectedVariant == null ? void 0 : selectedVariant.id) ?? "";
2156
2272
  const disabled = explicitVariantId === null || variantId === "" || selectedVariant === null || addingItem || passthroughProps.disabled;
2157
2273
  React.useEffect(() => {
2158
2274
  if (addingItem && status === "idle") {
@@ -2161,52 +2277,46 @@
2161
2277
  }, [status, addingItem]);
2162
2278
  const handleAddItem = React.useCallback(() => {
2163
2279
  setAddingItem(true);
2164
- linesAdd([{
2165
- quantity,
2166
- merchandiseId: variantId || "",
2167
- attributes,
2168
- sellingPlanId
2169
- }]);
2280
+ linesAdd([
2281
+ {
2282
+ quantity,
2283
+ merchandiseId: variantId || "",
2284
+ attributes,
2285
+ sellingPlanId
2286
+ }
2287
+ ]);
2170
2288
  }, [linesAdd, quantity, variantId, attributes, sellingPlanId]);
2171
- return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(BaseButton, {
2172
- ...passthroughProps,
2173
- disabled,
2174
- onClick,
2175
- defaultOnClick: handleAddItem,
2176
- __self: this,
2177
- __source: {
2178
- fileName: _jsxFileName$a,
2179
- lineNumber: 71,
2180
- columnNumber: 7
2181
- }
2182
- }, children), accessibleAddingToCartLabel ? /* @__PURE__ */ React__default.default.createElement("p", {
2183
- style: {
2184
- position: "absolute",
2185
- width: "1px",
2186
- height: "1px",
2187
- padding: "0",
2188
- margin: "-1px",
2189
- overflow: "hidden",
2190
- clip: "rect(0, 0, 0, 0)",
2191
- whiteSpace: "nowrap",
2192
- borderWidth: "0"
2289
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
2290
+ BaseButton,
2291
+ {
2292
+ ...passthroughProps,
2293
+ disabled,
2294
+ onClick,
2295
+ defaultOnClick: handleAddItem
2193
2296
  },
2194
- role: "alert",
2195
- "aria-live": "assertive",
2196
- __self: this,
2197
- __source: {
2198
- fileName: _jsxFileName$a,
2199
- lineNumber: 80,
2200
- columnNumber: 9
2201
- }
2202
- }, addingItem ? accessibleAddingToCartLabel : null) : null);
2297
+ children
2298
+ ), accessibleAddingToCartLabel ? /* @__PURE__ */ React.createElement(
2299
+ "p",
2300
+ {
2301
+ style: {
2302
+ position: "absolute",
2303
+ width: "1px",
2304
+ height: "1px",
2305
+ padding: "0",
2306
+ margin: "-1px",
2307
+ overflow: "hidden",
2308
+ clip: "rect(0, 0, 0, 0)",
2309
+ whiteSpace: "nowrap",
2310
+ borderWidth: "0"
2311
+ },
2312
+ role: "alert",
2313
+ "aria-live": "assertive"
2314
+ },
2315
+ addingItem ? accessibleAddingToCartLabel : null
2316
+ ) : null);
2203
2317
  }
2204
- var _jsxFileName$9 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BuyNowButton.tsx";
2205
2318
  function BuyNowButton(props) {
2206
- const {
2207
- cartCreate,
2208
- checkoutUrl
2209
- } = useCart();
2319
+ const { cartCreate, checkoutUrl } = useCart();
2210
2320
  const [loading, setLoading] = React.useState(false);
2211
2321
  const {
2212
2322
  quantity,
@@ -2224,55 +2334,47 @@
2224
2334
  const handleBuyNow = React.useCallback(() => {
2225
2335
  setLoading(true);
2226
2336
  cartCreate({
2227
- lines: [{
2228
- quantity: quantity != null ? quantity : 1,
2229
- merchandiseId: variantId,
2230
- attributes
2231
- }]
2337
+ lines: [
2338
+ {
2339
+ quantity: quantity ?? 1,
2340
+ merchandiseId: variantId,
2341
+ attributes
2342
+ }
2343
+ ]
2232
2344
  });
2233
2345
  }, [cartCreate, quantity, variantId, attributes]);
2234
- return /* @__PURE__ */ React__default.default.createElement(BaseButton, {
2235
- disabled: loading != null ? loading : passthroughProps.disabled,
2236
- ...passthroughProps,
2237
- onClick,
2238
- defaultOnClick: handleBuyNow,
2239
- __self: this,
2240
- __source: {
2241
- fileName: _jsxFileName$9,
2242
- lineNumber: 53,
2243
- columnNumber: 5
2244
- }
2245
- }, children);
2346
+ return /* @__PURE__ */ React.createElement(
2347
+ BaseButton,
2348
+ {
2349
+ disabled: loading ?? passthroughProps.disabled,
2350
+ ...passthroughProps,
2351
+ onClick,
2352
+ defaultOnClick: handleBuyNow
2353
+ },
2354
+ children
2355
+ );
2246
2356
  }
2247
- var _jsxFileName$8 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartCheckoutButton.tsx";
2248
2357
  function CartCheckoutButton(props) {
2249
2358
  const [requestedCheckout, setRequestedCheckout] = React.useState(false);
2250
- const {
2251
- status,
2252
- checkoutUrl
2253
- } = useCart();
2254
- const {
2255
- children,
2256
- ...passthroughProps
2257
- } = props;
2359
+ const { status, checkoutUrl } = useCart();
2360
+ const { children, ...passthroughProps } = props;
2258
2361
  React.useEffect(() => {
2259
2362
  if (requestedCheckout && checkoutUrl && status === "idle") {
2260
2363
  window.location.href = checkoutUrl;
2261
2364
  }
2262
2365
  }, [requestedCheckout, status, checkoutUrl]);
2263
- return /* @__PURE__ */ React__default.default.createElement(BaseButton, {
2264
- ...passthroughProps,
2265
- disabled: requestedCheckout || passthroughProps.disabled,
2266
- onClick: () => setRequestedCheckout(true),
2267
- __self: this,
2268
- __source: {
2269
- fileName: _jsxFileName$8,
2270
- lineNumber: 28,
2271
- columnNumber: 5
2272
- }
2273
- }, children);
2366
+ return /* @__PURE__ */ React.createElement(
2367
+ BaseButton,
2368
+ {
2369
+ ...passthroughProps,
2370
+ disabled: requestedCheckout || passthroughProps.disabled,
2371
+ onClick: () => setRequestedCheckout(true)
2372
+ },
2373
+ children
2374
+ );
2274
2375
  }
2275
2376
  const storefrontApiCustomScalars = {
2377
+ // Keep in sync with the definitions in the app/nextjs/codegen.ts!
2276
2378
  DateTime: "string",
2277
2379
  Decimal: "string",
2278
2380
  HTML: "string",
@@ -2280,9 +2382,7 @@
2280
2382
  Color: "string",
2281
2383
  UnsignedInt64: "string"
2282
2384
  };
2283
- var _jsxFileName$7 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";
2284
2385
  function ExternalVideo(props) {
2285
- var _a, _b;
2286
2386
  const {
2287
2387
  data,
2288
2388
  options,
@@ -2304,22 +2404,19 @@
2304
2404
  }
2305
2405
  finalUrl = urlObject.toString();
2306
2406
  }
2307
- return /* @__PURE__ */ React__default.default.createElement("iframe", {
2308
- ...passthroughProps,
2309
- id: id != null ? id : data.embedUrl,
2310
- title: (_b = (_a = data.alt) != null ? _a : data.id) != null ? _b : "external video",
2311
- frameBorder,
2312
- allow,
2313
- allowFullScreen,
2314
- src: finalUrl,
2315
- loading,
2316
- __self: this,
2317
- __source: {
2318
- fileName: _jsxFileName$7,
2319
- lineNumber: 56,
2320
- columnNumber: 5
2407
+ return /* @__PURE__ */ React.createElement(
2408
+ "iframe",
2409
+ {
2410
+ ...passthroughProps,
2411
+ id: id ?? data.embedUrl,
2412
+ title: data.alt ?? data.id ?? "external video",
2413
+ frameBorder,
2414
+ allow,
2415
+ allowFullScreen,
2416
+ src: finalUrl,
2417
+ loading
2321
2418
  }
2322
- });
2419
+ );
2323
2420
  }
2324
2421
  const PRODUCTION_CDN_HOSTNAMES = [
2325
2422
  "cdn.shopify.com",
@@ -2338,7 +2435,7 @@
2338
2435
  scale
2339
2436
  }) {
2340
2437
  const newUrl = new URL(src);
2341
- const multipliedScale = scale != null ? scale : 1;
2438
+ const multipliedScale = scale ?? 1;
2342
2439
  if (width) {
2343
2440
  let finalWidth;
2344
2441
  if (typeof width === "string") {
@@ -2369,32 +2466,31 @@
2369
2466
  loaderOptions,
2370
2467
  elementProps
2371
2468
  }) {
2372
- var _a, _b, _c, _d, _e, _f;
2373
2469
  let aspectRatio = null;
2374
2470
  if ((sfapiImage == null ? void 0 : sfapiImage.width) && (sfapiImage == null ? void 0 : sfapiImage.height)) {
2375
2471
  aspectRatio = (sfapiImage == null ? void 0 : sfapiImage.width) / (sfapiImage == null ? void 0 : sfapiImage.height);
2376
2472
  }
2377
2473
  if ((loaderOptions == null ? void 0 : loaderOptions.width) || (loaderOptions == null ? void 0 : loaderOptions.height)) {
2378
2474
  return {
2379
- width: (_a = loaderOptions == null ? void 0 : loaderOptions.width) != null ? _a : aspectRatio && typeof loaderOptions.height === "number" ? Math.round(aspectRatio * loaderOptions.height) : null,
2380
- height: (_b = loaderOptions == null ? void 0 : loaderOptions.height) != null ? _b : aspectRatio && typeof loaderOptions.width === "number" ? Math.round(aspectRatio * loaderOptions.width) : null
2475
+ width: (loaderOptions == null ? void 0 : loaderOptions.width) ?? (aspectRatio && typeof loaderOptions.height === "number" ? Math.round(aspectRatio * loaderOptions.height) : null),
2476
+ height: (loaderOptions == null ? void 0 : loaderOptions.height) ?? (aspectRatio && typeof loaderOptions.width === "number" ? Math.round(aspectRatio * loaderOptions.width) : null)
2381
2477
  };
2382
2478
  }
2383
2479
  if ((elementProps == null ? void 0 : elementProps.width) || (elementProps == null ? void 0 : elementProps.height)) {
2384
2480
  return {
2385
- width: (_c = elementProps == null ? void 0 : elementProps.width) != null ? _c : aspectRatio && typeof elementProps.height === "number" ? Math.round(aspectRatio * elementProps.height) : null,
2386
- height: (_d = elementProps == null ? void 0 : elementProps.height) != null ? _d : aspectRatio && typeof elementProps.width === "number" ? Math.round(aspectRatio * elementProps.width) : null
2481
+ width: (elementProps == null ? void 0 : elementProps.width) ?? (aspectRatio && typeof elementProps.height === "number" ? Math.round(aspectRatio * elementProps.height) : null),
2482
+ height: (elementProps == null ? void 0 : elementProps.height) ?? (aspectRatio && typeof elementProps.width === "number" ? Math.round(aspectRatio * elementProps.width) : null)
2387
2483
  };
2388
2484
  }
2389
2485
  if ((sfapiImage == null ? void 0 : sfapiImage.width) || (sfapiImage == null ? void 0 : sfapiImage.height)) {
2390
2486
  return {
2391
- width: (_e = sfapiImage == null ? void 0 : sfapiImage.width) != null ? _e : null,
2392
- height: (_f = sfapiImage == null ? void 0 : sfapiImage.height) != null ? _f : null
2487
+ // can't calculate the aspect ratio here
2488
+ width: (sfapiImage == null ? void 0 : sfapiImage.width) ?? null,
2489
+ height: (sfapiImage == null ? void 0 : sfapiImage.height) ?? null
2393
2490
  };
2394
2491
  }
2395
2492
  return { width: null, height: null };
2396
2493
  }
2397
- var _jsxFileName$6 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";
2398
2494
  function Image({
2399
2495
  data,
2400
2496
  width,
@@ -2406,20 +2502,18 @@
2406
2502
  decoding = "async",
2407
2503
  ...rest
2408
2504
  }) {
2409
- var _a, _b, _c, _d, _e, _f, _g, _h;
2410
2505
  if (!data.url) {
2411
- const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${(_a = data.id) != null ? _a : "no ID provided"}`;
2506
+ const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${data.id ?? "no ID provided"}`;
2412
2507
  {
2413
2508
  throw new Error(missingUrlError);
2414
2509
  }
2415
2510
  }
2416
2511
  if (!data.altText && !rest.alt) {
2417
- console.warn(`<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. Image: ${(_b = data.id) != null ? _b : data.url}`);
2512
+ console.warn(
2513
+ `<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. Image: ${data.id ?? data.url}`
2514
+ );
2418
2515
  }
2419
- const {
2420
- width: imgElementWidth,
2421
- height: imgElementHeight
2422
- } = getShopifyImageDimensions({
2516
+ const { width: imgElementWidth, height: imgElementHeight } = getShopifyImageDimensions({
2423
2517
  data,
2424
2518
  loaderOptions,
2425
2519
  elementProps: {
@@ -2428,7 +2522,9 @@
2428
2522
  }
2429
2523
  });
2430
2524
  if (!imgElementWidth || !imgElementHeight) {
2431
- console.warn(`<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${(_c = data.id) != null ? _c : data.url}`);
2525
+ console.warn(
2526
+ `<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${data.id ?? data.url}`
2527
+ );
2432
2528
  }
2433
2529
  let finalSrc = data.url;
2434
2530
  if (loader) {
@@ -2439,11 +2535,13 @@
2439
2535
  height: imgElementHeight
2440
2536
  });
2441
2537
  if (typeof finalSrc !== "string" || !finalSrc) {
2442
- throw new Error(`<Image/>: 'loader' did not return a valid string. Image: ${(_d = data.id) != null ? _d : data.url}`);
2538
+ throw new Error(
2539
+ `<Image/>: 'loader' did not return a valid string. Image: ${data.id ?? data.url}`
2540
+ );
2443
2541
  }
2444
2542
  }
2445
2543
  const maxWidth = width && imgElementWidth && width < imgElementWidth ? width : imgElementWidth;
2446
- const finalSrcset = (_e = rest.srcSet) != null ? _e : internalImageSrcSet({
2544
+ const finalSrcset = rest.srcSet ?? internalImageSrcSet({
2447
2545
  ...loaderOptions,
2448
2546
  widths,
2449
2547
  src: data.url,
@@ -2451,23 +2549,20 @@
2451
2549
  height: imgElementHeight,
2452
2550
  loader
2453
2551
  });
2454
- return /* @__PURE__ */ React__namespace.createElement("img", {
2455
- id: (_f = data.id) != null ? _f : "",
2456
- alt: (_h = (_g = data.altText) != null ? _g : rest.alt) != null ? _h : "",
2457
- loading: loading != null ? loading : "lazy",
2458
- ...rest,
2459
- src: finalSrc,
2460
- width: imgElementWidth != null ? imgElementWidth : void 0,
2461
- height: imgElementHeight != null ? imgElementHeight : void 0,
2462
- srcSet: finalSrcset,
2463
- decoding,
2464
- __self: this,
2465
- __source: {
2466
- fileName: _jsxFileName$6,
2467
- lineNumber: 150,
2468
- columnNumber: 5
2552
+ return /* @__PURE__ */ React__namespace.createElement(
2553
+ "img",
2554
+ {
2555
+ id: data.id ?? "",
2556
+ alt: data.altText ?? rest.alt ?? "",
2557
+ loading: loading ?? "lazy",
2558
+ ...rest,
2559
+ src: finalSrc,
2560
+ width: imgElementWidth ?? void 0,
2561
+ height: imgElementHeight ?? void 0,
2562
+ srcSet: finalSrcset,
2563
+ decoding
2469
2564
  }
2470
- });
2565
+ );
2471
2566
  }
2472
2567
  function internalImageSrcSet({
2473
2568
  src,
@@ -2480,7 +2575,9 @@
2480
2575
  }) {
2481
2576
  const hasCustomWidths = widths && Array.isArray(widths);
2482
2577
  if (hasCustomWidths && widths.some((size) => isNaN(size))) {
2483
- throw new Error(`<Image/>: the 'widths' must be an array of numbers. Image: ${src}`);
2578
+ throw new Error(
2579
+ `<Image/>: the 'widths' must be an array of numbers. Image: ${src}`
2580
+ );
2484
2581
  }
2485
2582
  let aspectRatio = 1;
2486
2583
  if (width && height) {
@@ -2491,17 +2588,20 @@
2491
2588
  setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);
2492
2589
  }
2493
2590
  const srcGenerator = loader ? loader : addImageSizeParametersToUrl;
2494
- return setSizes.map((size) => `${srcGenerator({
2495
- src,
2496
- width: size,
2497
- height: crop ? Number(size) * aspectRatio : void 0,
2498
- crop,
2499
- scale
2500
- })} ${size}w`).join(", ");
2501
- }
2502
- var _jsxFileName$5 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Video.tsx";
2591
+ return setSizes.map(
2592
+ (size) => `${srcGenerator({
2593
+ src,
2594
+ width: size,
2595
+ // height is not applied if there is no crop
2596
+ // if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size
2597
+ height: crop ? Number(size) * aspectRatio : void 0,
2598
+ crop,
2599
+ scale
2600
+ })} ${size}w`
2601
+ ).join(", ");
2602
+ }
2503
2603
  function Video(props) {
2504
- var _a, _b;
2604
+ var _a;
2505
2605
  const {
2506
2606
  data,
2507
2607
  previewImageOptions,
@@ -2512,41 +2612,39 @@
2512
2612
  ...passthroughProps
2513
2613
  } = props;
2514
2614
  const posterUrl = shopifyImageLoader({
2515
- src: (_b = (_a = data.previewImage) == null ? void 0 : _a.url) != null ? _b : "",
2615
+ src: ((_a = data.previewImage) == null ? void 0 : _a.url) ?? "",
2516
2616
  ...previewImageOptions
2517
2617
  });
2518
2618
  if (!data.sources) {
2519
2619
  throw new Error(`<Video/> requires a 'data.sources' array`);
2520
2620
  }
2521
- return /* @__PURE__ */ React__default.default.createElement("video", {
2522
- ...passthroughProps,
2523
- id,
2524
- playsInline,
2525
- controls,
2526
- poster: posterUrl,
2527
- __self: this,
2528
- __source: {
2529
- fileName: _jsxFileName$5,
2530
- lineNumber: 42,
2531
- columnNumber: 5
2532
- }
2533
- }, data.sources.map((source) => {
2534
- if (!((source == null ? void 0 : source.url) && (source == null ? void 0 : source.mimeType))) {
2535
- throw new Error(`<Video/> needs 'source.url' and 'source.mimeType'`);
2536
- }
2537
- return /* @__PURE__ */ React__default.default.createElement("source", {
2538
- ...sourceProps,
2539
- key: source.url,
2540
- src: source.url,
2541
- type: source.mimeType,
2542
- __self: this,
2543
- __source: {
2544
- fileName: _jsxFileName$5,
2545
- lineNumber: 54,
2546
- columnNumber: 11
2547
- }
2548
- });
2549
- }));
2621
+ return (
2622
+ // eslint-disable-next-line jsx-a11y/media-has-caption
2623
+ /* @__PURE__ */ React.createElement(
2624
+ "video",
2625
+ {
2626
+ ...passthroughProps,
2627
+ id,
2628
+ playsInline,
2629
+ controls,
2630
+ poster: posterUrl
2631
+ },
2632
+ data.sources.map((source) => {
2633
+ if (!((source == null ? void 0 : source.url) && (source == null ? void 0 : source.mimeType))) {
2634
+ throw new Error(`<Video/> needs 'source.url' and 'source.mimeType'`);
2635
+ }
2636
+ return /* @__PURE__ */ React.createElement(
2637
+ "source",
2638
+ {
2639
+ ...sourceProps,
2640
+ key: source.url,
2641
+ src: source.url,
2642
+ type: source.mimeType
2643
+ }
2644
+ );
2645
+ })
2646
+ )
2647
+ );
2550
2648
  }
2551
2649
  const SCRIPTS_LOADED = {};
2552
2650
  function loadScript(src, options) {
@@ -2594,22 +2692,21 @@
2594
2692
  }, [url, stringifiedOptions, options]);
2595
2693
  return status;
2596
2694
  }
2597
- var _jsxFileName$4 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";
2598
2695
  function ModelViewer(props) {
2599
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2600
- const [modelViewer, setModelViewer] = React.useState(void 0);
2696
+ var _a, _b, _c;
2697
+ const [modelViewer, setModelViewer] = React.useState(
2698
+ void 0
2699
+ );
2601
2700
  const callbackRef = React.useCallback((node) => {
2602
2701
  setModelViewer(node);
2603
2702
  }, []);
2604
- const {
2605
- data,
2606
- children,
2607
- className,
2608
- ...passthroughProps
2609
- } = props;
2610
- const modelViewerLoadedStatus = useLoadScript("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js", {
2611
- module: true
2612
- });
2703
+ const { data, children, className, ...passthroughProps } = props;
2704
+ const modelViewerLoadedStatus = useLoadScript(
2705
+ "https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",
2706
+ {
2707
+ module: true
2708
+ }
2709
+ );
2613
2710
  React.useEffect(() => {
2614
2711
  if (!modelViewer) {
2615
2712
  return;
@@ -2621,25 +2718,43 @@
2621
2718
  if (passthroughProps.onPreload)
2622
2719
  modelViewer.addEventListener("preload", passthroughProps.onPreload);
2623
2720
  if (passthroughProps.onModelVisibility)
2624
- modelViewer.addEventListener("model-visibility", passthroughProps.onModelVisibility);
2721
+ modelViewer.addEventListener(
2722
+ "model-visibility",
2723
+ passthroughProps.onModelVisibility
2724
+ );
2625
2725
  if (passthroughProps.onProgress)
2626
2726
  modelViewer.addEventListener("progress", passthroughProps.onProgress);
2627
2727
  if (passthroughProps.onArStatus)
2628
2728
  modelViewer.addEventListener("ar-status", passthroughProps.onArStatus);
2629
2729
  if (passthroughProps.onArTracking)
2630
- modelViewer.addEventListener("ar-tracking", passthroughProps.onArTracking);
2730
+ modelViewer.addEventListener(
2731
+ "ar-tracking",
2732
+ passthroughProps.onArTracking
2733
+ );
2631
2734
  if (passthroughProps.onQuickLookButtonTapped)
2632
- modelViewer.addEventListener("quick-look-button-tapped", passthroughProps.onQuickLookButtonTapped);
2735
+ modelViewer.addEventListener(
2736
+ "quick-look-button-tapped",
2737
+ passthroughProps.onQuickLookButtonTapped
2738
+ );
2633
2739
  if (passthroughProps.onCameraChange)
2634
- modelViewer.addEventListener("camera-change", passthroughProps.onCameraChange);
2740
+ modelViewer.addEventListener(
2741
+ "camera-change",
2742
+ passthroughProps.onCameraChange
2743
+ );
2635
2744
  if (passthroughProps.onEnvironmentChange)
2636
- modelViewer.addEventListener("environment-change", passthroughProps.onEnvironmentChange);
2745
+ modelViewer.addEventListener(
2746
+ "environment-change",
2747
+ passthroughProps.onEnvironmentChange
2748
+ );
2637
2749
  if (passthroughProps.onPlay)
2638
2750
  modelViewer.addEventListener("play", passthroughProps.onPlay);
2639
2751
  if (passthroughProps.onPause)
2640
2752
  modelViewer.addEventListener("ar-status", passthroughProps.onPause);
2641
2753
  if (passthroughProps.onSceneGraphReady)
2642
- modelViewer.addEventListener("scene-graph-ready", passthroughProps.onSceneGraphReady);
2754
+ modelViewer.addEventListener(
2755
+ "scene-graph-ready",
2756
+ passthroughProps.onSceneGraphReady
2757
+ );
2643
2758
  return () => {
2644
2759
  if (modelViewer == null) {
2645
2760
  return;
@@ -2651,27 +2766,66 @@
2651
2766
  if (passthroughProps.onPreload)
2652
2767
  modelViewer.removeEventListener("preload", passthroughProps.onPreload);
2653
2768
  if (passthroughProps.onModelVisibility)
2654
- modelViewer.removeEventListener("model-visibility", passthroughProps.onModelVisibility);
2769
+ modelViewer.removeEventListener(
2770
+ "model-visibility",
2771
+ passthroughProps.onModelVisibility
2772
+ );
2655
2773
  if (passthroughProps.onProgress)
2656
- modelViewer.removeEventListener("progress", passthroughProps.onProgress);
2774
+ modelViewer.removeEventListener(
2775
+ "progress",
2776
+ passthroughProps.onProgress
2777
+ );
2657
2778
  if (passthroughProps.onArStatus)
2658
- modelViewer.removeEventListener("ar-status", passthroughProps.onArStatus);
2779
+ modelViewer.removeEventListener(
2780
+ "ar-status",
2781
+ passthroughProps.onArStatus
2782
+ );
2659
2783
  if (passthroughProps.onArTracking)
2660
- modelViewer.removeEventListener("ar-tracking", passthroughProps.onArTracking);
2784
+ modelViewer.removeEventListener(
2785
+ "ar-tracking",
2786
+ passthroughProps.onArTracking
2787
+ );
2661
2788
  if (passthroughProps.onQuickLookButtonTapped)
2662
- modelViewer.removeEventListener("quick-look-button-tapped", passthroughProps.onQuickLookButtonTapped);
2789
+ modelViewer.removeEventListener(
2790
+ "quick-look-button-tapped",
2791
+ passthroughProps.onQuickLookButtonTapped
2792
+ );
2663
2793
  if (passthroughProps.onCameraChange)
2664
- modelViewer.removeEventListener("camera-change", passthroughProps.onCameraChange);
2794
+ modelViewer.removeEventListener(
2795
+ "camera-change",
2796
+ passthroughProps.onCameraChange
2797
+ );
2665
2798
  if (passthroughProps.onEnvironmentChange)
2666
- modelViewer.removeEventListener("environment-change", passthroughProps.onEnvironmentChange);
2799
+ modelViewer.removeEventListener(
2800
+ "environment-change",
2801
+ passthroughProps.onEnvironmentChange
2802
+ );
2667
2803
  if (passthroughProps.onPlay)
2668
2804
  modelViewer.removeEventListener("play", passthroughProps.onPlay);
2669
2805
  if (passthroughProps.onPause)
2670
2806
  modelViewer.removeEventListener("ar-status", passthroughProps.onPause);
2671
2807
  if (passthroughProps.onSceneGraphReady)
2672
- modelViewer.removeEventListener("scene-graph-ready", passthroughProps.onSceneGraphReady);
2808
+ modelViewer.removeEventListener(
2809
+ "scene-graph-ready",
2810
+ passthroughProps.onSceneGraphReady
2811
+ );
2673
2812
  };
2674
- }, [modelViewer, passthroughProps.onArStatus, passthroughProps.onArTracking, passthroughProps.onCameraChange, passthroughProps.onEnvironmentChange, passthroughProps.onError, passthroughProps.onLoad, passthroughProps.onModelVisibility, passthroughProps.onPause, passthroughProps.onPlay, passthroughProps.onPreload, passthroughProps.onProgress, passthroughProps.onQuickLookButtonTapped, passthroughProps.onSceneGraphReady]);
2813
+ }, [
2814
+ modelViewer,
2815
+ passthroughProps.onArStatus,
2816
+ passthroughProps.onArTracking,
2817
+ passthroughProps.onCameraChange,
2818
+ passthroughProps.onEnvironmentChange,
2819
+ passthroughProps.onError,
2820
+ passthroughProps.onLoad,
2821
+ passthroughProps.onModelVisibility,
2822
+ passthroughProps.onPause,
2823
+ passthroughProps.onPlay,
2824
+ passthroughProps.onPreload,
2825
+ passthroughProps.onProgress,
2826
+ passthroughProps.onQuickLookButtonTapped,
2827
+ passthroughProps.onSceneGraphReady
2828
+ ]);
2675
2829
  if (modelViewerLoadedStatus !== "done") {
2676
2830
  return null;
2677
2831
  }
@@ -2682,63 +2836,62 @@
2682
2836
  }
2683
2837
  }
2684
2838
  if (!data.alt) {
2685
- console.warn(`<ModelViewer/> requires the 'data.alt' prop for accessibility`);
2686
- }
2687
- return /* @__PURE__ */ React__default.default.createElement("model-viewer", {
2688
- ref: callbackRef,
2689
- ...passthroughProps,
2690
- className,
2691
- id: (_c = passthroughProps.id) != null ? _c : data.id,
2692
- src: data.sources[0].url,
2693
- alt: (_d = data.alt) != null ? _d : null,
2694
- "camera-controls": (_e = passthroughProps.cameraControls) != null ? _e : true,
2695
- poster: (_g = passthroughProps.poster || ((_f = data.previewImage) == null ? void 0 : _f.url)) != null ? _g : null,
2696
- autoplay: (_h = passthroughProps.autoplay) != null ? _h : true,
2697
- loading: passthroughProps.loading,
2698
- reveal: passthroughProps.reveal,
2699
- ar: passthroughProps.ar,
2700
- "ar-modes": passthroughProps.arModes,
2701
- "ar-scale": passthroughProps.arScale,
2702
- "ar-placement": passthroughProps.arPlacement,
2703
- "ios-src": passthroughProps.iosSrc,
2704
- "touch-action": passthroughProps.touchAction,
2705
- "disable-zoom": passthroughProps.disableZoom,
2706
- "orbit-sensitivity": passthroughProps.orbitSensitivity,
2707
- "auto-rotate": passthroughProps.autoRotate,
2708
- "auto-rotate-delay": passthroughProps.autoRotateDelay,
2709
- "rotation-per-second": passthroughProps.rotationPerSecond,
2710
- "interaction-policy": passthroughProps.interactionPolicy,
2711
- "interaction-prompt": passthroughProps.interactionPrompt,
2712
- "interaction-prompt-style": passthroughProps.interactionPromptStyle,
2713
- "interaction-prompt-threshold": passthroughProps.interactionPromptThreshold,
2714
- "camera-orbit": passthroughProps.cameraOrbit,
2715
- "camera-target": passthroughProps.cameraTarget,
2716
- "field-of-view": passthroughProps.fieldOfView,
2717
- "max-camera-orbit": passthroughProps.maxCameraOrbit,
2718
- "min-camera-orbit": passthroughProps.minCameraOrbit,
2719
- "max-field-of-view": passthroughProps.maxFieldOfView,
2720
- "min-field-of-view": passthroughProps.minFieldOfView,
2721
- bounds: passthroughProps.bounds,
2722
- "interpolation-decay": (_i = passthroughProps.interpolationDecay) != null ? _i : 100,
2723
- "skybox-image": passthroughProps.skyboxImage,
2724
- "environment-image": passthroughProps.environmentImage,
2725
- exposure: passthroughProps.exposure,
2726
- "shadow-intensity": (_j = passthroughProps.shadowIntensity) != null ? _j : 0,
2727
- "shadow-softness": (_k = passthroughProps.shadowSoftness) != null ? _k : 0,
2728
- "animation-name": passthroughProps.animationName,
2729
- "animation-crossfade-duration": passthroughProps.animationCrossfadeDuration,
2730
- "variant-name": passthroughProps.variantName,
2731
- orientation: passthroughProps.orientation,
2732
- scale: passthroughProps.scale,
2733
- __self: this,
2734
- __source: {
2735
- fileName: _jsxFileName$4,
2736
- lineNumber: 222,
2737
- columnNumber: 5
2738
- }
2739
- }, children);
2740
- }
2741
- var _jsxFileName$3 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";
2839
+ console.warn(
2840
+ `<ModelViewer/> requires the 'data.alt' prop for accessibility`
2841
+ );
2842
+ }
2843
+ return /* @__PURE__ */ React.createElement(
2844
+ "model-viewer",
2845
+ {
2846
+ ref: callbackRef,
2847
+ ...passthroughProps,
2848
+ className,
2849
+ id: passthroughProps.id ?? data.id,
2850
+ src: data.sources[0].url,
2851
+ alt: data.alt ?? null,
2852
+ "camera-controls": passthroughProps.cameraControls ?? true,
2853
+ poster: (passthroughProps.poster || ((_c = data.previewImage) == null ? void 0 : _c.url)) ?? null,
2854
+ autoplay: passthroughProps.autoplay ?? true,
2855
+ loading: passthroughProps.loading,
2856
+ reveal: passthroughProps.reveal,
2857
+ ar: passthroughProps.ar,
2858
+ "ar-modes": passthroughProps.arModes,
2859
+ "ar-scale": passthroughProps.arScale,
2860
+ "ar-placement": passthroughProps.arPlacement,
2861
+ "ios-src": passthroughProps.iosSrc,
2862
+ "touch-action": passthroughProps.touchAction,
2863
+ "disable-zoom": passthroughProps.disableZoom,
2864
+ "orbit-sensitivity": passthroughProps.orbitSensitivity,
2865
+ "auto-rotate": passthroughProps.autoRotate,
2866
+ "auto-rotate-delay": passthroughProps.autoRotateDelay,
2867
+ "rotation-per-second": passthroughProps.rotationPerSecond,
2868
+ "interaction-policy": passthroughProps.interactionPolicy,
2869
+ "interaction-prompt": passthroughProps.interactionPrompt,
2870
+ "interaction-prompt-style": passthroughProps.interactionPromptStyle,
2871
+ "interaction-prompt-threshold": passthroughProps.interactionPromptThreshold,
2872
+ "camera-orbit": passthroughProps.cameraOrbit,
2873
+ "camera-target": passthroughProps.cameraTarget,
2874
+ "field-of-view": passthroughProps.fieldOfView,
2875
+ "max-camera-orbit": passthroughProps.maxCameraOrbit,
2876
+ "min-camera-orbit": passthroughProps.minCameraOrbit,
2877
+ "max-field-of-view": passthroughProps.maxFieldOfView,
2878
+ "min-field-of-view": passthroughProps.minFieldOfView,
2879
+ bounds: passthroughProps.bounds,
2880
+ "interpolation-decay": passthroughProps.interpolationDecay ?? 100,
2881
+ "skybox-image": passthroughProps.skyboxImage,
2882
+ "environment-image": passthroughProps.environmentImage,
2883
+ exposure: passthroughProps.exposure,
2884
+ "shadow-intensity": passthroughProps.shadowIntensity ?? 0,
2885
+ "shadow-softness": passthroughProps.shadowSoftness ?? 0,
2886
+ "animation-name": passthroughProps.animationName,
2887
+ "animation-crossfade-duration": passthroughProps.animationCrossfadeDuration,
2888
+ "variant-name": passthroughProps.variantName,
2889
+ orientation: passthroughProps.orientation,
2890
+ scale: passthroughProps.scale
2891
+ },
2892
+ children
2893
+ );
2894
+ }
2742
2895
  function MediaFile({
2743
2896
  data,
2744
2897
  mediaOptions,
@@ -2752,56 +2905,40 @@
2752
2905
  throw new Error(noDataImage);
2753
2906
  }
2754
2907
  }
2755
- return /* @__PURE__ */ React__default.default.createElement(Image, {
2756
- ...passthroughProps,
2757
- ...mediaOptions == null ? void 0 : mediaOptions.image,
2758
- data: data.image,
2759
- __self: this,
2760
- __source: {
2761
- fileName: _jsxFileName$3,
2762
- lineNumber: 54,
2763
- columnNumber: 9
2908
+ return /* @__PURE__ */ React.createElement(
2909
+ Image,
2910
+ {
2911
+ ...passthroughProps,
2912
+ ...mediaOptions == null ? void 0 : mediaOptions.image,
2913
+ data: data.image
2764
2914
  }
2765
- });
2915
+ );
2766
2916
  }
2767
2917
  case "Video": {
2768
- return /* @__PURE__ */ React__default.default.createElement(Video, {
2769
- ...passthroughProps,
2770
- ...mediaOptions == null ? void 0 : mediaOptions.video,
2771
- data,
2772
- __self: this,
2773
- __source: {
2774
- fileName: _jsxFileName$3,
2775
- lineNumber: 63,
2776
- columnNumber: 9
2777
- }
2778
- });
2918
+ return /* @__PURE__ */ React.createElement(Video, { ...passthroughProps, ...mediaOptions == null ? void 0 : mediaOptions.video, data });
2779
2919
  }
2780
2920
  case "ExternalVideo": {
2781
- return /* @__PURE__ */ React__default.default.createElement(ExternalVideo, {
2782
- ...passthroughProps,
2783
- ...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
2784
- data,
2785
- __self: this,
2786
- __source: {
2787
- fileName: _jsxFileName$3,
2788
- lineNumber: 68,
2789
- columnNumber: 9
2921
+ return /* @__PURE__ */ React.createElement(
2922
+ ExternalVideo,
2923
+ {
2924
+ ...passthroughProps,
2925
+ ...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
2926
+ data
2790
2927
  }
2791
- });
2928
+ );
2792
2929
  }
2793
2930
  case "Model3d": {
2794
- return /* @__PURE__ */ React__default.default.createElement(ModelViewer, {
2795
- ...passthroughProps,
2796
- ...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
2797
- data,
2798
- __self: this,
2799
- __source: {
2800
- fileName: _jsxFileName$3,
2801
- lineNumber: 78,
2802
- columnNumber: 9
2803
- }
2804
- });
2931
+ return (
2932
+ // @ts-expect-error There are issues with the inferred HTML attribute types here for ModelViewer (and contentEditable), but I think that's a little bit beyond me at the moment
2933
+ /* @__PURE__ */ React.createElement(
2934
+ ModelViewer,
2935
+ {
2936
+ ...passthroughProps,
2937
+ ...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
2938
+ data
2939
+ }
2940
+ )
2941
+ );
2805
2942
  }
2806
2943
  default: {
2807
2944
  const typenameMissingMessage = `<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media.`;
@@ -2812,7 +2949,6 @@
2812
2949
  }
2813
2950
  }
2814
2951
  function parseMetafield(metafield) {
2815
- var _a, _b, _c, _d;
2816
2952
  if (!metafield.type) {
2817
2953
  const noTypeError = `parseMetafield(): The 'type' field is required in order to parse the Metafield.`;
2818
2954
  {
@@ -2859,7 +2995,7 @@
2859
2995
  case "list.weight": {
2860
2996
  let parsedValue = null;
2861
2997
  try {
2862
- parsedValue = parseJSON((_a = metafield.value) != null ? _a : "");
2998
+ parsedValue = parseJSON(metafield.value ?? "");
2863
2999
  } catch (err) {
2864
3000
  const parseError = `parseMetafield(): attempted to JSON.parse the 'metafield.value' property, but failed.`;
2865
3001
  {
@@ -2875,11 +3011,11 @@
2875
3011
  case "date_time":
2876
3012
  return {
2877
3013
  ...metafield,
2878
- parsedValue: new Date((_b = metafield.value) != null ? _b : "")
3014
+ parsedValue: new Date(metafield.value ?? "")
2879
3015
  };
2880
3016
  case "list.date":
2881
3017
  case "list.date_time": {
2882
- const jsonParseValue = parseJSON((_c = metafield == null ? void 0 : metafield.value) != null ? _c : "");
3018
+ const jsonParseValue = parseJSON((metafield == null ? void 0 : metafield.value) ?? "");
2883
3019
  return {
2884
3020
  ...metafield,
2885
3021
  parsedValue: jsonParseValue.map((dateString) => new Date(dateString))
@@ -2898,7 +3034,7 @@
2898
3034
  case "list.variant_reference":
2899
3035
  return {
2900
3036
  ...metafield,
2901
- parsedValue: flattenConnection((_d = metafield.references) != null ? _d : void 0)
3037
+ parsedValue: flattenConnection(metafield.references ?? void 0)
2902
3038
  };
2903
3039
  default: {
2904
3040
  const typeNotFoundError = `parseMetafield(): the 'metafield.type' you passed in is not supported. Your type: "${metafield.type}". If you believe this is an error, please open an issue on GitHub.`;
@@ -2918,17 +3054,20 @@
2918
3054
  return JSON.parse(json);
2919
3055
  }
2920
3056
  function useMoney(money) {
2921
- const {
2922
- locale
2923
- } = useShop();
3057
+ const { locale } = useShop();
2924
3058
  if (!locale) {
2925
- throw new Error(`useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`);
3059
+ throw new Error(
3060
+ `useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`
3061
+ );
2926
3062
  }
2927
3063
  const amount = parseFloat(money.amount);
2928
- const options = React.useMemo(() => ({
2929
- style: "currency",
2930
- currency: money.currencyCode
2931
- }), [money.currencyCode]);
3064
+ const options = React.useMemo(
3065
+ () => ({
3066
+ style: "currency",
3067
+ currency: money.currencyCode
3068
+ }),
3069
+ [money.currencyCode]
3070
+ );
2932
3071
  const defaultFormatter = useLazyFormatter(locale, options);
2933
3072
  const nameFormatter = useLazyFormatter(locale, {
2934
3073
  ...options,
@@ -2949,41 +3088,62 @@
2949
3088
  maximumFractionDigits: 0
2950
3089
  });
2951
3090
  const isPartCurrency = (part) => part.type === "currency";
2952
- const lazyFormatters = React.useMemo(() => ({
2953
- original: () => money,
2954
- currencyCode: () => money.currencyCode,
2955
- localizedString: () => defaultFormatter().format(amount),
2956
- parts: () => defaultFormatter().formatToParts(amount),
2957
- withoutTrailingZeros: () => amount % 1 === 0 ? withoutTrailingZerosFormatter().format(amount) : defaultFormatter().format(amount),
2958
- withoutTrailingZerosAndCurrency: () => amount % 1 === 0 ? withoutTrailingZerosOrCurrencyFormatter().format(amount) : withoutCurrencyFormatter().format(amount),
2959
- currencyName: () => {
2960
- var _a, _b;
2961
- return (_b = (_a = nameFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) != null ? _b : money.currencyCode;
2962
- },
2963
- currencySymbol: () => {
2964
- var _a, _b;
2965
- return (_b = (_a = defaultFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) != null ? _b : money.currencyCode;
2966
- },
2967
- currencyNarrowSymbol: () => {
2968
- var _a, _b;
2969
- return (_b = (_a = narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) != null ? _b : "";
2970
- },
2971
- amount: () => defaultFormatter().formatToParts(amount).filter((part) => ["decimal", "fraction", "group", "integer", "literal"].includes(part.type)).map((part) => part.value).join("")
2972
- }), [money, amount, nameFormatter, defaultFormatter, narrowSymbolFormatter, withoutCurrencyFormatter, withoutTrailingZerosFormatter, withoutTrailingZerosOrCurrencyFormatter]);
2973
- return React.useMemo(() => new Proxy(lazyFormatters, {
2974
- get: (target, key) => {
2975
- var _a;
2976
- return (_a = Reflect.get(target, key)) == null ? void 0 : _a.call(null);
2977
- }
2978
- }), [lazyFormatters]);
3091
+ const lazyFormatters = React.useMemo(
3092
+ () => ({
3093
+ original: () => money,
3094
+ currencyCode: () => money.currencyCode,
3095
+ localizedString: () => defaultFormatter().format(amount),
3096
+ parts: () => defaultFormatter().formatToParts(amount),
3097
+ withoutTrailingZeros: () => amount % 1 === 0 ? withoutTrailingZerosFormatter().format(amount) : defaultFormatter().format(amount),
3098
+ withoutTrailingZerosAndCurrency: () => amount % 1 === 0 ? withoutTrailingZerosOrCurrencyFormatter().format(amount) : withoutCurrencyFormatter().format(amount),
3099
+ currencyName: () => {
3100
+ var _a;
3101
+ return ((_a = nameFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? money.currencyCode;
3102
+ },
3103
+ // e.g. "US dollars"
3104
+ currencySymbol: () => {
3105
+ var _a;
3106
+ return ((_a = defaultFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? money.currencyCode;
3107
+ },
3108
+ // e.g. "USD"
3109
+ currencyNarrowSymbol: () => {
3110
+ var _a;
3111
+ return ((_a = narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)) == null ? void 0 : _a.value) ?? "";
3112
+ },
3113
+ // e.g. "$"
3114
+ amount: () => defaultFormatter().formatToParts(amount).filter(
3115
+ (part) => ["decimal", "fraction", "group", "integer", "literal"].includes(
3116
+ part.type
3117
+ )
3118
+ ).map((part) => part.value).join("")
3119
+ }),
3120
+ [
3121
+ money,
3122
+ amount,
3123
+ nameFormatter,
3124
+ defaultFormatter,
3125
+ narrowSymbolFormatter,
3126
+ withoutCurrencyFormatter,
3127
+ withoutTrailingZerosFormatter,
3128
+ withoutTrailingZerosOrCurrencyFormatter
3129
+ ]
3130
+ );
3131
+ return React.useMemo(
3132
+ () => new Proxy(lazyFormatters, {
3133
+ get: (target, key) => {
3134
+ var _a;
3135
+ return (_a = Reflect.get(target, key)) == null ? void 0 : _a.call(null);
3136
+ }
3137
+ }),
3138
+ [lazyFormatters]
3139
+ );
2979
3140
  }
2980
3141
  function useLazyFormatter(locale, options) {
2981
3142
  return React.useMemo(() => {
2982
3143
  let memoized;
2983
- return () => memoized != null ? memoized : memoized = new Intl.NumberFormat(locale, options);
3144
+ return () => memoized ?? (memoized = new Intl.NumberFormat(locale, options));
2984
3145
  }, [locale, options]);
2985
3146
  }
2986
- var _jsxFileName$2 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";
2987
3147
  function Money({
2988
3148
  data,
2989
3149
  as,
@@ -2994,10 +3154,12 @@
2994
3154
  ...passthroughProps
2995
3155
  }) {
2996
3156
  if (!isMoney(data)) {
2997
- throw new Error(`<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`);
3157
+ throw new Error(
3158
+ `<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`
3159
+ );
2998
3160
  }
2999
3161
  const moneyObject = useMoney(data);
3000
- const Wrapper = as != null ? as : "div";
3162
+ const Wrapper = as ?? "div";
3001
3163
  let output = moneyObject.localizedString;
3002
3164
  if (withoutCurrency || withoutTrailingZeros) {
3003
3165
  if (withoutCurrency && !withoutTrailingZeros) {
@@ -3008,22 +3170,13 @@
3008
3170
  output = moneyObject.withoutTrailingZerosAndCurrency;
3009
3171
  }
3010
3172
  }
3011
- return /* @__PURE__ */ React__default.default.createElement(Wrapper, {
3012
- ...passthroughProps,
3013
- __self: this,
3014
- __source: {
3015
- fileName: _jsxFileName$2,
3016
- lineNumber: 65,
3017
- columnNumber: 5
3018
- }
3019
- }, output, measurement && measurement.referenceUnit && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, measurementSeparator, measurement.referenceUnit));
3173
+ return /* @__PURE__ */ React.createElement(Wrapper, { ...passthroughProps }, output, measurement && measurement.referenceUnit && /* @__PURE__ */ React.createElement(React.Fragment, null, measurementSeparator, measurement.referenceUnit));
3020
3174
  }
3021
3175
  function isMoney(maybeMoney) {
3022
3176
  return typeof maybeMoney.amount === "string" && !!maybeMoney.amount && typeof maybeMoney.currencyCode === "string" && !!maybeMoney.currencyCode;
3023
3177
  }
3024
- var _jsxFileName$1 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";
3025
3178
  function ProductPrice(props) {
3026
- var _a, _b, _c, _d, _e, _f, _g, _h;
3179
+ var _a, _b, _c, _d, _e, _f;
3027
3180
  const {
3028
3181
  priceType = "regular",
3029
3182
  variantId,
@@ -3036,17 +3189,19 @@
3036
3189
  }
3037
3190
  let price;
3038
3191
  let measurement;
3039
- const variant = variantId ? (_b = flattenConnection((_a = product == null ? void 0 : product.variants) != null ? _a : {}).find((variant2) => (variant2 == null ? void 0 : variant2.id) === variantId)) != null ? _b : null : null;
3192
+ const variant = variantId ? flattenConnection((product == null ? void 0 : product.variants) ?? {}).find(
3193
+ (variant2) => (variant2 == null ? void 0 : variant2.id) === variantId
3194
+ ) ?? null : null;
3040
3195
  if (priceType === "compareAt") {
3041
3196
  if (variantId && variant) {
3042
- if (((_c = variant.compareAtPriceV2) == null ? void 0 : _c.amount) === ((_d = variant.priceV2) == null ? void 0 : _d.amount)) {
3197
+ if (((_a = variant.compareAtPriceV2) == null ? void 0 : _a.amount) === ((_b = variant.priceV2) == null ? void 0 : _b.amount)) {
3043
3198
  return null;
3044
3199
  }
3045
3200
  price = variant.compareAtPriceV2;
3046
3201
  } else if (valueType === "max") {
3047
- price = (_e = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _e.maxVariantPrice;
3202
+ price = (_c = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _c.maxVariantPrice;
3048
3203
  } else {
3049
- price = (_f = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _f.minVariantPrice;
3204
+ price = (_d = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _d.minVariantPrice;
3050
3205
  }
3051
3206
  } else {
3052
3207
  if (variantId && variant) {
@@ -3056,39 +3211,19 @@
3056
3211
  measurement = variant.unitPriceMeasurement;
3057
3212
  }
3058
3213
  } else if (valueType === "max") {
3059
- price = (_g = product.priceRange) == null ? void 0 : _g.maxVariantPrice;
3214
+ price = (_e = product.priceRange) == null ? void 0 : _e.maxVariantPrice;
3060
3215
  } else {
3061
- price = (_h = product.priceRange) == null ? void 0 : _h.minVariantPrice;
3216
+ price = (_f = product.priceRange) == null ? void 0 : _f.minVariantPrice;
3062
3217
  }
3063
3218
  }
3064
3219
  if (!price) {
3065
3220
  return null;
3066
3221
  }
3067
3222
  if (measurement) {
3068
- return /* @__PURE__ */ React__default.default.createElement(Money, {
3069
- ...passthroughProps,
3070
- data: price,
3071
- measurement,
3072
- __self: this,
3073
- __source: {
3074
- fileName: _jsxFileName$1,
3075
- lineNumber: 81,
3076
- columnNumber: 7
3077
- }
3078
- });
3223
+ return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: price, measurement });
3079
3224
  }
3080
- return /* @__PURE__ */ React__default.default.createElement(Money, {
3081
- ...passthroughProps,
3082
- data: price,
3083
- __self: this,
3084
- __source: {
3085
- fileName: _jsxFileName$1,
3086
- lineNumber: 85,
3087
- columnNumber: 10
3088
- }
3089
- });
3225
+ return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: price });
3090
3226
  }
3091
- var _jsxFileName = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";
3092
3227
  const SHOPJS_URL = "https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";
3093
3228
  function ShopPayButton({
3094
3229
  variantIds,
@@ -3096,9 +3231,7 @@
3096
3231
  variantIdsAndQuantities,
3097
3232
  width
3098
3233
  }) {
3099
- const {
3100
- storeDomain
3101
- } = useShop();
3234
+ const { storeDomain } = useShop();
3102
3235
  const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);
3103
3236
  let ids;
3104
3237
  if (variantIds && variantIdsAndQuantities) {
@@ -3114,10 +3247,9 @@
3114
3247
  }, []);
3115
3248
  } else if (variantIdsAndQuantities) {
3116
3249
  ids = variantIdsAndQuantities.reduce((prev, curr) => {
3117
- var _a;
3118
3250
  const bareId = getIdFromGid(curr == null ? void 0 : curr.id);
3119
3251
  if (bareId) {
3120
- prev.push(`${bareId}:${(_a = curr == null ? void 0 : curr.quantity) != null ? _a : 1}`);
3252
+ prev.push(`${bareId}:${(curr == null ? void 0 : curr.quantity) ?? 1}`);
3121
3253
  }
3122
3254
  return prev;
3123
3255
  }, []);
@@ -3127,25 +3259,7 @@
3127
3259
  const style = width ? {
3128
3260
  "--shop-pay-button-width": width
3129
3261
  } : void 0;
3130
- return /* @__PURE__ */ React__default.default.createElement("div", {
3131
- className,
3132
- style,
3133
- __self: this,
3134
- __source: {
3135
- fileName: _jsxFileName,
3136
- lineNumber: 90,
3137
- columnNumber: 5
3138
- }
3139
- }, shopPayLoadedStatus === "done" && /* @__PURE__ */ React__default.default.createElement("shop-pay-button", {
3140
- "store-url": storeDomain,
3141
- variants: ids.join(","),
3142
- __self: this,
3143
- __source: {
3144
- fileName: _jsxFileName,
3145
- lineNumber: 92,
3146
- columnNumber: 9
3147
- }
3148
- }));
3262
+ return /* @__PURE__ */ React.createElement("div", { className, style }, shopPayLoadedStatus === "done" && /* @__PURE__ */ React.createElement("shop-pay-button", { "store-url": storeDomain, variants: ids.join(",") }));
3149
3263
  }
3150
3264
  function getIdFromGid(id) {
3151
3265
  if (!id)
@@ -3176,6 +3290,6 @@
3176
3290
  exports2.useMoney = useMoney;
3177
3291
  exports2.useProduct = useProduct;
3178
3292
  exports2.useShop = useShop;
3179
- Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3293
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
3180
3294
  });
3181
3295
  //# sourceMappingURL=hydrogen-react.dev.js.map