@plasmicpkgs/commerce-saleor 0.0.122 → 0.0.123

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.
@@ -18,6 +18,307 @@ var debounce = _interopDefault(require('debounce'));
18
18
  var CHECKOUT_ID_COOKIE = 'saleor.CheckoutID';
19
19
  var SALEOR_TOKEN = 'saleor.Token';
20
20
 
21
+ function _regeneratorRuntime() {
22
+ _regeneratorRuntime = function () {
23
+ return e;
24
+ };
25
+ var t,
26
+ e = {},
27
+ r = Object.prototype,
28
+ n = r.hasOwnProperty,
29
+ o = Object.defineProperty || function (t, e, r) {
30
+ t[e] = r.value;
31
+ },
32
+ i = "function" == typeof Symbol ? Symbol : {},
33
+ a = i.iterator || "@@iterator",
34
+ c = i.asyncIterator || "@@asyncIterator",
35
+ u = i.toStringTag || "@@toStringTag";
36
+ function define(t, e, r) {
37
+ return Object.defineProperty(t, e, {
38
+ value: r,
39
+ enumerable: !0,
40
+ configurable: !0,
41
+ writable: !0
42
+ }), t[e];
43
+ }
44
+ try {
45
+ define({}, "");
46
+ } catch (t) {
47
+ define = function (t, e, r) {
48
+ return t[e] = r;
49
+ };
50
+ }
51
+ function wrap(t, e, r, n) {
52
+ var i = e && e.prototype instanceof Generator ? e : Generator,
53
+ a = Object.create(i.prototype),
54
+ c = new Context(n || []);
55
+ return o(a, "_invoke", {
56
+ value: makeInvokeMethod(t, r, c)
57
+ }), a;
58
+ }
59
+ function tryCatch(t, e, r) {
60
+ try {
61
+ return {
62
+ type: "normal",
63
+ arg: t.call(e, r)
64
+ };
65
+ } catch (t) {
66
+ return {
67
+ type: "throw",
68
+ arg: t
69
+ };
70
+ }
71
+ }
72
+ e.wrap = wrap;
73
+ var h = "suspendedStart",
74
+ l = "suspendedYield",
75
+ f = "executing",
76
+ s = "completed",
77
+ y = {};
78
+ function Generator() {}
79
+ function GeneratorFunction() {}
80
+ function GeneratorFunctionPrototype() {}
81
+ var p = {};
82
+ define(p, a, function () {
83
+ return this;
84
+ });
85
+ var d = Object.getPrototypeOf,
86
+ v = d && d(d(values([])));
87
+ v && v !== r && n.call(v, a) && (p = v);
88
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
89
+ function defineIteratorMethods(t) {
90
+ ["next", "throw", "return"].forEach(function (e) {
91
+ define(t, e, function (t) {
92
+ return this._invoke(e, t);
93
+ });
94
+ });
95
+ }
96
+ function AsyncIterator(t, e) {
97
+ function invoke(r, o, i, a) {
98
+ var c = tryCatch(t[r], t, o);
99
+ if ("throw" !== c.type) {
100
+ var u = c.arg,
101
+ h = u.value;
102
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
103
+ invoke("next", t, i, a);
104
+ }, function (t) {
105
+ invoke("throw", t, i, a);
106
+ }) : e.resolve(h).then(function (t) {
107
+ u.value = t, i(u);
108
+ }, function (t) {
109
+ return invoke("throw", t, i, a);
110
+ });
111
+ }
112
+ a(c.arg);
113
+ }
114
+ var r;
115
+ o(this, "_invoke", {
116
+ value: function (t, n) {
117
+ function callInvokeWithMethodAndArg() {
118
+ return new e(function (e, r) {
119
+ invoke(t, n, e, r);
120
+ });
121
+ }
122
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
123
+ }
124
+ });
125
+ }
126
+ function makeInvokeMethod(e, r, n) {
127
+ var o = h;
128
+ return function (i, a) {
129
+ if (o === f) throw new Error("Generator is already running");
130
+ if (o === s) {
131
+ if ("throw" === i) throw a;
132
+ return {
133
+ value: t,
134
+ done: !0
135
+ };
136
+ }
137
+ for (n.method = i, n.arg = a;;) {
138
+ var c = n.delegate;
139
+ if (c) {
140
+ var u = maybeInvokeDelegate(c, n);
141
+ if (u) {
142
+ if (u === y) continue;
143
+ return u;
144
+ }
145
+ }
146
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
147
+ if (o === h) throw o = s, n.arg;
148
+ n.dispatchException(n.arg);
149
+ } else "return" === n.method && n.abrupt("return", n.arg);
150
+ o = f;
151
+ var p = tryCatch(e, r, n);
152
+ if ("normal" === p.type) {
153
+ if (o = n.done ? s : l, p.arg === y) continue;
154
+ return {
155
+ value: p.arg,
156
+ done: n.done
157
+ };
158
+ }
159
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
160
+ }
161
+ };
162
+ }
163
+ function maybeInvokeDelegate(e, r) {
164
+ var n = r.method,
165
+ o = e.iterator[n];
166
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
167
+ var i = tryCatch(o, e.iterator, r.arg);
168
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
169
+ var a = i.arg;
170
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
171
+ }
172
+ function pushTryEntry(t) {
173
+ var e = {
174
+ tryLoc: t[0]
175
+ };
176
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
177
+ }
178
+ function resetTryEntry(t) {
179
+ var e = t.completion || {};
180
+ e.type = "normal", delete e.arg, t.completion = e;
181
+ }
182
+ function Context(t) {
183
+ this.tryEntries = [{
184
+ tryLoc: "root"
185
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
186
+ }
187
+ function values(e) {
188
+ if (e || "" === e) {
189
+ var r = e[a];
190
+ if (r) return r.call(e);
191
+ if ("function" == typeof e.next) return e;
192
+ if (!isNaN(e.length)) {
193
+ var o = -1,
194
+ i = function next() {
195
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
196
+ return next.value = t, next.done = !0, next;
197
+ };
198
+ return i.next = i;
199
+ }
200
+ }
201
+ throw new TypeError(typeof e + " is not iterable");
202
+ }
203
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
204
+ value: GeneratorFunctionPrototype,
205
+ configurable: !0
206
+ }), o(GeneratorFunctionPrototype, "constructor", {
207
+ value: GeneratorFunction,
208
+ configurable: !0
209
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
210
+ var e = "function" == typeof t && t.constructor;
211
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
212
+ }, e.mark = function (t) {
213
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
214
+ }, e.awrap = function (t) {
215
+ return {
216
+ __await: t
217
+ };
218
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
219
+ return this;
220
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
221
+ void 0 === i && (i = Promise);
222
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
223
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
224
+ return t.done ? t.value : a.next();
225
+ });
226
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
227
+ return this;
228
+ }), define(g, "toString", function () {
229
+ return "[object Generator]";
230
+ }), e.keys = function (t) {
231
+ var e = Object(t),
232
+ r = [];
233
+ for (var n in e) r.push(n);
234
+ return r.reverse(), function next() {
235
+ for (; r.length;) {
236
+ var t = r.pop();
237
+ if (t in e) return next.value = t, next.done = !1, next;
238
+ }
239
+ return next.done = !0, next;
240
+ };
241
+ }, e.values = values, Context.prototype = {
242
+ constructor: Context,
243
+ reset: function (e) {
244
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
245
+ },
246
+ stop: function () {
247
+ this.done = !0;
248
+ var t = this.tryEntries[0].completion;
249
+ if ("throw" === t.type) throw t.arg;
250
+ return this.rval;
251
+ },
252
+ dispatchException: function (e) {
253
+ if (this.done) throw e;
254
+ var r = this;
255
+ function handle(n, o) {
256
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
257
+ }
258
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
259
+ var i = this.tryEntries[o],
260
+ a = i.completion;
261
+ if ("root" === i.tryLoc) return handle("end");
262
+ if (i.tryLoc <= this.prev) {
263
+ var c = n.call(i, "catchLoc"),
264
+ u = n.call(i, "finallyLoc");
265
+ if (c && u) {
266
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
267
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
268
+ } else if (c) {
269
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
270
+ } else {
271
+ if (!u) throw new Error("try statement without catch or finally");
272
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
273
+ }
274
+ }
275
+ }
276
+ },
277
+ abrupt: function (t, e) {
278
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
279
+ var o = this.tryEntries[r];
280
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
281
+ var i = o;
282
+ break;
283
+ }
284
+ }
285
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
286
+ var a = i ? i.completion : {};
287
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
288
+ },
289
+ complete: function (t, e) {
290
+ if ("throw" === t.type) throw t.arg;
291
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
292
+ },
293
+ finish: function (t) {
294
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
295
+ var r = this.tryEntries[e];
296
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
297
+ }
298
+ },
299
+ catch: function (t) {
300
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
301
+ var r = this.tryEntries[e];
302
+ if (r.tryLoc === t) {
303
+ var n = r.completion;
304
+ if ("throw" === n.type) {
305
+ var o = n.arg;
306
+ resetTryEntry(r);
307
+ }
308
+ return o;
309
+ }
310
+ }
311
+ throw new Error("illegal catch attempt");
312
+ },
313
+ delegateYield: function (e, r, n) {
314
+ return this.delegate = {
315
+ iterator: values(e),
316
+ resultName: r,
317
+ nextLoc: n
318
+ }, "next" === this.method && (this.arg = t), y;
319
+ }
320
+ }, e;
321
+ }
21
322
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
22
323
  try {
23
324
  var info = gen[key](arg);
@@ -75,664 +376,6 @@ function _objectWithoutPropertiesLoose(source, excluded) {
75
376
  return target;
76
377
  }
77
378
 
78
- function createCommonjsModule(fn, module) {
79
- return module = { exports: {} }, fn(module, module.exports), module.exports;
80
- }
81
-
82
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
83
- /**
84
- * Copyright (c) 2014-present, Facebook, Inc.
85
- *
86
- * This source code is licensed under the MIT license found in the
87
- * LICENSE file in the root directory of this source tree.
88
- */
89
-
90
- var runtime = function (exports) {
91
-
92
- var Op = Object.prototype;
93
- var hasOwn = Op.hasOwnProperty;
94
- var undefined$1; // More compressible than void 0.
95
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
96
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
97
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
98
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
99
- function define(obj, key, value) {
100
- Object.defineProperty(obj, key, {
101
- value: value,
102
- enumerable: true,
103
- configurable: true,
104
- writable: true
105
- });
106
- return obj[key];
107
- }
108
- try {
109
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
110
- define({}, "");
111
- } catch (err) {
112
- define = function define(obj, key, value) {
113
- return obj[key] = value;
114
- };
115
- }
116
- function wrap(innerFn, outerFn, self, tryLocsList) {
117
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
118
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
119
- var generator = Object.create(protoGenerator.prototype);
120
- var context = new Context(tryLocsList || []);
121
-
122
- // The ._invoke method unifies the implementations of the .next,
123
- // .throw, and .return methods.
124
- generator._invoke = makeInvokeMethod(innerFn, self, context);
125
- return generator;
126
- }
127
- exports.wrap = wrap;
128
-
129
- // Try/catch helper to minimize deoptimizations. Returns a completion
130
- // record like context.tryEntries[i].completion. This interface could
131
- // have been (and was previously) designed to take a closure to be
132
- // invoked without arguments, but in all the cases we care about we
133
- // already have an existing method we want to call, so there's no need
134
- // to create a new function object. We can even get away with assuming
135
- // the method takes exactly one argument, since that happens to be true
136
- // in every case, so we don't have to touch the arguments object. The
137
- // only additional allocation required is the completion record, which
138
- // has a stable shape and so hopefully should be cheap to allocate.
139
- function tryCatch(fn, obj, arg) {
140
- try {
141
- return {
142
- type: "normal",
143
- arg: fn.call(obj, arg)
144
- };
145
- } catch (err) {
146
- return {
147
- type: "throw",
148
- arg: err
149
- };
150
- }
151
- }
152
- var GenStateSuspendedStart = "suspendedStart";
153
- var GenStateSuspendedYield = "suspendedYield";
154
- var GenStateExecuting = "executing";
155
- var GenStateCompleted = "completed";
156
-
157
- // Returning this object from the innerFn has the same effect as
158
- // breaking out of the dispatch switch statement.
159
- var ContinueSentinel = {};
160
-
161
- // Dummy constructor functions that we use as the .constructor and
162
- // .constructor.prototype properties for functions that return Generator
163
- // objects. For full spec compliance, you may wish to configure your
164
- // minifier not to mangle the names of these two functions.
165
- function Generator() {}
166
- function GeneratorFunction() {}
167
- function GeneratorFunctionPrototype() {}
168
-
169
- // This is a polyfill for %IteratorPrototype% for environments that
170
- // don't natively support it.
171
- var IteratorPrototype = {};
172
- define(IteratorPrototype, iteratorSymbol, function () {
173
- return this;
174
- });
175
- var getProto = Object.getPrototypeOf;
176
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
177
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
178
- // This environment has a native %IteratorPrototype%; use it instead
179
- // of the polyfill.
180
- IteratorPrototype = NativeIteratorPrototype;
181
- }
182
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
183
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
184
- define(Gp, "constructor", GeneratorFunctionPrototype);
185
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
186
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
187
-
188
- // Helper for defining the .next, .throw, and .return methods of the
189
- // Iterator interface in terms of a single ._invoke method.
190
- function defineIteratorMethods(prototype) {
191
- ["next", "throw", "return"].forEach(function (method) {
192
- define(prototype, method, function (arg) {
193
- return this._invoke(method, arg);
194
- });
195
- });
196
- }
197
- exports.isGeneratorFunction = function (genFun) {
198
- var ctor = typeof genFun === "function" && genFun.constructor;
199
- return ctor ? ctor === GeneratorFunction ||
200
- // For the native GeneratorFunction constructor, the best we can
201
- // do is to check its .name property.
202
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
203
- };
204
- exports.mark = function (genFun) {
205
- if (Object.setPrototypeOf) {
206
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
207
- } else {
208
- genFun.__proto__ = GeneratorFunctionPrototype;
209
- define(genFun, toStringTagSymbol, "GeneratorFunction");
210
- }
211
- genFun.prototype = Object.create(Gp);
212
- return genFun;
213
- };
214
-
215
- // Within the body of any async function, `await x` is transformed to
216
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
217
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
218
- // meant to be awaited.
219
- exports.awrap = function (arg) {
220
- return {
221
- __await: arg
222
- };
223
- };
224
- function AsyncIterator(generator, PromiseImpl) {
225
- function invoke(method, arg, resolve, reject) {
226
- var record = tryCatch(generator[method], generator, arg);
227
- if (record.type === "throw") {
228
- reject(record.arg);
229
- } else {
230
- var result = record.arg;
231
- var value = result.value;
232
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
233
- return PromiseImpl.resolve(value.__await).then(function (value) {
234
- invoke("next", value, resolve, reject);
235
- }, function (err) {
236
- invoke("throw", err, resolve, reject);
237
- });
238
- }
239
- return PromiseImpl.resolve(value).then(function (unwrapped) {
240
- // When a yielded Promise is resolved, its final value becomes
241
- // the .value of the Promise<{value,done}> result for the
242
- // current iteration.
243
- result.value = unwrapped;
244
- resolve(result);
245
- }, function (error) {
246
- // If a rejected Promise was yielded, throw the rejection back
247
- // into the async generator function so it can be handled there.
248
- return invoke("throw", error, resolve, reject);
249
- });
250
- }
251
- }
252
- var previousPromise;
253
- function enqueue(method, arg) {
254
- function callInvokeWithMethodAndArg() {
255
- return new PromiseImpl(function (resolve, reject) {
256
- invoke(method, arg, resolve, reject);
257
- });
258
- }
259
- return previousPromise =
260
- // If enqueue has been called before, then we want to wait until
261
- // all previous Promises have been resolved before calling invoke,
262
- // so that results are always delivered in the correct order. If
263
- // enqueue has not been called before, then it is important to
264
- // call invoke immediately, without waiting on a callback to fire,
265
- // so that the async generator function has the opportunity to do
266
- // any necessary setup in a predictable way. This predictability
267
- // is why the Promise constructor synchronously invokes its
268
- // executor callback, and why async functions synchronously
269
- // execute code before the first await. Since we implement simple
270
- // async functions in terms of async generators, it is especially
271
- // important to get this right, even though it requires care.
272
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
273
- // Avoid propagating failures to Promises returned by later
274
- // invocations of the iterator.
275
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
276
- }
277
-
278
- // Define the unified helper method that is used to implement .next,
279
- // .throw, and .return (see defineIteratorMethods).
280
- this._invoke = enqueue;
281
- }
282
- defineIteratorMethods(AsyncIterator.prototype);
283
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
284
- return this;
285
- });
286
- exports.AsyncIterator = AsyncIterator;
287
-
288
- // Note that simple async functions are implemented on top of
289
- // AsyncIterator objects; they just return a Promise for the value of
290
- // the final result produced by the iterator.
291
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
292
- if (PromiseImpl === void 0) PromiseImpl = Promise;
293
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
294
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
295
- : iter.next().then(function (result) {
296
- return result.done ? result.value : iter.next();
297
- });
298
- };
299
- function makeInvokeMethod(innerFn, self, context) {
300
- var state = GenStateSuspendedStart;
301
- return function invoke(method, arg) {
302
- if (state === GenStateExecuting) {
303
- throw new Error("Generator is already running");
304
- }
305
- if (state === GenStateCompleted) {
306
- if (method === "throw") {
307
- throw arg;
308
- }
309
-
310
- // Be forgiving, per 25.3.3.3.3 of the spec:
311
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
312
- return doneResult();
313
- }
314
- context.method = method;
315
- context.arg = arg;
316
- while (true) {
317
- var delegate = context.delegate;
318
- if (delegate) {
319
- var delegateResult = maybeInvokeDelegate(delegate, context);
320
- if (delegateResult) {
321
- if (delegateResult === ContinueSentinel) continue;
322
- return delegateResult;
323
- }
324
- }
325
- if (context.method === "next") {
326
- // Setting context._sent for legacy support of Babel's
327
- // function.sent implementation.
328
- context.sent = context._sent = context.arg;
329
- } else if (context.method === "throw") {
330
- if (state === GenStateSuspendedStart) {
331
- state = GenStateCompleted;
332
- throw context.arg;
333
- }
334
- context.dispatchException(context.arg);
335
- } else if (context.method === "return") {
336
- context.abrupt("return", context.arg);
337
- }
338
- state = GenStateExecuting;
339
- var record = tryCatch(innerFn, self, context);
340
- if (record.type === "normal") {
341
- // If an exception is thrown from innerFn, we leave state ===
342
- // GenStateExecuting and loop back for another invocation.
343
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
344
- if (record.arg === ContinueSentinel) {
345
- continue;
346
- }
347
- return {
348
- value: record.arg,
349
- done: context.done
350
- };
351
- } else if (record.type === "throw") {
352
- state = GenStateCompleted;
353
- // Dispatch the exception by looping back around to the
354
- // context.dispatchException(context.arg) call above.
355
- context.method = "throw";
356
- context.arg = record.arg;
357
- }
358
- }
359
- };
360
- }
361
-
362
- // Call delegate.iterator[context.method](context.arg) and handle the
363
- // result, either by returning a { value, done } result from the
364
- // delegate iterator, or by modifying context.method and context.arg,
365
- // setting context.delegate to null, and returning the ContinueSentinel.
366
- function maybeInvokeDelegate(delegate, context) {
367
- var method = delegate.iterator[context.method];
368
- if (method === undefined$1) {
369
- // A .throw or .return when the delegate iterator has no .throw
370
- // method always terminates the yield* loop.
371
- context.delegate = null;
372
- if (context.method === "throw") {
373
- // Note: ["return"] must be used for ES3 parsing compatibility.
374
- if (delegate.iterator["return"]) {
375
- // If the delegate iterator has a return method, give it a
376
- // chance to clean up.
377
- context.method = "return";
378
- context.arg = undefined$1;
379
- maybeInvokeDelegate(delegate, context);
380
- if (context.method === "throw") {
381
- // If maybeInvokeDelegate(context) changed context.method from
382
- // "return" to "throw", let that override the TypeError below.
383
- return ContinueSentinel;
384
- }
385
- }
386
- context.method = "throw";
387
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
388
- }
389
- return ContinueSentinel;
390
- }
391
- var record = tryCatch(method, delegate.iterator, context.arg);
392
- if (record.type === "throw") {
393
- context.method = "throw";
394
- context.arg = record.arg;
395
- context.delegate = null;
396
- return ContinueSentinel;
397
- }
398
- var info = record.arg;
399
- if (!info) {
400
- context.method = "throw";
401
- context.arg = new TypeError("iterator result is not an object");
402
- context.delegate = null;
403
- return ContinueSentinel;
404
- }
405
- if (info.done) {
406
- // Assign the result of the finished delegate to the temporary
407
- // variable specified by delegate.resultName (see delegateYield).
408
- context[delegate.resultName] = info.value;
409
-
410
- // Resume execution at the desired location (see delegateYield).
411
- context.next = delegate.nextLoc;
412
-
413
- // If context.method was "throw" but the delegate handled the
414
- // exception, let the outer generator proceed normally. If
415
- // context.method was "next", forget context.arg since it has been
416
- // "consumed" by the delegate iterator. If context.method was
417
- // "return", allow the original .return call to continue in the
418
- // outer generator.
419
- if (context.method !== "return") {
420
- context.method = "next";
421
- context.arg = undefined$1;
422
- }
423
- } else {
424
- // Re-yield the result returned by the delegate method.
425
- return info;
426
- }
427
-
428
- // The delegate iterator is finished, so forget it and continue with
429
- // the outer generator.
430
- context.delegate = null;
431
- return ContinueSentinel;
432
- }
433
-
434
- // Define Generator.prototype.{next,throw,return} in terms of the
435
- // unified ._invoke helper method.
436
- defineIteratorMethods(Gp);
437
- define(Gp, toStringTagSymbol, "Generator");
438
-
439
- // A Generator should always return itself as the iterator object when the
440
- // @@iterator function is called on it. Some browsers' implementations of the
441
- // iterator prototype chain incorrectly implement this, causing the Generator
442
- // object to not be returned from this call. This ensures that doesn't happen.
443
- // See https://github.com/facebook/regenerator/issues/274 for more details.
444
- define(Gp, iteratorSymbol, function () {
445
- return this;
446
- });
447
- define(Gp, "toString", function () {
448
- return "[object Generator]";
449
- });
450
- function pushTryEntry(locs) {
451
- var entry = {
452
- tryLoc: locs[0]
453
- };
454
- if (1 in locs) {
455
- entry.catchLoc = locs[1];
456
- }
457
- if (2 in locs) {
458
- entry.finallyLoc = locs[2];
459
- entry.afterLoc = locs[3];
460
- }
461
- this.tryEntries.push(entry);
462
- }
463
- function resetTryEntry(entry) {
464
- var record = entry.completion || {};
465
- record.type = "normal";
466
- delete record.arg;
467
- entry.completion = record;
468
- }
469
- function Context(tryLocsList) {
470
- // The root entry object (effectively a try statement without a catch
471
- // or a finally block) gives us a place to store values thrown from
472
- // locations where there is no enclosing try statement.
473
- this.tryEntries = [{
474
- tryLoc: "root"
475
- }];
476
- tryLocsList.forEach(pushTryEntry, this);
477
- this.reset(true);
478
- }
479
- exports.keys = function (object) {
480
- var keys = [];
481
- for (var key in object) {
482
- keys.push(key);
483
- }
484
- keys.reverse();
485
-
486
- // Rather than returning an object with a next method, we keep
487
- // things simple and return the next function itself.
488
- return function next() {
489
- while (keys.length) {
490
- var key = keys.pop();
491
- if (key in object) {
492
- next.value = key;
493
- next.done = false;
494
- return next;
495
- }
496
- }
497
-
498
- // To avoid creating an additional object, we just hang the .value
499
- // and .done properties off the next function object itself. This
500
- // also ensures that the minifier will not anonymize the function.
501
- next.done = true;
502
- return next;
503
- };
504
- };
505
- function values(iterable) {
506
- if (iterable) {
507
- var iteratorMethod = iterable[iteratorSymbol];
508
- if (iteratorMethod) {
509
- return iteratorMethod.call(iterable);
510
- }
511
- if (typeof iterable.next === "function") {
512
- return iterable;
513
- }
514
- if (!isNaN(iterable.length)) {
515
- var i = -1,
516
- next = function next() {
517
- while (++i < iterable.length) {
518
- if (hasOwn.call(iterable, i)) {
519
- next.value = iterable[i];
520
- next.done = false;
521
- return next;
522
- }
523
- }
524
- next.value = undefined$1;
525
- next.done = true;
526
- return next;
527
- };
528
- return next.next = next;
529
- }
530
- }
531
-
532
- // Return an iterator with no values.
533
- return {
534
- next: doneResult
535
- };
536
- }
537
- exports.values = values;
538
- function doneResult() {
539
- return {
540
- value: undefined$1,
541
- done: true
542
- };
543
- }
544
- Context.prototype = {
545
- constructor: Context,
546
- reset: function reset(skipTempReset) {
547
- this.prev = 0;
548
- this.next = 0;
549
- // Resetting context._sent for legacy support of Babel's
550
- // function.sent implementation.
551
- this.sent = this._sent = undefined$1;
552
- this.done = false;
553
- this.delegate = null;
554
- this.method = "next";
555
- this.arg = undefined$1;
556
- this.tryEntries.forEach(resetTryEntry);
557
- if (!skipTempReset) {
558
- for (var name in this) {
559
- // Not sure about the optimal order of these conditions:
560
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
561
- this[name] = undefined$1;
562
- }
563
- }
564
- }
565
- },
566
- stop: function stop() {
567
- this.done = true;
568
- var rootEntry = this.tryEntries[0];
569
- var rootRecord = rootEntry.completion;
570
- if (rootRecord.type === "throw") {
571
- throw rootRecord.arg;
572
- }
573
- return this.rval;
574
- },
575
- dispatchException: function dispatchException(exception) {
576
- if (this.done) {
577
- throw exception;
578
- }
579
- var context = this;
580
- function handle(loc, caught) {
581
- record.type = "throw";
582
- record.arg = exception;
583
- context.next = loc;
584
- if (caught) {
585
- // If the dispatched exception was caught by a catch block,
586
- // then let that catch block handle the exception normally.
587
- context.method = "next";
588
- context.arg = undefined$1;
589
- }
590
- return !!caught;
591
- }
592
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
593
- var entry = this.tryEntries[i];
594
- var record = entry.completion;
595
- if (entry.tryLoc === "root") {
596
- // Exception thrown outside of any try block that could handle
597
- // it, so set the completion value of the entire function to
598
- // throw the exception.
599
- return handle("end");
600
- }
601
- if (entry.tryLoc <= this.prev) {
602
- var hasCatch = hasOwn.call(entry, "catchLoc");
603
- var hasFinally = hasOwn.call(entry, "finallyLoc");
604
- if (hasCatch && hasFinally) {
605
- if (this.prev < entry.catchLoc) {
606
- return handle(entry.catchLoc, true);
607
- } else if (this.prev < entry.finallyLoc) {
608
- return handle(entry.finallyLoc);
609
- }
610
- } else if (hasCatch) {
611
- if (this.prev < entry.catchLoc) {
612
- return handle(entry.catchLoc, true);
613
- }
614
- } else if (hasFinally) {
615
- if (this.prev < entry.finallyLoc) {
616
- return handle(entry.finallyLoc);
617
- }
618
- } else {
619
- throw new Error("try statement without catch or finally");
620
- }
621
- }
622
- }
623
- },
624
- abrupt: function abrupt(type, arg) {
625
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
626
- var entry = this.tryEntries[i];
627
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
628
- var finallyEntry = entry;
629
- break;
630
- }
631
- }
632
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
633
- // Ignore the finally entry if control is not jumping to a
634
- // location outside the try/catch block.
635
- finallyEntry = null;
636
- }
637
- var record = finallyEntry ? finallyEntry.completion : {};
638
- record.type = type;
639
- record.arg = arg;
640
- if (finallyEntry) {
641
- this.method = "next";
642
- this.next = finallyEntry.finallyLoc;
643
- return ContinueSentinel;
644
- }
645
- return this.complete(record);
646
- },
647
- complete: function complete(record, afterLoc) {
648
- if (record.type === "throw") {
649
- throw record.arg;
650
- }
651
- if (record.type === "break" || record.type === "continue") {
652
- this.next = record.arg;
653
- } else if (record.type === "return") {
654
- this.rval = this.arg = record.arg;
655
- this.method = "return";
656
- this.next = "end";
657
- } else if (record.type === "normal" && afterLoc) {
658
- this.next = afterLoc;
659
- }
660
- return ContinueSentinel;
661
- },
662
- finish: function finish(finallyLoc) {
663
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
664
- var entry = this.tryEntries[i];
665
- if (entry.finallyLoc === finallyLoc) {
666
- this.complete(entry.completion, entry.afterLoc);
667
- resetTryEntry(entry);
668
- return ContinueSentinel;
669
- }
670
- }
671
- },
672
- "catch": function _catch(tryLoc) {
673
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
674
- var entry = this.tryEntries[i];
675
- if (entry.tryLoc === tryLoc) {
676
- var record = entry.completion;
677
- if (record.type === "throw") {
678
- var thrown = record.arg;
679
- resetTryEntry(entry);
680
- }
681
- return thrown;
682
- }
683
- }
684
-
685
- // The context.catch method must only be called with a location
686
- // argument that corresponds to a known catch block.
687
- throw new Error("illegal catch attempt");
688
- },
689
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
690
- this.delegate = {
691
- iterator: values(iterable),
692
- resultName: resultName,
693
- nextLoc: nextLoc
694
- };
695
- if (this.method === "next") {
696
- // Deliberately forget the last sent value so that we don't
697
- // accidentally pass it on to the delegate.
698
- this.arg = undefined$1;
699
- }
700
- return ContinueSentinel;
701
- }
702
- };
703
-
704
- // Regardless of whether this script is executing as a CommonJS module
705
- // or not, return the runtime object so that we can declare the variable
706
- // regeneratorRuntime in the outer scope, which allows this module to be
707
- // injected easily by `bin/regenerator --include-runtime script.js`.
708
- return exports;
709
- }(
710
- // If this script is executing as a CommonJS module, use module.exports
711
- // as the regeneratorRuntime namespace. Otherwise create a new empty
712
- // object. Either way, the resulting object will be used to initialize
713
- // the regeneratorRuntime variable at the top of this file.
714
- module.exports );
715
- try {
716
- regeneratorRuntime = runtime;
717
- } catch (accidentalStrictMode) {
718
- // This module should not be running in strict mode, so the above
719
- // assignment should always work unless something is misconfigured. Just
720
- // in case runtime.js accidentally runs in strict mode, in modern engines
721
- // we can explicitly access globalThis. In older engines we can escape
722
- // strict mode using a global Function call. This could conceivably fail
723
- // if a Content Security Policy forbids using Function, but in that case
724
- // the proper solution is to fix the accidental strict mode problem. If
725
- // you've misconfigured your bundler to force strict mode and applied a
726
- // CSP to forbid Function, and you're not willing to fix either of those
727
- // problems, please detail your unique predicament in a GitHub issue.
728
- if (typeof globalThis === "object") {
729
- globalThis.regeneratorRuntime = runtime;
730
- } else {
731
- Function("r", "regeneratorRuntime = r")(runtime);
732
- }
733
- }
734
- });
735
-
736
379
  /*
737
380
  Forked from https://github.com/vercel/commerce/tree/main/packages/saleor/src
738
381
  Changes: None
@@ -766,6 +409,7 @@ var getSortVariables = function getSortVariables(sort, isCategory) {
766
409
  return output;
767
410
  };
768
411
 
412
+ var _getAsyncError, _ref;
769
413
  function getError(errors, status) {
770
414
  var _errors;
771
415
  errors = (_errors = errors) != null ? _errors : [{
@@ -777,69 +421,58 @@ function getError(errors, status) {
777
421
  });
778
422
  }
779
423
  function getAsyncError(_x) {
780
- return _getAsyncError.apply(this, arguments);
781
- }
782
- function _getAsyncError() {
783
- _getAsyncError = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(res) {
424
+ return (_getAsyncError = _getAsyncError || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
784
425
  var data;
785
- return runtime_1.wrap(function _callee2$(_context2) {
786
- while (1) {
787
- switch (_context2.prev = _context2.next) {
788
- case 0:
789
- _context2.next = 2;
790
- return res.json();
791
- case 2:
792
- data = _context2.sent;
793
- return _context2.abrupt("return", getError(data.errors, res.status));
794
- case 4:
795
- case "end":
796
- return _context2.stop();
797
- }
426
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
427
+ while (1) switch (_context.prev = _context.next) {
428
+ case 0:
429
+ _context.next = 2;
430
+ return res.json();
431
+ case 2:
432
+ data = _context.sent;
433
+ return _context.abrupt("return", getError(data.errors, res.status));
434
+ case 4:
435
+ case "end":
436
+ return _context.stop();
798
437
  }
799
- }, _callee2);
800
- }));
801
- return _getAsyncError.apply(this, arguments);
438
+ }, _callee);
439
+ }))).apply(this, arguments);
802
440
  }
803
- var handleFetchResponse = /*#__PURE__*/function () {
804
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(res) {
441
+ var handleFetchResponse = function handleFetchResponse(_x2) {
442
+ return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(res) {
805
443
  var _yield$res$json, data, errors;
806
- return runtime_1.wrap(function _callee$(_context) {
807
- while (1) {
808
- switch (_context.prev = _context.next) {
809
- case 0:
810
- if (!res.ok) {
811
- _context.next = 9;
812
- break;
813
- }
814
- _context.next = 3;
815
- return res.json();
816
- case 3:
817
- _yield$res$json = _context.sent;
818
- data = _yield$res$json.data;
819
- errors = _yield$res$json.errors;
820
- if (!(errors && errors.length)) {
821
- _context.next = 8;
822
- break;
823
- }
824
- throw getError(errors, res.status);
825
- case 8:
826
- return _context.abrupt("return", data);
827
- case 9:
828
- _context.next = 11;
829
- return getAsyncError(res);
830
- case 11:
831
- throw _context.sent;
832
- case 12:
833
- case "end":
834
- return _context.stop();
835
- }
444
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
445
+ while (1) switch (_context2.prev = _context2.next) {
446
+ case 0:
447
+ if (!res.ok) {
448
+ _context2.next = 9;
449
+ break;
450
+ }
451
+ _context2.next = 3;
452
+ return res.json();
453
+ case 3:
454
+ _yield$res$json = _context2.sent;
455
+ data = _yield$res$json.data;
456
+ errors = _yield$res$json.errors;
457
+ if (!(errors && errors.length)) {
458
+ _context2.next = 8;
459
+ break;
460
+ }
461
+ throw getError(errors, res.status);
462
+ case 8:
463
+ return _context2.abrupt("return", data);
464
+ case 9:
465
+ _context2.next = 11;
466
+ return getAsyncError(res);
467
+ case 11:
468
+ throw _context2.sent;
469
+ case 12:
470
+ case "end":
471
+ return _context2.stop();
836
472
  }
837
- }, _callee);
838
- }));
839
- return function handleFetchResponse(_x2) {
840
- return _ref.apply(this, arguments);
841
- };
842
- }();
473
+ }, _callee2);
474
+ }))).apply(this, arguments);
475
+ };
843
476
 
