@plasmicpkgs/commerce-local 0.0.1

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.
@@ -0,0 +1,1495 @@
1
+ import registerComponent from '@plasmicapp/host/registerComponent';
2
+ import React, { useCallback } from 'react';
3
+ import { useCart, CommerceError, getCommerceProvider, useCommerce as useCommerce$1 } from '@plasmicpkgs/commerce';
4
+
5
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
6
+ try {
7
+ var info = gen[key](arg);
8
+ var value = info.value;
9
+ } catch (error) {
10
+ reject(error);
11
+ return;
12
+ }
13
+
14
+ if (info.done) {
15
+ resolve(value);
16
+ } else {
17
+ Promise.resolve(value).then(_next, _throw);
18
+ }
19
+ }
20
+
21
+ function _asyncToGenerator(fn) {
22
+ return function () {
23
+ var self = this,
24
+ args = arguments;
25
+ return new Promise(function (resolve, reject) {
26
+ var gen = fn.apply(self, args);
27
+
28
+ function _next(value) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
+ }
31
+
32
+ function _throw(err) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
34
+ }
35
+
36
+ _next(undefined);
37
+ });
38
+ };
39
+ }
40
+
41
+ function _extends() {
42
+ _extends = Object.assign || function (target) {
43
+ for (var i = 1; i < arguments.length; i++) {
44
+ var source = arguments[i];
45
+
46
+ for (var key in source) {
47
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
48
+ target[key] = source[key];
49
+ }
50
+ }
51
+ }
52
+
53
+ return target;
54
+ };
55
+
56
+ return _extends.apply(this, arguments);
57
+ }
58
+
59
+ function _unsupportedIterableToArray(o, minLen) {
60
+ if (!o) return;
61
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
62
+ var n = Object.prototype.toString.call(o).slice(8, -1);
63
+ if (n === "Object" && o.constructor) n = o.constructor.name;
64
+ if (n === "Map" || n === "Set") return Array.from(o);
65
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
66
+ }
67
+
68
+ function _arrayLikeToArray(arr, len) {
69
+ if (len == null || len > arr.length) len = arr.length;
70
+
71
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
72
+
73
+ return arr2;
74
+ }
75
+
76
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
77
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
78
+ if (it) return (it = it.call(o)).next.bind(it);
79
+
80
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
81
+ if (it) o = it;
82
+ var i = 0;
83
+ return function () {
84
+ if (i >= o.length) return {
85
+ done: true
86
+ };
87
+ return {
88
+ done: false,
89
+ value: o[i++]
90
+ };
91
+ };
92
+ }
93
+
94
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
95
+ }
96
+
97
+ function createCommonjsModule(fn, module) {
98
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
99
+ }
100
+
101
+ var runtime_1 = createCommonjsModule(function (module) {
102
+ /**
103
+ * Copyright (c) 2014-present, Facebook, Inc.
104
+ *
105
+ * This source code is licensed under the MIT license found in the
106
+ * LICENSE file in the root directory of this source tree.
107
+ */
108
+
109
+ var runtime = (function (exports) {
110
+
111
+ var Op = Object.prototype;
112
+ var hasOwn = Op.hasOwnProperty;
113
+ var undefined$1; // More compressible than void 0.
114
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
115
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
116
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
117
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
118
+
119
+ function define(obj, key, value) {
120
+ Object.defineProperty(obj, key, {
121
+ value: value,
122
+ enumerable: true,
123
+ configurable: true,
124
+ writable: true
125
+ });
126
+ return obj[key];
127
+ }
128
+ try {
129
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
130
+ define({}, "");
131
+ } catch (err) {
132
+ define = function(obj, key, value) {
133
+ return obj[key] = value;
134
+ };
135
+ }
136
+
137
+ function wrap(innerFn, outerFn, self, tryLocsList) {
138
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
139
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
140
+ var generator = Object.create(protoGenerator.prototype);
141
+ var context = new Context(tryLocsList || []);
142
+
143
+ // The ._invoke method unifies the implementations of the .next,
144
+ // .throw, and .return methods.
145
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
146
+
147
+ return generator;
148
+ }
149
+ exports.wrap = wrap;
150
+
151
+ // Try/catch helper to minimize deoptimizations. Returns a completion
152
+ // record like context.tryEntries[i].completion. This interface could
153
+ // have been (and was previously) designed to take a closure to be
154
+ // invoked without arguments, but in all the cases we care about we
155
+ // already have an existing method we want to call, so there's no need
156
+ // to create a new function object. We can even get away with assuming
157
+ // the method takes exactly one argument, since that happens to be true
158
+ // in every case, so we don't have to touch the arguments object. The
159
+ // only additional allocation required is the completion record, which
160
+ // has a stable shape and so hopefully should be cheap to allocate.
161
+ function tryCatch(fn, obj, arg) {
162
+ try {
163
+ return { type: "normal", arg: fn.call(obj, arg) };
164
+ } catch (err) {
165
+ return { type: "throw", arg: err };
166
+ }
167
+ }
168
+
169
+ var GenStateSuspendedStart = "suspendedStart";
170
+ var GenStateSuspendedYield = "suspendedYield";
171
+ var GenStateExecuting = "executing";
172
+ var GenStateCompleted = "completed";
173
+
174
+ // Returning this object from the innerFn has the same effect as
175
+ // breaking out of the dispatch switch statement.
176
+ var ContinueSentinel = {};
177
+
178
+ // Dummy constructor functions that we use as the .constructor and
179
+ // .constructor.prototype properties for functions that return Generator
180
+ // objects. For full spec compliance, you may wish to configure your
181
+ // minifier not to mangle the names of these two functions.
182
+ function Generator() {}
183
+ function GeneratorFunction() {}
184
+ function GeneratorFunctionPrototype() {}
185
+
186
+ // This is a polyfill for %IteratorPrototype% for environments that
187
+ // don't natively support it.
188
+ var IteratorPrototype = {};
189
+ IteratorPrototype[iteratorSymbol] = function () {
190
+ return this;
191
+ };
192
+
193
+ var getProto = Object.getPrototypeOf;
194
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
195
+ if (NativeIteratorPrototype &&
196
+ NativeIteratorPrototype !== Op &&
197
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
198
+ // This environment has a native %IteratorPrototype%; use it instead
199
+ // of the polyfill.
200
+ IteratorPrototype = NativeIteratorPrototype;
201
+ }
202
+
203
+ var Gp = GeneratorFunctionPrototype.prototype =
204
+ Generator.prototype = Object.create(IteratorPrototype);
205
+ GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
206
+ GeneratorFunctionPrototype.constructor = GeneratorFunction;
207
+ GeneratorFunction.displayName = define(
208
+ GeneratorFunctionPrototype,
209
+ toStringTagSymbol,
210
+ "GeneratorFunction"
211
+ );
212
+
213
+ // Helper for defining the .next, .throw, and .return methods of the
214
+ // Iterator interface in terms of a single ._invoke method.
215
+ function defineIteratorMethods(prototype) {
216
+ ["next", "throw", "return"].forEach(function(method) {
217
+ define(prototype, method, function(arg) {
218
+ return this._invoke(method, arg);
219
+ });
220
+ });
221
+ }
222
+
223
+ exports.isGeneratorFunction = function(genFun) {
224
+ var ctor = typeof genFun === "function" && genFun.constructor;
225
+ return ctor
226
+ ? ctor === GeneratorFunction ||
227
+ // For the native GeneratorFunction constructor, the best we can
228
+ // do is to check its .name property.
229
+ (ctor.displayName || ctor.name) === "GeneratorFunction"
230
+ : false;
231
+ };
232
+
233
+ exports.mark = function(genFun) {
234
+ if (Object.setPrototypeOf) {
235
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
236
+ } else {
237
+ genFun.__proto__ = GeneratorFunctionPrototype;
238
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
239
+ }
240
+ genFun.prototype = Object.create(Gp);
241
+ return genFun;
242
+ };
243
+
244
+ // Within the body of any async function, `await x` is transformed to
245
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
246
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
247
+ // meant to be awaited.
248
+ exports.awrap = function(arg) {
249
+ return { __await: arg };
250
+ };
251
+
252
+ function AsyncIterator(generator, PromiseImpl) {
253
+ function invoke(method, arg, resolve, reject) {
254
+ var record = tryCatch(generator[method], generator, arg);
255
+ if (record.type === "throw") {
256
+ reject(record.arg);
257
+ } else {
258
+ var result = record.arg;
259
+ var value = result.value;
260
+ if (value &&
261
+ typeof value === "object" &&
262
+ hasOwn.call(value, "__await")) {
263
+ return PromiseImpl.resolve(value.__await).then(function(value) {
264
+ invoke("next", value, resolve, reject);
265
+ }, function(err) {
266
+ invoke("throw", err, resolve, reject);
267
+ });
268
+ }
269
+
270
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
271
+ // When a yielded Promise is resolved, its final value becomes
272
+ // the .value of the Promise<{value,done}> result for the
273
+ // current iteration.
274
+ result.value = unwrapped;
275
+ resolve(result);
276
+ }, function(error) {
277
+ // If a rejected Promise was yielded, throw the rejection back
278
+ // into the async generator function so it can be handled there.
279
+ return invoke("throw", error, resolve, reject);
280
+ });
281
+ }
282
+ }
283
+
284
+ var previousPromise;
285
+
286
+ function enqueue(method, arg) {
287
+ function callInvokeWithMethodAndArg() {
288
+ return new PromiseImpl(function(resolve, reject) {
289
+ invoke(method, arg, resolve, reject);
290
+ });
291
+ }
292
+
293
+ return previousPromise =
294
+ // If enqueue has been called before, then we want to wait until
295
+ // all previous Promises have been resolved before calling invoke,
296
+ // so that results are always delivered in the correct order. If
297
+ // enqueue has not been called before, then it is important to
298
+ // call invoke immediately, without waiting on a callback to fire,
299
+ // so that the async generator function has the opportunity to do
300
+ // any necessary setup in a predictable way. This predictability
301
+ // is why the Promise constructor synchronously invokes its
302
+ // executor callback, and why async functions synchronously
303
+ // execute code before the first await. Since we implement simple
304
+ // async functions in terms of async generators, it is especially
305
+ // important to get this right, even though it requires care.
306
+ previousPromise ? previousPromise.then(
307
+ callInvokeWithMethodAndArg,
308
+ // Avoid propagating failures to Promises returned by later
309
+ // invocations of the iterator.
310
+ callInvokeWithMethodAndArg
311
+ ) : callInvokeWithMethodAndArg();
312
+ }
313
+
314
+ // Define the unified helper method that is used to implement .next,
315
+ // .throw, and .return (see defineIteratorMethods).
316
+ this._invoke = enqueue;
317
+ }
318
+
319
+ defineIteratorMethods(AsyncIterator.prototype);
320
+ AsyncIterator.prototype[asyncIteratorSymbol] = function () {
321
+ return this;
322
+ };
323
+ exports.AsyncIterator = AsyncIterator;
324
+
325
+ // Note that simple async functions are implemented on top of
326
+ // AsyncIterator objects; they just return a Promise for the value of
327
+ // the final result produced by the iterator.
328
+ exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
329
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
330
+
331
+ var iter = new AsyncIterator(
332
+ wrap(innerFn, outerFn, self, tryLocsList),
333
+ PromiseImpl
334
+ );
335
+
336
+ return exports.isGeneratorFunction(outerFn)
337
+ ? iter // If outerFn is a generator, return the full iterator.
338
+ : iter.next().then(function(result) {
339
+ return result.done ? result.value : iter.next();
340
+ });
341
+ };
342
+
343
+ function makeInvokeMethod(innerFn, self, context) {
344
+ var state = GenStateSuspendedStart;
345
+
346
+ return function invoke(method, arg) {
347
+ if (state === GenStateExecuting) {
348
+ throw new Error("Generator is already running");
349
+ }
350
+
351
+ if (state === GenStateCompleted) {
352
+ if (method === "throw") {
353
+ throw arg;
354
+ }
355
+
356
+ // Be forgiving, per 25.3.3.3.3 of the spec:
357
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
358
+ return doneResult();
359
+ }
360
+
361
+ context.method = method;
362
+ context.arg = arg;
363
+
364
+ while (true) {
365
+ var delegate = context.delegate;
366
+ if (delegate) {
367
+ var delegateResult = maybeInvokeDelegate(delegate, context);
368
+ if (delegateResult) {
369
+ if (delegateResult === ContinueSentinel) continue;
370
+ return delegateResult;
371
+ }
372
+ }
373
+
374
+ if (context.method === "next") {
375
+ // Setting context._sent for legacy support of Babel's
376
+ // function.sent implementation.
377
+ context.sent = context._sent = context.arg;
378
+
379
+ } else if (context.method === "throw") {
380
+ if (state === GenStateSuspendedStart) {
381
+ state = GenStateCompleted;
382
+ throw context.arg;
383
+ }
384
+
385
+ context.dispatchException(context.arg);
386
+
387
+ } else if (context.method === "return") {
388
+ context.abrupt("return", context.arg);
389
+ }
390
+
391
+ state = GenStateExecuting;
392
+
393
+ var record = tryCatch(innerFn, self, context);
394
+ if (record.type === "normal") {
395
+ // If an exception is thrown from innerFn, we leave state ===
396
+ // GenStateExecuting and loop back for another invocation.
397
+ state = context.done
398
+ ? GenStateCompleted
399
+ : GenStateSuspendedYield;
400
+
401
+ if (record.arg === ContinueSentinel) {
402
+ continue;
403
+ }
404
+
405
+ return {
406
+ value: record.arg,
407
+ done: context.done
408
+ };
409
+
410
+ } else if (record.type === "throw") {
411
+ state = GenStateCompleted;
412
+ // Dispatch the exception by looping back around to the
413
+ // context.dispatchException(context.arg) call above.
414
+ context.method = "throw";
415
+ context.arg = record.arg;
416
+ }
417
+ }
418
+ };
419
+ }
420
+
421
+ // Call delegate.iterator[context.method](context.arg) and handle the
422
+ // result, either by returning a { value, done } result from the
423
+ // delegate iterator, or by modifying context.method and context.arg,
424
+ // setting context.delegate to null, and returning the ContinueSentinel.
425
+ function maybeInvokeDelegate(delegate, context) {
426
+ var method = delegate.iterator[context.method];
427
+ if (method === undefined$1) {
428
+ // A .throw or .return when the delegate iterator has no .throw
429
+ // method always terminates the yield* loop.
430
+ context.delegate = null;
431
+
432
+ if (context.method === "throw") {
433
+ // Note: ["return"] must be used for ES3 parsing compatibility.
434
+ if (delegate.iterator["return"]) {
435
+ // If the delegate iterator has a return method, give it a
436
+ // chance to clean up.
437
+ context.method = "return";
438
+ context.arg = undefined$1;
439
+ maybeInvokeDelegate(delegate, context);
440
+
441
+ if (context.method === "throw") {
442
+ // If maybeInvokeDelegate(context) changed context.method from
443
+ // "return" to "throw", let that override the TypeError below.
444
+ return ContinueSentinel;
445
+ }
446
+ }
447
+
448
+ context.method = "throw";
449
+ context.arg = new TypeError(
450
+ "The iterator does not provide a 'throw' method");
451
+ }
452
+
453
+ return ContinueSentinel;
454
+ }
455
+
456
+ var record = tryCatch(method, delegate.iterator, context.arg);
457
+
458
+ if (record.type === "throw") {
459
+ context.method = "throw";
460
+ context.arg = record.arg;
461
+ context.delegate = null;
462
+ return ContinueSentinel;
463
+ }
464
+
465
+ var info = record.arg;
466
+
467
+ if (! info) {
468
+ context.method = "throw";
469
+ context.arg = new TypeError("iterator result is not an object");
470
+ context.delegate = null;
471
+ return ContinueSentinel;
472
+ }
473
+
474
+ if (info.done) {
475
+ // Assign the result of the finished delegate to the temporary
476
+ // variable specified by delegate.resultName (see delegateYield).
477
+ context[delegate.resultName] = info.value;
478
+
479
+ // Resume execution at the desired location (see delegateYield).
480
+ context.next = delegate.nextLoc;
481
+
482
+ // If context.method was "throw" but the delegate handled the
483
+ // exception, let the outer generator proceed normally. If
484
+ // context.method was "next", forget context.arg since it has been
485
+ // "consumed" by the delegate iterator. If context.method was
486
+ // "return", allow the original .return call to continue in the
487
+ // outer generator.
488
+ if (context.method !== "return") {
489
+ context.method = "next";
490
+ context.arg = undefined$1;
491
+ }
492
+
493
+ } else {
494
+ // Re-yield the result returned by the delegate method.
495
+ return info;
496
+ }
497
+
498
+ // The delegate iterator is finished, so forget it and continue with
499
+ // the outer generator.
500
+ context.delegate = null;
501
+ return ContinueSentinel;
502
+ }
503
+
504
+ // Define Generator.prototype.{next,throw,return} in terms of the
505
+ // unified ._invoke helper method.
506
+ defineIteratorMethods(Gp);
507
+
508
+ define(Gp, toStringTagSymbol, "Generator");
509
+
510
+ // A Generator should always return itself as the iterator object when the
511
+ // @@iterator function is called on it. Some browsers' implementations of the
512
+ // iterator prototype chain incorrectly implement this, causing the Generator
513
+ // object to not be returned from this call. This ensures that doesn't happen.
514
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
515
+ Gp[iteratorSymbol] = function() {
516
+ return this;
517
+ };
518
+
519
+ Gp.toString = function() {
520
+ return "[object Generator]";
521
+ };
522
+
523
+ function pushTryEntry(locs) {
524
+ var entry = { tryLoc: locs[0] };
525
+
526
+ if (1 in locs) {
527
+ entry.catchLoc = locs[1];
528
+ }
529
+
530
+ if (2 in locs) {
531
+ entry.finallyLoc = locs[2];
532
+ entry.afterLoc = locs[3];
533
+ }
534
+
535
+ this.tryEntries.push(entry);
536
+ }
537
+
538
+ function resetTryEntry(entry) {
539
+ var record = entry.completion || {};
540
+ record.type = "normal";
541
+ delete record.arg;
542
+ entry.completion = record;
543
+ }
544
+
545
+ function Context(tryLocsList) {
546
+ // The root entry object (effectively a try statement without a catch
547
+ // or a finally block) gives us a place to store values thrown from
548
+ // locations where there is no enclosing try statement.
549
+ this.tryEntries = [{ tryLoc: "root" }];
550
+ tryLocsList.forEach(pushTryEntry, this);
551
+ this.reset(true);
552
+ }
553
+
554
+ exports.keys = function(object) {
555
+ var keys = [];
556
+ for (var key in object) {
557
+ keys.push(key);
558
+ }
559
+ keys.reverse();
560
+
561
+ // Rather than returning an object with a next method, we keep
562
+ // things simple and return the next function itself.
563
+ return function next() {
564
+ while (keys.length) {
565
+ var key = keys.pop();
566
+ if (key in object) {
567
+ next.value = key;
568
+ next.done = false;
569
+ return next;
570
+ }
571
+ }
572
+
573
+ // To avoid creating an additional object, we just hang the .value
574
+ // and .done properties off the next function object itself. This
575
+ // also ensures that the minifier will not anonymize the function.
576
+ next.done = true;
577
+ return next;
578
+ };
579
+ };
580
+
581
+ function values(iterable) {
582
+ if (iterable) {
583
+ var iteratorMethod = iterable[iteratorSymbol];
584
+ if (iteratorMethod) {
585
+ return iteratorMethod.call(iterable);
586
+ }
587
+
588
+ if (typeof iterable.next === "function") {
589
+ return iterable;
590
+ }
591
+
592
+ if (!isNaN(iterable.length)) {
593
+ var i = -1, next = function next() {
594
+ while (++i < iterable.length) {
595
+ if (hasOwn.call(iterable, i)) {
596
+ next.value = iterable[i];
597
+ next.done = false;
598
+ return next;
599
+ }
600
+ }
601
+
602
+ next.value = undefined$1;
603
+ next.done = true;
604
+
605
+ return next;
606
+ };
607
+
608
+ return next.next = next;
609
+ }
610
+ }
611
+
612
+ // Return an iterator with no values.
613
+ return { next: doneResult };
614
+ }
615
+ exports.values = values;
616
+
617
+ function doneResult() {
618
+ return { value: undefined$1, done: true };
619
+ }
620
+
621
+ Context.prototype = {
622
+ constructor: Context,
623
+
624
+ reset: function(skipTempReset) {
625
+ this.prev = 0;
626
+ this.next = 0;
627
+ // Resetting context._sent for legacy support of Babel's
628
+ // function.sent implementation.
629
+ this.sent = this._sent = undefined$1;
630
+ this.done = false;
631
+ this.delegate = null;
632
+
633
+ this.method = "next";
634
+ this.arg = undefined$1;
635
+
636
+ this.tryEntries.forEach(resetTryEntry);
637
+
638
+ if (!skipTempReset) {
639
+ for (var name in this) {
640
+ // Not sure about the optimal order of these conditions:
641
+ if (name.charAt(0) === "t" &&
642
+ hasOwn.call(this, name) &&
643
+ !isNaN(+name.slice(1))) {
644
+ this[name] = undefined$1;
645
+ }
646
+ }
647
+ }
648
+ },
649
+
650
+ stop: function() {
651
+ this.done = true;
652
+
653
+ var rootEntry = this.tryEntries[0];
654
+ var rootRecord = rootEntry.completion;
655
+ if (rootRecord.type === "throw") {
656
+ throw rootRecord.arg;
657
+ }
658
+
659
+ return this.rval;
660
+ },
661
+
662
+ dispatchException: function(exception) {
663
+ if (this.done) {
664
+ throw exception;
665
+ }
666
+
667
+ var context = this;
668
+ function handle(loc, caught) {
669
+ record.type = "throw";
670
+ record.arg = exception;
671
+ context.next = loc;
672
+
673
+ if (caught) {
674
+ // If the dispatched exception was caught by a catch block,
675
+ // then let that catch block handle the exception normally.
676
+ context.method = "next";
677
+ context.arg = undefined$1;
678
+ }
679
+
680
+ return !! caught;
681
+ }
682
+
683
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
684
+ var entry = this.tryEntries[i];
685
+ var record = entry.completion;
686
+
687
+ if (entry.tryLoc === "root") {
688
+ // Exception thrown outside of any try block that could handle
689
+ // it, so set the completion value of the entire function to
690
+ // throw the exception.
691
+ return handle("end");
692
+ }
693
+
694
+ if (entry.tryLoc <= this.prev) {
695
+ var hasCatch = hasOwn.call(entry, "catchLoc");
696
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
697
+
698
+ if (hasCatch && hasFinally) {
699
+ if (this.prev < entry.catchLoc) {
700
+ return handle(entry.catchLoc, true);
701
+ } else if (this.prev < entry.finallyLoc) {
702
+ return handle(entry.finallyLoc);
703
+ }
704
+
705
+ } else if (hasCatch) {
706
+ if (this.prev < entry.catchLoc) {
707
+ return handle(entry.catchLoc, true);
708
+ }
709
+
710
+ } else if (hasFinally) {
711
+ if (this.prev < entry.finallyLoc) {
712
+ return handle(entry.finallyLoc);
713
+ }
714
+
715
+ } else {
716
+ throw new Error("try statement without catch or finally");
717
+ }
718
+ }
719
+ }
720
+ },
721
+
722
+ abrupt: function(type, arg) {
723
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
724
+ var entry = this.tryEntries[i];
725
+ if (entry.tryLoc <= this.prev &&
726
+ hasOwn.call(entry, "finallyLoc") &&
727
+ this.prev < entry.finallyLoc) {
728
+ var finallyEntry = entry;
729
+ break;
730
+ }
731
+ }
732
+
733
+ if (finallyEntry &&
734
+ (type === "break" ||
735
+ type === "continue") &&
736
+ finallyEntry.tryLoc <= arg &&
737
+ arg <= finallyEntry.finallyLoc) {
738
+ // Ignore the finally entry if control is not jumping to a
739
+ // location outside the try/catch block.
740
+ finallyEntry = null;
741
+ }
742
+
743
+ var record = finallyEntry ? finallyEntry.completion : {};
744
+ record.type = type;
745
+ record.arg = arg;
746
+
747
+ if (finallyEntry) {
748
+ this.method = "next";
749
+ this.next = finallyEntry.finallyLoc;
750
+ return ContinueSentinel;
751
+ }
752
+
753
+ return this.complete(record);
754
+ },
755
+
756
+ complete: function(record, afterLoc) {
757
+ if (record.type === "throw") {
758
+ throw record.arg;
759
+ }
760
+
761
+ if (record.type === "break" ||
762
+ record.type === "continue") {
763
+ this.next = record.arg;
764
+ } else if (record.type === "return") {
765
+ this.rval = this.arg = record.arg;
766
+ this.method = "return";
767
+ this.next = "end";
768
+ } else if (record.type === "normal" && afterLoc) {
769
+ this.next = afterLoc;
770
+ }
771
+
772
+ return ContinueSentinel;
773
+ },
774
+
775
+ finish: function(finallyLoc) {
776
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
777
+ var entry = this.tryEntries[i];
778
+ if (entry.finallyLoc === finallyLoc) {
779
+ this.complete(entry.completion, entry.afterLoc);
780
+ resetTryEntry(entry);
781
+ return ContinueSentinel;
782
+ }
783
+ }
784
+ },
785
+
786
+ "catch": function(tryLoc) {
787
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
788
+ var entry = this.tryEntries[i];
789
+ if (entry.tryLoc === tryLoc) {
790
+ var record = entry.completion;
791
+ if (record.type === "throw") {
792
+ var thrown = record.arg;
793
+ resetTryEntry(entry);
794
+ }
795
+ return thrown;
796
+ }
797
+ }
798
+
799
+ // The context.catch method must only be called with a location
800
+ // argument that corresponds to a known catch block.
801
+ throw new Error("illegal catch attempt");
802
+ },
803
+
804
+ delegateYield: function(iterable, resultName, nextLoc) {
805
+ this.delegate = {
806
+ iterator: values(iterable),
807
+ resultName: resultName,
808
+ nextLoc: nextLoc
809
+ };
810
+
811
+ if (this.method === "next") {
812
+ // Deliberately forget the last sent value so that we don't
813
+ // accidentally pass it on to the delegate.
814
+ this.arg = undefined$1;
815
+ }
816
+
817
+ return ContinueSentinel;
818
+ }
819
+ };
820
+
821
+ // Regardless of whether this script is executing as a CommonJS module
822
+ // or not, return the runtime object so that we can declare the variable
823
+ // regeneratorRuntime in the outer scope, which allows this module to be
824
+ // injected easily by `bin/regenerator --include-runtime script.js`.
825
+ return exports;
826
+
827
+ }(
828
+ // If this script is executing as a CommonJS module, use module.exports
829
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
830
+ // object. Either way, the resulting object will be used to initialize
831
+ // the regeneratorRuntime variable at the top of this file.
832
+ module.exports
833
+ ));
834
+
835
+ try {
836
+ regeneratorRuntime = runtime;
837
+ } catch (accidentalStrictMode) {
838
+ // This module should not be running in strict mode, so the above
839
+ // assignment should always work unless something is misconfigured. Just
840
+ // in case runtime.js accidentally runs in strict mode, we can escape
841
+ // strict mode using a global Function call. This could conceivably fail
842
+ // if a Content Security Policy forbids using Function, but in that case
843
+ // the proper solution is to fix the accidental strict mode problem. If
844
+ // you've misconfigured your bundler to force strict mode and applied a
845
+ // CSP to forbid Function, and you're not willing to fix either of those
846
+ // problems, please detail your unique predicament in a GitHub issue.
847
+ Function("r", "regeneratorRuntime = r")(runtime);
848
+ }
849
+ });
850
+
851
+ var fetcher = /*#__PURE__*/function () {
852
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
853
+ var res, _yield$res$json, data;
854
+
855
+ return runtime_1.wrap(function _callee$(_context) {
856
+ while (1) {
857
+ switch (_context.prev = _context.next) {
858
+ case 0:
859
+ console.log('FETCHER');
860
+ _context.next = 3;
861
+ return fetch('./data.json');
862
+
863
+ case 3:
864
+ res = _context.sent;
865
+
866
+ if (!res.ok) {
867
+ _context.next = 10;
868
+ break;
869
+ }
870
+
871
+ _context.next = 7;
872
+ return res.json();
873
+
874
+ case 7:
875
+ _yield$res$json = _context.sent;
876
+ data = _yield$res$json.data;
877
+ return _context.abrupt("return", data);
878
+
879
+ case 10:
880
+ throw res;
881
+
882
+ case 11:
883
+ case "end":
884
+ return _context.stop();
885
+ }
886
+ }
887
+ }, _callee);
888
+ }));
889
+
890
+ return function fetcher() {
891
+ return _ref.apply(this, arguments);
892
+ };
893
+ }();
894
+
895
+ var LOCAL_CART_URL = 'localCartUrl';
896
+
897
+ var handler = {
898
+ fetchOptions: {
899
+ query: ''
900
+ },
901
+ fetcher: function fetcher(_ref) {
902
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
903
+ var _localStorage$getItem;
904
+
905
+ var cartId, fetch;
906
+ return runtime_1.wrap(function _callee$(_context) {
907
+ while (1) {
908
+ switch (_context.prev = _context.next) {
909
+ case 0:
910
+ cartId = _ref.input.cartId, fetch = _ref.fetch;
911
+
912
+ if (!cartId) {
913
+ cartId = LOCAL_CART_URL;
914
+ }
915
+
916
+ return _context.abrupt("return", JSON.parse((_localStorage$getItem = localStorage.getItem(cartId)) != null ? _localStorage$getItem : "null"));
917
+
918
+ case 3:
919
+ case "end":
920
+ return _context.stop();
921
+ }
922
+ }
923
+ }, _callee);
924
+ }))();
925
+ },
926
+ useHook: function useHook(_ref2) {
927
+ var useData = _ref2.useData;
928
+ return function (input) {
929
+ return useData({
930
+ swrOptions: _extends({
931
+ revalidateOnFocus: false
932
+ }, input == null ? void 0 : input.swrOptions)
933
+ });
934
+ };
935
+ }
936
+ };
937
+
938
+ var products = [
939
+ {
940
+ id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
941
+ name: "New Short Sleeve T-Shirt",
942
+ vendor: "Next.js",
943
+ path: "/new-short-sleeve-t-shirt",
944
+ slug: "new-short-sleeve-t-shirt",
945
+ price: {
946
+ value: 25,
947
+ currencyCode: "USD"
948
+ },
949
+ descriptionHtml: "<p><span>Show off your love for Next.js and Vercel with this unique,&nbsp;</span><strong>limited edition</strong><span>&nbsp;t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made!&nbsp;</span><strong>All proceeds will be donated to charity.</strong></p>",
950
+ images: [
951
+ {
952
+ url: "https://static1.plasmic.app/commerce/drop-shirt-0.png",
953
+ altText: "Shirt",
954
+ width: 1000,
955
+ height: 1000
956
+ },
957
+ {
958
+ url: "https://static1.plasmic.app/commerce/drop-shirt-1.png",
959
+ altText: "Shirt",
960
+ width: 1000,
961
+ height: 1000
962
+ },
963
+ {
964
+ url: "https://static1.plasmic.app/commerce/drop-shirt-2.png",
965
+ altText: "Shirt",
966
+ width: 1000,
967
+ height: 1000
968
+ }
969
+ ],
970
+ variants: [
971
+ {
972
+ id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
973
+ options: [
974
+ {
975
+ __typename: "MultipleChoiceOption",
976
+ id: "asd",
977
+ displayName: "Size",
978
+ values: [
979
+ {
980
+ label: "XL"
981
+ }
982
+ ]
983
+ }
984
+ ]
985
+ }
986
+ ],
987
+ options: [
988
+ {
989
+ id: "option-color",
990
+ displayName: "Color",
991
+ values: [
992
+ {
993
+ label: "color",
994
+ hexColors: [
995
+ "#222"
996
+ ]
997
+ }
998
+ ]
999
+ },
1000
+ {
1001
+ id: "option-size",
1002
+ displayName: "Size",
1003
+ values: [
1004
+ {
1005
+ label: "S"
1006
+ },
1007
+ {
1008
+ label: "M"
1009
+ },
1010
+ {
1011
+ label: "L"
1012
+ }
1013
+ ]
1014
+ }
1015
+ ]
1016
+ },
1017
+ {
1018
+ id: "Z2lkOi8vc2hvcGlmeS9Qcm9ksdWN0LzU0NDczMjUwMjQ0MjA=",
1019
+ name: "Lightweight Jacket",
1020
+ vendor: "Next.js",
1021
+ path: "/lightweight-jacket",
1022
+ slug: "lightweight-jacket",
1023
+ price: {
1024
+ value: 249.99,
1025
+ currencyCode: "USD"
1026
+ },
1027
+ descriptionHtml: "<p><span>Show off your love for Next.js and Vercel with this unique,&nbsp;</span><strong>limited edition</strong><span>&nbsp;t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made!&nbsp;</span><strong>All proceeds will be donated to charity.</strong></p>",
1028
+ images: [
1029
+ {
1030
+ url: "https://static1.plasmic.app/commerce/lightweight-jacket-0.png",
1031
+ altText: "Lightweight Jacket",
1032
+ width: 1000,
1033
+ height: 1000
1034
+ },
1035
+ {
1036
+ url: "https://static1.plasmic.app/commerce/lightweight-jacket-1.png",
1037
+ altText: "Lightweight Jacket",
1038
+ width: 1000,
1039
+ height: 1000
1040
+ },
1041
+ {
1042
+ url: "https://static1.plasmic.app/commerce/lightweight-jacket-2.png",
1043
+ altText: "Lightweight Jacket",
1044
+ width: 1000,
1045
+ height: 1000
1046
+ }
1047
+ ],
1048
+ variants: [
1049
+ {
1050
+ id: "Z2lkOid8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
1051
+ options: [
1052
+ {
1053
+ __typename: "MultipleChoiceOption",
1054
+ id: "asd",
1055
+ displayName: "Size",
1056
+ values: [
1057
+ {
1058
+ label: "XL"
1059
+ }
1060
+ ]
1061
+ }
1062
+ ]
1063
+ }
1064
+ ],
1065
+ options: [
1066
+ {
1067
+ id: "option-color",
1068
+ displayName: "Color",
1069
+ values: [
1070
+ {
1071
+ label: "color",
1072
+ hexColors: [
1073
+ "#222"
1074
+ ]
1075
+ }
1076
+ ]
1077
+ },
1078
+ {
1079
+ id: "option-size",
1080
+ displayName: "Size",
1081
+ values: [
1082
+ {
1083
+ label: "S"
1084
+ },
1085
+ {
1086
+ label: "M"
1087
+ },
1088
+ {
1089
+ label: "L"
1090
+ }
1091
+ ]
1092
+ }
1093
+ ]
1094
+ },
1095
+ {
1096
+ id: "Z2lkOis8vc2hvcGlmsddeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
1097
+ name: "Shirt",
1098
+ vendor: "Next.js",
1099
+ path: "/shirt",
1100
+ slug: "shirt",
1101
+ price: {
1102
+ value: 25,
1103
+ currencyCode: "USD"
1104
+ },
1105
+ descriptionHtml: "<p><span>Show off your love for Next.js and Vercel with this unique,&nbsp;</span><strong>limited edition</strong><span>&nbsp;t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made!&nbsp;</span><strong>All proceeds will be donated to charity.</strong></p>",
1106
+ images: [
1107
+ {
1108
+ url: "https://static1.plasmic.app/commerce/t-shirt-0.png",
1109
+ altText: "Shirt",
1110
+ width: 1000,
1111
+ height: 1000
1112
+ },
1113
+ {
1114
+ url: "https://static1.plasmic.app/commerce/t-shirt-1.png",
1115
+ altText: "Shirt",
1116
+ width: 1000,
1117
+ height: 1000
1118
+ },
1119
+ {
1120
+ url: "https://static1.plasmic.app/commerce/t-shirt-2.png",
1121
+ altText: "Shirt",
1122
+ width: 1000,
1123
+ height: 1000
1124
+ },
1125
+ {
1126
+ url: "https://static1.plasmic.app/commerce/t-shirt-3.png",
1127
+ altText: "Shirt",
1128
+ width: 1000,
1129
+ height: 1000
1130
+ },
1131
+ {
1132
+ url: "https://static1.plasmic.app/commerce/t-shirt-4.png",
1133
+ altText: "Shirt",
1134
+ width: 1000,
1135
+ height: 1000
1136
+ }
1137
+ ],
1138
+ variants: [
1139
+ {
1140
+ id: "Z2lkOi8vc2hvcGlmeS9Qcms9kdWN0LzU0NDczMjUwMjQ0MjAss=",
1141
+ options: [
1142
+ {
1143
+ __typename: "MultipleChoiceOption",
1144
+ id: "asd",
1145
+ displayName: "Size",
1146
+ values: [
1147
+ {
1148
+ label: "XL"
1149
+ }
1150
+ ]
1151
+ }
1152
+ ]
1153
+ }
1154
+ ],
1155
+ options: [
1156
+ {
1157
+ id: "option-color",
1158
+ displayName: "Color",
1159
+ values: [
1160
+ {
1161
+ label: "color",
1162
+ hexColors: [
1163
+ "#222"
1164
+ ]
1165
+ }
1166
+ ]
1167
+ },
1168
+ {
1169
+ id: "option-size",
1170
+ displayName: "Size",
1171
+ values: [
1172
+ {
1173
+ label: "S"
1174
+ },
1175
+ {
1176
+ label: "M"
1177
+ },
1178
+ {
1179
+ label: "L"
1180
+ }
1181
+ ]
1182
+ }
1183
+ ]
1184
+ }
1185
+ ];
1186
+ var data = {
1187
+ products: products
1188
+ };
1189
+
1190
+ var createCart = function createCart() {
1191
+ return {
1192
+ id: '',
1193
+ createdAt: '',
1194
+ currency: {
1195
+ code: ''
1196
+ },
1197
+ taxesIncluded: false,
1198
+ lineItems: [],
1199
+ lineItemsSubtotalPrice: 0,
1200
+ subtotalPrice: 0,
1201
+ totalPrice: 0
1202
+ };
1203
+ };
1204
+
1205
+ var handler$1 = {
1206
+ fetchOptions: {
1207
+ query: ''
1208
+ },
1209
+ fetcher: function fetcher(_ref) {
1210
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1211
+ var _item$quantity;
1212
+
1213
+ var item, fetch, lineItem, cart, _iterator, _step, product, _item$quantity2;
1214
+
1215
+ return runtime_1.wrap(function _callee$(_context) {
1216
+ while (1) {
1217
+ switch (_context.prev = _context.next) {
1218
+ case 0:
1219
+ item = _ref.input, fetch = _ref.fetch;
1220
+
1221
+ if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
1222
+ _context.next = 3;
1223
+ break;
1224
+ }
1225
+
1226
+ throw new CommerceError({
1227
+ message: 'The item quantity has to be a valid integer greater than 0'
1228
+ });
1229
+
1230
+ case 3:
1231
+ lineItem = {
1232
+ variantId: item.variantId,
1233
+ quantity: (_item$quantity = item.quantity) != null ? _item$quantity : 1
1234
+ };
1235
+
1236
+ if (!localStorage.getItem(LOCAL_CART_URL)) {
1237
+ cart = createCart();
1238
+ } else {
1239
+ cart = JSON.parse(localStorage.getItem(LOCAL_CART_URL));
1240
+ }
1241
+
1242
+ for (_iterator = _createForOfIteratorHelperLoose(data.products); !(_step = _iterator()).done;) {
1243
+ product = _step.value;
1244
+
1245
+ if (product.id === item.variantId || product.variants.some(function (productVariant) {
1246
+ return productVariant.id === item.variantId;
1247
+ })) {
1248
+ cart.lineItems.push(lineItem);
1249
+ cart.totalPrice += product.price.value * ((_item$quantity2 = item.quantity) != null ? _item$quantity2 : 1);
1250
+ cart.currency.code = product.price.currencyCode;
1251
+ }
1252
+ }
1253
+
1254
+ localStorage.setItem(LOCAL_CART_URL, JSON.stringify(cart));
1255
+ return _context.abrupt("return", cart);
1256
+
1257
+ case 8:
1258
+ case "end":
1259
+ return _context.stop();
1260
+ }
1261
+ }
1262
+ }, _callee);
1263
+ }))();
1264
+ },
1265
+ useHook: function useHook(_ref2) {
1266
+ var fetch = _ref2.fetch;
1267
+ return function () {
1268
+ var _useCart = useCart(),
1269
+ mutate = _useCart.mutate;
1270
+
1271
+ return useCallback( /*#__PURE__*/function () {
1272
+ var _addItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
1273
+ var data;
1274
+ return runtime_1.wrap(function _callee2$(_context2) {
1275
+ while (1) {
1276
+ switch (_context2.prev = _context2.next) {
1277
+ case 0:
1278
+ _context2.next = 2;
1279
+ return fetch({
1280
+ input: input
1281
+ });
1282
+
1283
+ case 2:
1284
+ data = _context2.sent;
1285
+ _context2.next = 5;
1286
+ return mutate(data, false);
1287
+
1288
+ case 5:
1289
+ return _context2.abrupt("return", data);
1290
+
1291
+ case 6:
1292
+ case "end":
1293
+ return _context2.stop();
1294
+ }
1295
+ }
1296
+ }, _callee2);
1297
+ }));
1298
+
1299
+ function addItem(_x) {
1300
+ return _addItem.apply(this, arguments);
1301
+ }
1302
+
1303
+ return addItem;
1304
+ }(), [fetch, mutate]);
1305
+ };
1306
+ }
1307
+ };
1308
+
1309
+ var handler$2 = {
1310
+ fetchOptions: {
1311
+ query: ''
1312
+ },
1313
+ fetcher: function fetcher(_ref) {
1314
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1315
+ return runtime_1.wrap(function _callee$(_context) {
1316
+ while (1) {
1317
+ switch (_context.prev = _context.next) {
1318
+ case 0:
1319
+
1320
+ case 1:
1321
+ case "end":
1322
+ return _context.stop();
1323
+ }
1324
+ }
1325
+ }, _callee);
1326
+ }))();
1327
+ },
1328
+ useHook: function useHook(_ref2) {
1329
+ return function () {
1330
+ return /*#__PURE__*/function () {
1331
+ var _addItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1332
+ return runtime_1.wrap(function _callee2$(_context2) {
1333
+ while (1) {
1334
+ switch (_context2.prev = _context2.next) {
1335
+ case 0:
1336
+ return _context2.abrupt("return", {});
1337
+
1338
+ case 1:
1339
+ case "end":
1340
+ return _context2.stop();
1341
+ }
1342
+ }
1343
+ }, _callee2);
1344
+ }));
1345
+
1346
+ function addItem() {
1347
+ return _addItem.apply(this, arguments);
1348
+ }
1349
+
1350
+ return addItem;
1351
+ }();
1352
+ };
1353
+ }
1354
+ };
1355
+
1356
+ var handler$3 = {
1357
+ fetchOptions: {
1358
+ query: ''
1359
+ },
1360
+ fetcher: function fetcher(_ref) {
1361
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1362
+ return runtime_1.wrap(function _callee$(_context) {
1363
+ while (1) {
1364
+ switch (_context.prev = _context.next) {
1365
+ case 0:
1366
+
1367
+ case 1:
1368
+ case "end":
1369
+ return _context.stop();
1370
+ }
1371
+ }
1372
+ }, _callee);
1373
+ }))();
1374
+ },
1375
+ useHook: function useHook(_ref2) {
1376
+ return function () {
1377
+ return /*#__PURE__*/function () {
1378
+ var _removeItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
1379
+ return runtime_1.wrap(function _callee2$(_context2) {
1380
+ while (1) {
1381
+ switch (_context2.prev = _context2.next) {
1382
+ case 0:
1383
+ return _context2.abrupt("return", {});
1384
+
1385
+ case 1:
1386
+ case "end":
1387
+ return _context2.stop();
1388
+ }
1389
+ }
1390
+ }, _callee2);
1391
+ }));
1392
+
1393
+ function removeItem(_x) {
1394
+ return _removeItem.apply(this, arguments);
1395
+ }
1396
+
1397
+ return removeItem;
1398
+ }();
1399
+ };
1400
+ }
1401
+ };
1402
+
1403
+ var handler$4 = {
1404
+ fetchOptions: {
1405
+ query: ''
1406
+ },
1407
+ fetcher: function fetcher(_ref) {
1408
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1409
+ return runtime_1.wrap(function _callee$(_context) {
1410
+ while (1) {
1411
+ switch (_context.prev = _context.next) {
1412
+ case 0:
1413
+ return _context.abrupt("return", {
1414
+ data: {
1415
+ products: data.products
1416
+ }
1417
+ });
1418
+
1419
+ case 2:
1420
+ case "end":
1421
+ return _context.stop();
1422
+ }
1423
+ }
1424
+ }, _callee);
1425
+ }))();
1426
+ },
1427
+ useHook: function useHook() {
1428
+ return function () {
1429
+ return {
1430
+ data: {
1431
+ products: data.products
1432
+ }
1433
+ };
1434
+ };
1435
+ }
1436
+ };
1437
+
1438
+ /*
1439
+ Forked from https://github.com/vercel/commerce/tree/main/packages/local/src
1440
+ Changes: Removed authentication, customer and wishlist hooks
1441
+ */
1442
+ var localProvider = {
1443
+ locale: 'en-us',
1444
+ cartCookie: 'LOCAL_CART',
1445
+ fetcher: fetcher,
1446
+ cart: {
1447
+ useCart: handler,
1448
+ useAddItem: handler$1,
1449
+ useUpdateItem: handler$2,
1450
+ useRemoveItem: handler$3
1451
+ },
1452
+ products: {
1453
+ useSearch: handler$4
1454
+ }
1455
+ };
1456
+
1457
+ /*
1458
+ Forked from https://github.com/vercel/commerce/tree/main/packages/local/src
1459
+ Changes: None
1460
+ */
1461
+ var CommerceProvider = /*#__PURE__*/getCommerceProvider(localProvider);
1462
+ var useCommerce = function useCommerce() {
1463
+ return useCommerce$1();
1464
+ };
1465
+
1466
+ var commerceProviderMeta = {
1467
+ name: "Local Provider",
1468
+ displayName: "Local Provider",
1469
+ props: {
1470
+ children: {
1471
+ type: "slot"
1472
+ }
1473
+ },
1474
+ importPath: "commerce-providers/local",
1475
+ importName: "LocalProvider"
1476
+ };
1477
+
1478
+ function CommerceProviderComponent(props) {
1479
+ return React.createElement(CommerceProvider, null, props.children);
1480
+ }
1481
+
1482
+ function registerCommerceProvider(loader, customCommerceProviderMeta) {
1483
+ var doRegisterComponent = function doRegisterComponent() {
1484
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1485
+ };
1486
+
1487
+ doRegisterComponent(CommerceProviderComponent, customCommerceProviderMeta != null ? customCommerceProviderMeta : commerceProviderMeta);
1488
+ }
1489
+
1490
+ function registerAll(loader) {
1491
+ registerCommerceProvider(loader);
1492
+ }
1493
+
1494
+ export { CommerceProvider, localProvider, registerAll, registerCommerceProvider, useCommerce };
1495
+ //# sourceMappingURL=commerce-local.esm.js.map