@plasmicpkgs/commerce 0.0.1 → 0.0.5

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 (118) hide show
  1. package/README.md +1 -0
  2. package/dist/api/endpoints/cart.d.ts +4 -0
  3. package/dist/api/endpoints/catalog/products.d.ts +4 -0
  4. package/dist/api/index.d.ts +75 -0
  5. package/dist/api/operations.d.ts +130 -0
  6. package/dist/api/utils/errors.d.ts +10 -0
  7. package/dist/api/utils/is-allowed-method.d.ts +3 -0
  8. package/dist/api/utils/is-allowed-operation.d.ts +6 -0
  9. package/dist/api/utils/types.d.ts +34 -0
  10. package/dist/cart/use-add-item.d.ts +5 -6
  11. package/dist/cart/use-cart.d.ts +5 -6
  12. package/dist/cart/use-remove-item.d.ts +5 -6
  13. package/dist/cart/use-update-item.d.ts +5 -6
  14. package/dist/commerce.cjs.development.js +1933 -0
  15. package/dist/commerce.cjs.development.js.map +1 -0
  16. package/dist/commerce.cjs.production.min.js +2 -0
  17. package/dist/commerce.cjs.production.min.js.map +1 -0
  18. package/dist/commerce.d.ts +41 -0
  19. package/dist/commerce.esm.js +1908 -0
  20. package/dist/commerce.esm.js.map +1 -0
  21. package/dist/contexts.d.ts +10 -7
  22. package/dist/index.d.ts +25 -71
  23. package/dist/index.js +7 -28
  24. package/dist/product/use-price.d.ts +26 -26
  25. package/dist/product/use-search.d.ts +6 -6
  26. package/dist/registerAddToCartButton.d.ts +9 -0
  27. package/dist/registerProductCollection.d.ts +18 -11
  28. package/dist/registerProductMedia.d.ts +10 -0
  29. package/dist/registerProductPrice.d.ts +9 -0
  30. package/dist/registerProductQuantity.d.ts +11 -0
  31. package/dist/registerProductTextField.d.ts +10 -0
  32. package/dist/registerProductVariantPicker.d.ts +9 -0
  33. package/dist/registerUseCart.d.ts +9 -0
  34. package/dist/registerable.d.ts +4 -4
  35. package/dist/site/use-brands.d.ts +5 -0
  36. package/dist/site/use-categories.d.ts +5 -0
  37. package/dist/types/cart.d.ts +157 -157
  38. package/dist/types/checkout.d.ts +57 -57
  39. package/dist/types/common.d.ts +13 -13
  40. package/dist/types/customer/address.d.ts +110 -110
  41. package/dist/types/customer/card.d.ts +113 -113
  42. package/dist/types/customer/index.d.ts +24 -24
  43. package/dist/types/index.d.ts +12 -12
  44. package/dist/types/login.d.ts +27 -27
  45. package/dist/types/logout.d.ts +17 -17
  46. package/dist/types/page.d.ts +24 -24
  47. package/dist/types/product.d.ts +102 -99
  48. package/dist/types/signup.d.ts +23 -23
  49. package/dist/types/site.d.ts +41 -17
  50. package/dist/types/wishlist.d.ts +83 -83
  51. package/dist/utils/default-fetcher.d.ts +4 -4
  52. package/dist/utils/define-property.d.ts +21 -21
  53. package/dist/utils/errors.d.ts +27 -27
  54. package/dist/utils/get-product-price.d.ts +2 -0
  55. package/dist/utils/types.d.ts +95 -94
  56. package/dist/utils/use-data.d.ts +12 -12
  57. package/dist/utils/use-hook.d.ts +6 -6
  58. package/package.json +13 -13
  59. package/dist/auth/use-login.d.ts +0 -6
  60. package/dist/auth/use-login.js +0 -9
  61. package/dist/auth/use-logout.d.ts +0 -6
  62. package/dist/auth/use-logout.js +0 -9
  63. package/dist/auth/use-signup.d.ts +0 -6
  64. package/dist/auth/use-signup.js +0 -9
  65. package/dist/cart/use-add-item.js +0 -9
  66. package/dist/cart/use-cart.js +0 -18
  67. package/dist/cart/use-remove-item.js +0 -9
  68. package/dist/cart/use-update-item.js +0 -9
  69. package/dist/checkout/use-checkout.d.ts +0 -6
  70. package/dist/checkout/use-checkout.js +0 -18
  71. package/dist/checkout/use-submit-checkout.d.ts +0 -6
  72. package/dist/checkout/use-submit-checkout.js +0 -9
  73. package/dist/contexts.js +0 -46
  74. package/dist/customer/address/use-add-item.d.ts +0 -6
  75. package/dist/customer/address/use-add-item.js +0 -9
  76. package/dist/customer/address/use-addresses.d.ts +0 -6
  77. package/dist/customer/address/use-addresses.js +0 -18
  78. package/dist/customer/address/use-remove-item.d.ts +0 -6
  79. package/dist/customer/address/use-remove-item.js +0 -9
  80. package/dist/customer/address/use-update-item.d.ts +0 -6
  81. package/dist/customer/address/use-update-item.js +0 -9
  82. package/dist/customer/card/use-add-item.d.ts +0 -6
  83. package/dist/customer/card/use-add-item.js +0 -9
  84. package/dist/customer/card/use-cards.d.ts +0 -6
  85. package/dist/customer/card/use-cards.js +0 -18
  86. package/dist/customer/card/use-remove-item.d.ts +0 -6
  87. package/dist/customer/card/use-remove-item.js +0 -9
  88. package/dist/customer/card/use-update-item.d.ts +0 -6
  89. package/dist/customer/card/use-update-item.js +0 -9
  90. package/dist/customer/use-customer.d.ts +0 -6
  91. package/dist/customer/use-customer.js +0 -9
  92. package/dist/product/use-price.js +0 -33
  93. package/dist/product/use-search.js +0 -9
  94. package/dist/registerProductCollection.js +0 -42
  95. package/dist/registerProductImage.d.ts +0 -13
  96. package/dist/registerProductImage.js +0 -37
  97. package/dist/registerable.js +0 -0
  98. package/dist/tsconfig.tsbuildinfo +0 -2970
  99. package/dist/types/cart.js +0 -0
  100. package/dist/types/checkout.js +0 -0
  101. package/dist/types/common.js +0 -0
  102. package/dist/types/customer/address.js +0 -0
  103. package/dist/types/customer/card.js +0 -0
  104. package/dist/types/customer/index.js +0 -2
  105. package/dist/types/index.js +0 -11
  106. package/dist/types/login.js +0 -0
  107. package/dist/types/logout.js +0 -0
  108. package/dist/types/page.js +0 -0
  109. package/dist/types/product.js +0 -0
  110. package/dist/types/signup.js +0 -0
  111. package/dist/types/site.js +0 -0
  112. package/dist/types/wishlist.js +0 -0
  113. package/dist/utils/default-fetcher.js +0 -3
  114. package/dist/utils/define-property.js +0 -4
  115. package/dist/utils/errors.js +0 -24
  116. package/dist/utils/types.js +0 -0
  117. package/dist/utils/use-data.js +0 -43
  118. package/dist/utils/use-hook.js +0 -37