844
477
  var getSearchVariables = function getSearchVariables(_ref) {
845
478
  var search = _ref.search,
@@ -911,44 +544,40 @@ var CheckoutLineUpdate = /* GraphQL */"\n mutation CheckoutLineUpdate($checkout
911
544
  */
912
545
  var CheckoutLineDelete = /* GraphQL */"\n mutation CheckoutLineDelete($checkoutId: ID!, $lineId: ID!) {\n checkoutLineDelete(checkoutId: $checkoutId, lineId: $lineId) {\n errors {\n code\n field\n message\n }\n checkout {\n ...CheckoutDetails\n }\n }\n }\n " + CheckoutDetails + "\n";
913
546
 
914
- var checkoutCreate = /*#__PURE__*/function () {
915
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(fetch) {
547
+ var _ref$1;
548
+ var checkoutCreate = function checkoutCreate(_x) {
549
+ return (_ref$1 = _ref$1 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetch) {
916
550
  var _data$checkoutCreate;
917
551
  var data, checkout, checkoutId, checkoutToken, value, options;
918
- return runtime_1.wrap(function _callee$(_context) {
919
- while (1) {
920
- switch (_context.prev = _context.next) {
921
- case 0:
922
- _context.next = 2;
923
- return fetch({
924
- query: CheckoutCreate
925
- });
926
- case 2:
927
- data = _context.sent;
928
- checkout = (_data$checkoutCreate = data.checkoutCreate) == null ? void 0 : _data$checkoutCreate.checkout;
929
- checkoutId = checkout == null ? void 0 : checkout.id;
930
- checkoutToken = checkout == null ? void 0 : checkout.token;
931
- value = checkoutId + ":" + checkoutToken;
932
- if (checkoutId) {
933
- options = {
934
- expires: 60 * 60 * 24 * 30,
935
- sameSite: "none",
936
- secure: true
937
- };
938
- Cookies.set(CHECKOUT_ID_COOKIE, value, options);
939
- }
940
- return _context.abrupt("return", checkout);
941
- case 9:
942
- case "end":
943
- return _context.stop();
944
- }
552
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
553
+ while (1) switch (_context.prev = _context.next) {
554
+ case 0:
555
+ _context.next = 2;
556
+ return fetch({
557
+ query: CheckoutCreate
558
+ });
559
+ case 2:
560
+ data = _context.sent;
561
+ checkout = (_data$checkoutCreate = data.checkoutCreate) == null ? void 0 : _data$checkoutCreate.checkout;
562
+ checkoutId = checkout == null ? void 0 : checkout.id;
563
+ checkoutToken = checkout == null ? void 0 : checkout.token;
564
+ value = checkoutId + ":" + checkoutToken;
565
+ if (checkoutId) {
566
+ options = {
567
+ expires: 60 * 60 * 24 * 30,
568
+ sameSite: "none",
569
+ secure: true
570
+ };
571
+ Cookies.set(CHECKOUT_ID_COOKIE, value, options);
572
+ }
573
+ return _context.abrupt("return", checkout);
574
+ case 9:
575
+ case "end":
576
+ return _context.stop();
945
577
  }
946
578
  }, _callee);
947
- }));
948
- return function checkoutCreate(_x) {
949
- return _ref.apply(this, arguments);
950
- };
951
- }();
579
+ }))).apply(this, arguments);
580
+ };
952
581
 
