@shopify/hydrogen-react 0.0.0-next-7fb60a6 → 0.0.0-next-10065ee

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 (242) hide show
  1. package/README.md +6 -4
  2. package/dist/dev/CartProvider.cjs +485 -0
  3. package/dist/dev/CartProvider.cjs.map +1 -0
  4. package/dist/dev/CartProvider.js +485 -0
  5. package/dist/dev/CartProvider.js.map +1 -0
  6. package/dist/dev/Metafield.cjs +2 -2
  7. package/dist/dev/Metafield.cjs.map +1 -1
  8. package/dist/dev/ModelViewer.cjs +4 -4
  9. package/dist/dev/ModelViewer.cjs.map +1 -1
  10. package/dist/dev/ProductProvider.cjs +14 -14
  11. package/dist/dev/ProductProvider.cjs.map +1 -1
  12. package/dist/dev/ShopifyProvider.cjs +4 -4
  13. package/dist/dev/ShopifyProvider.cjs.map +1 -1
  14. package/dist/dev/Video.cjs +2 -2
  15. package/dist/dev/_virtual/index.cjs +5 -0
  16. package/dist/dev/_virtual/index.cjs.map +1 -0
  17. package/dist/dev/_virtual/index.js +5 -0
  18. package/dist/dev/_virtual/index.js.map +1 -0
  19. package/dist/dev/_virtual/use-sync-external-store-shim.development.cjs +5 -0
  20. package/dist/dev/_virtual/use-sync-external-store-shim.development.cjs.map +1 -0
  21. package/dist/dev/_virtual/use-sync-external-store-shim.development.js +5 -0
  22. package/dist/dev/_virtual/use-sync-external-store-shim.development.js.map +1 -0
  23. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.cjs +5 -0
  24. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.cjs.map +1 -0
  25. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js +5 -0
  26. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
  27. package/dist/dev/_virtual/with-selector.cjs +5 -0
  28. package/dist/dev/_virtual/with-selector.cjs.map +1 -0
  29. package/dist/dev/_virtual/with-selector.development.cjs +5 -0
  30. package/dist/dev/_virtual/with-selector.development.cjs.map +1 -0
  31. package/dist/dev/_virtual/with-selector.development.js +5 -0
  32. package/dist/dev/_virtual/with-selector.development.js.map +1 -0
  33. package/dist/dev/_virtual/with-selector.js +5 -0
  34. package/dist/dev/_virtual/with-selector.js.map +1 -0
  35. package/dist/dev/_virtual/with-selector.production.min.cjs +5 -0
  36. package/dist/dev/_virtual/with-selector.production.min.cjs.map +1 -0
  37. package/dist/dev/_virtual/with-selector.production.min.js +5 -0
  38. package/dist/dev/_virtual/with-selector.production.min.js.map +1 -0
  39. package/dist/dev/cart-constants.cjs +17 -0
  40. package/dist/dev/cart-constants.cjs.map +1 -0
  41. package/dist/dev/cart-constants.js +17 -0
  42. package/dist/dev/cart-constants.js.map +1 -0
  43. package/dist/dev/cart-hooks.cjs +89 -0
  44. package/dist/dev/cart-hooks.cjs.map +1 -0
  45. package/dist/dev/cart-hooks.js +89 -0
  46. package/dist/dev/cart-hooks.js.map +1 -0
  47. package/dist/dev/cart-queries.cjs +216 -0
  48. package/dist/dev/cart-queries.cjs.map +1 -0
  49. package/dist/dev/cart-queries.js +216 -0
  50. package/dist/dev/cart-queries.js.map +1 -0
  51. package/dist/dev/flatten-connection.cjs +6 -0
  52. package/dist/dev/flatten-connection.cjs.map +1 -1
  53. package/dist/dev/flatten-connection.js +6 -0
  54. package/dist/dev/flatten-connection.js.map +1 -1
  55. package/dist/dev/index.cjs +6 -0
  56. package/dist/dev/index.cjs.map +1 -1
  57. package/dist/dev/index.js +6 -0
  58. package/dist/dev/index.js.map +1 -1
  59. package/dist/dev/load-script.cjs +3 -3
  60. package/dist/dev/load-script.cjs.map +1 -1
  61. package/dist/dev/node_modules/@xstate/fsm/es/index.cjs +158 -0
  62. package/dist/dev/node_modules/@xstate/fsm/es/index.cjs.map +1 -0
  63. package/dist/dev/node_modules/@xstate/fsm/es/index.js +159 -0
  64. package/dist/dev/node_modules/@xstate/fsm/es/index.js.map +1 -0
  65. package/dist/dev/node_modules/@xstate/react/es/fsm.cjs +94 -0
  66. package/dist/dev/node_modules/@xstate/react/es/fsm.cjs.map +1 -0
  67. package/dist/dev/node_modules/@xstate/react/es/fsm.js +94 -0
  68. package/dist/dev/node_modules/@xstate/react/es/fsm.js.map +1 -0
  69. package/dist/dev/node_modules/@xstate/react/es/useConstant.cjs +30 -0
  70. package/dist/dev/node_modules/@xstate/react/es/useConstant.cjs.map +1 -0
  71. package/dist/dev/node_modules/@xstate/react/es/useConstant.js +12 -0
  72. package/dist/dev/node_modules/@xstate/react/es/useConstant.js.map +1 -0
  73. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs +5 -0
  74. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs.map +1 -0
  75. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +6 -0
  76. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -0
  77. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs +107 -0
  78. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs.map +1 -0
  79. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +105 -0
  80. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
  81. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs +74 -0
  82. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs.map +1 -0
  83. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +72 -0
  84. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
  85. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs +138 -0
  86. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map +1 -0
  87. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +136 -0
  88. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
  89. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs +60 -0
  90. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs.map +1 -0
  91. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +58 -0
  92. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -0
  93. package/dist/dev/node_modules/use-sync-external-store/shim/index.cjs +21 -0
  94. package/dist/dev/node_modules/use-sync-external-store/shim/index.cjs.map +1 -0
  95. package/dist/dev/node_modules/use-sync-external-store/shim/index.js +21 -0
  96. package/dist/dev/node_modules/use-sync-external-store/shim/index.js.map +1 -0
  97. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.cjs +12 -0
  98. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.cjs.map +1 -0
  99. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js +11 -0
  100. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
  101. package/dist/dev/node_modules/worktop/cookie/index.cjs +27 -0
  102. package/dist/dev/node_modules/worktop/cookie/index.cjs.map +1 -0
  103. package/dist/dev/node_modules/worktop/cookie/index.js +27 -0
  104. package/dist/dev/node_modules/worktop/cookie/index.js.map +1 -0
  105. package/dist/dev/useCartAPIStateMachine.cjs +326 -0
  106. package/dist/dev/useCartAPIStateMachine.cjs.map +1 -0
  107. package/dist/dev/useCartAPIStateMachine.js +326 -0
  108. package/dist/dev/useCartAPIStateMachine.js.map +1 -0
  109. package/dist/dev/useCartActions.cjs +123 -0
  110. package/dist/dev/useCartActions.cjs.map +1 -0
  111. package/dist/dev/useCartActions.js +123 -0
  112. package/dist/dev/useCartActions.js.map +1 -0
  113. package/dist/dev/useMoney.cjs +5 -5
  114. package/dist/dev/useMoney.cjs.map +1 -1
  115. package/dist/prod/CartProvider.cjs +485 -0
  116. package/dist/prod/CartProvider.cjs.map +1 -0
  117. package/dist/prod/CartProvider.js +485 -0
  118. package/dist/prod/CartProvider.js.map +1 -0
  119. package/dist/prod/Metafield.cjs +2 -2
  120. package/dist/prod/Metafield.cjs.map +1 -1
  121. package/dist/prod/ModelViewer.cjs +4 -4
  122. package/dist/prod/ModelViewer.cjs.map +1 -1
  123. package/dist/prod/ProductProvider.cjs +14 -14
  124. package/dist/prod/ProductProvider.cjs.map +1 -1
  125. package/dist/prod/ShopifyProvider.cjs +4 -4
  126. package/dist/prod/ShopifyProvider.cjs.map +1 -1
  127. package/dist/prod/Video.cjs +2 -2
  128. package/dist/prod/_virtual/index.cjs +5 -0
  129. package/dist/prod/_virtual/index.cjs.map +1 -0
  130. package/dist/prod/_virtual/index.js +5 -0
  131. package/dist/prod/_virtual/index.js.map +1 -0
  132. package/dist/prod/_virtual/use-sync-external-store-shim.development.cjs +5 -0
  133. package/dist/prod/_virtual/use-sync-external-store-shim.development.cjs.map +1 -0
  134. package/dist/prod/_virtual/use-sync-external-store-shim.development.js +5 -0
  135. package/dist/prod/_virtual/use-sync-external-store-shim.development.js.map +1 -0
  136. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.cjs +5 -0
  137. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.cjs.map +1 -0
  138. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js +5 -0
  139. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
  140. package/dist/prod/_virtual/with-selector.cjs +5 -0
  141. package/dist/prod/_virtual/with-selector.cjs.map +1 -0
  142. package/dist/prod/_virtual/with-selector.development.cjs +5 -0
  143. package/dist/prod/_virtual/with-selector.development.cjs.map +1 -0
  144. package/dist/prod/_virtual/with-selector.development.js +5 -0
  145. package/dist/prod/_virtual/with-selector.development.js.map +1 -0
  146. package/dist/prod/_virtual/with-selector.js +5 -0
  147. package/dist/prod/_virtual/with-selector.js.map +1 -0
  148. package/dist/prod/_virtual/with-selector.production.min.cjs +5 -0
  149. package/dist/prod/_virtual/with-selector.production.min.cjs.map +1 -0
  150. package/dist/prod/_virtual/with-selector.production.min.js +5 -0
  151. package/dist/prod/_virtual/with-selector.production.min.js.map +1 -0
  152. package/dist/prod/cart-constants.cjs +17 -0
  153. package/dist/prod/cart-constants.cjs.map +1 -0
  154. package/dist/prod/cart-constants.js +17 -0
  155. package/dist/prod/cart-constants.js.map +1 -0
  156. package/dist/prod/cart-hooks.cjs +89 -0
  157. package/dist/prod/cart-hooks.cjs.map +1 -0
  158. package/dist/prod/cart-hooks.js +89 -0
  159. package/dist/prod/cart-hooks.js.map +1 -0
  160. package/dist/prod/cart-queries.cjs +216 -0
  161. package/dist/prod/cart-queries.cjs.map +1 -0
  162. package/dist/prod/cart-queries.js +216 -0
  163. package/dist/prod/cart-queries.js.map +1 -0
  164. package/dist/prod/flatten-connection.cjs +7 -0
  165. package/dist/prod/flatten-connection.cjs.map +1 -1
  166. package/dist/prod/flatten-connection.js +7 -0
  167. package/dist/prod/flatten-connection.js.map +1 -1
  168. package/dist/prod/index.cjs +6 -0
  169. package/dist/prod/index.cjs.map +1 -1
  170. package/dist/prod/index.js +6 -0
  171. package/dist/prod/index.js.map +1 -1
  172. package/dist/prod/load-script.cjs +3 -3
  173. package/dist/prod/load-script.cjs.map +1 -1
  174. package/dist/prod/node_modules/@xstate/fsm/es/index.cjs +158 -0
  175. package/dist/prod/node_modules/@xstate/fsm/es/index.cjs.map +1 -0
  176. package/dist/prod/node_modules/@xstate/fsm/es/index.js +159 -0
  177. package/dist/prod/node_modules/@xstate/fsm/es/index.js.map +1 -0
  178. package/dist/prod/node_modules/@xstate/react/es/fsm.cjs +94 -0
  179. package/dist/prod/node_modules/@xstate/react/es/fsm.cjs.map +1 -0
  180. package/dist/prod/node_modules/@xstate/react/es/fsm.js +94 -0
  181. package/dist/prod/node_modules/@xstate/react/es/fsm.js.map +1 -0
  182. package/dist/prod/node_modules/@xstate/react/es/useConstant.cjs +30 -0
  183. package/dist/prod/node_modules/@xstate/react/es/useConstant.cjs.map +1 -0
  184. package/dist/prod/node_modules/@xstate/react/es/useConstant.js +12 -0
  185. package/dist/prod/node_modules/@xstate/react/es/useConstant.js.map +1 -0
  186. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs +5 -0
  187. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs.map +1 -0
  188. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +6 -0
  189. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -0
  190. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs +107 -0
  191. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs.map +1 -0
  192. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +105 -0
  193. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
  194. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs +74 -0
  195. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs.map +1 -0
  196. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +72 -0
  197. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
  198. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs +138 -0
  199. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map +1 -0
  200. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +136 -0
  201. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
  202. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs +60 -0
  203. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs.map +1 -0
  204. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +58 -0
  205. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -0
  206. package/dist/prod/node_modules/use-sync-external-store/shim/index.cjs +21 -0
  207. package/dist/prod/node_modules/use-sync-external-store/shim/index.cjs.map +1 -0
  208. package/dist/prod/node_modules/use-sync-external-store/shim/index.js +21 -0
  209. package/dist/prod/node_modules/use-sync-external-store/shim/index.js.map +1 -0
  210. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.cjs +12 -0
  211. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.cjs.map +1 -0
  212. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js +11 -0
  213. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
  214. package/dist/prod/node_modules/worktop/cookie/index.cjs +27 -0
  215. package/dist/prod/node_modules/worktop/cookie/index.cjs.map +1 -0
  216. package/dist/prod/node_modules/worktop/cookie/index.js +27 -0
  217. package/dist/prod/node_modules/worktop/cookie/index.js.map +1 -0
  218. package/dist/prod/useCartAPIStateMachine.cjs +326 -0
  219. package/dist/prod/useCartAPIStateMachine.cjs.map +1 -0
  220. package/dist/prod/useCartAPIStateMachine.js +326 -0
  221. package/dist/prod/useCartAPIStateMachine.js.map +1 -0
  222. package/dist/prod/useCartActions.cjs +123 -0
  223. package/dist/prod/useCartActions.cjs.map +1 -0
  224. package/dist/prod/useCartActions.js +123 -0
  225. package/dist/prod/useCartActions.js.map +1 -0
  226. package/dist/prod/useMoney.cjs +5 -5
  227. package/dist/prod/useMoney.cjs.map +1 -1
  228. package/dist/types/CartProvider.d.ts +61 -0
  229. package/dist/types/cart-constants.d.ts +8 -0
  230. package/dist/types/cart-hooks.d.ts +24 -0
  231. package/dist/types/cart-queries.d.ts +10 -0
  232. package/dist/types/cart-types.d.ts +289 -0
  233. package/dist/types/flatten-connection.d.ts +3 -1
  234. package/dist/types/index.d.cts +3 -0
  235. package/dist/types/index.d.ts +3 -0
  236. package/dist/types/useCartAPIStateMachine.d.ts +25 -0
  237. package/dist/types/useCartActions.d.ts +64 -0
  238. package/dist/umd/hydrogen-react.dev.js +1941 -94
  239. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  240. package/dist/umd/hydrogen-react.prod.js +339 -2
  241. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  242. package/package.json +16 -12