@@ -0,0 +1,1933 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
8
+ var React = require('react');
9
+ var React__default = _interopDefault(React);
10
+ var reactHookForm = require('react-hook-form');
11
+ var useSWR = _interopDefault(require('swr'));
12
+ var host = require('@plasmicapp/host');
13
+ var Cookies = _interopDefault(require('js-cookie'));
14
+
15
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
16
+ try {
17
+ var info = gen[key](arg);
18
+ var value = info.value;
19
+ } catch (error) {
20
+ reject(error);
21
+ return;
22
+ }
23
+
24
+ if (info.done) {
25
+ resolve(value);
26
+ } else {
27
+ Promise.resolve(value).then(_next, _throw);
28
+ }
29
+ }
30
+
31
+ function _asyncToGenerator(fn) {
32
+ return function () {
33
+ var self = this,
34
+ args = arguments;
35
+ return new Promise(function (resolve, reject) {
36
+ var gen = fn.apply(self, args);
37
+
38
+ function _next(value) {
39
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
40
+ }
41
+
42
+ function _throw(err) {
43
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
44
+ }
45
+
46
+ _next(undefined);
47
+ });
48
+ };
49
+ }
50
+
51
+ function _extends() {
52
+ _extends = Object.assign || function (target) {
53
+ for (var i = 1; i < arguments.length; i++) {
54
+ var source = arguments[i];
55
+
56
+ for (var key in source) {
57
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
58
+ target[key] = source[key];
59
+ }
60
+ }
61
+ }
62
+
63
+ return target;
64
+ };
65
+
66
+ return _extends.apply(this, arguments);
67
+ }
68
+
69
+ function _inheritsLoose(subClass, superClass) {
70
+ subClass.prototype = Object.create(superClass.prototype);
71
+ subClass.prototype.constructor = subClass;
72
+
73
+ _setPrototypeOf(subClass, superClass);
74
+ }
75
+
76
+ function _getPrototypeOf(o) {
77
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
78
+ return o.__proto__ || Object.getPrototypeOf(o);
79
+ };
80
+ return _getPrototypeOf(o);
81
+ }
82
+
83
+ function _setPrototypeOf(o, p) {
84
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
85
+ o.__proto__ = p;
86
+ return o;
87
+ };
88
+
89
+ return _setPrototypeOf(o, p);
90
+ }
91
+
92
+ function _isNativeReflectConstruct() {
93
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
94
+ if (Reflect.construct.sham) return false;
95
+ if (typeof Proxy === "function") return true;
96
+
97
+ try {
98
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
99
+ return true;
100
+ } catch (e) {
101
+ return false;
102
+ }
103
+ }
104
+
105
+ function _construct(Parent, args, Class) {
106
+ if (_isNativeReflectConstruct()) {
107
+ _construct = Reflect.construct;
108
+ } else {
109
+ _construct = function _construct(Parent, args, Class) {
110
+ var a = [null];
111
+ a.push.apply(a, args);
112
+ var Constructor = Function.bind.apply(Parent, a);
113
+ var instance = new Constructor();
114
+ if (Class) _setPrototypeOf(instance, Class.prototype);
115
+ return instance;
116
+ };
117
+ }
118
+
119
+ return _construct.apply(null, arguments);
120
+ }
121
+
122
+ function _isNativeFunction(fn) {
123
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
124
+ }
125
+
126
+ function _wrapNativeSuper(Class) {
127
+ var _cache = typeof Map === "function" ? new Map() : undefined;
128
+
129
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
130
+ if (Class === null || !_isNativeFunction(Class)) return Class;
131
+
132
+ if (typeof Class !== "function") {
133
+ throw new TypeError("Super expression must either be null or a function");
134
+ }
135
+
136
+ if (typeof _cache !== "undefined") {
137
+ if (_cache.has(Class)) return _cache.get(Class);
138
+
139
+ _cache.set(Class, Wrapper);
140
+ }
141
+
142
+ function Wrapper() {
143
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
144
+ }
145
+
146
+ Wrapper.prototype = Object.create(Class.prototype, {
147
+ constructor: {
148
+ value: Wrapper,
149
+ enumerable: false,
150
+ writable: true,
151
+ configurable: true
152
+ }
153
+ });
154
+ return _setPrototypeOf(Wrapper, Class);
155
+ };
156
+
157
+ return _wrapNativeSuper(Class);
158
+ }
159
+
160
+ function _objectWithoutPropertiesLoose(source, excluded) {
161
+ if (source == null) return {};
162
+ var target = {};
163
+ var sourceKeys = Object.keys(source);
164
+ var key, i;
165
+
166
+ for (i = 0; i < sourceKeys.length; i++) {
167
+ key = sourceKeys[i];
168
+ if (excluded.indexOf(key) >= 0) continue;
169
+ target[key] = source[key];
170
+ }
171
+
172
+ return target;
173
+ }
174
+
175
+ function createCommonjsModule(fn, module) {
176
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
177
+ }
178
+
179
+ var runtime_1 = createCommonjsModule(function (module) {
180
+ /**
181
+ * Copyright (c) 2014-present, Facebook, Inc.
182
+ *
183
+ * This source code is licensed under the MIT license found in the
184
+ * LICENSE file in the root directory of this source tree.
185
+ */
186
+
187
+ var runtime = (function (exports) {
188
+
189
+ var Op = Object.prototype;
190
+ var hasOwn = Op.hasOwnProperty;
191
+ var undefined$1; // More compressible than void 0.
192
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
193
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
194
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
195
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
196
+
197
+ function define(obj, key, value) {
198
+ Object.defineProperty(obj, key, {
199
+ value: value,
200
+ enumerable: true,
201
+ configurable: true,
202
+ writable: true
203
+ });
204
+ return obj[key];
205
+ }
206
+ try {
207
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
208
+ define({}, "");
209
+ } catch (err) {
210
+ define = function(obj, key, value) {
211
+ return obj[key] = value;
212
+ };
213
+ }
214
+
215
+ function wrap(innerFn, outerFn, self, tryLocsList) {
216
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
217
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
218
+ var generator = Object.create(protoGenerator.prototype);
219
+ var context = new Context(tryLocsList || []);
220
+
221
+ // The ._invoke method unifies the implementations of the .next,
222
+ // .throw, and .return methods.
223
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
224
+
225
+ return generator;
226
+ }
227
+ exports.wrap = wrap;
228
+
229
+ // Try/catch helper to minimize deoptimizations. Returns a completion
230
+ // record like context.tryEntries[i].completion. This interface could
231
+ // have been (and was previously) designed to take a closure to be
232
+ // invoked without arguments, but in all the cases we care about we
233
+ // already have an existing method we want to call, so there's no need
234
+ // to create a new function object. We can even get away with assuming
235
+ // the method takes exactly one argument, since that happens to be true
236
+ // in every case, so we don't have to touch the arguments object. The
237
+ // only additional allocation required is the completion record, which
238
+ // has a stable shape and so hopefully should be cheap to allocate.
239
+ function tryCatch(fn, obj, arg) {
240
+ try {
241
+ return { type: "normal", arg: fn.call(obj, arg) };
242
+ } catch (err) {
243
+ return { type: "throw", arg: err };
244
+ }
245
+ }
246
+
247
+ var GenStateSuspendedStart = "suspendedStart";
248
+ var GenStateSuspendedYield = "suspendedYield";
249
+ var GenStateExecuting = "executing";
250
+ var GenStateCompleted = "completed";
251
+
252
+ // Returning this object from the innerFn has the same effect as
253
+ // breaking out of the dispatch switch statement.
254
+ var ContinueSentinel = {};
255
+
256
+ // Dummy constructor functions that we use as the .constructor and
257
+ // .constructor.prototype properties for functions that return Generator
258
+ // objects. For full spec compliance, you may wish to configure your
259
+ // minifier not to mangle the names of these two functions.
260
+ function Generator() {}
261
+ function GeneratorFunction() {}
262
+ function GeneratorFunctionPrototype() {}
263
+
264
+ // This is a polyfill for %IteratorPrototype% for environments that
265
+ // don't natively support it.
266
+ var IteratorPrototype = {};
267
+ define(IteratorPrototype, iteratorSymbol, function () {
268
+ return this;
269
+ });
270
+
271
+ var getProto = Object.getPrototypeOf;
272
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
273
+ if (NativeIteratorPrototype &&
274
+ NativeIteratorPrototype !== Op &&
275
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
276
+ // This environment has a native %IteratorPrototype%; use it instead
277
+ // of the polyfill.
278
+ IteratorPrototype = NativeIteratorPrototype;
279
+ }
280
+
281
+ var Gp = GeneratorFunctionPrototype.prototype =
282
+ Generator.prototype = Object.create(IteratorPrototype);
283
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
284
+ define(Gp, "constructor", GeneratorFunctionPrototype);
285
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
286
+ GeneratorFunction.displayName = define(
287
+ GeneratorFunctionPrototype,
288
+ toStringTagSymbol,
289
+ "GeneratorFunction"
290
+ );
291
+
292
+ // Helper for defining the .next, .throw, and .return methods of the
293
+ // Iterator interface in terms of a single ._invoke method.
294
+ function defineIteratorMethods(prototype) {
295
+ ["next", "throw", "return"].forEach(function(method) {
296
+ define(prototype, method, function(arg) {
297
+ return this._invoke(method, arg);
298
+ });
299
+ });
300
+ }
301
+
302
+ exports.isGeneratorFunction = function(genFun) {
303
+ var ctor = typeof genFun === "function" && genFun.constructor;
304
+ return ctor
305
+ ? ctor === GeneratorFunction ||
306
+ // For the native GeneratorFunction constructor, the best we can
307
+ // do is to check its .name property.
308
+ (ctor.displayName || ctor.name) === "GeneratorFunction"
309
+ : false;
310
+ };
311
+
312
+ exports.mark = function(genFun) {
313
+ if (Object.setPrototypeOf) {
314
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
315
+ } else {
316
+ genFun.__proto__ = GeneratorFunctionPrototype;
317
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
318
+ }
319
+ genFun.prototype = Object.create(Gp);
320
+ return genFun;
321
+ };
322
+
323
+ // Within the body of any async function, `await x` is transformed to
324
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
325
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
326
+ // meant to be awaited.
327
+ exports.awrap = function(arg) {
328
+ return { __await: arg };
329
+ };
330
+
331
+ function AsyncIterator(generator, PromiseImpl) {
332
+ function invoke(method, arg, resolve, reject) {
333
+ var record = tryCatch(generator[method], generator, arg);
334
+ if (record.type === "throw") {
335
+ reject(record.arg);
336
+ } else {
337
+ var result = record.arg;
338
+ var value = result.value;
339
+ if (value &&
340
+ typeof value === "object" &&
341
+ hasOwn.call(value, "__await")) {
342
+ return PromiseImpl.resolve(value.__await).then(function(value) {
343
+ invoke("next", value, resolve, reject);
344
+ }, function(err) {
345
+ invoke("throw", err, resolve, reject);
346
+ });
347
+ }
348
+
349
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
350
+ // When a yielded Promise is resolved, its final value becomes
351
+ // the .value of the Promise<{value,done}> result for the
352
+ // current iteration.
353
+ result.value = unwrapped;
354
+ resolve(result);
355
+ }, function(error) {
356
+ // If a rejected Promise was yielded, throw the rejection back
357
+ // into the async generator function so it can be handled there.
358
+ return invoke("throw", error, resolve, reject);
359
+ });
360
+ }
361
+ }
362
+
363
+ var previousPromise;
364
+
365
+ function enqueue(method, arg) {
366
+ function callInvokeWithMethodAndArg() {
367
+ return new PromiseImpl(function(resolve, reject) {
368
+ invoke(method, arg, resolve, reject);
369
+ });
370
+ }
371
+
372
+ return previousPromise =
373
+ // If enqueue has been called before, then we want to wait until
374
+ // all previous Promises have been resolved before calling invoke,
375
+ // so that results are always delivered in the correct order. If
376
+ // enqueue has not been called before, then it is important to
377
+ // call invoke immediately, without waiting on a callback to fire,
378
+ // so that the async generator function has the opportunity to do
379
+ // any necessary setup in a predictable way. This predictability
380
+ // is why the Promise constructor synchronously invokes its
381
+ // executor callback, and why async functions synchronously
382
+ // execute code before the first await. Since we implement simple
383
+ // async functions in terms of async generators, it is especially
384
+ // important to get this right, even though it requires care.
385
+ previousPromise ? previousPromise.then(
386
+ callInvokeWithMethodAndArg,
387
+ // Avoid propagating failures to Promises returned by later
388
+ // invocations of the iterator.
389
+ callInvokeWithMethodAndArg
390
+ ) : callInvokeWithMethodAndArg();
391
+ }
392
+
393
+ // Define the unified helper method that is used to implement .next,
394
+ // .throw, and .return (see defineIteratorMethods).
395
+ this._invoke = enqueue;
396
+ }
397
+
398
+ defineIteratorMethods(AsyncIterator.prototype);
399
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
400
+ return this;
401
+ });
402
+ exports.AsyncIterator = AsyncIterator;
403
+
404
+ // Note that simple async functions are implemented on top of
405
+ // AsyncIterator objects; they just return a Promise for the value of
406
+ // the final result produced by the iterator.
407
+ exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
408
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
409
+
410
+ var iter = new AsyncIterator(
411
+ wrap(innerFn, outerFn, self, tryLocsList),
412
+ PromiseImpl
413
+ );
414
+
415
+ return exports.isGeneratorFunction(outerFn)
416
+ ? iter // If outerFn is a generator, return the full iterator.
417
+ : iter.next().then(function(result) {
418
+ return result.done ? result.value : iter.next();
419
+ });
420
+ };
421
+
422
+ function makeInvokeMethod(innerFn, self, context) {
423
+ var state = GenStateSuspendedStart;
424
+
425
+ return function invoke(method, arg) {
426
+ if (state === GenStateExecuting) {
427
+ throw new Error("Generator is already running");
428
+ }
429
+
430
+ if (state === GenStateCompleted) {
431
+ if (method === "throw") {
432
+ throw arg;
433
+ }
434
+
435
+ // Be forgiving, per 25.3.3.3.3 of the spec:
436
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
437
+ return doneResult();
438
+ }
439
+
440
+ context.method = method;
441
+ context.arg = arg;
442
+
443
+ while (true) {
444
+ var delegate = context.delegate;
445
+ if (delegate) {
446
+ var delegateResult = maybeInvokeDelegate(delegate, context);
447
+ if (delegateResult) {
448
+ if (delegateResult === ContinueSentinel) continue;
449
+ return delegateResult;
450
+ }
451
+ }
452
+
453
+ if (context.method === "next") {
454
+ // Setting context._sent for legacy support of Babel's
455
+ // function.sent implementation.
456
+ context.sent = context._sent = context.arg;
457
+
458
+ } else if (context.method === "throw") {
459
+ if (state === GenStateSuspendedStart) {
460
+ state = GenStateCompleted;
461
+ throw context.arg;
462
+ }
463
+
464
+ context.dispatchException(context.arg);
465
+
466
+ } else if (context.method === "return") {
467
+ context.abrupt("return", context.arg);
468
+ }
469
+
470
+ state = GenStateExecuting;
471
+
472
+ var record = tryCatch(innerFn, self, context);
473
+ if (record.type === "normal") {
474
+ // If an exception is thrown from innerFn, we leave state ===
475
+ // GenStateExecuting and loop back for another invocation.
476
+ state = context.done
477
+ ? GenStateCompleted
478
+ : GenStateSuspendedYield;
479
+
480
+ if (record.arg === ContinueSentinel) {
481
+ continue;
482
+ }
483
+
484
+ return {
485
+ value: record.arg,
486
+ done: context.done
487
+ };
488
+
489
+ } else if (record.type === "throw") {
490
+ state = GenStateCompleted;
491
+ // Dispatch the exception by looping back around to the
492
+ // context.dispatchException(context.arg) call above.
493
+ context.method = "throw";
494
+ context.arg = record.arg;
495
+ }
496
+ }
497
+ };
498
+ }
499
+
500
+ // Call delegate.iterator[context.method](context.arg) and handle the
501
+ // result, either by returning a { value, done } result from the
502
+ // delegate iterator, or by modifying context.method and context.arg,
503
+ // setting context.delegate to null, and returning the ContinueSentinel.
504
+ function maybeInvokeDelegate(delegate, context) {
505
+ var method = delegate.iterator[context.method];
506
+ if (method === undefined$1) {
507
+ // A .throw or .return when the delegate iterator has no .throw
508
+ // method always terminates the yield* loop.
509
+ context.delegate = null;
510
+
511
+ if (context.method === "throw") {
512
+ // Note: ["return"] must be used for ES3 parsing compatibility.
513
+ if (delegate.iterator["return"]) {
514
+ // If the delegate iterator has a return method, give it a
515
+ // chance to clean up.
516
+ context.method = "return";
517
+ context.arg = undefined$1;
518
+ maybeInvokeDelegate(delegate, context);
519
+
520
+ if (context.method === "throw") {
521
+ // If maybeInvokeDelegate(context) changed context.method from
522
+ // "return" to "throw", let that override the TypeError below.
523
+ return ContinueSentinel;
524
+ }
525
+ }
526
+
527
+ context.method = "throw";
528
+ context.arg = new TypeError(
529
+ "The iterator does not provide a 'throw' method");
530
+ }
531
+
532
+ return ContinueSentinel;
533
+ }
534
+
535
+ var record = tryCatch(method, delegate.iterator, context.arg);
536
+
537
+ if (record.type === "throw") {
538
+ context.method = "throw";
539
+ context.arg = record.arg;
540
+ context.delegate = null;
541
+ return ContinueSentinel;
542
+ }
543
+
544
+ var info = record.arg;
545
+
546
+ if (! info) {
547
+ context.method = "throw";
548
+ context.arg = new TypeError("iterator result is not an object");
549
+ context.delegate = null;
550
+ return ContinueSentinel;
551
+ }
552
+
553
+ if (info.done) {
554
+ // Assign the result of the finished delegate to the temporary
555
+ // variable specified by delegate.resultName (see delegateYield).
556
+ context[delegate.resultName] = info.value;
557
+
558
+ // Resume execution at the desired location (see delegateYield).
559
+ context.next = delegate.nextLoc;
560
+
561
+ // If context.method was "throw" but the delegate handled the
562
+ // exception, let the outer generator proceed normally. If
563
+ // context.method was "next", forget context.arg since it has been
564
+ // "consumed" by the delegate iterator. If context.method was
565
+ // "return", allow the original .return call to continue in the
566
+ // outer generator.
567
+ if (context.method !== "return") {
568
+ context.method = "next";
569
+ context.arg = undefined$1;
570
+ }
571
+
572
+ } else {
573
+ // Re-yield the result returned by the delegate method.
574
+ return info;
575
+ }
576
+
577
+ // The delegate iterator is finished, so forget it and continue with
578
+ // the outer generator.
579
+ context.delegate = null;
580
+ return ContinueSentinel;
581
+ }
582
+
583
+ // Define Generator.prototype.{next,throw,return} in terms of the
584
+ // unified ._invoke helper method.
585
+ defineIteratorMethods(Gp);
586
+
587
+ define(Gp, toStringTagSymbol, "Generator");
588
+
589
+ // A Generator should always return itself as the iterator object when the
590
+ // @@iterator function is called on it. Some browsers' implementations of the
591
+ // iterator prototype chain incorrectly implement this, causing the Generator
592
+ // object to not be returned from this call. This ensures that doesn't happen.
593
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
594
+ define(Gp, iteratorSymbol, function() {
595
+ return this;
596
+ });
597
+
598
+ define(Gp, "toString", function() {
599
+ return "[object Generator]";
600
+ });
601
+
602
+ function pushTryEntry(locs) {
603
+ var entry = { tryLoc: locs[0] };
604
+
605
+ if (1 in locs) {
606
+ entry.catchLoc = locs[1];
607
+ }
608
+
609
+ if (2 in locs) {
610
+ entry.finallyLoc = locs[2];
611
+ entry.afterLoc = locs[3];
612
+ }
613
+
614
+ this.tryEntries.push(entry);
615
+ }
616
+
617
+ function resetTryEntry(entry) {
618
+ var record = entry.completion || {};
619
+ record.type = "normal";
620
+ delete record.arg;
621
+ entry.completion = record;
622
+ }
623
+
624
+ function Context(tryLocsList) {
625
+ // The root entry object (effectively a try statement without a catch
626
+ // or a finally block) gives us a place to store values thrown from
627
+ // locations where there is no enclosing try statement.
628
+ this.tryEntries = [{ tryLoc: "root" }];
629
+ tryLocsList.forEach(pushTryEntry, this);
630
+ this.reset(true);
631
+ }
632
+
633
+ exports.keys = function(object) {
634
+ var keys = [];
635
+ for (var key in object) {
636
+ keys.push(key);
637
+ }
638
+ keys.reverse();
639
+
640
+ // Rather than returning an object with a next method, we keep
641
+ // things simple and return the next function itself.
642
+ return function next() {
643
+ while (keys.length) {
644
+ var key = keys.pop();
645
+ if (key in object) {
646
+ next.value = key;
647
+ next.done = false;
648
+ return next;
649
+ }
650
+ }
651
+
652
+ // To avoid creating an additional object, we just hang the .value
653
+ // and .done properties off the next function object itself. This
654
+ // also ensures that the minifier will not anonymize the function.
655
+ next.done = true;
656
+ return next;
657
+ };
658
+ };
659
+
660
+ function values(iterable) {
661
+ if (iterable) {
662
+ var iteratorMethod = iterable[iteratorSymbol];
663
+ if (iteratorMethod) {
664
+ return iteratorMethod.call(iterable);
665
+ }
666
+
667
+ if (typeof iterable.next === "function") {
668
+ return iterable;
669
+ }
670
+
671
+ if (!isNaN(iterable.length)) {
672
+ var i = -1, next = function next() {
673
+ while (++i < iterable.length) {
674
+ if (hasOwn.call(iterable, i)) {
675
+ next.value = iterable[i];
676
+ next.done = false;
677
+ return next;
678
+ }
679
+ }
680
+
681
+ next.value = undefined$1;
682
+ next.done = true;
683
+
684
+ return next;
685
+ };
686
+
687
+ return next.next = next;
688
+ }
689
+ }
690
+
691
+ // Return an iterator with no values.
692
+ return { next: doneResult };
693
+ }
694
+ exports.values = values;
695
+
696
+ function doneResult() {
697
+ return { value: undefined$1, done: true };
698
+ }
699
+
700
+ Context.prototype = {
701
+ constructor: Context,
702
+
703
+ reset: function(skipTempReset) {
704
+ this.prev = 0;
705
+ this.next = 0;
706
+ // Resetting context._sent for legacy support of Babel's
707
+ // function.sent implementation.
708
+ this.sent = this._sent = undefined$1;
709
+ this.done = false;
710
+ this.delegate = null;
711
+
712
+ this.method = "next";
713
+ this.arg = undefined$1;
714
+
715
+ this.tryEntries.forEach(resetTryEntry);
716
+
717
+ if (!skipTempReset) {
718
+ for (var name in this) {
719
+ // Not sure about the optimal order of these conditions:
720
+ if (name.charAt(0) === "t" &&
721
+ hasOwn.call(this, name) &&
722
+ !isNaN(+name.slice(1))) {
723
+ this[name] = undefined$1;
724
+ }
725
+ }
726
+ }
727
+ },
728
+
729
+ stop: function() {
730
+ this.done = true;
731
+
732
+ var rootEntry = this.tryEntries[0];
733
+ var rootRecord = rootEntry.completion;
734
+ if (rootRecord.type === "throw") {
735
+ throw rootRecord.arg;
736
+ }
737
+
738
+ return this.rval;
739
+ },
740
+
741
+ dispatchException: function(exception) {
742
+ if (this.done) {
743
+ throw exception;
744
+ }
745
+
746
+ var context = this;
747
+ function handle(loc, caught) {
748
+ record.type = "throw";
749
+ record.arg = exception;
750
+ context.next = loc;
751
+
752
+ if (caught) {
753
+ // If the dispatched exception was caught by a catch block,
754
+ // then let that catch block handle the exception normally.
755
+ context.method = "next";
756
+ context.arg = undefined$1;
757
+ }
758
+
759
+ return !! caught;
760
+ }
761
+
762
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
763
+ var entry = this.tryEntries[i];
764
+ var record = entry.completion;
765
+
766
+ if (entry.tryLoc === "root") {
767
+ // Exception thrown outside of any try block that could handle
768
+ // it, so set the completion value of the entire function to
769
+ // throw the exception.
770
+ return handle("end");
771
+ }
772
+
773
+ if (entry.tryLoc <= this.prev) {
774
+ var hasCatch = hasOwn.call(entry, "catchLoc");
775
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
776
+
777
+ if (hasCatch && hasFinally) {
778
+ if (this.prev < entry.catchLoc) {
779
+ return handle(entry.catchLoc, true);
780
+ } else if (this.prev < entry.finallyLoc) {
781
+ return handle(entry.finallyLoc);
782
+ }
783
+
784
+ } else if (hasCatch) {
785
+ if (this.prev < entry.catchLoc) {
786
+ return handle(entry.catchLoc, true);
787
+ }
788
+
789
+ } else if (hasFinally) {
790
+ if (this.prev < entry.finallyLoc) {
791
+ return handle(entry.finallyLoc);
792
+ }
793
+
794
+ } else {
795
+ throw new Error("try statement without catch or finally");
796
+ }
797
+ }
798
+ }
799
+ },
800
+
801
+ abrupt: function(type, arg) {
802
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
803
+ var entry = this.tryEntries[i];
804
+ if (entry.tryLoc <= this.prev &&
805
+ hasOwn.call(entry, "finallyLoc") &&
806
+ this.prev < entry.finallyLoc) {
807
+ var finallyEntry = entry;
808
+ break;
809
+ }
810
+ }
811
+
812
+ if (finallyEntry &&
813
+ (type === "break" ||
814
+ type === "continue") &&
815
+ finallyEntry.tryLoc <= arg &&
816
+ arg <= finallyEntry.finallyLoc) {
817
+ // Ignore the finally entry if control is not jumping to a
818
+ // location outside the try/catch block.
819
+ finallyEntry = null;
820
+ }
821
+
822
+ var record = finallyEntry ? finallyEntry.completion : {};
823
+ record.type = type;
824
+ record.arg = arg;
825
+
826
+ if (finallyEntry) {
827
+ this.method = "next";
828
+ this.next = finallyEntry.finallyLoc;
829
+ return ContinueSentinel;
830
+ }
831
+
832
+ return this.complete(record);
833
+ },
834
+
835
+ complete: function(record, afterLoc) {
836
+ if (record.type === "throw") {
837
+ throw record.arg;
838
+ }
839
+
840
+ if (record.type === "break" ||
841
+ record.type === "continue") {
842
+ this.next = record.arg;
843
+ } else if (record.type === "return") {
844
+ this.rval = this.arg = record.arg;
845
+ this.method = "return";
846
+ this.next = "end";
847
+ } else if (record.type === "normal" && afterLoc) {
848
+ this.next = afterLoc;
849
+ }
850
+
851
+ return ContinueSentinel;
852
+ },
853
+
854
+ finish: function(finallyLoc) {
855
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
856
+ var entry = this.tryEntries[i];
857
+ if (entry.finallyLoc === finallyLoc) {
858
+ this.complete(entry.completion, entry.afterLoc);
859
+ resetTryEntry(entry);
860
+ return ContinueSentinel;
861
+ }
862
+ }
863
+ },
864
+
865
+ "catch": function(tryLoc) {
866
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
867
+ var entry = this.tryEntries[i];
868
+ if (entry.tryLoc === tryLoc) {
869
+ var record = entry.completion;
870
+ if (record.type === "throw") {
871
+ var thrown = record.arg;
872
+ resetTryEntry(entry);
873
+ }
874
+ return thrown;
875
+ }
876
+ }
877
+
878
+ // The context.catch method must only be called with a location
879
+ // argument that corresponds to a known catch block.
880
+ throw new Error("illegal catch attempt");
881
+ },
882
+
883
+ delegateYield: function(iterable, resultName, nextLoc) {
884
+ this.delegate = {
885
+ iterator: values(iterable),
886
+ resultName: resultName,
887
+ nextLoc: nextLoc
888
+ };
889
+
890
+ if (this.method === "next") {
891
+ // Deliberately forget the last sent value so that we don't
892
+ // accidentally pass it on to the delegate.
893
+ this.arg = undefined$1;
894
+ }
895
+
896
+ return ContinueSentinel;
897
+ }
898
+ };
899
+
900
+ // Regardless of whether this script is executing as a CommonJS module
901
+ // or not, return the runtime object so that we can declare the variable
902
+ // regeneratorRuntime in the outer scope, which allows this module to be
903
+ // injected easily by `bin/regenerator --include-runtime script.js`.
904
+ return exports;
905
+
906
+ }(
907
+ // If this script is executing as a CommonJS module, use module.exports
908
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
909
+ // object. Either way, the resulting object will be used to initialize
910
+ // the regeneratorRuntime variable at the top of this file.
911
+ module.exports
912
+ ));
913
+
914
+ try {
915
+ regeneratorRuntime = runtime;
916
+ } catch (accidentalStrictMode) {
917
+ // This module should not be running in strict mode, so the above
918
+ // assignment should always work unless something is misconfigured. Just
919
+ // in case runtime.js accidentally runs in strict mode, in modern engines
920
+ // we can explicitly access globalThis. In older engines we can escape
921
+ // strict mode using a global Function call. This could conceivably fail
922
+ // if a Content Security Policy forbids using Function, but in that case
923
+ // the proper solution is to fix the accidental strict mode problem. If
924
+ // you've misconfigured your bundler to force strict mode and applied a
925
+ // CSP to forbid Function, and you're not willing to fix either of those
926
+ // problems, please detail your unique predicament in a GitHub issue.
927
+ if (typeof globalThis === "object") {
928
+ globalThis.regeneratorRuntime = runtime;
929
+ } else {
930
+ Function("r", "regeneratorRuntime = r")(runtime);
931
+ }
932
+ }
933
+ });
934
+
935
+ var ProductContext = /*#__PURE__*/React__default.createContext(undefined);
936
+ function ProductProvider(_ref) {
937
+ var product = _ref.product,
938
+ children = _ref.children;
939
+ var methods = reactHookForm.useForm();
940
+ return React__default.createElement(ProductContext.Provider, {
941
+ value: product,
942
+ key: product.id
943
+ }, React__default.createElement(reactHookForm.FormProvider, Object.assign({}, methods), children));
944
+ }
945
+ function useProduct() {
946
+ return React.useContext(ProductContext);
947
+ }
948
+
949
+ var _excluded = ["children"];
950
+ var Commerce = /*#__PURE__*/React.createContext({});
951
+ function CoreCommerceProvider(_ref) {
952
+ var provider = _ref.provider,
953
+ children = _ref.children;
954
+ var providerRef = React.useRef(provider); // TODO: Remove the fetcherRef
955
+
956
+ var fetcherRef = React.useRef(provider.fetcher); // If the parent re-renders this provider will re-render every
957
+ // consumer unless we memoize the config
958
+
959
+ var _providerRef$current = providerRef.current,
960
+ locale = _providerRef$current.locale,
961
+ cartCookie = _providerRef$current.cartCookie;
962
+ var cfg = React.useMemo(function () {
963
+ return {
964
+ providerRef: providerRef,
965
+ fetcherRef: fetcherRef,
966
+ locale: locale,
967
+ cartCookie: cartCookie
968
+ };
969
+ }, [locale, cartCookie]);
970
+ return React__default.createElement(Commerce.Provider, {
971
+ value: cfg
972
+ }, children);
973
+ }
974
+ function getCommerceProvider(provider) {
975
+ return function CommerceProvider(_ref2) {
976
+ var children = _ref2.children,
977
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded);
978
+
979
+ return React__default.createElement(CoreCommerceProvider, {
980
+ provider: _extends({}, provider, props)
981
+ }, children);
982
+ };
983
+ }
984
+ function useCommerce() {
985
+ return React.useContext(Commerce);
986
+ }
987
+
988
+ /*
989
+ Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
990
+ Changes: None
991
+ */
992
+ // Taken from https://fettblog.eu/typescript-assertion-signatures/
993
+ function defineProperty(obj, prop, val) {
994
+ Object.defineProperty(obj, prop, val);
995
+ }
996
+
997
+ var CommerceError = /*#__PURE__*/function (_Error) {
998
+ _inheritsLoose(CommerceError, _Error);
999
+
1000
+ function CommerceError(_ref) {
1001
+ var _this;
1002
+
1003
+ var message = _ref.message,
1004
+ code = _ref.code,
1005
+ errors = _ref.errors;
1006
+ var error = message ? _extends({
1007
+ message: message
1008
+ }, code ? {
1009
+ code: code
1010
+ } : {}) : errors[0];
1011
+ _this = _Error.call(this, error.message) || this;
1012
+ _this.errors = message ? [error] : errors;
1013
+ if (error.code) _this.code = error.code;
1014
+ return _this;
1015
+ }
1016
+
1017
+ return CommerceError;
1018
+ }( /*#__PURE__*/_wrapNativeSuper(Error)); // Used for errors that come from a bad implementation of the hooks
1019
+
1020
+ var ValidationError = /*#__PURE__*/function (_CommerceError) {
1021
+ _inheritsLoose(ValidationError, _CommerceError);
1022
+
1023
+ function ValidationError(options) {
1024
+ var _this2;
1025
+
1026
+ _this2 = _CommerceError.call(this, options) || this;
1027
+ _this2.code = 'validation_error';
1028
+ return _this2;
1029
+ }
1030
+
1031
+ return ValidationError;
1032
+ }(CommerceError);
1033
+ var FetcherError = /*#__PURE__*/function (_CommerceError2) {
1034
+ _inheritsLoose(FetcherError, _CommerceError2);
1035
+
1036
+ function FetcherError(options) {
1037
+ var _this3;
1038
+
1039
+ _this3 = _CommerceError2.call(this, options) || this;
1040
+ _this3.status = options.status;
1041
+ return _this3;
1042
+ }
1043
+
1044
+ return FetcherError;
1045
+ }(CommerceError);
1046
+
1047
+ var useData = function useData(options, input, fetcherFn, swrOptions) {
1048
+ var hookInput = Array.isArray(input) ? input : Object.entries(input);
1049
+
1050
+ var fetcher = /*#__PURE__*/function () {
1051
+ var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(url, query, method) {
1052
+ var _len,
1053
+ args,
1054
+ _key,
1055
+ _args = arguments;
1056
+
1057
+ return runtime_1.wrap(function _callee$(_context) {
1058
+ while (1) {
1059
+ switch (_context.prev = _context.next) {
1060
+ case 0:
1061
+ _context.prev = 0;
1062
+
1063
+ for (_len = _args.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
1064
+ args[_key - 3] = _args[_key];
1065
+ }
1066
+
1067
+ _context.next = 4;
1068
+ return options.fetcher({
1069
+ options: {
1070
+ url: url,
1071
+ query: query,
1072
+ method: method
1073
+ },
1074
+ // Transform the input array into an object
1075
+ input: args.reduce(function (obj, val, i) {
1076
+ obj[hookInput[i][0]] = val;
1077
+ return obj;
1078
+ }, {}),
1079
+ fetch: fetcherFn
1080
+ });
1081
+
1082
+ case 4:
1083
+ return _context.abrupt("return", _context.sent);
1084
+
1085
+ case 7:
1086
+ _context.prev = 7;
1087
+ _context.t0 = _context["catch"](0);
1088
+
1089
+ // SWR will not log errors, but any error that's not an instance
1090
+ // of CommerceError is not welcomed by this hook
1091
+ if (!(_context.t0 instanceof CommerceError)) {
1092
+ console.error(_context.t0);
1093
+ }
1094
+
1095
+ throw _context.t0;
1096
+
1097
+ case 11:
1098
+ case "end":
1099
+ return _context.stop();
1100
+ }
1101
+ }
1102
+ }, _callee, null, [[0, 7]]);
1103
+ }));
1104
+
1105
+ return function fetcher(_x, _x2, _x3) {
1106
+ return _ref.apply(this, arguments);
1107
+ };
1108
+ }();
1109
+
1110
+ var response = useSWR(function () {
1111
+ var opts = options.fetchOptions;
1112
+ return opts ? [opts.url, opts.query, opts.method].concat(hookInput.map(function (e) {
1113
+ return e[1];
1114
+ })) : null;
1115
+ }, fetcher, swrOptions);
1116
+
1117
+ if (!('isLoading' in response)) {
1118
+ defineProperty(response, 'isLoading', {
1119
+ get: function get() {
1120
+ return response.data === undefined;
1121
+ },
1122
+ enumerable: true
1123
+ });
1124
+ }
1125
+
1126
+ return response;
1127
+ };
1128
+
1129
+ /*
1130
+ Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
1131
+ Changes: None
1132
+ */
1133
+ function useFetcher() {
1134
+ var _providerRef$current$;
1135
+
1136
+ var _useCommerce = useCommerce(),
1137
+ providerRef = _useCommerce.providerRef,
1138
+ fetcherRef = _useCommerce.fetcherRef;
1139
+
1140
+ return (_providerRef$current$ = providerRef.current.fetcher) != null ? _providerRef$current$ : fetcherRef.current;
1141
+ }
1142
+ function useHook(fn) {
1143
+ var _useCommerce2 = useCommerce(),
1144
+ providerRef = _useCommerce2.providerRef;
1145
+
1146
+ var provider = providerRef.current;
1147
+ return fn(provider);
1148
+ }
1149
+ function useSWRHook(hook) {
1150
+ var fetcher = useFetcher();
1151
+ return hook.useHook({
1152
+ useData: function useData$1(ctx) {
1153
+ var _ctx$input;
1154
+
1155
+ var response = useData(hook, (_ctx$input = ctx == null ? void 0 : ctx.input) != null ? _ctx$input : [], fetcher, ctx == null ? void 0 : ctx.swrOptions);
1156
+
1157
+ return response;
1158
+ }
1159
+ });
1160
+ }
1161
+ function useMutationHook(hook) {
1162
+ var fetcher = useFetcher();
1163
+ return hook.useHook({
1164
+ fetch: React.useCallback(function (_temp) {
1165
+ var _ref = _temp === void 0 ? {} : _temp,
1166
+ input = _ref.input;
1167
+
1168
+ return hook.fetcher({
1169
+ input: input,
1170
+ options: hook.fetchOptions,
1171
+ fetch: fetcher
1172
+ });
1173
+ }, [fetcher, hook.fetchOptions])
1174
+ });
1175
+ }
1176
+
1177
+ var SWRFetcher = function SWRFetcher(_ref) {
1178
+ var options = _ref.options,
1179
+ fetch = _ref.fetch;
1180
+ return fetch(options);
1181
+ };
1182
+ var mutationFetcher = function mutationFetcher(_ref2) {
1183
+ var input = _ref2.input,
1184
+ options = _ref2.options,
1185
+ fetch = _ref2.fetch;
1186
+ return fetch(_extends({}, options, {
1187
+ body: input
1188
+ }));
1189
+ };
1190
+
1191
+ var fetcher = mutationFetcher;
1192
+
1193
+ var fn = function fn(provider) {
1194
+ var _provider$cart;
1195
+
1196
+ return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useAddItem;
1197
+ };
1198
+
1199
+ var useAddItem = function useAddItem() {
1200
+ var hook = useHook(fn);
1201
+ return useMutationHook(_extends({
1202
+ fetcher: fetcher
1203
+ }, hook)).apply(void 0, arguments);
1204
+ };
1205
+
1206
+ var addToCartButtonMeta = {
1207
+ name: "plasmic-commerce-add-to-cart-button",
1208
+ displayName: "Add To Cart Button",
1209
+ props: {
1210
+ children: {
1211
+ type: "slot",
1212
+ defaultValue: [{
1213
+ type: "button",
1214
+ value: "Add To Cart"
1215
+ }]
1216
+ }
1217
+ },
1218
+ importPath: "commerce-providers/commerce",
1219
+ importName: "AddToCartButton"
1220
+ };
1221
+
1222
+ function AddToCartButton(props) {
1223
+ var children = props.children;
1224
+ var product = useProduct();
1225
+ var form = reactHookForm.useFormContext();
1226
+ var addItem = useAddItem();
1227
+
1228
+ var addToCart = /*#__PURE__*/function () {
1229
+ var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1230
+ var _form$getValues$Produ;
1231
+
1232
+ var quantity, variantId;
1233
+ return runtime_1.wrap(function _callee$(_context) {
1234
+ while (1) {
1235
+ switch (_context.prev = _context.next) {
1236
+ case 0:
1237
+ quantity = (_form$getValues$Produ = +form.getValues()["ProductQuantity"]) != null ? _form$getValues$Produ : 1;
1238
+
1239
+ if (!(isNaN(quantity) || quantity < 1)) {
1240
+ _context.next = 3;
1241
+ break;
1242
+ }
1243
+
1244
+ throw new CommerceError({
1245
+ message: 'The item quantity has to be a valid integer greater than 0'
1246
+ });
1247
+
1248
+ case 3:
1249
+ if (!product) {
1250
+ _context.next = 7;
1251
+ break;
1252
+ }
1253
+
1254
+ variantId = form.getValues()["ProductVariant"];
1255
+ _context.next = 7;
1256
+ return addItem({
1257
+ productId: product.id,
1258
+ variantId: variantId,
1259
+ quantity: quantity
1260
+ });
1261
+
1262
+ case 7:
1263
+ case "end":
1264
+ return _context.stop();
1265
+ }
1266
+ }
1267
+ }, _callee);
1268
+ }));
1269
+
1270
+ return function addToCart() {
1271
+ return _ref.apply(this, arguments);
1272
+ };
1273
+ }();
1274
+
1275
+ return React__default.isValidElement(children) ? React__default.cloneElement(children, {
1276
+ onClick: function onClick(e) {
1277
+ if (children.props.onClick && typeof children.props.onClick === "function") {
1278
+ children.props.onClick(e);
1279
+ }
1280
+
1281
+ addToCart();
1282
+ }
1283
+ }) : null;
1284
+ }
1285
+
1286
+ function registerAddToCartButton(loader, customAddToCartButtonMeta) {
1287
+ var doRegisterComponent = function doRegisterComponent() {
1288
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1289
+ };
1290
+
1291
+ doRegisterComponent(AddToCartButton, customAddToCartButtonMeta != null ? customAddToCartButtonMeta : addToCartButtonMeta);
1292
+ }
1293
+
1294
+ var fetcher$1 = SWRFetcher;
1295
+
1296
+ var fn$1 = function fn(provider) {
1297
+ var _provider$products;
1298
+
1299
+ return (_provider$products = provider.products) == null ? void 0 : _provider$products.useSearch;
1300
+ };
1301
+
1302
+ var useSearch = function useSearch(input) {
1303
+ var hook = useHook(fn$1);
1304
+ return useSWRHook(_extends({
1305
+ fetcher: fetcher$1
1306
+ }, hook))(input);
1307
+ };
1308
+
1309
+ var productCollectionMeta = {
1310
+ name: "plasmic-commerce-product-collection",
1311
+ displayName: "Product Collection",
1312
+ props: {
1313
+ children: {
1314
+ type: "slot",
1315
+ defaultValue: [{
1316
+ type: "vbox",
1317
+ children: [{
1318
+ type: "component",
1319
+ name: "plasmic-commerce-product-text-field",
1320
+ props: {
1321
+ field: "name"
1322
+ }
1323
+ }, {
1324
+ type: "component",
1325
+ name: "plasmic-commerce-product-media"
1326
+ }],
1327
+ styles: {
1328
+ width: "100%",
1329
+ minWidth: 0
1330
+ }
1331
+ }]
1332
+ },
1333
+ count: "number",
1334
+ category: {
1335
+ type: "choice",
1336
+ options: function options(props, ctx) {
1337
+ var _ctx$categories$map;
1338
+
1339
+ return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
1340
+ return {
1341
+ label: category.name,
1342
+ value: category.id
1343
+ };
1344
+ })) != null ? _ctx$categories$map : [];
1345
+ }
1346
+ },
1347
+ brand: {
1348
+ type: "choice",
1349
+ options: function options(props, ctx) {
1350
+ var _ctx$brands$map;
1351
+
1352
+ return (_ctx$brands$map = ctx == null ? void 0 : ctx.brands.map(function (brand) {
1353
+ return {
1354
+ label: brand.name,
1355
+ value: brand.entityId
1356
+ };
1357
+ })) != null ? _ctx$brands$map : [];
1358
+ }
1359
+ }
1360
+ },
1361
+ defaultStyles: {
1362
+ display: "grid",
1363
+ gridTemplateColumns: "1fr 1fr 1fr 1fr",
1364
+ gridRowGap: "8px",
1365
+ gridColumnGap: "8px",
1366
+ padding: "8px",
1367
+ maxWidth: "100%"
1368
+ },
1369
+ importPath: "commerce-providers/commerce",
1370
+ importName: "ProductCollection"
1371
+ };
1372
+
1373
+ function ProductCollection(props) {
1374
+ var className = props.className,
1375
+ children = props.children,
1376
+ count = props.count,
1377
+ category = props.category,
1378
+ brand = props.brand,
1379
+ setControlContextData = props.setControlContextData;
1380
+
1381
+ var _useSearch = useSearch({
1382
+ categoryId: category,
1383
+ brandId: brand,
1384
+ count: count
1385
+ }),
1386
+ data = _useSearch.data;
1387
+
1388
+ var _useCategories = useCategories({}),
1389
+ categories = _useCategories.data;
1390
+
1391
+ var _useBrands = useBrands({}),
1392
+ brands = _useBrands.data;
1393
+
1394
+ if (categories && brands) {
1395
+ setControlContextData == null ? void 0 : setControlContextData({
1396
+ categories: categories,
1397
+ brands: brands
1398
+ });
1399
+ }
1400
+
1401
+ return React__default.createElement("div", {
1402
+ className: className
1403
+ }, data == null ? void 0 : data.products.map(function (product, i) {
1404
+ return React__default.createElement(ProductProvider, {
1405
+ product: product,
1406
+ key: product.id
1407
+ }, host.repeatedElement(i === 0, children));
1408
+ }));
1409
+ }
1410
+
1411
+ function registerProductCollection(loader, customProductCollectionMeta) {
1412
+ var doRegisterComponent = function doRegisterComponent() {
1413
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1414
+ };
1415
+
1416
+ doRegisterComponent(ProductCollection, customProductCollectionMeta != null ? customProductCollectionMeta : productCollectionMeta);
1417
+ }
1418
+
1419
+ var placeholderImage = "https://static1.plasmic.app/commerce/lightweight-jacket-0.png";
1420
+ var productMediaMeta = {
1421
+ name: "plasmic-commerce-product-media",
1422
+ displayName: "Product Media",
1423
+ props: {
1424
+ mediaIndex: "number"
1425
+ },
1426
+ importPath: "commerce-providers/commerce",
1427
+ importName: "ProductMedia"
1428
+ };
1429
+ function ProductMedia(props) {
1430
+ var _image$url;
1431
+
1432
+ var className = props.className,
1433
+ _props$mediaIndex = props.mediaIndex,
1434
+ mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex;
1435
+ var product = useProduct();
1436
+ var image = product == null ? void 0 : product.images[mediaIndex];
1437
+ return React__default.createElement("img", {
1438
+ alt: (product == null ? void 0 : product.name) || 'Product Image',
1439
+ src: product ? (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "" : placeholderImage,
1440
+ loading: 'lazy',
1441
+ className: className
1442
+ });
1443
+ }
1444
+ function registerProductMedia(loader, customProductMediaMeta) {
1445
+ var doRegisterComponent = function doRegisterComponent() {
1446
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1447
+ };
1448
+
1449
+ doRegisterComponent(ProductMedia, customProductMediaMeta != null ? customProductMediaMeta : productMediaMeta);
1450
+ }
1451
+
1452
+ /*
1453
+ Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
1454
+ Changes: None
1455
+ */
1456
+ function formatPrice(_ref) {
1457
+ var amount = _ref.amount,
1458
+ currencyCode = _ref.currencyCode,
1459
+ locale = _ref.locale;
1460
+ var formatCurrency = new Intl.NumberFormat(locale, {
1461
+ style: 'currency',
1462
+ currency: currencyCode
1463
+ });
1464
+ return formatCurrency.format(amount);
1465
+ }
1466
+ function formatVariantPrice(_ref2) {
1467
+ var amount = _ref2.amount,
1468
+ baseAmount = _ref2.baseAmount,
1469
+ currencyCode = _ref2.currencyCode,
1470
+ locale = _ref2.locale;
1471
+ var hasDiscount = baseAmount > amount;
1472
+ var formatDiscount = new Intl.NumberFormat(locale, {
1473
+ style: 'percent'
1474
+ });
1475
+ var discount = hasDiscount ? formatDiscount.format((baseAmount - amount) / baseAmount) : null;
1476
+ var price = formatPrice({
1477
+ amount: amount,
1478
+ currencyCode: currencyCode,
1479
+ locale: locale
1480
+ });
1481
+ var basePrice = hasDiscount ? formatPrice({
1482
+ amount: baseAmount,
1483
+ currencyCode: currencyCode,
1484
+ locale: locale
1485
+ }) : null;
1486
+ return {
1487
+ price: price,
1488
+ basePrice: basePrice,
1489
+ discount: discount
1490
+ };
1491
+ }
1492
+ function usePrice(data) {
1493
+ var _ref3 = data != null ? data : {},
1494
+ amount = _ref3.amount,
1495
+ baseAmount = _ref3.baseAmount,
1496
+ currencyCode = _ref3.currencyCode;
1497
+
1498
+ var _useCommerce = useCommerce(),
1499
+ locale = _useCommerce.locale;
1500
+
1501
+ var value = React.useMemo(function () {
1502
+ if (typeof amount !== 'number' || !currencyCode) return '';
1503
+ return baseAmount ? formatVariantPrice({
1504
+ amount: amount,
1505
+ baseAmount: baseAmount,
1506
+ currencyCode: currencyCode,
1507
+ locale: locale
1508
+ }) : formatPrice({
1509
+ amount: amount,
1510
+ currencyCode: currencyCode,
1511
+ locale: locale
1512
+ });
1513
+ }, [amount, baseAmount, currencyCode]);
1514
+ return typeof value === 'string' ? {
1515
+ price: value
1516
+ } : value;
1517
+ }
1518
+
1519
+ var getProductPrice = function getProductPrice(product, variantId) {
1520
+ var _product$variants$fin, _product$variants$fin2;
1521
+
1522
+ return (_product$variants$fin = (_product$variants$fin2 = product.variants.find(function (variant) {
1523
+ return variant.id === variantId;
1524
+ })) == null ? void 0 : _product$variants$fin2.price) != null ? _product$variants$fin : product.price.value;
1525
+ };
1526
+
1527
+ var productPriceMeta = {
1528
+ name: "plasmic-commerce-product-price",
1529
+ displayName: "Product Price",
1530
+ props: {},
1531
+ importPath: "commerce-providers/commerce",
1532
+ importName: "ProductPrice"
1533
+ };
1534
+ function ProductPrice(props) {
1535
+ var className = props.className;
1536
+ var product = useProduct();
1537
+ var form = reactHookForm.useFormContext();
1538
+
1539
+ if (!product) {
1540
+ throw new Error("This component must be within a product context.");
1541
+ }
1542
+
1543
+ var watchProductVariant = form.watch("ProductVariant", product == null ? void 0 : product.variants[0].id);
1544
+
1545
+ var _usePrice = usePrice({
1546
+ amount: product ? getProductPrice(product, watchProductVariant) : 0,
1547
+ currencyCode: product ? product.price.currencyCode : 'USD'
1548
+ }),
1549
+ price = _usePrice.price;
1550
+
1551
+ return React__default.createElement("span", {
1552
+ className: className
1553
+ }, price);
1554
+ }
1555
+ function registerProductPrice(loader, customProductPriceMeta) {
1556
+ var doRegisterComponent = function doRegisterComponent() {
1557
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1558
+ };
1559
+
1560
+ doRegisterComponent(ProductPrice, customProductPriceMeta != null ? customProductPriceMeta : productPriceMeta);
1561
+ }
1562
+
1563
+ var productQuantityMeta = {
1564
+ name: "plasmic-commerce-product-quantity",
1565
+ displayName: "Product Quantity",
1566
+ props: {
1567
+ children: {
1568
+ type: "slot",
1569
+ defaultValue: [{
1570
+ type: "input",
1571
+ attrs: {
1572
+ value: "1"
1573
+ }
1574
+ }]
1575
+ }
1576
+ },
1577
+ importPath: "commerce-providers/commerce",
1578
+ importName: "ProductQuantity"
1579
+ };
1580
+ function ProductQuantity(props) {
1581
+ var className = props.className,
1582
+ children = props.children;
1583
+ var form = reactHookForm.useFormContext();
1584
+ return React__default.createElement("div", {
1585
+ className: className
1586
+ }, React__default.createElement(reactHookForm.Controller, {
1587
+ name: "ProductQuantity",
1588
+ defaultValue: 1,
1589
+ control: form == null ? void 0 : form.control,
1590
+ render: function render(_ref) {
1591
+ var field = _ref.field;
1592
+ return React__default.isValidElement(children) ? React__default.cloneElement(children, _extends({}, children.props, field, {
1593
+ name: "ProductQuantity"
1594
+ })) : React__default.createElement(React__default.Fragment, null);
1595
+ }
1596
+ }));
1597
+ }
1598
+ function registerProductQuantity(loader, customProductQuantityMeta) {
1599
+ var doRegisterComponent = function doRegisterComponent() {
1600
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1601
+ };
1602
+
1603
+ doRegisterComponent(ProductQuantity, customProductQuantityMeta != null ? customProductQuantityMeta : productQuantityMeta);
1604
+ }
1605
+
1606
+ var productTextFieldMeta = {
1607
+ name: "plasmic-commerce-product-text-field",
1608
+ displayName: "Product Text Field",
1609
+ props: {
1610
+ field: {
1611
+ type: "choice",
1612
+ options: ["id", "name", "description", "sku", "slug", "path"]
1613
+ }
1614
+ },
1615
+ importPath: "commerce-providers/commerce",
1616
+ importName: "ProductTextField"
1617
+ };
1618
+ function ProductTextField(props) {
1619
+ var className = props.className,
1620
+ field = props.field;
1621
+ var product = useProduct();
1622
+
1623
+ if (!product) {
1624
+ return React__default.createElement("span", {
1625
+ className: className
1626
+ }, "Fake Product Field");
1627
+ }
1628
+
1629
+ if (!field) {
1630
+ return React__default.createElement("span", {
1631
+ className: className
1632
+ }, "Unknown Product Field");
1633
+ }
1634
+
1635
+ var value;
1636
+
1637
+ if (field === "description") {
1638
+ return product.descriptionHtml ? React__default.createElement("div", {
1639
+ className: className,
1640
+ dangerouslySetInnerHTML: {
1641
+ __html: product.descriptionHtml
1642
+ }
1643
+ }) : React__default.createElement("div", {
1644
+ className: className
1645
+ }, product.description);
1646
+ } else {
1647
+ value = product[field];
1648
+ }
1649
+
1650
+ return React__default.createElement("span", {
1651
+ className: className
1652
+ }, value);
1653
+ }
1654
+ function registerTextField(loader, customProductTextFieldMeta) {
1655
+ var doRegisterComponent = function doRegisterComponent() {
1656
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1657
+ };
1658
+
1659
+ doRegisterComponent(ProductTextField, customProductTextFieldMeta != null ? customProductTextFieldMeta : productTextFieldMeta);
1660
+ }
1661
+
1662
+ var productVariantPickerMeta = {
1663
+ name: "plasmic-commerce-product-variant-picker",
1664
+ displayName: "Product Variant Picker",
1665
+ props: {},
1666
+ importPath: "commerce-providers/commerce",
1667
+ importName: "ProductVariantPicker"
1668
+ };
1669
+ function ProductVariantPicker(props) {
1670
+ var className = props.className;
1671
+ var product = useProduct();
1672
+ var form = reactHookForm.useFormContext();
1673
+ return React__default.createElement(reactHookForm.Controller, {
1674
+ name: "ProductVariant",
1675
+ control: form == null ? void 0 : form.control,
1676
+ defaultValue: product == null ? void 0 : product.variants[0].id,
1677
+ render: function render(_ref) {
1678
+ var _product$variants$map;
1679
+
1680
+ var field = _ref.field;
1681
+ return React__default.createElement("select", Object.assign({
1682
+ className: className
1683
+ }, field), (_product$variants$map = product == null ? void 0 : product.variants.map(function (variant) {
1684
+ return React__default.createElement("option", {
1685
+ value: variant.id
1686
+ }, variant.name);
1687
+ })) != null ? _product$variants$map : React__default.createElement("option", null, "Fake Product Variant"));
1688
+ }
1689
+ });
1690
+ }
1691
+ function registerProductVariantPicker(loader, customProductVariantPickerMeta) {
1692
+ var doRegisterComponent = function doRegisterComponent() {
1693
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1694
+ };
1695
+
1696
+ doRegisterComponent(ProductVariantPicker, customProductVariantPickerMeta != null ? customProductVariantPickerMeta : productVariantPickerMeta);
1697
+ }
1698
+
1699
+ var fetcher$2 = /*#__PURE__*/function () {
1700
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
1701
+ var options, cartId, fetch;
1702
+ return runtime_1.wrap(function _callee$(_context) {
1703
+ while (1) {
1704
+ switch (_context.prev = _context.next) {
1705
+ case 0:
1706
+ options = _ref.options, cartId = _ref.input.cartId, fetch = _ref.fetch;
1707
+
1708
+ if (!cartId) {
1709
+ _context.next = 7;
1710
+ break;
1711
+ }
1712
+
1713
+ _context.next = 4;
1714
+ return fetch(options);
1715
+
1716
+ case 4:
1717
+ _context.t0 = _context.sent;
1718
+ _context.next = 8;
1719
+ break;
1720
+
1721
+ case 7:
1722
+ _context.t0 = null;
1723
+
1724
+ case 8:
1725
+ return _context.abrupt("return", _context.t0);
1726
+
1727
+ case 9:
1728
+ case "end":
1729
+ return _context.stop();
1730
+ }
1731
+ }
1732
+ }, _callee);
1733
+ }));
1734
+
1735
+ return function fetcher(_x) {
1736
+ return _ref2.apply(this, arguments);
1737
+ };
1738
+ }();
1739
+
1740
+ var fn$2 = function fn(provider) {
1741
+ var _provider$cart;
1742
+
1743
+ return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useCart;
1744
+ };
1745
+
1746
+ var useCart = function useCart(input) {
1747
+ var _hook$fetcher;
1748
+
1749
+ var hook = useHook(fn$2);
1750
+
1751
+ var _useCommerce = useCommerce(),
1752
+ cartCookie = _useCommerce.cartCookie;
1753
+
1754
+ var fetcherFn = (_hook$fetcher = hook.fetcher) != null ? _hook$fetcher : fetcher$2;
1755
+
1756
+ var wrapper = function wrapper(context) {
1757
+ context.input.cartId = Cookies.get(cartCookie);
1758
+ return fetcherFn(context);
1759
+ };
1760
+
1761
+ return useSWRHook(_extends({}, hook, {
1762
+ fetcher: wrapper
1763
+ }))(input);
1764
+ };
1765
+
1766
+ var useCartMeta = {
1767
+ name: "plasmic-commerce-use-cart",
1768
+ displayName: "Use Cart",
1769
+ props: {
1770
+ field: {
1771
+ type: "choice",
1772
+ options: ["Size", "Total Price"]
1773
+ }
1774
+ },
1775
+ importPath: "commerce-providers/commerce",
1776
+ importName: "UseCart"
1777
+ };
1778
+
1779
+ function UseCartComponent(props) {
1780
+ var _data$totalPrice, _data$currency$code;
1781
+
1782
+ var className = props.className,
1783
+ field = props.field;
1784
+
1785
+ var _useCart = useCart(),
1786
+ data = _useCart.data;
1787
+
1788
+ var _usePrice = usePrice({
1789
+ amount: (_data$totalPrice = data == null ? void 0 : data.totalPrice) != null ? _data$totalPrice : 0,
1790
+ currencyCode: (_data$currency$code = data == null ? void 0 : data.currency.code) != null ? _data$currency$code : "USD"
1791
+ }),
1792
+ price = _usePrice.price;
1793
+
1794
+ if (!field) {
1795
+ return React__default.createElement("p", null, "You must set the field prop");
1796
+ }
1797
+
1798
+ var value;
1799
+
1800
+ if (field === "Size") {
1801
+ var _data$lineItems$lengt;
1802
+
1803
+ value = "" + ((_data$lineItems$lengt = data == null ? void 0 : data.lineItems.length) != null ? _data$lineItems$lengt : 0);
1804
+ } else if (field === "Total Price") {
1805
+ value = "" + price;
1806
+ }
1807
+
1808
+ return React__default.createElement("span", {
1809
+ className: className
1810
+ }, value);
1811
+ }
1812
+
1813
+ function registerUseCart(loader, customUseCartMeta) {
1814
+ var doRegisterComponent = function doRegisterComponent() {
1815
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1816
+ };
1817
+
1818
+ doRegisterComponent(UseCartComponent, customUseCartMeta != null ? customUseCartMeta : useCartMeta);
1819
+ }
1820
+
1821
+ var x = function x() {
1822
+ return 2;
1823
+ };
1824
+
1825
+
1826
+
1827
+ var product = {
1828
+ __proto__: null
1829
+ };
1830
+
1831
+ var fetcher$3 = SWRFetcher;
1832
+
1833
+ var fn$3 = function fn(provider) {
1834
+ var _provider$site;
1835
+
1836
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useCategories;
1837
+ };
1838
+
1839
+ var useCategories = function useCategories(input) {
1840
+ var hook = useHook(fn$3);
1841
+ return useSWRHook(_extends({
1842
+ fetcher: fetcher$3
1843
+ }, hook))(input);
1844
+ };
1845
+
1846
+ var fetcher$4 = SWRFetcher;
1847
+
1848
+ var fn$4 = function fn(provider) {
1849
+ var _provider$site;
1850
+
1851
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
1852
+ };
1853
+
1854
+ var useBrands = function useBrands(input) {
1855
+ var hook = useHook(fn$4);
1856
+ return useSWRHook(_extends({
1857
+ fetcher: fetcher$4
1858
+ }, hook))(input);
1859
+ };
1860
+
1861
+ var fetcher$5 = mutationFetcher;
1862
+
1863
+ var fn$5 = function fn(provider) {
1864
+ var _provider$cart;
1865
+
1866
+ return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useRemoveItem;
1867
+ };
1868
+
1869
+ var useRemoveItem = function useRemoveItem(input) {
1870
+ var hook = useHook(fn$5);
1871
+ return useMutationHook(_extends({
1872
+ fetcher: fetcher$5
1873
+ }, hook))(input);
1874
+ };
1875
+
1876
+ var fetcher$6 = mutationFetcher;
1877
+
1878
+ var fn$6 = function fn(provider) {
1879
+ var _provider$cart;
1880
+
1881
+ return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useUpdateItem;
1882
+ };
1883
+
1884
+ var useUpdateItem = function useUpdateItem(input) {
1885
+ var hook = useHook(fn$6);
1886
+ return useMutationHook(_extends({
1887
+ fetcher: fetcher$6
1888
+ }, hook))(input);
1889
+ };
1890
+
1891
+
1892
+
1893
+ var cart = {
1894
+ __proto__: null
1895
+ };
1896
+
1897
+
1898
+
1899
+ var site = {
1900
+ __proto__: null
1901
+ };
1902
+
1903
+ function registerAll(loader) {
1904
+ registerProductCollection(loader);
1905
+ registerTextField(loader);
1906
+ registerProductPrice(loader);
1907
+ registerProductMedia(loader);
1908
+ registerUseCart(loader);
1909
+ registerAddToCartButton(loader);
1910
+ registerProductQuantity(loader);
1911
+ registerProductVariantPicker(loader);
1912
+ }
1913
+
1914
+ exports.CartType = cart;
1915
+ exports.CommerceError = CommerceError;
1916
+ exports.CoreCommerceProvider = CoreCommerceProvider;
1917
+ exports.FetcherError = FetcherError;
1918
+ exports.ProductTypes = product;
1919
+ exports.SiteTypes = site;
1920
+ exports.ValidationError = ValidationError;
1921
+ exports.fetcher = fetcher$1;
1922
+ exports.getCommerceProvider = getCommerceProvider;
1923
+ exports.registerAll = registerAll;
1924
+ exports.useAddItem = useAddItem;
1925
+ exports.useBrands = useBrands;
1926
+ exports.useCart = useCart;
1927
+ exports.useCategories = useCategories;
1928
+ exports.useCommerce = useCommerce;
1929
+ exports.useRemoveItem = useRemoveItem;
1930
+ exports.useSearch = useSearch;
1931
+ exports.useUpdateItem = useUpdateItem;
1932
+ exports.x = x;
1933
+ //# sourceMappingURL=commerce.cjs.development.js.map