953
582
  var _excluded = ["id", "name", "media", "variants", "description", "slug", "pricing"];
954
583
  /* eslint-disable */
@@ -1003,7 +632,7 @@ var normalizeProductVariants = function normalizeProductVariants(variants) {
1003
632
  sku = variant.sku,
1004
633
  name = variant.name,
1005
634
  pricing = variant.pricing;
1006
- var price = (pricing == null ? void 0 : (_pricing$price = pricing.price) == null ? void 0 : _pricing$price.net) && ((_money = money(pricing.price.net)) == null ? void 0 : _money.value);
635
+ var price = (pricing == null || (_pricing$price = pricing.price) == null ? void 0 : _pricing$price.net) && ((_money = money(pricing.price.net)) == null ? void 0 : _money.value);
1007
636
  return {
1008
637
  id: id,
1009
638
  name: name,
@@ -1016,7 +645,7 @@ var normalizeProductVariants = function normalizeProductVariants(variants) {
1016
645
  });
1017
646
  };
1018
647
  function normalizeProduct(productNode) {
1019
- var _JSON$parse, _JSON$parse$blocks$, _pricing$priceRange, _pricing$priceRange$s;
648
+ var _JSON$parse, _pricing$priceRange;
1020
649
  var id = productNode.id,
1021
650
  name = productNode.name,
1022
651
  _productNode$media = productNode.media,
@@ -1030,10 +659,10 @@ function normalizeProduct(productNode) {
1030
659
  id: id,
1031
660
  name: name,
1032
661
  vendor: "",
1033
- description: description ? (_JSON$parse = JSON.parse(description)) == null ? void 0 : (_JSON$parse$blocks$ = _JSON$parse.blocks[0]) == null ? void 0 : _JSON$parse$blocks$.data.text : "",
662
+ description: description ? (_JSON$parse = JSON.parse(description)) == null || (_JSON$parse = _JSON$parse.blocks[0]) == null ? void 0 : _JSON$parse.data.text : "",
1034
663
  path: "/" + slug,
1035
664
  slug: slug == null ? void 0 : slug.replace(/^\/+|\/+$/g, ""),
1036
- price: (pricing == null ? void 0 : (_pricing$priceRange = pricing.priceRange) == null ? void 0 : (_pricing$priceRange$s = _pricing$priceRange.start) == null ? void 0 : _pricing$priceRange$s.net) && money(pricing.priceRange.start.net) || {
665
+ price: (pricing == null || (_pricing$priceRange = pricing.priceRange) == null || (_pricing$priceRange = _pricing$priceRange.start) == null ? void 0 : _pricing$priceRange.net) && money(pricing.priceRange.start.net) || {
1037
666
  value: 0,
1038
667
  currencyCode: "USD"
1039
668
  },
@@ -1047,7 +676,7 @@ function normalizeProduct(productNode) {
1047
676
  return product;
1048
677
  }
1049
678
  function normalizeCart(checkout) {
1050
- var _checkout$totalPrice, _checkout$subtotalPri, _checkout$subtotalPri2, _checkout$subtotalPri3, _checkout$subtotalPri4, _checkout$totalPrice2;
679
+ var _checkout$totalPrice, _checkout$subtotalPri, _checkout$subtotalPri2, _checkout$totalPrice2;
1051
680
  var lines = checkout.lines;
1052
681
  var lineItems = lines.length > 0 ? lines == null ? void 0 : lines.map(normalizeLineItem) : [];
1053
682
  return {
@@ -1060,21 +689,21 @@ function normalizeCart(checkout) {
1060
689
  },
1061
690
  taxesIncluded: false,
1062
691
  lineItems: lineItems,
1063
- lineItemsSubtotalPrice: (_checkout$subtotalPri = checkout.subtotalPrice) == null ? void 0 : (_checkout$subtotalPri2 = _checkout$subtotalPri.gross) == null ? void 0 : _checkout$subtotalPri2.amount,
1064
- subtotalPrice: (_checkout$subtotalPri3 = checkout.subtotalPrice) == null ? void 0 : (_checkout$subtotalPri4 = _checkout$subtotalPri3.gross) == null ? void 0 : _checkout$subtotalPri4.amount,
692
+ lineItemsSubtotalPrice: (_checkout$subtotalPri = checkout.subtotalPrice) == null || (_checkout$subtotalPri = _checkout$subtotalPri.gross) == null ? void 0 : _checkout$subtotalPri.amount,
693
+ subtotalPrice: (_checkout$subtotalPri2 = checkout.subtotalPrice) == null || (_checkout$subtotalPri2 = _checkout$subtotalPri2.gross) == null ? void 0 : _checkout$subtotalPri2.amount,
1065
694
  totalPrice: (_checkout$totalPrice2 = checkout.totalPrice) == null ? void 0 : _checkout$totalPrice2.gross.amount,
1066
695
  discounts: []
1067
696
  };
1068
697
  }
1069
698
  function normalizeLineItem(_ref3) {
1070
- var _variant$product, _variant$sku, _variant$pricing, _variant$pricing$pric, _variant$product2;
699
+ var _variant$product, _variant$sku, _variant$pricing, _variant$product2;
1071
700
  var id = _ref3.id,
1072
701
  variant = _ref3.variant,
1073
702
  quantity = _ref3.quantity;
1074
703
  return {
1075
704
  id: id,
1076
705
  variantId: String(variant == null ? void 0 : variant.id),
1077
- productId: String(variant == null ? void 0 : (_variant$product = variant.product) == null ? void 0 : _variant$product.id),
706
+ productId: String(variant == null || (_variant$product = variant.product) == null ? void 0 : _variant$product.id),
1078
707
  name: "" + variant.product.name,
1079
708
  quantity: quantity,
1080
709
  variant: {
@@ -1085,10 +714,10 @@ function normalizeLineItem(_ref3) {
1085
714
  url: variant != null && variant.media[0] ? variant == null ? void 0 : variant.media[0].url : placeholderImg
1086
715
  },
1087
716
  requiresShipping: false,
1088
- price: variant == null ? void 0 : (_variant$pricing = variant.pricing) == null ? void 0 : (_variant$pricing$pric = _variant$pricing.price) == null ? void 0 : _variant$pricing$pric.gross.amount,
717
+ price: variant == null || (_variant$pricing = variant.pricing) == null || (_variant$pricing = _variant$pricing.price) == null ? void 0 : _variant$pricing.gross.amount,
1089
718
  listPrice: 0
1090
719
  },
1091
- path: String(variant == null ? void 0 : (_variant$product2 = variant.product) == null ? void 0 : _variant$product2.slug),
720
+ path: String(variant == null || (_variant$product2 = variant.product) == null ? void 0 : _variant$product2.slug),
1092
721
  discounts: [],
1093
722
  options: []
1094
723
  };
@@ -1136,7 +765,7 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
1136
765
  });
1137
766
  }
1138
767
  var checkout = checkoutPayload == null ? void 0 : checkoutPayload.checkout;
1139
- if ((checkoutPayload == null ? void 0 : (_checkoutPayload$erro = checkoutPayload.errors) == null ? void 0 : _checkoutPayload$erro.length) === 1 && checkoutPayload.errors[0].code === "PRODUCT_UNAVAILABLE_FOR_PURCHASE") {
768
+ if ((checkoutPayload == null || (_checkoutPayload$erro = checkoutPayload.errors) == null ? void 0 : _checkoutPayload$erro.length) === 1 && checkoutPayload.errors[0].code === "PRODUCT_UNAVAILABLE_FOR_PURCHASE") {
1140
769
  console.error(checkoutPayload.errors[0]);
1141
770
  return undefined;
1142
771
  }
@@ -1200,43 +829,41 @@ var handler = {
1200
829
  query: CheckoutOne
1201
830
  },
1202
831
  fetcher: function fetcher(_ref) {
1203
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
832
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1204
833
  var _checkout;
1205
834
  var checkoutId, options, fetch, checkout, _checkoutId, data;
1206
- return runtime_1.wrap(function _callee$(_context) {
1207
- while (1) {
1208
- switch (_context.prev = _context.next) {
1209
- case 0:
1210
- checkoutId = _ref.input.cartId, options = _ref.options, fetch = _ref.fetch;
1211
- if (!checkoutId) {
1212
- _context.next = 7;
1213
- break;
1214
- }
1215
- _checkoutId = getCheckoutId().checkoutToken;
1216
- _context.next = 5;
1217
- return fetch(_extends({}, options, {
1218
- variables: {
1219
- checkoutId: _checkoutId
1220
- }
1221
- }));
1222
- case 5:
1223
- data = _context.sent;
1224
- checkout = data;
1225
- case 7:
1226
- if (!((_checkout = checkout) != null && _checkout.completedAt || !checkoutId)) {
1227
- _context.next = 11;
1228
- break;
835
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
836
+ while (1) switch (_context.prev = _context.next) {
837
+ case 0:
838
+ checkoutId = _ref.input.cartId, options = _ref.options, fetch = _ref.fetch;
839
+ if (!checkoutId) {
840
+ _context.next = 7;
841
+ break;
842
+ }
843
+ _checkoutId = getCheckoutId().checkoutToken;
844
+ _context.next = 5;
845
+ return fetch(_extends({}, options, {
846
+ variables: {
847
+ checkoutId: _checkoutId
1229
848
  }
1230
- _context.next = 10;
1231
- return checkoutCreate(fetch);
1232
- case 10:
1233
- checkout = _context.sent;
1234
- case 11:
1235
- return _context.abrupt("return", checkoutToCart(checkout));
1236
- case 12:
1237
- case "end":
1238
- return _context.stop();
1239
- }
849
+ }));
850
+ case 5:
851
+ data = _context.sent;
852
+ checkout = data;
853
+ case 7:
854
+ if (!((_checkout = checkout) != null && _checkout.completedAt || !checkoutId)) {
855
+ _context.next = 11;
856
+ break;
857
+ }
858
+ _context.next = 10;
859
+ return checkoutCreate(fetch);
860
+ case 10:
861
+ checkout = _context.sent;
862
+ case 11:
863
+ return _context.abrupt("return", checkoutToCart(checkout));
864
+ case 12:
865
+ case "end":
866
+ return _context.stop();
1240
867
  }
1241
868
  }, _callee);
1242
869
  }))();
@@ -1269,40 +896,38 @@ var handler$1 = {
1269
896
  query: CheckoutLineAdd
1270
897
  },
1271
898
  fetcher: function fetcher(_ref) {
1272
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
899
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1273
900
  var _item$quantity;
1274
901
  var item, options, fetch, _yield$fetch, checkoutLinesAdd;
1275
- return runtime_1.wrap(function _callee$(_context) {
1276
- while (1) {
1277
- switch (_context.prev = _context.next) {
1278
- case 0:
1279
- item = _ref.input, options = _ref.options, fetch = _ref.fetch;
1280
- if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
1281
- _context.next = 3;
1282
- break;
902
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
903
+ while (1) switch (_context.prev = _context.next) {
904
+ case 0:
905
+ item = _ref.input, options = _ref.options, fetch = _ref.fetch;
906
+ if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
907
+ _context.next = 3;
908
+ break;
909
+ }
910
+ throw new commerce.CommerceError({
911
+ message: "The item quantity has to be a valid integer greater than 0"
912
+ });
913
+ case 3:
914
+ _context.next = 5;
915
+ return fetch(_extends({}, options, {
916
+ variables: {
917
+ checkoutId: getCheckoutId().checkoutId,
918
+ lineItems: [{
919
+ variantId: item.variantId,
920
+ quantity: (_item$quantity = item.quantity) != null ? _item$quantity : 1
921
+ }]
1283
922
  }
1284
- throw new commerce.CommerceError({
1285
- message: "The item quantity has to be a valid integer greater than 0"
1286
- });
1287
- case 3:
1288
- _context.next = 5;
1289
- return fetch(_extends({}, options, {
1290
- variables: {
1291
- checkoutId: getCheckoutId().checkoutId,
1292
- lineItems: [{
1293
- variantId: item.variantId,
1294
- quantity: (_item$quantity = item.quantity) != null ? _item$quantity : 1
1295
- }]
1296
- }
1297
- }));
1298
- case 5:
1299
- _yield$fetch = _context.sent;
1300
- checkoutLinesAdd = _yield$fetch.checkoutLinesAdd;
1301
- return _context.abrupt("return", checkoutToCart(checkoutLinesAdd));
1302
- case 8:
1303
- case "end":
1304
- return _context.stop();
1305
- }
923
+ }));
924
+ case 5:
925
+ _yield$fetch = _context.sent;
926
+ checkoutLinesAdd = _yield$fetch.checkoutLinesAdd;
927
+ return _context.abrupt("return", checkoutToCart(checkoutLinesAdd));
928
+ case 8:
929
+ case "end":
930
+ return _context.stop();
1306
931
  }
1307
932
  }, _callee);
1308
933
  }))();