@@ -1,3 +1,340 @@
1
- (function(b,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],g):(b=typeof globalThis<"u"?globalThis:b||self,g(b.hydrogenreact={},b.React))})(this,function(b,g){"use strict";const Q=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function R(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const h=Q(g),ee=R(g);var re="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";function F(e){var d,f;const{data:r,options:t,id:i=r.id,frameBorder:a="0",allow:o="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:u=!0,loading:n="lazy",...l}=e;if(!r.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let c=r.embedUrl;if(t){const m=new URL(r.embedUrl);for(const y of Object.keys(t))m.searchParams.set(y,t[y]);c=m.toString()}return h.default.createElement("iframe",{...l,id:i!=null?i:r.embedUrl,title:(f=(d=r.alt)!=null?d:r.id)!=null?f:"external video",frameBorder:a,allow:o,allowFullScreen:u,src:c,loading:n,__self:this,__source:{fileName:re,lineNumber:56,columnNumber:5}})}function E(e){return e.nodes?e.nodes:e.edges?e.edges.map(r=>{if(!(r!=null&&r.node))throw new Error("Connection edges must contain nodes");return r.node}):[]}const ne=["cdn.shopify.com","cdn.shopifycdn.net","shopify-assets.shopifycdn.com","shopify-assets.shopifycdn.net"],te=["spin.dev"],oe=[...ne,...te],M=[352,832,1200,1920,2560];function D({src:e,width:r,height:t,crop:i,scale:a}){const o=new URL(e),u=a!=null?a:1;if(r){let n;typeof r=="string"?n=(M[0]*u).toString():n=(Number(r)*u).toString(),o.searchParams.append("width",n)}return t&&typeof t=="number"&&o.searchParams.append("height",(t*u).toString()),i&&o.searchParams.append("crop",i),o.toString()}function j(e){const r=new URL(e.src);return!oe.some(i=>r.hostname.endsWith(i))||!e.width&&!e.height&&!e.crop&&!e.scale?e.src:D(e)}function ie({data:e,loaderOptions:r,elementProps:t}){var a,o,u,n,l,c;let i=null;return(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&(i=(e==null?void 0:e.width)/(e==null?void 0:e.height)),(r==null?void 0:r.width)||(r==null?void 0:r.height)?{width:(a=r==null?void 0:r.width)!=null?a:i&&typeof r.height=="number"?Math.round(i*r.height):null,height:(o=r==null?void 0:r.height)!=null?o:i&&typeof r.width=="number"?Math.round(i*r.width):null}:(t==null?void 0:t.width)||(t==null?void 0:t.height)?{width:(u=t==null?void 0:t.width)!=null?u:i&&typeof t.height=="number"?Math.round(i*t.height):null,height:(n=t==null?void 0:t.height)!=null?n:i&&typeof t.width=="number"?Math.round(i*t.width):null}:(e==null?void 0:e.width)||(e==null?void 0:e.height)?{width:(l=e==null?void 0:e.width)!=null?l:null,height:(c=e==null?void 0:e.height)!=null?c:null}:{width:null,height:null}}var ae="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";function P({data:e,width:r,height:t,loading:i,loader:a=j,loaderOptions:o,widths:u,decoding:n="async",...l}){var N,v,s,_,S,p;if(!e.url){const A=`<Image/>: the 'data' prop requires the 'url' property. Image: ${(N=e.id)!=null?N:"no ID provided"}`;return console.error(A),null}const{width:c,height:d}=ie({data:e,loaderOptions:o,elementProps:{width:r,height:t}});let f=e.url;if(a&&(f=a({...o,src:e.url,width:c,height:d}),typeof f!="string"||!f))throw new Error(`<Image/>: 'loader' did not return a valid string. Image: ${(v=e.id)!=null?v:e.url}`);const m=r&&c&&r<c?r:c,y=(s=l.srcSet)!=null?s:ue({...o,widths:u,src:e.url,width:m,height:d,loader:a});return ee.createElement("img",{id:(_=e.id)!=null?_:"",alt:(p=(S=e.altText)!=null?S:l.alt)!=null?p:"",loading:i!=null?i:"lazy",...l,src:f,width:c!=null?c:void 0,height:d!=null?d:void 0,srcSet:y,decoding:n,__self:this,__source:{fileName:ae,lineNumber:150,columnNumber:5}})}function ue({src:e,width:r,crop:t,scale:i,widths:a,loader:o,height:u}){const n=a&&Array.isArray(a);if(n&&a.some(f=>isNaN(f)))throw new Error(`<Image/>: the 'widths' must be an array of numbers. Image: ${e}`);let l=1;r&&u&&(l=Number(u)/Number(r));let c=n?a:M;!n&&r&&r<M[M.length-1]&&(c=M.filter(f=>f<=r));const d=o||D;return c.map(f=>`${d({src:e,width:f,height:t?Number(f)*l:void 0,crop:t,scale:i})} ${f}w`).join(", ")}var U="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Video.tsx";function x(e){var c,d;const{data:r,previewImageOptions:t,id:i=r.id,playsInline:a=!0,controls:o=!0,sourceProps:u={},...n}=e,l=j({src:(d=(c=r.previewImage)==null?void 0:c.url)!=null?d:"",...t});if(!r.sources)throw new Error("<Video/> requires a 'data.sources' array");return h.default.createElement("video",{...n,id:i,playsInline:a,controls:o,poster:l,__self:this,__source:{fileName:U,lineNumber:42,columnNumber:5}},r.sources.map(f=>{if(!((f==null?void 0:f.url)&&(f==null?void 0:f.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return h.default.createElement("source",{...u,key:f.url,src:f.url,type:f.mimeType,__self:this,__source:{fileName:U,lineNumber:54,columnNumber:11}})}))}const $={};function le(e,r){const t=$[e];if(t)return t;const i=new Promise((a,o)=>{const u=document.createElement("script");r!=null&&r.module?u.type="module":u.type="text/javascript",u.src=e,u.onload=()=>{a(!0)},u.onerror=()=>{o(!1)},(r==null?void 0:r.in)==="head"?document.head.appendChild(u):document.body.appendChild(u)});return $[e]=i,i}function q(e,r){const[t,i]=g.useState("loading"),a=JSON.stringify(r);return g.useEffect(()=>{async function o(){try{i("loading"),await le(e,r),i("done")}catch{i("error")}}o()},[e,a,r]),t}var ce="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";function W(e){var c,d,f,m,y,N,v,s,_,S,p;const[r,t]=g.useState(void 0),i=g.useCallback(A=>{t(A)},[]),{data:a,children:o,className:u,...n}=e,l=q("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return g.useEffect(()=>{if(!!r)return n.onError&&r.addEventListener("error",n.onError),n.onLoad&&r.addEventListener("load",n.onLoad),n.onPreload&&r.addEventListener("preload",n.onPreload),n.onModelVisibility&&r.addEventListener("model-visibility",n.onModelVisibility),n.onProgress&&r.addEventListener("progress",n.onProgress),n.onArStatus&&r.addEventListener("ar-status",n.onArStatus),n.onArTracking&&r.addEventListener("ar-tracking",n.onArTracking),n.onQuickLookButtonTapped&&r.addEventListener("quick-look-button-tapped",n.onQuickLookButtonTapped),n.onCameraChange&&r.addEventListener("camera-change",n.onCameraChange),n.onEnvironmentChange&&r.addEventListener("environment-change",n.onEnvironmentChange),n.onPlay&&r.addEventListener("play",n.onPlay),n.onPause&&r.addEventListener("ar-status",n.onPause),n.onSceneGraphReady&&r.addEventListener("scene-graph-ready",n.onSceneGraphReady),()=>{r!=null&&(n.onError&&r.removeEventListener("error",n.onError),n.onLoad&&r.removeEventListener("load",n.onLoad),n.onPreload&&r.removeEventListener("preload",n.onPreload),n.onModelVisibility&&r.removeEventListener("model-visibility",n.onModelVisibility),n.onProgress&&r.removeEventListener("progress",n.onProgress),n.onArStatus&&r.removeEventListener("ar-status",n.onArStatus),n.onArTracking&&r.removeEventListener("ar-tracking",n.onArTracking),n.onQuickLookButtonTapped&&r.removeEventListener("quick-look-button-tapped",n.onQuickLookButtonTapped),n.onCameraChange&&r.removeEventListener("camera-change",n.onCameraChange),n.onEnvironmentChange&&r.removeEventListener("environment-change",n.onEnvironmentChange),n.onPlay&&r.removeEventListener("play",n.onPlay),n.onPause&&r.removeEventListener("ar-status",n.onPause),n.onSceneGraphReady&&r.removeEventListener("scene-graph-ready",n.onSceneGraphReady))}},[r,n.onArStatus,n.onArTracking,n.onCameraChange,n.onEnvironmentChange,n.onError,n.onLoad,n.onModelVisibility,n.onPause,n.onPlay,n.onPreload,n.onProgress,n.onQuickLookButtonTapped,n.onSceneGraphReady]),l!=="done"?null:(d=(c=a.sources)==null?void 0:c[0])!=null&&d.url?h.default.createElement("model-viewer",{ref:i,...n,className:u,id:(f=n.id)!=null?f:a.id,src:a.sources[0].url,alt:(m=a.alt)!=null?m:null,"camera-controls":(y=n.cameraControls)!=null?y:!0,poster:(v=n.poster||((N=a.previewImage)==null?void 0:N.url))!=null?v:null,autoplay:(s=n.autoplay)!=null?s:!0,loading:n.loading,reveal:n.reveal,ar:n.ar,"ar-modes":n.arModes,"ar-scale":n.arScale,"ar-placement":n.arPlacement,"ios-src":n.iosSrc,"touch-action":n.touchAction,"disable-zoom":n.disableZoom,"orbit-sensitivity":n.orbitSensitivity,"auto-rotate":n.autoRotate,"auto-rotate-delay":n.autoRotateDelay,"rotation-per-second":n.rotationPerSecond,"interaction-policy":n.interactionPolicy,"interaction-prompt":n.interactionPrompt,"interaction-prompt-style":n.interactionPromptStyle,"interaction-prompt-threshold":n.interactionPromptThreshold,"camera-orbit":n.cameraOrbit,"camera-target":n.cameraTarget,"field-of-view":n.fieldOfView,"max-camera-orbit":n.maxCameraOrbit,"min-camera-orbit":n.minCameraOrbit,"max-field-of-view":n.maxFieldOfView,"min-field-of-view":n.minFieldOfView,bounds:n.bounds,"interpolation-decay":(_=n.interpolationDecay)!=null?_:100,"skybox-image":n.skyboxImage,"environment-image":n.environmentImage,exposure:n.exposure,"shadow-intensity":(S=n.shadowIntensity)!=null?S:0,"shadow-softness":(p=n.shadowSoftness)!=null?p:0,"animation-name":n.animationName,"animation-crossfade-duration":n.animationCrossfadeDuration,"variant-name":n.variantName,orientation:n.orientation,scale:n.scale,__self:this,__source:{fileName:ce,lineNumber:222,columnNumber:5}},o):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}var T="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";function se({data:e,mediaOptions:r,...t}){switch(e.__typename){case"MediaImage":return e.image?h.default.createElement(P,{...t,...r==null?void 0:r.image,data:e.image,__self:this,__source:{fileName:T,lineNumber:50,columnNumber:9}}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return h.default.createElement(x,{...t,...r==null?void 0:r.video,data:e,__self:this,__source:{fileName:T,lineNumber:59,columnNumber:9}});case"ExternalVideo":return h.default.createElement(F,{...t,...r==null?void 0:r.externalVideo,data:e,__self:this,__source:{fileName:T,lineNumber:64,columnNumber:9}});case"Model3d":return h.default.createElement(W,{...t,...r==null?void 0:r.modelViewer,data:e,__self:this,__source:{fileName:T,lineNumber:73,columnNumber:9}});default:return console.error("<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to correctly render the correct component for this media. Rendering 'null' by default"),null}}const C="2022-07";var fe="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";const I=g.createContext({storeDomain:"test.myshopify.com",storefrontToken:"abc123",storefrontApiVersion:C,country:{isoCode:"US"},language:{isoCode:"EN"},locale:"EN-US"});function me({children:e,shopifyConfig:r}){if(!r)throw new Error("The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'");r.storefrontApiVersion!==C&&console.warn(`This version of Hydrogen-UI is built for Shopify's Storefront API version ${C}, but it looks like you're using version ${r.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen-UI and the Storefront API.`);const t=g.useMemo(()=>({...r,storeDomain:r.storeDomain.replace(/^https?:\/\//,"")}),[r]);return h.default.createElement(I.Provider,{value:t,__self:this,__source:{fileName:fe,lineNumber:49,columnNumber:5}},e)}function L(){const e=g.useContext(I);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}var w="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Metafield.tsx";function de(e){var n,l,c,d,f,m,y,N,v;const{data:r,as:t,...i}=e,{locale:a}=L(),o=g.useMemo(()=>B(r),[r]);if(!o)return console.warn("<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'"),null;if(o.value===null||o.value===void 0){const s=`<Metafield/>: No metafield value for metafield ${(n=o.id)!=null?n:o.key}. Rendering 'null'`;return console.warn(s),null}switch(o.type){case"date":{const s=t!=null?t:"time";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:68,columnNumber:9}},o.value.toLocaleDateString(a))}case"date_time":{const s=t!=null?t:"time";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:76,columnNumber:9}},o.value.toLocaleString(a))}case"weight":case"dimension":case"volume":{const s=t!=null?t:"span";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:86,columnNumber:9}},_e(o.value,a))}case"rating":{const s=t!=null?t:"span";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:94,columnNumber:9}},o.value.value)}case"single_line_text_field":{const s=t!=null?t:"span";return h.default.createElement(s,{...i,dangerouslySetInnerHTML:{__html:o.value},__self:this,__source:{fileName:w,lineNumber:102,columnNumber:9}})}case"multi_line_text_field":{const s=t!=null?t:"div";return h.default.createElement(s,{...i,dangerouslySetInnerHTML:{__html:o.value.split(`
2
- `).join("<br/>")},__self:this,__source:{fileName:w,lineNumber:111,columnNumber:9}})}case"url":{const s=new URL(o.value);return h.default.createElement("a",{href:s.href.replace(s.protocol,""),...i,__self:this,__source:{fileName:w,lineNumber:122,columnNumber:9}},o.value)}case"json":{const s=t!=null?t:"span";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:133,columnNumber:9}},JSON.stringify(o.value))}case"product_reference":case"variant_reference":case"page_reference":{const s=t!=null?t:"span",_=o.reference;return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:144,columnNumber:9}},(c=(l=_==null?void 0:_.title)!=null?l:_==null?void 0:_.id)!=null?c:"")}case"list.single_line_text_field":{const s=t!=null?t:"ul",_=o.references?E(o.references):[];return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:155,columnNumber:9}},_.map((S,p)=>h.default.createElement("li",{key:`${S!=null?S:""}-${p}`,__self:this,__source:{fileName:w,lineNumber:159,columnNumber:13}},S)))}case"file_reference":if(((d=o.reference)==null?void 0:d.__typename)==="MediaImage"){const s=o.reference;return s.image?h.default.createElement(P,{data:s.image,...i,__self:this,__source:{fileName:w,lineNumber:168,columnNumber:11}}):null}else if(((f=o.reference)==null?void 0:f.__typename)==="GenericFile"){const s=o.reference;return s.previewImage?h.default.createElement("a",{href:(y=(m=o.reference)==null?void 0:m.url)!=null?y:"",...i,__self:this,__source:{fileName:w,lineNumber:173,columnNumber:11}},h.default.createElement(P,{data:s.previewImage,__self:this,__source:{fileName:w,lineNumber:174,columnNumber:13}})):null}else if(((N=o.reference)==null?void 0:N.__typename)==="Video"){const s=o.reference;return h.default.createElement(x,{...i,data:s,__self:this,__source:{fileName:w,lineNumber:179,columnNumber:16}})}}const u=t!=null?t:"span";return h.default.createElement(u,{...i,__self:this,__source:{fileName:w,lineNumber:186,columnNumber:5}},(v=o.value)==null?void 0:v.toString())}function B(e){return e?{...e,value:H(e)}:null}function H(e){if(!e)return null;if(e.value===null||e.value===void 0)return e.value;switch(e.type){case"boolean":return e.value==="true";case"number_integer":return parseInt(e.value);case"number_decimal":return parseFloat(e.value);case"date":case"date_time":return new Date(e.value);case"json":case"weight":case"dimension":case"volume":case"rating":return he(e.value);case"color":case"single_line_text_field":case"multi_line_text_field":case"product_reference":case"page_reference":case"variant_reference":case"file_reference":case"url":default:return e.value}}function he(e){return String(e).includes("__proto__")?JSON.parse(e,(r,t)=>{if(r!=="__proto__")return t}):JSON.parse(e)}const ge={mm:"millimeter",cm:"centimeter",m:"meter",in:"inch",ft:"foot",yd:"yard",ml:"milliliter",l:"liter",us_fl_oz:"fluid-ounce",us_gal:"gallon",kg:"kilogram",g:"gram",lb:"pound",oz:"ounce"};function _e(e,r="en-us",t={}){let i={value:e.value,unit:ge[e.unit]};return i.unit==null&&(i=ye(e.value,e.unit)),new Intl.NumberFormat(r,{...t,unit:i.unit,style:"unit"}).format(i.value)}function ye(e,r){switch(r){case"cl":return{value:e/1e3,unit:"liter"};case"m3":return{value:e*1e3,unit:"liter"};case"us_pt":return{value:e*.125,unit:"gallon"};case"us_qt":return{value:e*.5,unit:"gallon"};case"us_oz":return{value:e/128,unit:"gallon"};case"imp_pt":return{value:e/6.661,unit:"gallon"};case"imp_qt":return{value:e/3.331,unit:"gallon"};case"imp_gal":return{value:e/1.201,unit:"gallon"};case"imp_fl_oz":return{value:e*.96076,unit:"fluid-ounce"};default:throw new Error(`Unit not supported: ${r}`)}}function z(e){const{locale:r}=L();if(!r)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");const t=parseFloat(e.amount),i=g.useMemo(()=>({style:"currency",currency:e.currencyCode}),[e.currencyCode]),a=k(r,i),o=k(r,{...i,currencyDisplay:"name"}),u=k(r,{...i,currencyDisplay:"narrowSymbol"}),n=k(r,{...i,minimumFractionDigits:0,maximumFractionDigits:0}),l=k(r),c=k(r,{minimumFractionDigits:0,maximumFractionDigits:0}),d=m=>m.type==="currency",f=g.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>a().format(t),parts:()=>a().formatToParts(t),withoutTrailingZeros:()=>t%1===0?n().format(t):a().format(t),withoutTrailingZerosAndCurrency:()=>t%1===0?c().format(t):l().format(t),currencyName:()=>{var m,y;return(y=(m=o().formatToParts(t).find(d))==null?void 0:m.value)!=null?y:e.currencyCode},currencySymbol:()=>{var m,y;return(y=(m=a().formatToParts(t).find(d))==null?void 0:m.value)!=null?y:e.currencyCode},currencyNarrowSymbol:()=>{var m,y;return(y=(m=u().formatToParts(t).find(d))==null?void 0:m.value)!=null?y:""},amount:()=>a().formatToParts(t).filter(m=>["decimal","fraction","group","integer","literal"].includes(m.type)).map(m=>m.value).join("")}),[e,t,o,a,u,l,n,c]);return g.useMemo(()=>new Proxy(f,{get:(m,y)=>{var N;return(N=Reflect.get(m,y))==null?void 0:N.call(null)}}),[f])}function k(e,r){return g.useMemo(()=>{let t;return()=>t!=null?t:t=new Intl.NumberFormat(e,r)},[e,r])}var be="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";function V({data:e,as:r,withoutCurrency:t,withoutTrailingZeros:i,measurement:a,measurementSeparator:o="/",...u}){if(!Se(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const n=z(e),l=r!=null?r:"div";let c=n.localizedString;return(t||i)&&(t&&!i?c=n.amount:!t&&i?c=n.withoutTrailingZeros:c=n.withoutTrailingZerosAndCurrency),h.default.createElement(l,{...u,__self:this,__source:{fileName:be,lineNumber:65,columnNumber:5}},c,a&&a.referenceUnit&&h.default.createElement(h.default.Fragment,null,o,a.referenceUnit))}function Se(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}var G="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";function Ne(e){var c,d,f,m,y,N,v,s;const{priceType:r="regular",variantId:t,valueType:i="min",data:a,...o}=e;if(a==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let u,n;const l=t&&(d=E((c=a==null?void 0:a.variants)!=null?c:{}).find(_=>(_==null?void 0:_.id)===t))!=null?d:null;if(r==="compareAt")if(t&&l){if(((f=l.compareAtPriceV2)==null?void 0:f.amount)===((m=l.priceV2)==null?void 0:m.amount))return null;u=l.compareAtPriceV2}else i==="max"?u=(y=a==null?void 0:a.compareAtPriceRange)==null?void 0:y.maxVariantPrice:u=(N=a==null?void 0:a.compareAtPriceRange)==null?void 0:N.minVariantPrice;else t&&l?(u=l.priceV2,i==="unit"&&(u=l.unitPrice,n=l.unitPriceMeasurement)):i==="max"?u=(v=a.priceRange)==null?void 0:v.maxVariantPrice:u=(s=a.priceRange)==null?void 0:s.minVariantPrice;return u?n?h.default.createElement(V,{...o,data:u,measurement:n,__self:this,__source:{fileName:G,lineNumber:81,columnNumber:7}}):h.default.createElement(V,{...o,data:u,__self:this,__source:{fileName:G,lineNumber:85,columnNumber:10}}):null}var we="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";const O=g.createContext(null);function pe({children:e,data:r,initialVariantId:t}){const i=g.useMemo(()=>{var s;return E((s=r.variants)!=null?s:{})},[r.variants]);if(!ke(i))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=g.useMemo(()=>Ee(i),[i]),[o,u]=g.useState(()=>J(t,i)),[n,l]=g.useState(()=>K(o));g.useEffect(()=>{const s=J(t,i);u(s),l(K(s))},[t,i]);const c=g.useCallback((s,_)=>{l(S=>{const p={...S,[s]:_};return u(X(i,p)),p})},[l,i]),d=g.useCallback((s,_)=>{var p;const S=X(i,{...n,[s]:_});return(p=S==null?void 0:S.availableForSale)!=null?p:!0},[n,i]),f=g.useMemo(()=>{var s;return E((s=r.sellingPlanGroups)!=null?s:{}).map(_=>{var S;return{..._,sellingPlans:E((S=_==null?void 0:_.sellingPlans)!=null?S:{})}})},[r.sellingPlanGroups]),[m,y]=g.useState(void 0),N=g.useMemo(()=>{var s,_;if(!(!o||!m)){if(!((s=o.sellingPlanAllocations)!=null&&s.nodes)&&!((_=o.sellingPlanAllocations)!=null&&_.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return E(o.sellingPlanAllocations).find(S=>{var p;return((p=S==null?void 0:S.sellingPlan)==null?void 0:p.id)===m.id})}},[o,m]),v=g.useMemo(()=>({variants:i,variantsConnection:r.variants,options:a,selectedVariant:o,setSelectedVariant:u,selectedOptions:n,setSelectedOption:c,setSelectedOptions:l,isOptionInStock:d,selectedSellingPlan:m,setSelectedSellingPlan:y,selectedSellingPlanAllocation:N,sellingPlanGroups:f,sellingPlanGroupsConnection:r.sellingPlanGroups}),[d,a,r.sellingPlanGroups,r.variants,n,m,N,o,f,c,i]);return h.default.createElement(O.Provider,{value:v,__self:this,__source:{fileName:we,lineNumber:201,columnNumber:5}},e)}function ve(){const e=g.useContext(O);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function X(e,r){var t,i;if(!(!e.length||((i=(t=e==null?void 0:e[0])==null?void 0:t.selectedOptions)==null?void 0:i.length)!==Object.keys(r).length))return e==null?void 0:e.find(a=>Object.entries(r).every(([o,u])=>{var n;return(n=a==null?void 0:a.selectedOptions)==null?void 0:n.some(l=>(l==null?void 0:l.name)===o&&(l==null?void 0:l.value)===u)}))}function Ee(e){const r=e.reduce((t,i)=>{var a;if(!i.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(a=i==null?void 0:i.selectedOptions)==null||a.forEach(o=>{var u,n,l,c;t[(u=o==null?void 0:o.name)!=null?u:""]=t[(n=o==null?void 0:o.name)!=null?n:""]||new Set,t[(l=o==null?void 0:o.name)!=null?l:""].add((c=o==null?void 0:o.value)!=null?c:"")}),t},{});return Object.keys(r).map(t=>({name:t,values:Array.from(r[t])}))}function J(e,r){if(e){const t=r.find(i=>(i==null?void 0:i.id)===e);return t||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),t}if(e===null)return null;if(e===void 0)return r.find(t=>t==null?void 0:t.availableForSale)||r[0]}function K(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((r,t)=>{var i,a;return r[(i=t==null?void 0:t.name)!=null?i:""]=(a=t==null?void 0:t.value)!=null?a:"",r},{}):{}}function ke(e){return!(!e||!Array.isArray(e))}var Y="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";const Me="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Ce({variantIds:e,className:r,variantIdsAndQuantities:t,width:i}){const{storeDomain:a}=L(),o=q(Me);let u;if(e&&t)throw new Error(Te);if(e)u=e.reduce((l,c)=>{const d=Z(c);return d&&l.push(d),l},[]);else if(t)u=t.reduce((l,c)=>{var f;const d=Z(c==null?void 0:c.id);return d&&l.push(`${d}:${(f=c==null?void 0:c.quantity)!=null?f:1}`),l},[]);else throw new Error(Pe);const n=i?{"--shop-pay-button-width":i}:void 0;return h.default.createElement("div",{className:r,style:n,__self:this,__source:{fileName:Y,lineNumber:90,columnNumber:5}},o==="done"&&h.default.createElement("shop-pay-button",{"store-url":`https://${a}`,variants:u.join(","),__self:this,__source:{fileName:Y,lineNumber:92,columnNumber:9}}))}function Z(e){if(!!e)return e.split("/").pop()}const Pe='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',Te="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component";function Le({storeDomain:e,privateStorefrontToken:r,publicStorefrontToken:t,storefrontApiVersion:i,contentType:a}){return i!==C&&console.warn(`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen-UI is targeting. You may run into unexpected errors if these versions don't match. Received verion: "${i}"; expected version ${C}`),{getStorefrontApiUrl(o){var u,n;return`https://${(u=o==null?void 0:o.storeDomain)!=null?u:e}.myshopify.com/api/${(n=o==null?void 0:o.storefrontApiVersion)!=null?n:i}/graphql.json`},getPrivateTokenHeaders(o){var n,l,c;if(!r&&!(o!=null&&o.privateStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'");return{"content-type":((n=o==null?void 0:o.contentType)!=null?n:a)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":i,"Shopify-Storefront-Private-Token":(c=(l=o==null?void 0:o.privateStorefrontToken)!=null?l:r)!=null?c:"",...o!=null&&o.buyerIp?{"Shopify-Storefront-Buyer-IP":o.buyerIp}:{}}},getPublicTokenHeaders(o){var n,l,c;if(!t&&!(o!=null&&o.publicStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'");return{"content-type":((n=o==null?void 0:o.contentType)!=null?n:a)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":i,"X-Shopify-Storefront-Access-Token":(c=(l=o==null?void 0:o.publicStorefrontToken)!=null?l:t)!=null?c:""}}}}b.ExternalVideo=F,b.Image=P,b.MediaFile=se,b.Metafield=de,b.ModelViewer=W,b.Money=V,b.ProductPrice=Ne,b.ProductProvider=pe,b.ShopPayButton=Ce,b.ShopifyProvider=me,b.Video=x,b.createStorefrontClient=Le,b.flattenConnection=E,b.parseMetafield=B,b.parseMetafieldValue=H,b.useMoney=z,b.useProduct=ve,b.useShop=L,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(L,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],g):(L=typeof globalThis<"u"?globalThis:L||self,g(L.hydrogenreact={},L.React))})(this,function(L,g){"use strict";const yt=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function ht(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const w=yt(g),ve=ht(g),Q="2022-07";var _t="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";const be=g.createContext({storeDomain:"test.myshopify.com",storefrontToken:"abc123",storefrontApiVersion:Q,country:{isoCode:"US"},language:{isoCode:"EN"},locale:"EN-US"});function gt({children:e,shopifyConfig:t}){if(!t)throw new Error("The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'");t.storefrontApiVersion!==Q&&console.warn(`This version of Hydrogen-UI is built for Shopify's Storefront API version ${Q}, but it looks like you're using version ${t.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen-UI and the Storefront API.`);const r=g.useMemo(()=>({...t,storeDomain:t.storeDomain.replace(/^https?:\/\//,"")}),[t]);return w.default.createElement(be.Provider,{value:r,__self:this,__source:{fileName:_t,lineNumber:49,columnNumber:5}},e)}function X(){const e=g.useContext(be);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}function x(e){if(!e){const t=`flattenConnection(): needs a 'connection' to flatten, but received '${e}' instead`;return console.error(t),[]}return e.nodes?e.nodes:e.edges?e.edges.map(t=>{if(!(t!=null&&t.node))throw new Error("Connection edges must contain nodes");return t.node}):[]}const Et=e=>`
2
+ mutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
3
+ cartLinesAdd(cartId: $cartId, lines: $lines) {
4
+ cart {
5
+ ...CartFragment
6
+ }
7
+ }
8
+ }
9
+
10
+ ${e}
11
+ `,Ce=e=>`
12
+ mutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
13
+ cartCreate(input: $input) {
14
+ cart {
15
+ ...CartFragment
16
+ }
17
+ }
18
+ }
19
+
20
+ ${e}
21
+ `,pt=e=>`
22
+ mutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
23
+ cartLinesRemove(cartId: $cartId, lineIds: $lines) {
24
+ cart {
25
+ ...CartFragment
26
+ }
27
+ }
28
+ }
29
+
30
+ ${e}
31
+ `,St=e=>`
32
+ mutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
33
+ cartLinesUpdate(cartId: $cartId, lines: $lines) {
34
+ cart {
35
+ ...CartFragment
36
+ }
37
+ }
38
+ }
39
+
40
+ ${e}
41
+ `,vt=e=>`
42
+ mutation CartNoteUpdate($cartId: ID!, $note: String, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
43
+ cartNoteUpdate(cartId: $cartId, note: $note) {
44
+ cart {
45
+ ...CartFragment
46
+ }
47
+ }
48
+ }
49
+
50
+ ${e}
51
+ `,bt=e=>`
52
+ mutation CartBuyerIdentityUpdate(
53
+ $cartId: ID!
54
+ $buyerIdentity: CartBuyerIdentityInput!
55
+ $numCartLines: Int = 250
56
+ $country: CountryCode = ZZ
57
+ ) @inContext(country: $country) {
58
+ cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
59
+ cart {
60
+ ...CartFragment
61
+ }
62
+ }
63
+ }
64
+
65
+ ${e}
66
+ `,Ct=e=>`
67
+ mutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
68
+ cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
69
+ cart {
70
+ ...CartFragment
71
+ }
72
+ }
73
+ }
74
+
75
+ ${e}
76
+ `,Tt=e=>`
77
+ mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
78
+ cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
79
+ cart {
80
+ ...CartFragment
81
+ }
82
+ }
83
+ }
84
+
85
+ ${e}
86
+ `,At=e=>`
87
+ query CartQuery($id: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
88
+ cart(id: $id) {
89
+ ...CartFragment
90
+ }
91
+ }
92
+
93
+ ${e}
94
+ `,Nt=`
95
+ fragment CartFragment on Cart {
96
+ id
97
+ checkoutUrl
98
+ totalQuantity
99
+ buyerIdentity {
100
+ countryCode
101
+ customer {
102
+ id
103
+ email
104
+ firstName
105
+ lastName
106
+ displayName
107
+ }
108
+ email
109
+ phone
110
+ }
111
+ lines(first: $numCartLines) {
112
+ edges {
113
+ node {
114
+ id
115
+ quantity
116
+ attributes {
117
+ key
118
+ value
119
+ }
120
+ cost {
121
+ totalAmount {
122
+ amount
123
+ currencyCode
124
+ }
125
+ compareAtAmountPerQuantity {
126
+ amount
127
+ currencyCode
128
+ }
129
+ }
130
+ merchandise {
131
+ ... on ProductVariant {
132
+ id
133
+ availableForSale
134
+ compareAtPriceV2 {
135
+ ...MoneyFragment
136
+ }
137
+ priceV2 {
138
+ ...MoneyFragment
139
+ }
140
+ requiresShipping
141
+ title
142
+ image {
143
+ ...ImageFragment
144
+ }
145
+ product {
146
+ handle
147
+ title
148
+ id
149
+ }
150
+ selectedOptions {
151
+ name
152
+ value
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
159
+ cost {
160
+ subtotalAmount {
161
+ ...MoneyFragment
162
+ }
163
+ totalAmount {
164
+ ...MoneyFragment
165
+ }
166
+ totalDutyAmount {
167
+ ...MoneyFragment
168
+ }
169
+ totalTaxAmount {
170
+ ...MoneyFragment
171
+ }
172
+ }
173
+ note
174
+ attributes {
175
+ key
176
+ value
177
+ }
178
+ discountCodes {
179
+ code
180
+ }
181
+ }
182
+
183
+ fragment MoneyFragment on MoneyV2 {
184
+ currencyCode
185
+ amount
186
+ }
187
+ fragment ImageFragment on Image {
188
+ id
189
+ url
190
+ altText
191
+ width
192
+ height
193
+ }
194
+ `,se="shopifyCartId",wt="X-Shopify-Storefront-Access-Token",It="Shopify-Storefront-Id",Ot="Shopify-Storefront-Y",Dt="Shopify-Storefront-S",Te="_shopify_y",Ae="_shopify_s";var Lt=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Ut(e){let t={},r,a,o=0,i=e.split(/;\s*/g),u,n;for(;o<i.length;o++)if(a=i[o],r=a.indexOf("="),~r){if(u=a.substring(0,r++).trim(),n=a.substring(r).trim(),n[0]==='"'&&(n=n.substring(1,n.length-1)),~n.indexOf("%"))try{n=decodeURIComponent(n)}catch{}Lt.has(a=u.toLowerCase())?a==="expires"?t.expires=new Date(n):a==="max-age"?t.maxage=+n:t[a]=n:t[u]=n}else(u=a.trim().toLowerCase())&&(u==="httponly"||u==="secure")&&(t[u]=!0);return t}function le(){const{storeDomain:e,storefrontApiVersion:t,storefrontToken:r,storefrontId:a}=X();return g.useCallback(({query:o,variables:i})=>{const u={"Content-Type":"application/json","X-SDK-Variant":"hydrogen","X-SDK-Version":t,[wt]:r};a&&(u[It]=a);const n=Ut(document.cookie);return n[Te]&&n[Ae]&&(u[Ot]=n[Te],u[Dt]=n[Ae]),fetch(`https://${e}/api/${t}/graphql.json`,{method:"POST",headers:u,body:JSON.stringify({query:o.toString(),variables:i})}).then(l=>l.json()).catch(l=>({data:void 0,errors:l.toString()}))},[e,t,r,a])}function Pt(){const[e,t]=g.useState(),[r,a]=g.useState(),[o,i]=g.useState(),u=le(),n=g.useCallback(async l=>{var c,h;const{data:d,errors:_}=await u({query:Ce(Nt),variables:{input:l}});if(_&&(i(_.toString()),t(void 0),a(void 0)),(c=d==null?void 0:d.cartCreate)!=null&&c.cart){const m=d.cartCreate.cart;t({...m,lines:x(m.lines),note:(h=m.note)!=null?h:void 0}),a(m.checkoutUrl)}},[u]);return{cart:e,checkoutUrl:r,error:o,createInstantCheckout:n}}/*! *****************************************************************************
195
+ Copyright (c) Microsoft Corporation.
196
+
197
+ Permission to use, copy, modify, and/or distribute this software for any
198
+ purpose with or without fee is hereby granted.
199
+
200
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
201
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
202
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
203
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
204
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
205
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
206
+ PERFORMANCE OF THIS SOFTWARE.
207
+ ***************************************************************************** */function Ne(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var a,o,i=r.call(e),u=[];try{for(;(t===void 0||t-- >0)&&!(a=i.next()).done;)u.push(a.value)}catch(n){o={error:n}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}var Y;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(Y||(Y={}));var we={type:"xstate.init"};function de(e){return e===void 0?[]:[].concat(e)}function J(e){return{type:"xstate.assign",assignment:e}}function Ie(e,t){return typeof(e=typeof e=="string"&&t&&t[e]?t[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function ae(e){return function(t){return e===t}}function Oe(e){return typeof e=="string"?{type:e}:e}function De(e,t){return{value:e,context:t,actions:[],changed:!1,matches:ae(e)}}function Le(e,t,r){var a=t,o=!1;return[e.filter(function(i){if(i.type==="xstate.assign"){o=!0;var u=Object.assign({},a);return typeof i.assignment=="function"?u=i.assignment(a,r):Object.keys(i.assignment).forEach(function(n){u[n]=typeof i.assignment[n]=="function"?i.assignment[n](a,r):i.assignment[n]}),a=u,!1}return!0}),a,o]}function Ue(e,t){t===void 0&&(t={});var r=Ne(Le(de(e.states[e.initial].entry).map(function(u){return Ie(u,t.actions)}),e.context,we),2),a=r[0],o=r[1],i={config:e,_options:t,initialState:{value:e.initial,actions:a,context:o,matches:ae(e.initial)},transition:function(u,n){var l,d,_=typeof u=="string"?{value:u,context:e.context}:u,c=_.value,h=_.context,m=Oe(n),p=e.states[c];if(p.on){var A=de(p.on[m.type]);try{for(var f=function(D){var G=typeof Symbol=="function"&&Symbol.iterator,P=G&&D[G],ue=0;if(P)return P.call(D);if(D&&typeof D.length=="number")return{next:function(){return D&&ue>=D.length&&(D=void 0),{value:D&&D[ue++],done:!D}}};throw new TypeError(G?"Object is not iterable.":"Symbol.iterator is not defined.")}(A),S=f.next();!S.done;S=f.next()){var v=S.value;if(v===void 0)return De(c,h);var b=typeof v=="string"?{target:v}:v,s=b.target,y=b.actions,E=y===void 0?[]:y,N=b.cond,I=N===void 0?function(){return!0}:N,T=s===void 0,O=s!=null?s:c,M=e.states[O];if(I(h,m)){var $=Ne(Le((T?de(E):[].concat(p.exit,E,M.entry).filter(function(D){return D})).map(function(D){return Ie(D,i._options.actions)}),h,m),3),F=$[0],W=$[1],K=$[2],H=s!=null?s:c;return{value:H,context:W,actions:F,changed:s!==c||F.length>0||K,matches:ae(H)}}}}catch(D){l={error:D}}finally{try{S&&!S.done&&(d=f.return)&&d.call(f)}finally{if(l)throw l.error}}}return De(c,h)}};return i}var Pe=function(e,t){return e.actions.forEach(function(r){var a=r.exec;return a&&a(e.context,t)})};function Mt(e){var t=e.initialState,r=Y.NotStarted,a=new Set,o={_machine:e,send:function(i){r===Y.Running&&(t=e.transition(t,i),Pe(t,Oe(i)),a.forEach(function(u){return u(t)}))},subscribe:function(i){return a.add(i),i(t),{unsubscribe:function(){return a.delete(i)}}},start:function(i){if(i){var u=typeof i=="object"?i:{context:e.config.context,value:i};t={value:u.value,actions:[],context:u.context,matches:ae(u.value)}}else t=e.initialState;return r=Y.Running,Pe(t,we),o},stop:function(){return r=Y.Stopped,a.clear(),o},get state(){return t},get status(){return r}};return o}var Rt=g.useLayoutEffect,Me={exports:{}},fe={},me={exports:{}},ye={};/**
208
+ * @license React
209
+ * use-sync-external-store-shim.production.min.js
210
+ *
211
+ * Copyright (c) Facebook, Inc. and its affiliates.
212
+ *
213
+ * This source code is licensed under the MIT license found in the
214
+ * LICENSE file in the root directory of this source tree.
215
+ */var Re;function kt(){if(Re)return ye;Re=1;var e=w.default;function t(c,h){return c===h&&(c!==0||1/c===1/h)||c!==c&&h!==h}var r=typeof Object.is=="function"?Object.is:t,a=e.useState,o=e.useEffect,i=e.useLayoutEffect,u=e.useDebugValue;function n(c,h){var m=h(),p=a({inst:{value:m,getSnapshot:h}}),A=p[0].inst,f=p[1];return i(function(){A.value=m,A.getSnapshot=h,l(A)&&f({inst:A})},[c,m,h]),o(function(){return l(A)&&f({inst:A}),c(function(){l(A)&&f({inst:A})})},[c]),u(m),m}function l(c){var h=c.getSnapshot;c=c.value;try{var m=h();return!r(c,m)}catch{return!0}}function d(c,h){return h()}var _=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:n;return ye.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:_,ye}var he={};/**
216
+ * @license React
217
+ * use-sync-external-store-shim.development.js
218
+ *
219
+ * Copyright (c) Facebook, Inc. and its affiliates.
220
+ *
221
+ * This source code is licensed under the MIT license found in the
222
+ * LICENSE file in the root directory of this source tree.
223
+ */var ke;function $t(){return ke||(ke=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=w.default,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function r(b){{for(var s=arguments.length,y=new Array(s>1?s-1:0),E=1;E<s;E++)y[E-1]=arguments[E];a("error",b,y)}}function a(b,s,y){{var E=t.ReactDebugCurrentFrame,N=E.getStackAddendum();N!==""&&(s+="%s",y=y.concat([N]));var I=y.map(function(T){return String(T)});I.unshift("Warning: "+s),Function.prototype.apply.call(console[b],console,I)}}function o(b,s){return b===s&&(b!==0||1/b===1/s)||b!==b&&s!==s}var i=typeof Object.is=="function"?Object.is:o,u=e.useState,n=e.useEffect,l=e.useLayoutEffect,d=e.useDebugValue,_=!1,c=!1;function h(b,s,y){_||e.startTransition!==void 0&&(_=!0,r("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."));var E=s();if(!c){var N=s();i(E,N)||(r("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}var I=u({inst:{value:E,getSnapshot:s}}),T=I[0].inst,O=I[1];return l(function(){T.value=E,T.getSnapshot=s,m(T)&&O({inst:T})},[b,E,s]),n(function(){m(T)&&O({inst:T});var M=function(){m(T)&&O({inst:T})};return b(M)},[b]),d(E),E}function m(b){var s=b.getSnapshot,y=b.value;try{var E=s();return!i(y,E)}catch{return!0}}function p(b,s,y){return s()}var A=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",f=!A,S=f?p:h,v=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:S;he.useSyncExternalStore=v,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),he}var $e;function Ve(){return $e||($e=1,function(e){process.env.NODE_ENV==="production"?e.exports=kt():e.exports=$t()}(me)),me.exports}/**
224
+ * @license React
225
+ * use-sync-external-store-shim/with-selector.production.min.js
226
+ *
227
+ * Copyright (c) Facebook, Inc. and its affiliates.
228
+ *
229
+ * This source code is licensed under the MIT license found in the
230
+ * LICENSE file in the root directory of this source tree.
231
+ */var Fe;function Vt(){if(Fe)return fe;Fe=1;var e=w.default,t=Ve();function r(d,_){return d===_&&(d!==0||1/d===1/_)||d!==d&&_!==_}var a=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,i=e.useRef,u=e.useEffect,n=e.useMemo,l=e.useDebugValue;return fe.useSyncExternalStoreWithSelector=function(d,_,c,h,m){var p=i(null);if(p.current===null){var A={hasValue:!1,value:null};p.current=A}else A=p.current;p=n(function(){function S(E){if(!v){if(v=!0,b=E,E=h(E),m!==void 0&&A.hasValue){var N=A.value;if(m(N,E))return s=N}return s=E}if(N=s,a(b,E))return N;var I=h(E);return m!==void 0&&m(N,I)?N:(b=E,s=I)}var v=!1,b,s,y=c===void 0?null:c;return[function(){return S(_())},y===null?void 0:function(){return S(y())}]},[_,c,h,m]);var f=o(d,p[0],p[1]);return u(function(){A.hasValue=!0,A.value=f},[f]),l(f),f},fe}var _e={};/**
232
+ * @license React
233
+ * use-sync-external-store-shim/with-selector.development.js
234
+ *
235
+ * Copyright (c) Facebook, Inc. and its affiliates.
236
+ *
237
+ * This source code is licensed under the MIT license found in the
238
+ * LICENSE file in the root directory of this source tree.
239
+ */var xe;function Ft(){return xe||(xe=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=w.default,t=Ve();function r(_,c){return _===c&&(_!==0||1/_===1/c)||_!==_&&c!==c}var a=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,i=e.useRef,u=e.useEffect,n=e.useMemo,l=e.useDebugValue;function d(_,c,h,m,p){var A=i(null),f;A.current===null?(f={hasValue:!1,value:null},A.current=f):f=A.current;var S=n(function(){var y=!1,E,N,I=function($){if(!y){y=!0,E=$;var F=m($);if(p!==void 0&&f.hasValue){var W=f.value;if(p(W,F))return N=W,W}return N=F,F}var K=E,H=N;if(a(K,$))return H;var D=m($);return p!==void 0&&p(H,D)?H:(E=$,N=D,D)},T=h===void 0?null:h,O=function(){return I(c())},M=T===null?void 0:function(){return I(T())};return[O,M]},[c,h,m,p]),v=S[0],b=S[1],s=o(_,v,b);return u(function(){f.hasValue=!0,f.value=s},[s]),l(s),s}_e.useSyncExternalStoreWithSelector=d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),_e}(function(e){process.env.NODE_ENV==="production"?e.exports=Vt():e.exports=Ft()})(Me);function xt(e){var t=ve.useRef();return t.current||(t.current={v:e()}),t.current.v}var je=globalThis&&globalThis.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var a=r.call(e),o,i=[],u;try{for(;(t===void 0||t-- >0)&&!(o=a.next()).done;)i.push(o.value)}catch(n){u={error:n}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(u)throw u.error}}return i};function jt(e){return e}var qt=function(e){var t;return e.subscribe(function(r){t=r}).unsubscribe(),t};function Ht(e,t){var r=g.useRef();if(process.env.NODE_ENV!=="production"){var a=je(g.useState(e),1),o=a[0];e!==o&&console.warn("Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.\nPlease make sure that you pass the same Machine as argument each time.")}var i=je(xt(function(){var d=[],_=Mt(Ue(e.config,t||e._options)),c=_.send;return _.send=function(h){if(_.status===Y.NotStarted){d.push(h);return}c(h),r.current=_.state},[_,d]}),2),u=i[0],n=i[1];Rt(function(){t&&(u._machine._options=t)});var l=Wt(u);return g.useEffect(function(){return u.start(r.current),n.forEach(u.send),r.current=u.state,function(){u.stop()}},[]),l}var Bt=function(e,t){return t.changed===!1};function Wt(e){var t=g.useCallback(function(){return qt(e)},[e]),r=g.useCallback(function(o){var i=e.subscribe(o).unsubscribe;return i},[e]),a=Me.exports.useSyncExternalStoreWithSelector(r,t,t,jt,Bt);return[a,e.send,e]}function Yt({numCartLines:e,cartFragment:t,countryCode:r="US"}){const a=le(),o=g.useCallback(m=>a({query:At(t),variables:{id:m,numCartLines:e,country:r}}),[a,t,e,r]),i=g.useCallback(m=>a({query:Ce(t),variables:{input:m,numCartLines:e,country:r}}),[t,r,a,e]),u=g.useCallback((m,p)=>a({query:Et(t),variables:{cartId:m,lines:p,numCartLines:e,country:r}}),[t,r,a,e]),n=g.useCallback((m,p)=>a({query:St(t),variables:{cartId:m,lines:p,numCartLines:e,country:r}}),[t,r,a,e]),l=g.useCallback((m,p)=>a({query:pt(t),variables:{cartId:m,lines:p,numCartLines:e,country:r}}),[t,r,a,e]),d=g.useCallback((m,p)=>a({query:vt(t),variables:{cartId:m,note:p,numCartLines:e,country:r}}),[a,t,e,r]),_=g.useCallback((m,p)=>a({query:bt(t),variables:{cartId:m,buyerIdentity:p,numCartLines:e,country:r}}),[t,r,a,e]),c=g.useCallback((m,p)=>a({query:Ct(t),variables:{cartId:m,attributes:p,numCartLines:e,country:r}}),[t,r,a,e]),h=g.useCallback((m,p)=>a({query:Tt(t),variables:{cartId:m,discountCodes:p,numCartLines:e,country:r}}),[t,r,a,e]);return g.useMemo(()=>({cartFetch:o,cartCreate:i,cartLineAdd:u,cartLineUpdate:n,cartLineRemove:l,noteUpdate:d,buyerIdentityUpdate:_,cartAttributesUpdate:c,discountCodesUpdate:h,cartFragment:t}),[o,i,u,n,l,d,_,c,h,t])}function j(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[J({prevCart:r=>r==null?void 0:r.cart,cart:(r,a)=>{var o;return(o=a==null?void 0:a.payload)==null?void 0:o.cart},rawCartResult:(r,a)=>{var o;return(o=a==null?void 0:a.payload)==null?void 0:o.rawCartResult},errors:r=>{}})]},ERROR:{target:(t==null?void 0:t.errorTarget)||"error",actions:[J({prevCart:r=>r==null?void 0:r.cart,cart:r=>r==null?void 0:r.lastValidCart,errors:(r,a)=>{var o;return(o=a==null?void 0:a.payload)==null?void 0:o.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:J({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const ee={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[J({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>ge(t.payload.cart)})]}},qe={CARTLINE_ADD:{target:"cartLineAdding"},CARTLINE_UPDATE:{target:"cartLineUpdating"},CARTLINE_REMOVE:{target:"cartLineRemoving"},NOTE_UPDATE:{target:"noteUpdating"},BUYER_IDENTITY_UPDATE:{target:"buyerIdentityUpdating"},CART_ATTRIBUTES_UPDATE:{target:"cartAttributesUpdating"},DISCOUNT_CODES_UPDATE:{target:"discountCodesUpdating"}};function Gt(e){return Ue({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&ge(e)},states:{uninitialized:{on:ee},cartCompleted:{on:ee},initializationError:{on:ee},idle:{on:{...ee,...qe}},error:{on:{...ee,...qe}},cartFetching:j("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:j("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:j("cartLineRemoveAction"),cartLineUpdating:j("cartLineUpdateAction"),cartLineAdding:j("cartLineAddAction"),noteUpdating:j("noteUpdateAction"),buyerIdentityUpdating:j("buyerIdentityUpdateAction"),cartAttributesUpdating:j("cartAttributesUpdateAction"),discountCodesUpdating:j("discountCodesUpdateAction")}})}function Zt({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:a,data:o,cartFragment:i,countryCode:u}){const{cartFetch:n,cartCreate:l,cartLineAdd:d,cartLineUpdate:_,cartLineRemove:c,noteUpdate:h,buyerIdentityUpdate:m,cartAttributesUpdate:p,discountCodesUpdate:A}=Yt({numCartLines:e,cartFragment:i,countryCode:u}),f=g.useMemo(()=>Gt(o),[o]),[S,v,b]=Ht(f,{actions:{cartFetchAction:async(s,y)=>{var T;if(y.type!=="CART_FETCH")return;const{data:E,errors:N}=await n((T=y==null?void 0:y.payload)==null?void 0:T.cartId),I=q(y,E==null?void 0:E.cart,N);v(I)},cartCreateAction:async(s,y)=>{var T;if(y.type!=="CART_CREATE")return;const{data:E,errors:N}=await l(y==null?void 0:y.payload),I=q(y,(T=E==null?void 0:E.cartCreate)==null?void 0:T.cart,N);v(I)},cartLineAddAction:async(s,y)=>{var T,O;if(y.type!=="CARTLINE_ADD"||!((T=s==null?void 0:s.cart)!=null&&T.id))return;const{data:E,errors:N}=await d(s.cart.id,y.payload.lines),I=q(y,(O=E==null?void 0:E.cartLinesAdd)==null?void 0:O.cart,N);v(I)},cartLineUpdateAction:async(s,y)=>{var T,O;if(y.type!=="CARTLINE_UPDATE"||!((T=s==null?void 0:s.cart)!=null&&T.id))return;const{data:E,errors:N}=await _(s.cart.id,y.payload.lines),I=q(y,(O=E==null?void 0:E.cartLinesUpdate)==null?void 0:O.cart,N);v(I)},cartLineRemoveAction:async(s,y)=>{var T,O;if(y.type!=="CARTLINE_REMOVE"||!((T=s==null?void 0:s.cart)!=null&&T.id))return;const{data:E,errors:N}=await c(s.cart.id,y.payload.lines),I=q(y,(O=E==null?void 0:E.cartLinesRemove)==null?void 0:O.cart,N);v(I)},noteUpdateAction:async(s,y)=>{var T,O;if(y.type!=="NOTE_UPDATE"||!((T=s==null?void 0:s.cart)!=null&&T.id))return;const{data:E,errors:N}=await h(s.cart.id,y.payload.note),I=q(y,(O=E==null?void 0:E.cartNoteUpdate)==null?void 0:O.cart,N);v(I)},buyerIdentityUpdateAction:async(s,y)=>{var T,O;if(y.type!=="BUYER_IDENTITY_UPDATE"||!((T=s==null?void 0:s.cart)!=null&&T.id))return;const{data:E,errors:N}=await m(s.cart.id,y.payload.buyerIdentity),I=q(y,(O=E==null?void 0:E.cartBuyerIdentityUpdate)==null?void 0:O.cart,N);v(I)},cartAttributesUpdateAction:async(s,y)=>{var T,O;if(y.type!=="CART_ATTRIBUTES_UPDATE"||!((T=s==null?void 0:s.cart)!=null&&T.id))return;const{data:E,errors:N}=await p(s.cart.id,y.payload.attributes),I=q(y,(O=E==null?void 0:E.cartAttributesUpdate)==null?void 0:O.cart,N);v(I)},discountCodesUpdateAction:async(s,y)=>{var T,O;if(y.type!=="DISCOUNT_CODES_UPDATE"||!((T=s==null?void 0:s.cart)!=null&&T.id))return;const{data:E,errors:N}=await A(s.cart.id,y.payload.discountCodes),I=q(y,(O=E==null?void 0:E.cartDiscountCodesUpdate)==null?void 0:O.cart,N);v(I)},...t&&{onCartActionEntry:(s,y)=>{Kt(y)&&t(s,y)}},...r&&{onCartActionOptimisticUI:J((s,y)=>r(s,y))},...a&&{onCartActionComplete:(s,y)=>{zt(y)&&a(s,y)}}}});return g.useMemo(()=>[S,v,b],[S,v,b])}function ge(e){var t;return{...e,lines:x(e==null?void 0:e.lines),note:(t=e.note)!=null?t:void 0}}function q(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:ge(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Kt(e){return e.type==="CART_CREATE"||e.type==="CARTLINE_ADD"||e.type==="CARTLINE_UPDATE"||e.type==="CARTLINE_REMOVE"||e.type==="NOTE_UPDATE"||e.type==="BUYER_IDENTITY_UPDATE"||e.type==="CART_ATTRIBUTES_UPDATE"||e.type==="DISCOUNT_CODES_UPDATE"}function zt(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}var Qt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartProvider.tsx";const He=g.createContext(null);function Xt(){const e=g.useContext(He);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function Jt({children:e,numCartLines:t,onCreate:r,onLineAdd:a,onLineRemove:o,onLineUpdate:i,onNoteUpdate:u,onBuyerIdentityUpdate:n,onAttributesUpdate:l,onDiscountCodesUpdate:d,onCreateComplete:_,onLineAddComplete:c,onLineRemoveComplete:h,onLineUpdateComplete:m,onNoteUpdateComplete:p,onBuyerIdentityUpdateComplete:A,onAttributesUpdateComplete:f,onDiscountCodesUpdateComplete:S,data:v,cartFragment:b=nr,customerAccessToken:s,countryCode:y="US"}){var ut,ct,st,lt,dt,ft,mt;y&&(y=y.toUpperCase());const[E,N]=g.useState(y),[I,T]=g.useState(s),O=g.useRef(!1);(E!==y||I!==s)&&(N(y),T(s),O.current=!1);const[M,$]=Zt({numCartLines:t,data:v,cartFragment:b,countryCode:y,onCartActionEntry(C,R){try{switch(R.type){case"CART_CREATE":return r==null?void 0:r();case"CARTLINE_ADD":return a==null?void 0:a();case"CARTLINE_REMOVE":return o==null?void 0:o();case"CARTLINE_UPDATE":return i==null?void 0:i();case"NOTE_UPDATE":return u==null?void 0:u();case"BUYER_IDENTITY_UPDATE":return n==null?void 0:n();case"CART_ATTRIBUTES_UPDATE":return l==null?void 0:l();case"DISCOUNT_CODES_UPDATE":return d==null?void 0:d()}}catch(V){console.error("Cart entry action failed",V)}},onCartActionOptimisticUI(C,R){var V,B,re,ne;if(!(C!=null&&C.cart))return{cart:void 0};switch(R.type){case"CARTLINE_REMOVE":return{...C,lastValidCart:C.cart,cart:{...C.cart,lines:(B=(V=C==null?void 0:C.cart)==null?void 0:V.lines)==null?void 0:B.filter(U=>(U==null?void 0:U.id)&&!R.payload.lines.includes(U==null?void 0:U.id))}};case"CARTLINE_UPDATE":return{...C,lastValidCart:C.cart,cart:{...C.cart,lines:(ne=(re=C==null?void 0:C.cart)==null?void 0:re.lines)==null?void 0:ne.map(U=>{const z=R.payload.lines.find(({id:ce})=>ce===(U==null?void 0:U.id));return z&&z.quantity?{...U,quantity:z.quantity}:U})}}}return{cart:C.cart?{...C.cart}:void 0}},onCartActionComplete(C,R){const V=R.payload.cartActionEvent;try{switch(R.type){case"RESOLVE":switch(V.type){case"CART_CREATE":return _==null?void 0:_();case"CARTLINE_ADD":return c==null?void 0:c();case"CARTLINE_REMOVE":return h==null?void 0:h();case"CARTLINE_UPDATE":return m==null?void 0:m();case"NOTE_UPDATE":return p==null?void 0:p();case"BUYER_IDENTITY_UPDATE":return rr(C,V)&&(O.current=!0),A==null?void 0:A();case"CART_ATTRIBUTES_UPDATE":return f==null?void 0:f();case"DISCOUNT_CODES_UPDATE":return S==null?void 0:S()}}}catch(B){console.error("onCartActionComplete failed",B)}}}),F=g.useRef(!1),W=M.matches("cartCompleted"),K=(M.value==="idle"||M.value==="error"||M.value==="cartCompleted")&&y!==((st=(ct=(ut=M==null?void 0:M.context)==null?void 0:ut.cart)==null?void 0:ct.buyerIdentity)==null?void 0:st.countryCode)&&!M.context.errors,H=g.useRef(!1);g.useEffect(()=>{if(!F.current&&!H.current){if(!v&&Ee("localStorage")){H.current=!0;try{const C=window.localStorage.getItem(se);C&&$({type:"CART_FETCH",payload:{cartId:C}})}catch(C){console.warn("error fetching cartId"),console.warn(C)}}F.current=!0}},[v,F,$]),g.useEffect(()=>{!K||O.current||$({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:y,customerAccessToken:s}}})},[y,s,K,O,$]);const D=g.useCallback(C=>{if(!F.current)return console.warn("Cart isn't ready yet");$(C)},[$]);g.useEffect(()=>{var C,R,V;if(((R=(C=M==null?void 0:M.context)==null?void 0:C.cart)==null?void 0:R.id)&&Ee("localStorage"))try{window.localStorage.setItem(se,(V=M.context.cart)==null?void 0:V.id)}catch(B){console.warn("Failed to save cartId to localStorage",B)}},[(dt=(lt=M==null?void 0:M.context)==null?void 0:lt.cart)==null?void 0:dt.id]),g.useEffect(()=>{if(W&&Ee("localStorage"))try{window.localStorage.removeItem(se)}catch(C){console.warn("Failed to delete cartId from localStorage",C)}},[W]);const G=g.useCallback(C=>{var R,V;y&&!((R=C.buyerIdentity)!=null&&R.countryCode)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.countryCode=y),s&&!((V=C.buyerIdentity)!=null&&V.customerAccessToken)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.customerAccessToken=s),D({type:"CART_CREATE",payload:C})},[y,s,D]),P=tr(M),ue=g.useMemo(()=>{var C,R,V,B,re,ne;return{...(R=(C=P==null?void 0:P.context)==null?void 0:C.cart)!=null?R:{lines:[],attributes:[]},status:er(P.value),error:(V=P==null?void 0:P.context)==null?void 0:V.errors,totalQuantity:(ne=(re=(B=P==null?void 0:P.context)==null?void 0:B.cart)==null?void 0:re.totalQuantity)!=null?ne:0,cartCreate:G,linesAdd(U){var z,ce;(ce=(z=P==null?void 0:P.context)==null?void 0:z.cart)!=null&&ce.id?D({type:"CARTLINE_ADD",payload:{lines:U}}):G({lines:U})},linesRemove(U){D({type:"CARTLINE_REMOVE",payload:{lines:U}})},linesUpdate(U){D({type:"CARTLINE_UPDATE",payload:{lines:U}})},noteUpdate(U){D({type:"NOTE_UPDATE",payload:{note:U}})},buyerIdentityUpdate(U){D({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:U}})},cartAttributesUpdate(U){D({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:U}})},discountCodesUpdate(U){D({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:U}})},cartFragment:b}},[G,(ft=P==null?void 0:P.context)==null?void 0:ft.cart,(mt=P==null?void 0:P.context)==null?void 0:mt.errors,P.value,b,D]);return w.default.createElement(He.Provider,{value:ue,__self:this,__source:{fileName:Qt,lineNumber:425,columnNumber:5}},e)}function er(e){switch(e){case"uninitialized":case"initializationError":return"uninitialized";case"idle":case"cartCompleted":case"error":return"idle";case"cartFetching":return"fetching";case"cartCreating":return"creating";case"cartLineAdding":case"cartLineRemoving":case"cartLineUpdating":case"noteUpdating":case"buyerIdentityUpdating":case"cartAttributesUpdating":case"discountCodesUpdating":return"updating"}}function tr(e){const[t,r]=g.useTransition(),[a,o]=g.useState(e),i=g.useRef(!1);t&&(i.current=!0);const u=g.useRef(!1);return!t&&i.current&&(u.current=!0),g.useEffect(()=>{r(()=>{u.current||o(e)})},[e]),u.current?e:a}function Ee(e){let t;try{t=window[e];const r="__storage_test__";return t.setItem(r,r),t.removeItem(r),!0}catch(r){return r instanceof DOMException&&(r.code===22||r.code===1014||r.name==="QuotaExceededError"||r.name==="NS_ERROR_DOM_QUOTA_REACHED")&&t&&t.length!==0}}function rr(e,t){var r,a;return t.payload.buyerIdentity.countryCode&&((a=(r=e.cart)==null?void 0:r.buyerIdentity)==null?void 0:a.countryCode)!==t.payload.buyerIdentity.countryCode}const nr=`
240
+ fragment CartFragment on Cart {
241
+ id
242
+ checkoutUrl
243
+ totalQuantity
244
+ buyerIdentity {
245
+ countryCode
246
+ customer {
247
+ id
248
+ email
249
+ firstName
250
+ lastName
251
+ displayName
252
+ }
253
+ email
254
+ phone
255
+ }
256
+ lines(first: $numCartLines) {
257
+ edges {
258
+ node {
259
+ id
260
+ quantity
261
+ attributes {
262
+ key
263
+ value
264
+ }
265
+ cost {
266
+ totalAmount {
267
+ amount
268
+ currencyCode
269
+ }
270
+ compareAtAmountPerQuantity {
271
+ amount
272
+ currencyCode
273
+ }
274
+ }
275
+ merchandise {
276
+ ... on ProductVariant {
277
+ id
278
+ availableForSale
279
+ compareAtPriceV2 {
280
+ ...MoneyFragment
281
+ }
282
+ priceV2 {
283
+ ...MoneyFragment
284
+ }
285
+ requiresShipping
286
+ title
287
+ image {
288
+ ...ImageFragment
289
+ }
290
+ product {
291
+ handle
292
+ title
293
+ }
294
+ selectedOptions {
295
+ name
296
+ value
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+ }
303
+ cost {
304
+ subtotalAmount {
305
+ ...MoneyFragment
306
+ }
307
+ totalAmount {
308
+ ...MoneyFragment
309
+ }
310
+ totalDutyAmount {
311
+ ...MoneyFragment
312
+ }
313
+ totalTaxAmount {
314
+ ...MoneyFragment
315
+ }
316
+ }
317
+ note
318
+ attributes {
319
+ key
320
+ value
321
+ }
322
+ discountCodes {
323
+ code
324
+ }
325
+ }
326
+
327
+ fragment MoneyFragment on MoneyV2 {
328
+ currencyCode
329
+ amount
330
+ }
331
+ fragment ImageFragment on Image {
332
+ id
333
+ url
334
+ altText
335
+ width
336
+ height
337
+ }
338
+ `;var ar="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";function Be(e){var _,c;const{data:t,options:r,id:a=t.id,frameBorder:o="0",allow:i="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:u=!0,loading:n="lazy",...l}=e;if(!t.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let d=t.embedUrl;if(r){const h=new URL(t.embedUrl);for(const m of Object.keys(r))h.searchParams.set(m,r[m]);d=h.toString()}return w.default.createElement("iframe",{...l,id:a!=null?a:t.embedUrl,title:(c=(_=t.alt)!=null?_:t.id)!=null?c:"external video",frameBorder:o,allow:i,allowFullScreen:u,src:d,loading:n,__self:this,__source:{fileName:ar,lineNumber:56,columnNumber:5}})}const ir=["cdn.shopify.com","cdn.shopifycdn.net","shopify-assets.shopifycdn.com","shopify-assets.shopifycdn.net"],or=["spin.dev"],ur=[...ir,...or],te=[352,832,1200,1920,2560];function We({src:e,width:t,height:r,crop:a,scale:o}){const i=new URL(e),u=o!=null?o:1;if(t){let n;typeof t=="string"?n=(te[0]*u).toString():n=(Number(t)*u).toString(),i.searchParams.append("width",n)}return r&&typeof r=="number"&&i.searchParams.append("height",(r*u).toString()),a&&i.searchParams.append("crop",a),i.toString()}function Ye(e){const t=new URL(e.src);return!ur.some(a=>t.hostname.endsWith(a))||!e.width&&!e.height&&!e.crop&&!e.scale?e.src:We(e)}function cr({data:e,loaderOptions:t,elementProps:r}){var o,i,u,n,l,d;let a=null;return(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&(a=(e==null?void 0:e.width)/(e==null?void 0:e.height)),(t==null?void 0:t.width)||(t==null?void 0:t.height)?{width:(o=t==null?void 0:t.width)!=null?o:a&&typeof t.height=="number"?Math.round(a*t.height):null,height:(i=t==null?void 0:t.height)!=null?i:a&&typeof t.width=="number"?Math.round(a*t.width):null}:(r==null?void 0:r.width)||(r==null?void 0:r.height)?{width:(u=r==null?void 0:r.width)!=null?u:a&&typeof r.height=="number"?Math.round(a*r.height):null,height:(n=r==null?void 0:r.height)!=null?n:a&&typeof r.width=="number"?Math.round(a*r.width):null}:(e==null?void 0:e.width)||(e==null?void 0:e.height)?{width:(l=e==null?void 0:e.width)!=null?l:null,height:(d=e==null?void 0:e.height)!=null?d:null}:{width:null,height:null}}var sr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";function ie({data:e,width:t,height:r,loading:a,loader:o=Ye,loaderOptions:i,widths:u,decoding:n="async",...l}){var p,A,f,S,v,b;if(!e.url){const s=`<Image/>: the 'data' prop requires the 'url' property. Image: ${(p=e.id)!=null?p:"no ID provided"}`;return console.error(s),null}const{width:d,height:_}=cr({data:e,loaderOptions:i,elementProps:{width:t,height:r}});let c=e.url;if(o&&(c=o({...i,src:e.url,width:d,height:_}),typeof c!="string"||!c))throw new Error(`<Image/>: 'loader' did not return a valid string. Image: ${(A=e.id)!=null?A:e.url}`);const h=t&&d&&t<d?t:d,m=(f=l.srcSet)!=null?f:lr({...i,widths:u,src:e.url,width:h,height:_,loader:o});return ve.createElement("img",{id:(S=e.id)!=null?S:"",alt:(b=(v=e.altText)!=null?v:l.alt)!=null?b:"",loading:a!=null?a:"lazy",...l,src:c,width:d!=null?d:void 0,height:_!=null?_:void 0,srcSet:m,decoding:n,__self:this,__source:{fileName:sr,lineNumber:150,columnNumber:5}})}function lr({src:e,width:t,crop:r,scale:a,widths:o,loader:i,height:u}){const n=o&&Array.isArray(o);if(n&&o.some(c=>isNaN(c)))throw new Error(`<Image/>: the 'widths' must be an array of numbers. Image: ${e}`);let l=1;t&&u&&(l=Number(u)/Number(t));let d=n?o:te;!n&&t&&t<te[te.length-1]&&(d=te.filter(c=>c<=t));const _=i||We;return d.map(c=>`${_({src:e,width:c,height:r?Number(c)*l:void 0,crop:r,scale:a})} ${c}w`).join(", ")}var Ge="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Video.tsx";function pe(e){var d,_;const{data:t,previewImageOptions:r,id:a=t.id,playsInline:o=!0,controls:i=!0,sourceProps:u={},...n}=e,l=Ye({src:(_=(d=t.previewImage)==null?void 0:d.url)!=null?_:"",...r});if(!t.sources)throw new Error("<Video/> requires a 'data.sources' array");return w.default.createElement("video",{...n,id:a,playsInline:o,controls:i,poster:l,__self:this,__source:{fileName:Ge,lineNumber:42,columnNumber:5}},t.sources.map(c=>{if(!((c==null?void 0:c.url)&&(c==null?void 0:c.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return w.default.createElement("source",{...u,key:c.url,src:c.url,type:c.mimeType,__self:this,__source:{fileName:Ge,lineNumber:54,columnNumber:11}})}))}const Ze={};function dr(e,t){const r=Ze[e];if(r)return r;const a=new Promise((o,i)=>{const u=document.createElement("script");t!=null&&t.module?u.type="module":u.type="text/javascript",u.src=e,u.onload=()=>{o(!0)},u.onerror=()=>{i(!1)},(t==null?void 0:t.in)==="head"?document.head.appendChild(u):document.body.appendChild(u)});return Ze[e]=a,a}function Ke(e,t){const[r,a]=g.useState("loading"),o=JSON.stringify(t);return g.useEffect(()=>{async function i(){try{a("loading"),await dr(e,t),a("done")}catch{a("error")}}i()},[e,o,t]),r}var fr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";function ze(e){var d,_,c,h,m,p,A,f,S,v,b;const[t,r]=g.useState(void 0),a=g.useCallback(s=>{r(s)},[]),{data:o,children:i,className:u,...n}=e,l=Ke("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return g.useEffect(()=>{if(!!t)return n.onError&&t.addEventListener("error",n.onError),n.onLoad&&t.addEventListener("load",n.onLoad),n.onPreload&&t.addEventListener("preload",n.onPreload),n.onModelVisibility&&t.addEventListener("model-visibility",n.onModelVisibility),n.onProgress&&t.addEventListener("progress",n.onProgress),n.onArStatus&&t.addEventListener("ar-status",n.onArStatus),n.onArTracking&&t.addEventListener("ar-tracking",n.onArTracking),n.onQuickLookButtonTapped&&t.addEventListener("quick-look-button-tapped",n.onQuickLookButtonTapped),n.onCameraChange&&t.addEventListener("camera-change",n.onCameraChange),n.onEnvironmentChange&&t.addEventListener("environment-change",n.onEnvironmentChange),n.onPlay&&t.addEventListener("play",n.onPlay),n.onPause&&t.addEventListener("ar-status",n.onPause),n.onSceneGraphReady&&t.addEventListener("scene-graph-ready",n.onSceneGraphReady),()=>{t!=null&&(n.onError&&t.removeEventListener("error",n.onError),n.onLoad&&t.removeEventListener("load",n.onLoad),n.onPreload&&t.removeEventListener("preload",n.onPreload),n.onModelVisibility&&t.removeEventListener("model-visibility",n.onModelVisibility),n.onProgress&&t.removeEventListener("progress",n.onProgress),n.onArStatus&&t.removeEventListener("ar-status",n.onArStatus),n.onArTracking&&t.removeEventListener("ar-tracking",n.onArTracking),n.onQuickLookButtonTapped&&t.removeEventListener("quick-look-button-tapped",n.onQuickLookButtonTapped),n.onCameraChange&&t.removeEventListener("camera-change",n.onCameraChange),n.onEnvironmentChange&&t.removeEventListener("environment-change",n.onEnvironmentChange),n.onPlay&&t.removeEventListener("play",n.onPlay),n.onPause&&t.removeEventListener("ar-status",n.onPause),n.onSceneGraphReady&&t.removeEventListener("scene-graph-ready",n.onSceneGraphReady))}},[t,n.onArStatus,n.onArTracking,n.onCameraChange,n.onEnvironmentChange,n.onError,n.onLoad,n.onModelVisibility,n.onPause,n.onPlay,n.onPreload,n.onProgress,n.onQuickLookButtonTapped,n.onSceneGraphReady]),l!=="done"?null:(_=(d=o.sources)==null?void 0:d[0])!=null&&_.url?w.default.createElement("model-viewer",{ref:a,...n,className:u,id:(c=n.id)!=null?c:o.id,src:o.sources[0].url,alt:(h=o.alt)!=null?h:null,"camera-controls":(m=n.cameraControls)!=null?m:!0,poster:(A=n.poster||((p=o.previewImage)==null?void 0:p.url))!=null?A:null,autoplay:(f=n.autoplay)!=null?f:!0,loading:n.loading,reveal:n.reveal,ar:n.ar,"ar-modes":n.arModes,"ar-scale":n.arScale,"ar-placement":n.arPlacement,"ios-src":n.iosSrc,"touch-action":n.touchAction,"disable-zoom":n.disableZoom,"orbit-sensitivity":n.orbitSensitivity,"auto-rotate":n.autoRotate,"auto-rotate-delay":n.autoRotateDelay,"rotation-per-second":n.rotationPerSecond,"interaction-policy":n.interactionPolicy,"interaction-prompt":n.interactionPrompt,"interaction-prompt-style":n.interactionPromptStyle,"interaction-prompt-threshold":n.interactionPromptThreshold,"camera-orbit":n.cameraOrbit,"camera-target":n.cameraTarget,"field-of-view":n.fieldOfView,"max-camera-orbit":n.maxCameraOrbit,"min-camera-orbit":n.minCameraOrbit,"max-field-of-view":n.maxFieldOfView,"min-field-of-view":n.minFieldOfView,bounds:n.bounds,"interpolation-decay":(S=n.interpolationDecay)!=null?S:100,"skybox-image":n.skyboxImage,"environment-image":n.environmentImage,exposure:n.exposure,"shadow-intensity":(v=n.shadowIntensity)!=null?v:0,"shadow-softness":(b=n.shadowSoftness)!=null?b:0,"animation-name":n.animationName,"animation-crossfade-duration":n.animationCrossfadeDuration,"variant-name":n.variantName,orientation:n.orientation,scale:n.scale,__self:this,__source:{fileName:fr,lineNumber:222,columnNumber:5}},i):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}var oe="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";function mr({data:e,mediaOptions:t,...r}){switch(e.__typename){case"MediaImage":return e.image?w.default.createElement(ie,{...r,...t==null?void 0:t.image,data:e.image,__self:this,__source:{fileName:oe,lineNumber:50,columnNumber:9}}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return w.default.createElement(pe,{...r,...t==null?void 0:t.video,data:e,__self:this,__source:{fileName:oe,lineNumber:59,columnNumber:9}});case"ExternalVideo":return w.default.createElement(Be,{...r,...t==null?void 0:t.externalVideo,data:e,__self:this,__source:{fileName:oe,lineNumber:64,columnNumber:9}});case"Model3d":return w.default.createElement(ze,{...r,...t==null?void 0:t.modelViewer,data:e,__self:this,__source:{fileName:oe,lineNumber:73,columnNumber:9}});default:return console.error("<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to correctly render the correct component for this media. Rendering 'null' by default"),null}}var k="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Metafield.tsx";function yr(e){var n,l,d,_,c,h,m,p,A;const{data:t,as:r,...a}=e,{locale:o}=X(),i=g.useMemo(()=>Qe(t),[t]);if(!i)return console.warn("<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'"),null;if(i.value===null||i.value===void 0){const f=`<Metafield/>: No metafield value for metafield ${(n=i.id)!=null?n:i.key}. Rendering 'null'`;return console.warn(f),null}switch(i.type){case"date":{const f=r!=null?r:"time";return w.default.createElement(f,{...a,__self:this,__source:{fileName:k,lineNumber:68,columnNumber:9}},i.value.toLocaleDateString(o))}case"date_time":{const f=r!=null?r:"time";return w.default.createElement(f,{...a,__self:this,__source:{fileName:k,lineNumber:76,columnNumber:9}},i.value.toLocaleString(o))}case"weight":case"dimension":case"volume":{const f=r!=null?r:"span";return w.default.createElement(f,{...a,__self:this,__source:{fileName:k,lineNumber:86,columnNumber:9}},gr(i.value,o))}case"rating":{const f=r!=null?r:"span";return w.default.createElement(f,{...a,__self:this,__source:{fileName:k,lineNumber:94,columnNumber:9}},i.value.value)}case"single_line_text_field":{const f=r!=null?r:"span";return w.default.createElement(f,{...a,dangerouslySetInnerHTML:{__html:i.value},__self:this,__source:{fileName:k,lineNumber:102,columnNumber:9}})}case"multi_line_text_field":{const f=r!=null?r:"div";return w.default.createElement(f,{...a,dangerouslySetInnerHTML:{__html:i.value.split(`
339
+ `).join("<br/>")},__self:this,__source:{fileName:k,lineNumber:111,columnNumber:9}})}case"url":{const f=new URL(i.value);return w.default.createElement("a",{href:f.href.replace(f.protocol,""),...a,__self:this,__source:{fileName:k,lineNumber:122,columnNumber:9}},i.value)}case"json":{const f=r!=null?r:"span";return w.default.createElement(f,{...a,__self:this,__source:{fileName:k,lineNumber:133,columnNumber:9}},JSON.stringify(i.value))}case"product_reference":case"variant_reference":case"page_reference":{const f=r!=null?r:"span",S=i.reference;return w.default.createElement(f,{...a,__self:this,__source:{fileName:k,lineNumber:144,columnNumber:9}},(d=(l=S==null?void 0:S.title)!=null?l:S==null?void 0:S.id)!=null?d:"")}case"list.single_line_text_field":{const f=r!=null?r:"ul",S=i.references?x(i.references):[];return w.default.createElement(f,{...a,__self:this,__source:{fileName:k,lineNumber:155,columnNumber:9}},S.map((v,b)=>w.default.createElement("li",{key:`${v!=null?v:""}-${b}`,__self:this,__source:{fileName:k,lineNumber:159,columnNumber:13}},v)))}case"file_reference":if(((_=i.reference)==null?void 0:_.__typename)==="MediaImage"){const f=i.reference;return f.image?w.default.createElement(ie,{data:f.image,...a,__self:this,__source:{fileName:k,lineNumber:168,columnNumber:11}}):null}else if(((c=i.reference)==null?void 0:c.__typename)==="GenericFile"){const f=i.reference;return f.previewImage?w.default.createElement("a",{href:(m=(h=i.reference)==null?void 0:h.url)!=null?m:"",...a,__self:this,__source:{fileName:k,lineNumber:173,columnNumber:11}},w.default.createElement(ie,{data:f.previewImage,__self:this,__source:{fileName:k,lineNumber:174,columnNumber:13}})):null}else if(((p=i.reference)==null?void 0:p.__typename)==="Video"){const f=i.reference;return w.default.createElement(pe,{...a,data:f,__self:this,__source:{fileName:k,lineNumber:179,columnNumber:16}})}}const u=r!=null?r:"span";return w.default.createElement(u,{...a,__self:this,__source:{fileName:k,lineNumber:186,columnNumber:5}},(A=i.value)==null?void 0:A.toString())}function Qe(e){return e?{...e,value:Xe(e)}:null}function Xe(e){if(!e)return null;if(e.value===null||e.value===void 0)return e.value;switch(e.type){case"boolean":return e.value==="true";case"number_integer":return parseInt(e.value);case"number_decimal":return parseFloat(e.value);case"date":case"date_time":return new Date(e.value);case"json":case"weight":case"dimension":case"volume":case"rating":return hr(e.value);case"color":case"single_line_text_field":case"multi_line_text_field":case"product_reference":case"page_reference":case"variant_reference":case"file_reference":case"url":default:return e.value}}function hr(e){return String(e).includes("__proto__")?JSON.parse(e,(t,r)=>{if(t!=="__proto__")return r}):JSON.parse(e)}const _r={mm:"millimeter",cm:"centimeter",m:"meter",in:"inch",ft:"foot",yd:"yard",ml:"milliliter",l:"liter",us_fl_oz:"fluid-ounce",us_gal:"gallon",kg:"kilogram",g:"gram",lb:"pound",oz:"ounce"};function gr(e,t="en-us",r={}){let a={value:e.value,unit:_r[e.unit]};return a.unit==null&&(a=Er(e.value,e.unit)),new Intl.NumberFormat(t,{...r,unit:a.unit,style:"unit"}).format(a.value)}function Er(e,t){switch(t){case"cl":return{value:e/1e3,unit:"liter"};case"m3":return{value:e*1e3,unit:"liter"};case"us_pt":return{value:e*.125,unit:"gallon"};case"us_qt":return{value:e*.5,unit:"gallon"};case"us_oz":return{value:e/128,unit:"gallon"};case"imp_pt":return{value:e/6.661,unit:"gallon"};case"imp_qt":return{value:e/3.331,unit:"gallon"};case"imp_gal":return{value:e/1.201,unit:"gallon"};case"imp_fl_oz":return{value:e*.96076,unit:"fluid-ounce"};default:throw new Error(`Unit not supported: ${t}`)}}function Je(e){const{locale:t}=X();if(!t)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");const r=parseFloat(e.amount),a=g.useMemo(()=>({style:"currency",currency:e.currencyCode}),[e.currencyCode]),o=Z(t,a),i=Z(t,{...a,currencyDisplay:"name"}),u=Z(t,{...a,currencyDisplay:"narrowSymbol"}),n=Z(t,{...a,minimumFractionDigits:0,maximumFractionDigits:0}),l=Z(t),d=Z(t,{minimumFractionDigits:0,maximumFractionDigits:0}),_=h=>h.type==="currency",c=g.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>o().format(r),parts:()=>o().formatToParts(r),withoutTrailingZeros:()=>r%1===0?n().format(r):o().format(r),withoutTrailingZerosAndCurrency:()=>r%1===0?d().format(r):l().format(r),currencyName:()=>{var h,m;return(m=(h=i().formatToParts(r).find(_))==null?void 0:h.value)!=null?m:e.currencyCode},currencySymbol:()=>{var h,m;return(m=(h=o().formatToParts(r).find(_))==null?void 0:h.value)!=null?m:e.currencyCode},currencyNarrowSymbol:()=>{var h,m;return(m=(h=u().formatToParts(r).find(_))==null?void 0:h.value)!=null?m:""},amount:()=>o().formatToParts(r).filter(h=>["decimal","fraction","group","integer","literal"].includes(h.type)).map(h=>h.value).join("")}),[e,r,i,o,u,l,n,d]);return g.useMemo(()=>new Proxy(c,{get:(h,m)=>{var p;return(p=Reflect.get(h,m))==null?void 0:p.call(null)}}),[c])}function Z(e,t){return g.useMemo(()=>{let r;return()=>r!=null?r:r=new Intl.NumberFormat(e,t)},[e,t])}var pr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";function Se({data:e,as:t,withoutCurrency:r,withoutTrailingZeros:a,measurement:o,measurementSeparator:i="/",...u}){if(!Sr(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const n=Je(e),l=t!=null?t:"div";let d=n.localizedString;return(r||a)&&(r&&!a?d=n.amount:!r&&a?d=n.withoutTrailingZeros:d=n.withoutTrailingZerosAndCurrency),w.default.createElement(l,{...u,__self:this,__source:{fileName:pr,lineNumber:65,columnNumber:5}},d,o&&o.referenceUnit&&w.default.createElement(w.default.Fragment,null,i,o.referenceUnit))}function Sr(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}var et="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";function vr(e){var d,_,c,h,m,p,A,f;const{priceType:t="regular",variantId:r,valueType:a="min",data:o,...i}=e;if(o==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let u,n;const l=r&&(_=x((d=o==null?void 0:o.variants)!=null?d:{}).find(S=>(S==null?void 0:S.id)===r))!=null?_:null;if(t==="compareAt")if(r&&l){if(((c=l.compareAtPriceV2)==null?void 0:c.amount)===((h=l.priceV2)==null?void 0:h.amount))return null;u=l.compareAtPriceV2}else a==="max"?u=(m=o==null?void 0:o.compareAtPriceRange)==null?void 0:m.maxVariantPrice:u=(p=o==null?void 0:o.compareAtPriceRange)==null?void 0:p.minVariantPrice;else r&&l?(u=l.priceV2,a==="unit"&&(u=l.unitPrice,n=l.unitPriceMeasurement)):a==="max"?u=(A=o.priceRange)==null?void 0:A.maxVariantPrice:u=(f=o.priceRange)==null?void 0:f.minVariantPrice;return u?n?w.default.createElement(Se,{...i,data:u,measurement:n,__self:this,__source:{fileName:et,lineNumber:81,columnNumber:7}}):w.default.createElement(Se,{...i,data:u,__self:this,__source:{fileName:et,lineNumber:85,columnNumber:10}}):null}var br="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";const tt=g.createContext(null);function Cr({children:e,data:t,initialVariantId:r}){const a=g.useMemo(()=>{var f;return x((f=t.variants)!=null?f:{})},[t.variants]);if(!Nr(a))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const o=g.useMemo(()=>Ar(a),[a]),[i,u]=g.useState(()=>nt(r,a)),[n,l]=g.useState(()=>at(i));g.useEffect(()=>{const f=nt(r,a);u(f),l(at(f))},[r,a]);const d=g.useCallback((f,S)=>{l(v=>{const b={...v,[f]:S};return u(rt(a,b)),b})},[l,a]),_=g.useCallback((f,S)=>{var b;const v=rt(a,{...n,[f]:S});return(b=v==null?void 0:v.availableForSale)!=null?b:!0},[n,a]),c=g.useMemo(()=>{var f;return x((f=t.sellingPlanGroups)!=null?f:{}).map(S=>{var v;return{...S,sellingPlans:x((v=S==null?void 0:S.sellingPlans)!=null?v:{})}})},[t.sellingPlanGroups]),[h,m]=g.useState(void 0),p=g.useMemo(()=>{var f,S;if(!(!i||!h)){if(!((f=i.sellingPlanAllocations)!=null&&f.nodes)&&!((S=i.sellingPlanAllocations)!=null&&S.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return x(i.sellingPlanAllocations).find(v=>{var b;return((b=v==null?void 0:v.sellingPlan)==null?void 0:b.id)===h.id})}},[i,h]),A=g.useMemo(()=>({variants:a,variantsConnection:t.variants,options:o,selectedVariant:i,setSelectedVariant:u,selectedOptions:n,setSelectedOption:d,setSelectedOptions:l,isOptionInStock:_,selectedSellingPlan:h,setSelectedSellingPlan:m,selectedSellingPlanAllocation:p,sellingPlanGroups:c,sellingPlanGroupsConnection:t.sellingPlanGroups}),[_,o,t.sellingPlanGroups,t.variants,n,h,p,i,c,d,a]);return w.default.createElement(tt.Provider,{value:A,__self:this,__source:{fileName:br,lineNumber:201,columnNumber:5}},e)}function Tr(){const e=g.useContext(tt);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function rt(e,t){var r,a;if(!(!e.length||((a=(r=e==null?void 0:e[0])==null?void 0:r.selectedOptions)==null?void 0:a.length)!==Object.keys(t).length))return e==null?void 0:e.find(o=>Object.entries(t).every(([i,u])=>{var n;return(n=o==null?void 0:o.selectedOptions)==null?void 0:n.some(l=>(l==null?void 0:l.name)===i&&(l==null?void 0:l.value)===u)}))}function Ar(e){const t=e.reduce((r,a)=>{var o;if(!a.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(o=a==null?void 0:a.selectedOptions)==null||o.forEach(i=>{var u,n,l,d;r[(u=i==null?void 0:i.name)!=null?u:""]=r[(n=i==null?void 0:i.name)!=null?n:""]||new Set,r[(l=i==null?void 0:i.name)!=null?l:""].add((d=i==null?void 0:i.value)!=null?d:"")}),r},{});return Object.keys(t).map(r=>({name:r,values:Array.from(t[r])}))}function nt(e,t){if(e){const r=t.find(a=>(a==null?void 0:a.id)===e);return r||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),r}if(e===null)return null;if(e===void 0)return t.find(r=>r==null?void 0:r.availableForSale)||t[0]}function at(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((t,r)=>{var a,o;return t[(a=r==null?void 0:r.name)!=null?a:""]=(o=r==null?void 0:r.value)!=null?o:"",t},{}):{}}function Nr(e){return!(!e||!Array.isArray(e))}var it="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";const wr="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Ir({variantIds:e,className:t,variantIdsAndQuantities:r,width:a}){const{storeDomain:o}=X(),i=Ke(wr);let u;if(e&&r)throw new Error(Dr);if(e)u=e.reduce((l,d)=>{const _=ot(d);return _&&l.push(_),l},[]);else if(r)u=r.reduce((l,d)=>{var c;const _=ot(d==null?void 0:d.id);return _&&l.push(`${_}:${(c=d==null?void 0:d.quantity)!=null?c:1}`),l},[]);else throw new Error(Or);const n=a?{"--shop-pay-button-width":a}:void 0;return w.default.createElement("div",{className:t,style:n,__self:this,__source:{fileName:it,lineNumber:90,columnNumber:5}},i==="done"&&w.default.createElement("shop-pay-button",{"store-url":`https://${o}`,variants:u.join(","),__self:this,__source:{fileName:it,lineNumber:92,columnNumber:9}}))}function ot(e){if(!!e)return e.split("/").pop()}const Or='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',Dr="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component";function Lr({storeDomain:e,privateStorefrontToken:t,publicStorefrontToken:r,storefrontApiVersion:a,contentType:o}){return a!==Q&&console.warn(`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen-UI is targeting. You may run into unexpected errors if these versions don't match. Received verion: "${a}"; expected version ${Q}`),{getStorefrontApiUrl(i){var u,n;return`https://${(u=i==null?void 0:i.storeDomain)!=null?u:e}.myshopify.com/api/${(n=i==null?void 0:i.storefrontApiVersion)!=null?n:a}/graphql.json`},getPrivateTokenHeaders(i){var n,l,d;if(!t&&!(i!=null&&i.privateStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'");return{"content-type":((n=i==null?void 0:i.contentType)!=null?n:o)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":a,"Shopify-Storefront-Private-Token":(d=(l=i==null?void 0:i.privateStorefrontToken)!=null?l:t)!=null?d:"",...i!=null&&i.buyerIp?{"Shopify-Storefront-Buyer-IP":i.buyerIp}:{}}},getPublicTokenHeaders(i){var n,l,d;if(!r&&!(i!=null&&i.publicStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'");return{"content-type":((n=i==null?void 0:i.contentType)!=null?n:o)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":a,"X-Shopify-Storefront-Access-Token":(d=(l=i==null?void 0:i.publicStorefrontToken)!=null?l:r)!=null?d:""}}}}L.CartProvider=Jt,L.ExternalVideo=Be,L.Image=ie,L.MediaFile=mr,L.Metafield=yr,L.ModelViewer=ze,L.Money=Se,L.ProductPrice=vr,L.ProductProvider=Cr,L.ShopPayButton=Ir,L.ShopifyProvider=gt,L.Video=pe,L.createStorefrontClient=Lr,L.flattenConnection=x,L.parseMetafield=Qe,L.parseMetafieldValue=Xe,L.useCart=Xt,L.useCartFetch=le,L.useInstantCheckout=Pt,L.useMoney=Je,L.useProduct=Tr,L.useShop=X,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
3
340
  //# sourceMappingURL=hydrogen-react.prod.js.map