@@ -1310,47 +935,42 @@ var handler$1 = {
1310
935
  useHook: function useHook(_ref2) {
1311
936
  var fetch = _ref2.fetch;
1312
937
  return function () {
938
+ var _addItem;
1313
939
  var _useCart = commerce.useCart(),
1314
940
  mutate = _useCart.mutate;
1315
- return React.useCallback( /*#__PURE__*/function () {
1316
- var _addItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
941
+ return React.useCallback(function addItem(_x) {
942
+ return (_addItem = _addItem || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
1317
943
  var data;
1318
- return runtime_1.wrap(function _callee2$(_context2) {
1319
- while (1) {
1320
- switch (_context2.prev = _context2.next) {
1321
- case 0:
1322
- _context2.next = 2;
1323
- return fetch({
1324
- input: input
1325
- });
1326
- case 2:
1327
- data = _context2.sent;
1328
- if (!data) {
1329
- _context2.next = 8;
1330
- break;
1331
- }
1332
- _context2.next = 6;
1333
- return mutate(data, false);
1334
- case 6:
1335
- _context2.next = 10;
944
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
945
+ while (1) switch (_context2.prev = _context2.next) {
946
+ case 0:
947
+ _context2.next = 2;
948
+ return fetch({
949
+ input: input
950
+ });
951
+ case 2:
952
+ data = _context2.sent;
953
+ if (!data) {
954
+ _context2.next = 8;
1336
955
  break;
1337
- case 8:
1338
- _context2.next = 10;
1339
- return mutate();
1340
- case 10:
1341
- return _context2.abrupt("return", data);
1342
- case 11:
1343
- case "end":
1344
- return _context2.stop();
1345
- }
956
+ }
957
+ _context2.next = 6;
958
+ return mutate(data, false);
959
+ case 6:
960
+ _context2.next = 10;
961
+ break;
962
+ case 8:
963
+ _context2.next = 10;
964
+ return mutate();
965
+ case 10:
966
+ return _context2.abrupt("return", data);
967
+ case 11:
968
+ case "end":
969
+ return _context2.stop();
1346
970
  }
1347
971
  }, _callee2);
1348
- }));
1349
- function addItem(_x) {
1350
- return _addItem.apply(this, arguments);
1351
- }
1352
- return addItem;
1353
- }(), [fetch, mutate]);
972
+ }))).apply(this, arguments);
973
+ }, [fetch, mutate]);
1354
974
  };
1355
975
  }
1356
976
  };
@@ -1360,27 +980,25 @@ var handler$2 = {
1360
980
  query: CheckoutLineDelete
1361
981
  },
1362
982
  fetcher: function fetcher(_ref) {
1363
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
983
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1364
984
  var itemId, options, fetch, data;
1365
- return runtime_1.wrap(function _callee$(_context) {
1366
- while (1) {
1367
- switch (_context.prev = _context.next) {
1368
- case 0:
1369
- itemId = _ref.input.itemId, options = _ref.options, fetch = _ref.fetch;
1370
- _context.next = 3;
1371
- return fetch(_extends({}, options, {
1372
- variables: {
1373
- checkoutId: getCheckoutId().checkoutId,
1374
- lineId: itemId
1375
- }
1376
- }));
1377
- case 3:
1378
- data = _context.sent;
1379
- return _context.abrupt("return", checkoutToCart(data.checkoutLineDelete));
1380
- case 5:
1381
- case "end":
1382
- return _context.stop();
1383
- }
985
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
986
+ while (1) switch (_context.prev = _context.next) {
987
+ case 0:
988
+ itemId = _ref.input.itemId, options = _ref.options, fetch = _ref.fetch;
989
+ _context.next = 3;
990
+ return fetch(_extends({}, options, {
991
+ variables: {
992
+ checkoutId: getCheckoutId().checkoutId,
993
+ lineId: itemId
994
+ }
995
+ }));
996
+ case 3:
997
+ data = _context.sent;
998
+ return _context.abrupt("return", checkoutToCart(data.checkoutLineDelete));
999
+ case 5:
1000
+ case "end":
1001
+ return _context.stop();
1384
1002
  }
1385
1003
  }, _callee);
1386
1004
  }))();
@@ -1388,39 +1006,34 @@ var handler$2 = {
1388
1006
  useHook: function useHook(_ref2) {
1389
1007
  var fetch = _ref2.fetch;
1390
1008
  return function () {
1009
+ var _removeItem;
1391
1010
  var _useCart = commerce.useCart(),
1392
1011
  mutate = _useCart.mutate;
1393
- return React.useCallback( /*#__PURE__*/function () {
1394
- var _removeItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
1012
+ return React.useCallback(function removeItem(_x) {
1013
+ return (_removeItem = _removeItem || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
1395
1014
  var data;
1396
- return runtime_1.wrap(function _callee2$(_context2) {
1397
- while (1) {
1398
- switch (_context2.prev = _context2.next) {
1399
- case 0:
1400
- _context2.next = 2;
1401
- return fetch({
1402
- input: {
1403
- itemId: input.id
1404
- }
1405
- });
1406
- case 2:
1407
- data = _context2.sent;
1408
- _context2.next = 5;
1409
- return mutate(data, false);
1410
- case 5:
1411
- return _context2.abrupt("return", data);
1412
- case 6:
1413
- case "end":
1414
- return _context2.stop();
1415
- }
1015
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1016
+ while (1) switch (_context2.prev = _context2.next) {
1017
+ case 0:
1018
+ _context2.next = 2;
1019
+ return fetch({
1020
+ input: {
1021
+ itemId: input.id
1022
+ }
1023
+ });
1024
+ case 2:
1025
+ data = _context2.sent;
1026
+ _context2.next = 5;
1027
+ return mutate(data, false);
1028
+ case 5:
1029
+ return _context2.abrupt("return", data);
1030
+ case 6:
1031
+ case "end":
1032
+ return _context2.stop();
1416
1033
  }
1417
1034
  }, _callee2);
1418
- }));
1419
- function removeItem(_x) {
1420
- return _removeItem.apply(this, arguments);
1421
- }
1422
- return removeItem;
1423
- }(), [fetch, mutate]);
1035
+ }))).apply(this, arguments);
1036
+ }, [fetch, mutate]);
1424
1037
  };
1425
1038
  }
1426
1039
  };
@@ -1430,59 +1043,57 @@ var handler$3 = {
1430
1043
  query: CheckoutLineUpdate
1431
1044
  },
1432
1045
  fetcher: function fetcher(_ref) {
1433
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1046
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1434
1047
  var _ref$input, itemId, item, options, fetch, checkoutId, _yield$fetch, checkoutLinesUpdate;
1435
- return runtime_1.wrap(function _callee$(_context) {
1436
- while (1) {
1437
- switch (_context.prev = _context.next) {
1438
- case 0:
1439
- _ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
1440
- if (!Number.isInteger(item.quantity)) {
1441
- _context.next = 6;
1442
- break;
1443
- }
1444
- if (!(item.quantity < 1)) {
1445
- _context.next = 4;
1446
- break;
1447
- }
1448
- return _context.abrupt("return", handler$2.fetcher({
1449
- options: handler$2.fetchOptions,
1450
- input: {
1451
- itemId: itemId
1452
- },
1453
- fetch: fetch
1454
- }));
1455
- case 4:
1048
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1049
+ while (1) switch (_context.prev = _context.next) {
1050
+ case 0:
1051
+ _ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
1052
+ if (!Number.isInteger(item.quantity)) {
1053
+ _context.next = 6;
1054
+ break;
1055
+ }
1056
+ if (!(item.quantity < 1)) {
1057
+ _context.next = 4;
1058
+ break;
1059
+ }
1060
+ return _context.abrupt("return", handler$2.fetcher({
1061
+ options: handler$2.fetchOptions,
1062
+ input: {
1063
+ itemId: itemId
1064
+ },
1065
+ fetch: fetch
1066
+ }));
1067
+ case 4:
1068
+ _context.next = 8;
1069
+ break;
1070
+ case 6:
1071
+ if (!item.quantity) {
1456
1072
  _context.next = 8;
1457
1073
  break;
1458
- case 6:
1459
- if (!item.quantity) {
1460
- _context.next = 8;
1461
- break;
1074
+ }
1075
+ throw new commerce.ValidationError({
1076
+ message: "The item quantity has to be a valid integer"
1077
+ });
1078
+ case 8:
1079
+ checkoutId = getCheckoutId().checkoutId;
1080
+ _context.next = 11;
1081
+ return fetch(_extends({}, options, {
1082
+ variables: {
1083
+ checkoutId: checkoutId,
1084
+ lineItems: [{
1085
+ itemId: itemId,
1086
+ quantity: item.quantity
1087
+ }]
1462
1088
  }
1463
- throw new commerce.ValidationError({
1464
- message: "The item quantity has to be a valid integer"
1465
- });
1466
- case 8:
1467
- checkoutId = getCheckoutId().checkoutId;
1468
- _context.next = 11;
1469
- return fetch(_extends({}, options, {
1470
- variables: {
1471
- checkoutId: checkoutId,
1472
- lineItems: [{
1473
- itemId: itemId,
1474
- quantity: item.quantity
1475
- }]
1476
- }
1477
- }));
1478
- case 11:
1479
- _yield$fetch = _context.sent;
1480
- checkoutLinesUpdate = _yield$fetch.checkoutLinesUpdate;
1481
- return _context.abrupt("return", checkoutToCart(checkoutLinesUpdate));
1482
- case 14:
1483
- case "end":
1484
- return _context.stop();
1485
- }
1089
+ }));
1090
+ case 11:
1091
+ _yield$fetch = _context.sent;
1092
+ checkoutLinesUpdate = _yield$fetch.checkoutLinesUpdate;
1093
+ return _context.abrupt("return", checkoutToCart(checkoutLinesUpdate));
1094
+ case 14:
1095
+ case "end":
1096
+ return _context.stop();
1486
1097
  }
1487
1098
  }, _callee);
1488
1099
  }))();
@@ -1490,7 +1101,7 @@ var handler$3 = {
1490
1101
  useHook: function useHook(_ref2) {
1491
1102
  var fetch = _ref2.fetch;
1492
1103
  return function (ctx) {
1493
- var _ctx$wait;
1104
+ var _ref3, _ctx$wait;
1494
1105
  if (ctx === void 0) {
1495
1106
  ctx = {};
1496
1107
  }
@@ -1498,49 +1109,44 @@ var handler$3 = {
1498
1109
  item = _ctx.item;
1499
1110
  var _useCart = commerce.useCart(),
1500
1111
  mutate = _useCart.mutate;
1501
- return React.useCallback(debounce( /*#__PURE__*/function () {
1502
- var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
1112
+ return React.useCallback(debounce(function (_x) {
1113
+ return (_ref3 = _ref3 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
1503
1114
  var _input$id;
1504
1115
  var itemId, data;
1505
- return runtime_1.wrap(function _callee2$(_context2) {
1506
- while (1) {
1507
- switch (_context2.prev = _context2.next) {
1508
- case 0:
1509
- itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
1510
- if (itemId) {
1511
- _context2.next = 3;
1512
- break;
1116
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1117
+ while (1) switch (_context2.prev = _context2.next) {
1118
+ case 0:
1119
+ itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
1120
+ if (itemId) {
1121
+ _context2.next = 3;
1122
+ break;
1123
+ }
1124
+ throw new commerce.ValidationError({
1125
+ message: "Invalid input used for this operation"
1126
+ });
1127
+ case 3:
1128
+ _context2.next = 5;
1129
+ return fetch({
1130
+ input: {
1131
+ item: {
1132
+ quantity: input.quantity
1133
+ },
1134
+ itemId: itemId
1513
1135
  }
1514
- throw new commerce.ValidationError({
1515
- message: "Invalid input used for this operation"
1516
- });
1517
- case 3:
1518
- _context2.next = 5;
1519
- return fetch({
1520
- input: {
1521
- item: {
1522
- quantity: input.quantity
1523
- },
1524
- itemId: itemId
1525
- }
1526
- });
1527
- case 5:
1528
- data = _context2.sent;
1529
- _context2.next = 8;
1530
- return mutate(data, false);
1531
- case 8:
1532
- return _context2.abrupt("return", data);
1533
- case 9:
1534
- case "end":
1535
- return _context2.stop();
1536
- }
1136
+ });
1137
+ case 5:
1138
+ data = _context2.sent;
1139
+ _context2.next = 8;
1140
+ return mutate(data, false);
1141
+ case 8:
1142
+ return _context2.abrupt("return", data);
1143
+ case 9:
1144
+ case "end":
1145
+ return _context2.stop();
1537
1146
  }
1538
1147
  }, _callee2);
1539
- }));
1540
- return function (_x) {
1541
- return _ref3.apply(this, arguments);
1542
- };
1543
- }(), (_ctx$wait = ctx.wait) != null ? _ctx$wait : 500), [fetch, mutate]);
1148
+ }))).apply(this, arguments);
1149
+ }, (_ctx$wait = ctx.wait) != null ? _ctx$wait : 500), [fetch, mutate]);
1544
1150
  };
1545
1151
  }
1546
1152
  };
@@ -1550,46 +1156,44 @@ var handler$4 = {
1550
1156
  query: CollectionMany
1551
1157
  },
1552
1158
  fetcher: function fetcher(_ref) {
1553
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1554
- var input, fetch, categoryId, _data$collections$edg, _data$collections, _data$collections$edg2, data, _data;
1555
- return runtime_1.wrap(function _callee$(_context) {
1556
- while (1) {
1557
- switch (_context.prev = _context.next) {
1558
- case 0:
1559
- input = _ref.input, fetch = _ref.fetch;
1560
- categoryId = input.categoryId;
1561
- if (categoryId) {
1562
- _context.next = 9;
1563
- break;
1159
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1160
+ var input, fetch, categoryId, _data$collections$edg, _data$collections, data, _data;
1161
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1162
+ while (1) switch (_context.prev = _context.next) {
1163
+ case 0:
1164
+ input = _ref.input, fetch = _ref.fetch;
1165
+ categoryId = input.categoryId;
1166
+ if (categoryId) {
1167
+ _context.next = 9;
1168
+ break;
1169
+ }
1170
+ _context.next = 5;
1171
+ return fetch({
1172
+ query: CollectionMany,
1173
+ variables: {
1174
+ first: 250
1564
1175
  }
1565
- _context.next = 5;
1566
- return fetch({
1567
- query: CollectionMany,
1568
- variables: {
1569
- first: 250
1570
- }
1571
- });
1572
- case 5:
1573
- data = _context.sent;
1574
- return _context.abrupt("return", (_data$collections$edg = (_data$collections = data.collections) == null ? void 0 : (_data$collections$edg2 = _data$collections.edges) == null ? void 0 : _data$collections$edg2.map(function (_ref2) {
1575
- var node = _ref2.node;
1576
- return normalizeCategory(node);
1577
- })) != null ? _data$collections$edg : []);
1578
- case 9:
1579
- _context.next = 11;
1580
- return fetch({
1581
- query: CollectionOne,
1582
- variables: {
1583
- categoryId: categoryId
1584
- }
1585
- });
1586
- case 11:
1587
- _data = _context.sent;
1588
- return _context.abrupt("return", !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
1589
- case 13:
1590
- case "end":
1591
- return _context.stop();
1592
- }
1176
+ });
1177
+ case 5:
1178
+ data = _context.sent;
1179
+ return _context.abrupt("return", (_data$collections$edg = (_data$collections = data.collections) == null || (_data$collections = _data$collections.edges) == null ? void 0 : _data$collections.map(function (_ref2) {
1180
+ var node = _ref2.node;
1181
+ return normalizeCategory(node);
1182
+ })) != null ? _data$collections$edg : []);
1183
+ case 9:
1184
+ _context.next = 11;
1185
+ return fetch({
1186
+ query: CollectionOne,
1187
+ variables: {
1188
+ categoryId: categoryId
1189
+ }
1190
+ });
1191
+ case 11:
1192
+ _data = _context.sent;
1193
+ return _context.abrupt("return", !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
1194
+ case 13:
1195
+ case "end":
1196
+ return _context.stop();
1593
1197
  }
1594
1198
  }, _callee);
1595
1199
  }))();
@@ -1623,16 +1227,14 @@ var handler$5 = {
1623
1227
  query: getAllProductVendors
1624
1228
  },
1625
1229
  fetcher: function fetcher(_ref) {
1626
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1627
- return runtime_1.wrap(function _callee$(_context) {
1628
- while (1) {
1629
- switch (_context.prev = _context.next) {
1630
- case 0:
1631
- return _context.abrupt("return", []);
1632
- case 2:
1633
- case "end":
1634
- return _context.stop();
1635
- }
1230
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1231
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1232
+ while (1) switch (_context.prev = _context.next) {
1233
+ case 0:
1234
+ return _context.abrupt("return", []);
1235
+ case 2:
1236
+ case "end":
1237
+ return _context.stop();
1636
1238
  }
1637
1239
  }, _callee);
1638
1240
  }))();
@@ -1665,45 +1267,43 @@ var handler$6 = {
1665
1267
  query: ProductMany
1666
1268
  },
1667
1269
  fetcher: function fetcher(_ref) {
1668
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1669
- var input, options, fetch, categoryId, brandId, data, edges, _data$collection$prod, _data$collection, _data$collection$prod2, _data$products$edges, _data$products;
1670
- return runtime_1.wrap(function _callee$(_context) {
1671
- while (1) {
1672
- switch (_context.prev = _context.next) {
1673
- case 0:
1674
- input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1675
- categoryId = input.categoryId, brandId = input.brandId;
1676
- _context.next = 4;
1677
- return fetch({
1678
- query: categoryId ? CollectionOne : options.query,
1679
- method: options == null ? void 0 : options.method,
1680
- variables: getSearchVariables(input)
1681
- });
1682
- case 4:
1683
- data = _context.sent;
1684
- if (categoryId) {
1685
- edges = (_data$collection$prod = (_data$collection = data.collection) == null ? void 0 : (_data$collection$prod2 = _data$collection.products) == null ? void 0 : _data$collection$prod2.edges) != null ? _data$collection$prod : [];
1686
- // FIXME @zaiste, no `vendor` in Saleor
1687
- // if (brandId) {
1688
- // edges = edges.filter(
1689
- // ({ node: { vendor } }: ProductCountableEdge) =>
1690
- // vendor.replace(/\s+/g, '-').toLowerCase() === brandId
1691
- // )
1692
- // }
1693
- } else {
1694
- edges = (_data$products$edges = (_data$products = data.products) == null ? void 0 : _data$products.edges) != null ? _data$products$edges : [];
1695
- }
1696
- return _context.abrupt("return", {
1697
- products: edges.map(function (_ref2) {
1698
- var node = _ref2.node;
1699
- return normalizeProduct(node);
1700
- }),
1701
- found: !!edges.length
1702
- });
1703
- case 7:
1704
- case "end":
1705
- return _context.stop();
1706
- }
1270
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1271
+ var input, options, fetch, categoryId, brandId, data, edges, _data$collection$prod, _data$collection, _data$products$edges, _data$products;
1272
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1273
+ while (1) switch (_context.prev = _context.next) {
1274
+ case 0:
1275
+ input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1276
+ categoryId = input.categoryId, brandId = input.brandId;
1277
+ _context.next = 4;
1278
+ return fetch({
1279
+ query: categoryId ? CollectionOne : options.query,
1280
+ method: options == null ? void 0 : options.method,
1281
+ variables: getSearchVariables(input)
1282
+ });
1283
+ case 4:
1284
+ data = _context.sent;
1285
+ if (categoryId) {
1286
+ edges = (_data$collection$prod = (_data$collection = data.collection) == null || (_data$collection = _data$collection.products) == null ? void 0 : _data$collection.edges) != null ? _data$collection$prod : [];
1287
+ // FIXME @zaiste, no `vendor` in Saleor
1288
+ // if (brandId) {
1289
+ // edges = edges.filter(
1290
+ // ({ node: { vendor } }: ProductCountableEdge) =>
1291
+ // vendor.replace(/\s+/g, '-').toLowerCase() === brandId
1292
+ // )
1293
+ // }
1294
+ } else {
1295
+ edges = (_data$products$edges = (_data$products = data.products) == null ? void 0 : _data$products.edges) != null ? _data$products$edges : [];
1296
+ }
1297
+ return _context.abrupt("return", {
1298
+ products: edges.map(function (_ref2) {
1299
+ var node = _ref2.node;
1300
+ return normalizeProduct(node);
1301
+ }),
1302
+ found: !!edges.length
1303
+ });
1304
+ case 7:
1305
+ case "end":
1306
+ return _context.stop();
1707
1307
  }
1708
1308
  }, _callee);
1709
1309
  }))();
@@ -1731,49 +1331,47 @@ var handler$7 = {
1731
1331
  query: ProductOneById
1732
1332
  },
1733
1333
  fetcher: function fetcher(_ref) {
1734
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1334
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1735
1335
  var input, fetch, id, data, response;
1736
- return runtime_1.wrap(function _callee$(_context) {
1737
- while (1) {
1738
- switch (_context.prev = _context.next) {
1739
- case 0:
1740
- input = _ref.input, fetch = _ref.fetch;
1741
- id = input.id;
1742
- if (id) {
1743
- _context.next = 4;
1744
- break;
1336
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1337
+ while (1) switch (_context.prev = _context.next) {
1338
+ case 0:
1339
+ input = _ref.input, fetch = _ref.fetch;
1340
+ id = input.id;
1341
+ if (id) {
1342
+ _context.next = 4;
1343
+ break;
1344
+ }
1345
+ return _context.abrupt("return", null);
1346
+ case 4:
1347
+ _context.next = 6;
1348
+ return fetch({
1349
+ query: ProductOneById,
1350
+ variables: {
1351
+ id: id
1745
1352
  }
1746
- return _context.abrupt("return", null);
1747
- case 4:
1748
- _context.next = 6;
1749
- return fetch({
1750
- query: ProductOneById,
1751
- variables: {
1752
- id: id
1753
- }
1754
- });
1755
- case 6:
1756
- data = _context.sent;
1757
- if (data.product) {
1758
- _context.next = 12;
1759
- break;
1353
+ });
1354
+ case 6:
1355
+ data = _context.sent;
1356
+ if (data.product) {
1357
+ _context.next = 12;
1358
+ break;
1359
+ }
1360
+ _context.next = 10;
1361
+ return fetch({
1362
+ query: ProductOneBySlug,
1363
+ variables: {
1364
+ slug: id
1760
1365
  }
1761
- _context.next = 10;
1762
- return fetch({
1763
- query: ProductOneBySlug,
1764
- variables: {
1765
- slug: id
1766
- }
1767
- });
1768
- case 10:
1769
- response = _context.sent;
1770
- return _context.abrupt("return", response.product ? normalizeProduct(response.product) : null);
1771
- case 12:
1772
- return _context.abrupt("return", data.product ? normalizeProduct(data.product) : null);
1773
- case 13:
1774
- case "end":
1775
- return _context.stop();
1776
- }
1366
+ });
1367
+ case 10:
1368
+ response = _context.sent;
1369
+ return _context.abrupt("return", response.product ? normalizeProduct(response.product) : null);
1370
+ case 12:
1371
+ return _context.abrupt("return", data.product ? normalizeProduct(data.product) : null);
1372
+ case 13:
1373
+ case "end":
1374
+ return _context.stop();
1777
1375
  }
1778
1376
  }, _callee);
1779
1377
  }))();
@@ -1796,43 +1394,39 @@ var handler$7 = {
1796
1394
 
1797
1395
  var _excluded$1 = ["locale"];
1798
1396
  var getFetcher = function getFetcher(saleorApiUrl) {
1799
- return /*#__PURE__*/function () {
1800
- var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
1397
+ var _ref2;
1398
+ return function (_x) {
1399
+ return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
1801
1400
  var _ref$url, url, _ref$method, method, query, variables, _ref3, vars, token;
1802
- return runtime_1.wrap(function _callee$(_context) {
1803
- while (1) {
1804
- switch (_context.prev = _context.next) {
1805
- case 0:
1806
- _ref$url = _ref.url, url = _ref$url === void 0 ? saleorApiUrl : _ref$url, _ref$method = _ref.method, method = _ref$method === void 0 ? 'POST' : _ref$method, query = _ref.query, variables = _ref.variables;
1807
- _ref3 = variables != null ? variables : {}, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
1808
- token = getToken();
1809
- _context.t0 = handleFetchResponse;
1810
- _context.next = 6;
1811
- return fetch(url, {
1812
- method: method,
1813
- body: JSON.stringify({
1814
- query: query,
1815
- variables: vars
1816
- }),
1817
- headers: {
1818
- Authorization: "JWT " + token,
1819
- 'Content-Type': 'application/json'
1820
- }
1821
- });
1822
- case 6:
1823
- _context.t1 = _context.sent;
1824
- return _context.abrupt("return", (0, _context.t0)(_context.t1));
1825
- case 8:
1826
- case "end":
1827
- return _context.stop();
1828
- }
1401
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1402
+ while (1) switch (_context.prev = _context.next) {
1403
+ case 0:
1404
+ _ref$url = _ref.url, url = _ref$url === void 0 ? saleorApiUrl : _ref$url, _ref$method = _ref.method, method = _ref$method === void 0 ? 'POST' : _ref$method, query = _ref.query, variables = _ref.variables;
1405
+ _ref3 = variables != null ? variables : {}, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
1406
+ token = getToken();
1407
+ _context.t0 = handleFetchResponse;
1408
+ _context.next = 6;
1409
+ return fetch(url, {
1410
+ method: method,
1411
+ body: JSON.stringify({
1412
+ query: query,
1413
+ variables: vars
1414
+ }),
1415
+ headers: {
1416
+ Authorization: "JWT " + token,
1417
+ 'Content-Type': 'application/json'
1418
+ }
1419
+ });
1420
+ case 6:
1421
+ _context.t1 = _context.sent;
1422
+ return _context.abrupt("return", (0, _context.t0)(_context.t1));
1423
+ case 8:
1424
+ case "end":
1425
+ return _context.stop();
1829
1426
  }
1830
1427
  }, _callee);
1831
- }));
1832
- return function (_x) {
1833
- return _ref2.apply(this, arguments);
1834
- };
1835
- }();
1428
+ }))).apply(this, arguments);
1429
+ };
1836
1430
  };
1837
1431
 
1838
1432
  /*