@shipengine/react-api 1.0.0-next.5 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/hooks/account-settings/index.d.ts +2 -0
  2. package/hooks/{use-get-account-settings.d.ts → account-settings/use-get-account-settings.d.ts} +1 -1
  3. package/hooks/account-settings/use-update-account-settings.d.ts +5 -0
  4. package/hooks/addresses/index.d.ts +2 -0
  5. package/hooks/{use-parse-address.d.ts → addresses/use-parse-address.d.ts} +1 -1
  6. package/hooks/{use-validate-addresses.d.ts → addresses/use-validate-addresses.d.ts} +1 -1
  7. package/hooks/carriers/index.d.ts +12 -0
  8. package/hooks/{use-add-funds.d.ts → carriers/use-add-funds.d.ts} +1 -1
  9. package/hooks/{use-connect-carrier.d.ts → carriers/use-connect-carrier.d.ts} +1 -1
  10. package/hooks/carriers/use-get-auto-funding-configuration.d.ts +4 -0
  11. package/hooks/{use-get-carrier-by-id.d.ts → carriers/use-get-carrier-by-id.d.ts} +1 -1
  12. package/hooks/carriers/use-get-countries-by-carrier.d.ts +5 -0
  13. package/hooks/carriers/use-get-currencies-by-carrier.d.ts +5 -0
  14. package/hooks/carriers/use-get-package-rating-group-by-carrier.d.ts +5 -0
  15. package/hooks/carriers/use-get-services-by-carrier.d.ts +7 -0
  16. package/hooks/carriers/use-get-wallet-history.d.ts +10 -0
  17. package/hooks/carriers/use-get-zones-by-carrier.d.ts +4 -0
  18. package/hooks/{use-list-carriers.d.ts → carriers/use-list-carriers.d.ts} +1 -1
  19. package/hooks/carriers/use-update-auto-funding.d.ts +5 -0
  20. package/hooks/custom-packages/index.d.ts +1 -0
  21. package/hooks/{use-list-custom-package-types.d.ts → custom-packages/use-list-custom-package-types.d.ts} +1 -1
  22. package/hooks/funding-sources/index.d.ts +6 -0
  23. package/hooks/funding-sources/use-create-funding-source.d.ts +7 -0
  24. package/hooks/funding-sources/use-funding-sources-add-funds.d.ts +7 -0
  25. package/hooks/funding-sources/use-get-funding-source-by-id.d.ts +4 -0
  26. package/hooks/funding-sources/use-list-funding-sources.d.ts +4 -0
  27. package/hooks/funding-sources/use-register-carrier.d.ts +5 -0
  28. package/hooks/funding-sources/use-update-funding-source.d.ts +12 -0
  29. package/hooks/index.d.ts +15 -33
  30. package/hooks/insurance/index.d.ts +1 -0
  31. package/hooks/{use-get-insurance-account.d.ts → insurance/use-get-insurance-account.d.ts} +1 -1
  32. package/hooks/labels/index.d.ts +4 -0
  33. package/hooks/{use-create-label.d.ts → labels/use-create-label.d.ts} +1 -1
  34. package/hooks/{use-get-label.d.ts → labels/use-get-label.d.ts} +1 -1
  35. package/hooks/{use-list-labels.d.ts → labels/use-list-labels.d.ts} +1 -1
  36. package/hooks/{use-void-label.d.ts → labels/use-void-label.d.ts} +1 -1
  37. package/hooks/order-sources/index.d.ts +2 -0
  38. package/hooks/order-sources/use-list-order-sources.d.ts +6 -0
  39. package/hooks/{use-refresh-order-source.d.ts → order-sources/use-refresh-order-source.d.ts} +2 -2
  40. package/hooks/rate-cards/index.d.ts +8 -0
  41. package/hooks/rate-cards/use-create-rate-card.d.ts +6 -0
  42. package/hooks/rate-cards/use-delete-rate-card.d.ts +4 -0
  43. package/hooks/rate-cards/use-download-rate-card.d.ts +5 -0
  44. package/hooks/rate-cards/use-get-rate-card-by-id.d.ts +5 -0
  45. package/hooks/rate-cards/use-list-rate-cards.d.ts +5 -0
  46. package/hooks/rate-cards/use-publish-rate-card.d.ts +5 -0
  47. package/hooks/rate-cards/use-update-rate-card.d.ts +6 -0
  48. package/hooks/rate-cards/use-upload-rate-card.d.ts +9 -0
  49. package/hooks/rates/index.d.ts +1 -0
  50. package/hooks/{use-calculate-rates.d.ts → rates/use-calculate-rates.d.ts} +1 -1
  51. package/hooks/sales-orders/index.d.ts +3 -0
  52. package/hooks/{use-get-sales-order.d.ts → sales-orders/use-get-sales-order.d.ts} +1 -1
  53. package/hooks/{use-list-sales-orders.d.ts → sales-orders/use-list-sales-orders.d.ts} +1 -1
  54. package/hooks/{use-notify-sales-order.d.ts → sales-orders/use-notify-sales-order.d.ts} +1 -1
  55. package/hooks/sales-orders-shipment/index.d.ts +4 -0
  56. package/hooks/{use-create-sales-order-shipment.d.ts → sales-orders-shipment/use-create-sales-order-shipment.d.ts} +1 -1
  57. package/hooks/{use-get-sales-order-shipment.d.ts → sales-orders-shipment/use-get-sales-order-shipment.d.ts} +1 -1
  58. package/hooks/{use-list-sales-order-shipments.d.ts → sales-orders-shipment/use-list-sales-order-shipments.d.ts} +1 -1
  59. package/hooks/{use-update-sales-order-shipment.d.ts → sales-orders-shipment/use-update-sales-order-shipment.d.ts} +1 -1
  60. package/hooks/shipments/index.d.ts +4 -0
  61. package/hooks/shipments/use-create-shipment.d.ts +10 -0
  62. package/hooks/shipments/use-get-shipment-rates.d.ts +6 -0
  63. package/hooks/shipments/use-get-shipment.d.ts +6 -0
  64. package/hooks/shipments/use-list-shipments.d.ts +7 -0
  65. package/hooks/warehouses/index.d.ts +4 -0
  66. package/hooks/{use-create-warehouse.d.ts → warehouses/use-create-warehouse.d.ts} +1 -1
  67. package/hooks/{use-delete-warehouse.d.ts → warehouses/use-delete-warehouse.d.ts} +1 -1
  68. package/hooks/warehouses/use-list-warehouses.d.ts +10 -0
  69. package/hooks/{use-update-warehouse.d.ts → warehouses/use-update-warehouse.d.ts} +1 -1
  70. package/index.js +1559 -16
  71. package/index.mjs +1412 -3264
  72. package/package.json +5 -4
  73. package/hooks/use-get-auto-funding-configuration.d.ts +0 -4
  74. package/hooks/use-get-shipment.d.ts +0 -6
  75. package/hooks/use-get-wallet-transaction-history.d.ts +0 -5
  76. package/hooks/use-list-order-sources.d.ts +0 -6
  77. package/hooks/use-list-warehouses.d.ts +0 -7
  78. package/hooks/use-update-account-settings.d.ts +0 -10
  79. package/hooks/use-update-auto-funding.d.ts +0 -5
  80. package/hooks/use-update-billing.d.ts +0 -8
package/index.mjs CHANGED
@@ -1,3341 +1,1489 @@
1
- import { QueryClient as Rn, QueryClientProvider as xn, useMutation as I, useQuery as N, useQueryClient as Cn } from "react-query";
2
- import { jsx as Ue } from "react/jsx-runtime";
3
- import { createContext as Fn, useState as Nn, useContext as $n } from "react";
4
- class W {
5
- constructor(e, t) {
6
- this.errorCode = t?.errorCode ?? "unknown", this.errorSource = t?.errorSource ?? "client", this.errorType = t?.errorType ?? "unknown", this.message = e;
7
- }
8
- static fromObject({ message: e, ...t }) {
9
- return new W(e, t);
10
- }
11
- }
12
- var Bt = /* @__PURE__ */ ((r) => (r.AMERICAN_EXPRESS = "americanexpress", r.DISCOVER = "discover", r.MASTERCARD = "mastercard", r.VISA = "visa", r))(Bt || {}), Lt = /* @__PURE__ */ ((r) => (r.USD = "usd", r.CAD = "cad", r.AUD = "aud", r.GBP = "gbp", r.EUR = "eur", r.NZD = "nzd", r))(Lt || {}), Ut = /* @__PURE__ */ ((r) => (r.DELIVERY = "delivery", r.SIGNATURE = "signature", r.ADULT_SIGNATURE = "adult_signature", r.DIRECT_SIGNATURE = "direct_signature", r.VERBAL_CONFIRMATION = "verbal_confirmation", r.DELIVERY_MAILED = "delivery_mailed", r.NONE = "none", r))(Ut || {}), qt = /* @__PURE__ */ ((r) => (r.DOCUMENTS = "documents", r.GIFT = "gift", r.MERCHANDISE = "merchandise", r.RETURNED_GOODS = "returned_goods", r.SAMPLE = "sample", r))(qt || {}), Mt = /* @__PURE__ */ ((r) => (r.RETURN_TO_SENDER = "return_to_sender", r.TREAT_AS_ABANDONED = "treat_as_abandoned", r))(Mt || {}), zt = /* @__PURE__ */ ((r) => (r.SHIPSURANCE = "shipsurance", r.CARRIER = "carrier", r.THIRD_PARTY = "third_party", r.NONE = "none", r))(zt || {});
13
- const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14
- __proto__: null,
15
- CodedError: W,
16
- ConfirmationType: Ut,
17
- CreditCardVendor: Bt,
18
- Currency: Lt,
19
- CustomsContentsType: qt,
20
- CustomsNonDeliveryType: Mt,
21
- InsuranceProviderType: zt
22
- }, Symbol.toStringTag, { value: "Module" }));
23
- class _n {
24
- constructor(e) {
25
- this.client = e, this.get = () => this.client.get("/v1/account/settings"), this.update = (t) => this.client.put("/v1/account/settings", t), this.client = e;
26
- }
27
- }
28
- class Dn {
29
- constructor(e) {
30
- this.client = e, this.validate = (t) => this.client.post("/v1/addresses/validate", t), this.parse = (t, n) => this.client.put("/v1/addresses/recognize", {
31
- address: n,
32
- text: t
33
- }), this.client = e;
34
- }
35
- }
36
- var jt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
37
- function kn(r) {
38
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
39
- }
40
- function Tn(r) {
41
- if (r.__esModule)
42
- return r;
43
- var e = r.default;
44
- if (typeof e == "function") {
45
- var t = function n() {
46
- if (this instanceof n) {
47
- var a = [null];
48
- a.push.apply(a, arguments);
49
- var i = Function.bind.apply(e, a);
50
- return new i();
51
- }
52
- return e.apply(this, arguments);
53
- };
54
- t.prototype = e.prototype;
55
- } else
56
- t = {};
57
- return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(r).forEach(function(n) {
58
- var a = Object.getOwnPropertyDescriptor(r, n);
59
- Object.defineProperty(t, n, a.get ? a : {
60
- enumerable: !0,
61
- get: function() {
62
- return r[n];
63
- }
64
- });
65
- }), t;
66
- }
67
- var hr = {}, Bn = {
68
- get exports() {
69
- return hr;
70
- },
71
- set exports(r) {
72
- hr = r;
73
- }
74
- }, xe = {}, Ln = {
75
- get exports() {
76
- return xe;
77
- },
78
- set exports(r) {
79
- xe = r;
80
- }
81
- }, Wt = function(e, t) {
82
- return function() {
83
- for (var a = new Array(arguments.length), i = 0; i < a.length; i++)
84
- a[i] = arguments[i];
85
- return e.apply(t, a);
86
- };
87
- }, Un = Wt, X = Object.prototype.toString;
88
- function $r(r) {
89
- return Array.isArray(r);
90
- }
91
- function yr(r) {
92
- return typeof r > "u";
93
- }
94
- function qn(r) {
95
- return r !== null && !yr(r) && r.constructor !== null && !yr(r.constructor) && typeof r.constructor.isBuffer == "function" && r.constructor.isBuffer(r);
96
- }
97
- function Gt(r) {
98
- return X.call(r) === "[object ArrayBuffer]";
99
- }
100
- function Mn(r) {
101
- return X.call(r) === "[object FormData]";
102
- }
103
- function zn(r) {
104
- var e;
105
- return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(r) : e = r && r.buffer && Gt(r.buffer), e;
106
- }
107
- function jn(r) {
108
- return typeof r == "string";
109
- }
110
- function Wn(r) {
111
- return typeof r == "number";
112
- }
113
- function Kt(r) {
114
- return r !== null && typeof r == "object";
115
- }
116
- function Ie(r) {
117
- if (X.call(r) !== "[object Object]")
118
- return !1;
119
- var e = Object.getPrototypeOf(r);
120
- return e === null || e === Object.prototype;
121
- }
122
- function Gn(r) {
123
- return X.call(r) === "[object Date]";
124
- }
125
- function Kn(r) {
126
- return X.call(r) === "[object File]";
127
- }
128
- function Hn(r) {
129
- return X.call(r) === "[object Blob]";
130
- }
131
- function Ht(r) {
132
- return X.call(r) === "[object Function]";
133
- }
134
- function Vn(r) {
135
- return Kt(r) && Ht(r.pipe);
136
- }
137
- function Jn(r) {
138
- return X.call(r) === "[object URLSearchParams]";
139
- }
140
- function Qn(r) {
141
- return r.trim ? r.trim() : r.replace(/^\s+|\s+$/g, "");
142
- }
143
- function Xn() {
144
- return typeof navigator < "u" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS") ? !1 : typeof window < "u" && typeof document < "u";
145
- }
146
- function _r(r, e) {
147
- if (!(r === null || typeof r > "u"))
148
- if (typeof r != "object" && (r = [r]), $r(r))
149
- for (var t = 0, n = r.length; t < n; t++)
150
- e.call(null, r[t], t, r);
151
- else
152
- for (var a in r)
153
- Object.prototype.hasOwnProperty.call(r, a) && e.call(null, r[a], a, r);
154
- }
155
- function vr() {
156
- var r = {};
157
- function e(a, i) {
158
- Ie(r[i]) && Ie(a) ? r[i] = vr(r[i], a) : Ie(a) ? r[i] = vr({}, a) : $r(a) ? r[i] = a.slice() : r[i] = a;
159
- }
160
- for (var t = 0, n = arguments.length; t < n; t++)
161
- _r(arguments[t], e);
162
- return r;
163
- }
164
- function Yn(r, e, t) {
165
- return _r(e, function(a, i) {
166
- t && typeof a == "function" ? r[i] = Un(a, t) : r[i] = a;
167
- }), r;
168
- }
169
- function Zn(r) {
170
- return r.charCodeAt(0) === 65279 && (r = r.slice(1)), r;
171
- }
172
- var k = {
173
- isArray: $r,
174
- isArrayBuffer: Gt,
175
- isBuffer: qn,
176
- isFormData: Mn,
177
- isArrayBufferView: zn,
178
- isString: jn,
179
- isNumber: Wn,
180
- isObject: Kt,
181
- isPlainObject: Ie,
182
- isUndefined: yr,
183
- isDate: Gn,
184
- isFile: Kn,
185
- isBlob: Hn,
186
- isFunction: Ht,
187
- isStream: Vn,
188
- isURLSearchParams: Jn,
189
- isStandardBrowserEnv: Xn,
190
- forEach: _r,
191
- merge: vr,
192
- extend: Yn,
193
- trim: Qn,
194
- stripBOM: Zn
195
- }, ie = k;
196
- function Hr(r) {
197
- return encodeURIComponent(r).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
198
- }
199
- var Vt = function(e, t, n) {
200
- if (!t)
201
- return e;
202
- var a;
203
- if (n)
204
- a = n(t);
205
- else if (ie.isURLSearchParams(t))
206
- a = t.toString();
207
- else {
208
- var i = [];
209
- ie.forEach(t, function(c, d) {
210
- c === null || typeof c > "u" || (ie.isArray(c) ? d = d + "[]" : c = [c], ie.forEach(c, function(o) {
211
- ie.isDate(o) ? o = o.toISOString() : ie.isObject(o) && (o = JSON.stringify(o)), i.push(Hr(d) + "=" + Hr(o));
212
- }));
213
- }), a = i.join("&");
214
- }
215
- if (a) {
216
- var s = e.indexOf("#");
217
- s !== -1 && (e = e.slice(0, s)), e += (e.indexOf("?") === -1 ? "?" : "&") + a;
218
- }
219
- return e;
220
- }, ea = k;
221
- function De() {
222
- this.handlers = [];
223
- }
224
- De.prototype.use = function(e, t, n) {
225
- return this.handlers.push({
226
- fulfilled: e,
227
- rejected: t,
228
- synchronous: n ? n.synchronous : !1,
229
- runWhen: n ? n.runWhen : null
230
- }), this.handlers.length - 1;
231
- };
232
- De.prototype.eject = function(e) {
233
- this.handlers[e] && (this.handlers[e] = null);
234
- };
235
- De.prototype.forEach = function(e) {
236
- ea.forEach(this.handlers, function(n) {
237
- n !== null && e(n);
238
- });
239
- };
240
- var ra = De, ta = k, na = function(e, t) {
241
- ta.forEach(e, function(a, i) {
242
- i !== t && i.toUpperCase() === t.toUpperCase() && (e[t] = a, delete e[i]);
243
- });
244
- }, Jt = function(e, t, n, a, i) {
245
- return e.config = t, n && (e.code = n), e.request = a, e.response = i, e.isAxiosError = !0, e.toJSON = function() {
246
- return {
247
- // Standard
248
- message: this.message,
249
- name: this.name,
250
- // Microsoft
251
- description: this.description,
252
- number: this.number,
253
- // Mozilla
254
- fileName: this.fileName,
255
- lineNumber: this.lineNumber,
256
- columnNumber: this.columnNumber,
257
- stack: this.stack,
258
- // Axios
259
- config: this.config,
260
- code: this.code,
261
- status: this.response && this.response.status ? this.response.status : null
262
- };
263
- }, e;
264
- }, Qt = {
265
- silentJSONParsing: !0,
266
- forcedJSONParsing: !0,
267
- clarifyTimeoutError: !1
268
- }, qe, Vr;
269
- function Xt() {
270
- if (Vr)
271
- return qe;
272
- Vr = 1;
273
- var r = Jt;
274
- return qe = function(t, n, a, i, s) {
275
- var l = new Error(t);
276
- return r(l, n, a, i, s);
277
- }, qe;
278
- }
279
- var Me, Jr;
280
- function aa() {
281
- if (Jr)
282
- return Me;
283
- Jr = 1;
284
- var r = Xt();
285
- return Me = function(t, n, a) {
286
- var i = a.config.validateStatus;
287
- !a.status || !i || i(a.status) ? t(a) : n(r(
288
- "Request failed with status code " + a.status,
289
- a.config,
290
- null,
291
- a.request,
292
- a
293
- ));
294
- }, Me;
295
- }
296
- var ze, Qr;
297
- function ia() {
298
- if (Qr)
299
- return ze;
300
- Qr = 1;
301
- var r = k;
302
- return ze = r.isStandardBrowserEnv() ? (
303
- // Standard browser envs support document.cookie
304
- function() {
305
- return {
306
- write: function(n, a, i, s, l, c) {
307
- var d = [];
308
- d.push(n + "=" + encodeURIComponent(a)), r.isNumber(i) && d.push("expires=" + new Date(i).toGMTString()), r.isString(s) && d.push("path=" + s), r.isString(l) && d.push("domain=" + l), c === !0 && d.push("secure"), document.cookie = d.join("; ");
309
- },
310
- read: function(n) {
311
- var a = document.cookie.match(new RegExp("(^|;\\s*)(" + n + ")=([^;]*)"));
312
- return a ? decodeURIComponent(a[3]) : null;
313
- },
314
- remove: function(n) {
315
- this.write(n, "", Date.now() - 864e5);
316
- }
317
- };
318
- }()
319
- ) : (
320
- // Non standard browser env (web workers, react-native) lack needed support.
321
- function() {
322
- return {
323
- write: function() {
324
- },
325
- read: function() {
326
- return null;
1
+ import { QueryClient, QueryClientProvider, useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { createContext, useState, useContext } from 'react';
4
+ import { ShipEngineAPI, SE } from '@shipengine/js-api';
5
+ export * from '@shipengine/js-api';
6
+
7
+ const ShipEngineContext = createContext(void 0);
8
+ const ShipEngine = ({ baseURL, children, headers, getToken }) => {
9
+ const [client, setClient] = useState(() => {
10
+ const token = getToken();
11
+ if (typeof token === "string")
12
+ return new ShipEngineAPI(token, {
13
+ baseURL,
14
+ getToken,
15
+ headers: headers != null ? headers : {}
16
+ });
17
+ token.then(
18
+ (t) => setClient(
19
+ new ShipEngineAPI(t, {
20
+ baseURL,
21
+ getToken,
22
+ headers: headers != null ? headers : {}
23
+ })
24
+ )
25
+ );
26
+ return void 0;
27
+ });
28
+ const queryClient = new QueryClient();
29
+ if (!client) {
30
+ return /* @__PURE__ */ jsx(
31
+ "div",
32
+ {
33
+ style: {
34
+ alignItems: "center",
35
+ display: "flex",
36
+ height: "100%",
37
+ justifyContent: "center",
38
+ width: "100%"
327
39
  },
328
- remove: function() {
329
- }
330
- };
331
- }()
332
- ), ze;
333
- }
334
- var je, Xr;
335
- function oa() {
336
- return Xr || (Xr = 1, je = function(e) {
337
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);
338
- }), je;
339
- }
340
- var We, Yr;
341
- function sa() {
342
- return Yr || (Yr = 1, We = function(e, t) {
343
- return t ? e.replace(/\/+$/, "") + "/" + t.replace(/^\/+/, "") : e;
344
- }), We;
345
- }
346
- var Ge, Zr;
347
- function ua() {
348
- if (Zr)
349
- return Ge;
350
- Zr = 1;
351
- var r = oa(), e = sa();
352
- return Ge = function(n, a) {
353
- return n && !r(a) ? e(n, a) : a;
354
- }, Ge;
355
- }
356
- var Ke, et;
357
- function la() {
358
- if (et)
359
- return Ke;
360
- et = 1;
361
- var r = k, e = [
362
- "age",
363
- "authorization",
364
- "content-length",
365
- "content-type",
366
- "etag",
367
- "expires",
368
- "from",
369
- "host",
370
- "if-modified-since",
371
- "if-unmodified-since",
372
- "last-modified",
373
- "location",
374
- "max-forwards",
375
- "proxy-authorization",
376
- "referer",
377
- "retry-after",
378
- "user-agent"
379
- ];
380
- return Ke = function(n) {
381
- var a = {}, i, s, l;
382
- return n && r.forEach(n.split(`
383
- `), function(d) {
384
- if (l = d.indexOf(":"), i = r.trim(d.substr(0, l)).toLowerCase(), s = r.trim(d.substr(l + 1)), i) {
385
- if (a[i] && e.indexOf(i) >= 0)
386
- return;
387
- i === "set-cookie" ? a[i] = (a[i] ? a[i] : []).concat([s]) : a[i] = a[i] ? a[i] + ", " + s : s;
40
+ children: "Loading..."
388
41
  }
389
- }), a;
390
- }, Ke;
391
- }
392
- var He, rt;
393
- function ca() {
394
- if (rt)
395
- return He;
396
- rt = 1;
397
- var r = k;
398
- return He = r.isStandardBrowserEnv() ? (
399
- // Standard browser envs have full support of the APIs needed to test
400
- // whether the request URL is of the same origin as current location.
401
- function() {
402
- var t = /(msie|trident)/i.test(navigator.userAgent), n = document.createElement("a"), a;
403
- function i(s) {
404
- var l = s;
405
- return t && (n.setAttribute("href", l), l = n.href), n.setAttribute("href", l), {
406
- href: n.href,
407
- protocol: n.protocol ? n.protocol.replace(/:$/, "") : "",
408
- host: n.host,
409
- search: n.search ? n.search.replace(/^\?/, "") : "",
410
- hash: n.hash ? n.hash.replace(/^#/, "") : "",
411
- hostname: n.hostname,
412
- port: n.port,
413
- pathname: n.pathname.charAt(0) === "/" ? n.pathname : "/" + n.pathname
414
- };
415
- }
416
- return a = i(window.location.href), function(l) {
417
- var c = r.isString(l) ? i(l) : l;
418
- return c.protocol === a.protocol && c.host === a.host;
419
- };
420
- }()
421
- ) : (
422
- // Non standard browser envs (web workers, react-native) lack needed support.
423
- function() {
424
- return function() {
425
- return !0;
426
- };
427
- }()
428
- ), He;
429
- }
430
- var Ve, tt;
431
- function ke() {
432
- if (tt)
433
- return Ve;
434
- tt = 1;
435
- function r(e) {
436
- this.message = e;
42
+ );
437
43
  }
438
- return r.prototype.toString = function() {
439
- return "Cancel" + (this.message ? ": " + this.message : "");
440
- }, r.prototype.__CANCEL__ = !0, Ve = r, Ve;
441
- }
442
- var Je, nt;
443
- function at() {
444
- if (nt)
445
- return Je;
446
- nt = 1;
447
- var r = k, e = aa(), t = ia(), n = Vt, a = ua(), i = la(), s = ca(), l = Xt(), c = Qt, d = ke();
448
- return Je = function(o) {
449
- return new Promise(function(p, y) {
450
- var v = o.data, m = o.headers, h = o.responseType, g;
451
- function A() {
452
- o.cancelToken && o.cancelToken.unsubscribe(g), o.signal && o.signal.removeEventListener("abort", g);
453
- }
454
- r.isFormData(v) && delete m["Content-Type"];
455
- var S = new XMLHttpRequest();
456
- if (o.auth) {
457
- var R = o.auth.username || "", q = o.auth.password ? unescape(encodeURIComponent(o.auth.password)) : "";
458
- m.Authorization = "Basic " + btoa(R + ":" + q);
459
- }
460
- var $ = a(o.baseURL, o.url);
461
- S.open(o.method.toUpperCase(), n($, o.params, o.paramsSerializer), !0), S.timeout = o.timeout;
462
- function V() {
463
- if (S) {
464
- var O = "getAllResponseHeaders" in S ? i(S.getAllResponseHeaders()) : null, _ = !h || h === "text" || h === "json" ? S.responseText : S.response, D = {
465
- data: _,
466
- status: S.status,
467
- statusText: S.statusText,
468
- headers: O,
469
- config: o,
470
- request: S
471
- };
472
- e(function(L) {
473
- p(L), A();
474
- }, function(L) {
475
- y(L), A();
476
- }, D), S = null;
477
- }
478
- }
479
- if ("onloadend" in S ? S.onloadend = V : S.onreadystatechange = function() {
480
- !S || S.readyState !== 4 || S.status === 0 && !(S.responseURL && S.responseURL.indexOf("file:") === 0) || setTimeout(V);
481
- }, S.onabort = function() {
482
- S && (y(l("Request aborted", o, "ECONNABORTED", S)), S = null);
483
- }, S.onerror = function() {
484
- y(l("Network Error", o, null, S)), S = null;
485
- }, S.ontimeout = function() {
486
- var _ = o.timeout ? "timeout of " + o.timeout + "ms exceeded" : "timeout exceeded", D = o.transitional || c;
487
- o.timeoutErrorMessage && (_ = o.timeoutErrorMessage), y(l(
488
- _,
489
- o,
490
- D.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED",
491
- S
492
- )), S = null;
493
- }, r.isStandardBrowserEnv()) {
494
- var U = (o.withCredentials || s($)) && o.xsrfCookieName ? t.read(o.xsrfCookieName) : void 0;
495
- U && (m[o.xsrfHeaderName] = U);
496
- }
497
- "setRequestHeader" in S && r.forEach(m, function(_, D) {
498
- typeof v > "u" && D.toLowerCase() === "content-type" ? delete m[D] : S.setRequestHeader(D, _);
499
- }), r.isUndefined(o.withCredentials) || (S.withCredentials = !!o.withCredentials), h && h !== "json" && (S.responseType = o.responseType), typeof o.onDownloadProgress == "function" && S.addEventListener("progress", o.onDownloadProgress), typeof o.onUploadProgress == "function" && S.upload && S.upload.addEventListener("progress", o.onUploadProgress), (o.cancelToken || o.signal) && (g = function(O) {
500
- S && (y(!O || O && O.type ? new d("canceled") : O), S.abort(), S = null);
501
- }, o.cancelToken && o.cancelToken.subscribe(g), o.signal && (o.signal.aborted ? g() : o.signal.addEventListener("abort", g))), v || (v = null), S.send(v);
502
- });
503
- }, Je;
504
- }
505
- var C = k, it = na, fa = Jt, pa = Qt, da = {
506
- "Content-Type": "application/x-www-form-urlencoded"
44
+ return /* @__PURE__ */ jsx(ShipEngineContext.Provider, { value: { client }, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children }) });
507
45
  };
508
- function ot(r, e) {
509
- !C.isUndefined(r) && C.isUndefined(r["Content-Type"]) && (r["Content-Type"] = e);
510
- }
511
- function ha() {
512
- var r;
513
- return (typeof XMLHttpRequest < "u" || typeof process < "u" && Object.prototype.toString.call(process) === "[object process]") && (r = at()), r;
514
- }
515
- function ya(r, e, t) {
516
- if (C.isString(r))
517
- try {
518
- return (e || JSON.parse)(r), C.trim(r);
519
- } catch (n) {
520
- if (n.name !== "SyntaxError")
521
- throw n;
522
- }
523
- return (t || JSON.stringify)(r);
524
- }
525
- var Te = {
526
- transitional: pa,
527
- adapter: ha(),
528
- transformRequest: [function(e, t) {
529
- return it(t, "Accept"), it(t, "Content-Type"), C.isFormData(e) || C.isArrayBuffer(e) || C.isBuffer(e) || C.isStream(e) || C.isFile(e) || C.isBlob(e) ? e : C.isArrayBufferView(e) ? e.buffer : C.isURLSearchParams(e) ? (ot(t, "application/x-www-form-urlencoded;charset=utf-8"), e.toString()) : C.isObject(e) || t && t["Content-Type"] === "application/json" ? (ot(t, "application/json"), ya(e)) : e;
530
- }],
531
- transformResponse: [function(e) {
532
- var t = this.transitional || Te.transitional, n = t && t.silentJSONParsing, a = t && t.forcedJSONParsing, i = !n && this.responseType === "json";
533
- if (i || a && C.isString(e) && e.length)
534
- try {
535
- return JSON.parse(e);
536
- } catch (s) {
537
- if (i)
538
- throw s.name === "SyntaxError" ? fa(s, this, "E_JSON_PARSE") : s;
539
- }
540
- return e;
541
- }],
542
- /**
543
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
544
- * timeout is not created.
545
- */
546
- timeout: 0,
547
- xsrfCookieName: "XSRF-TOKEN",
548
- xsrfHeaderName: "X-XSRF-TOKEN",
549
- maxContentLength: -1,
550
- maxBodyLength: -1,
551
- validateStatus: function(e) {
552
- return e >= 200 && e < 300;
553
- },
554
- headers: {
555
- common: {
556
- Accept: "application/json, text/plain, */*"
557
- }
46
+ const useShipEngine = () => {
47
+ const shipengine = useContext(ShipEngineContext);
48
+ if (!shipengine) {
49
+ throw new Error("useShipEngine must be called within a ShipEngineProvider");
558
50
  }
51
+ return shipengine;
559
52
  };
560
- C.forEach(["delete", "get", "head"], function(e) {
561
- Te.headers[e] = {};
562
- });
563
- C.forEach(["post", "put", "patch"], function(e) {
564
- Te.headers[e] = C.merge(da);
53
+
54
+ const delay = (ms) => new Promise((resolve) => {
55
+ setTimeout(() => resolve(true), ms);
565
56
  });
566
- var Dr = Te, va = k, ma = Dr, ga = function(e, t, n) {
567
- var a = this || ma;
568
- return va.forEach(n, function(s) {
569
- e = s.call(a, e, t);
570
- }), e;
571
- }, Qe, st;
572
- function Yt() {
573
- return st || (st = 1, Qe = function(e) {
574
- return !!(e && e.__CANCEL__);
575
- }), Qe;
576
- }
577
- var ut = k, Xe = ga, Sa = Yt(), wa = Dr, ba = ke();
578
- function Ye(r) {
579
- if (r.cancelToken && r.cancelToken.throwIfRequested(), r.signal && r.signal.aborted)
580
- throw new ba("canceled");
581
- }
582
- var Ea = function(e) {
583
- Ye(e), e.headers = e.headers || {}, e.data = Xe.call(
584
- e,
585
- e.data,
586
- e.headers,
587
- e.transformRequest
588
- ), e.headers = ut.merge(
589
- e.headers.common || {},
590
- e.headers[e.method] || {},
591
- e.headers
592
- ), ut.forEach(
593
- ["delete", "get", "head", "post", "put", "patch", "common"],
594
- function(a) {
595
- delete e.headers[a];
57
+
58
+ const onError = (errors) => errors.forEach(console.log);
59
+
60
+ var o={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},l={};function a(e){return "string"==typeof e?o[e.toLowerCase()]:e}function c(e,r){return c=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},c(e,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return !1}}function f(e,r,t){return f=u()?Reflect.construct:function(e,r,t){var s=[null];s.push.apply(s,r);var i=new(Function.bind.apply(e,s));return t&&c(i,t.prototype),i},f.apply(null,arguments)}function h(e){if(null==e)return e;if(Array.isArray(e))return e.slice();if("object"==typeof e){var r={};return Object.keys(e).forEach(function(t){r[t]=e[t];}),r}return e}function v(e){return void 0===e?"undefined":null===e?"null":Array.isArray(e)?"[ "+e.map(function(e){return v(e)}).join(", ")+" ]":"object"==typeof e?JSON.stringify(e):"function"==typeof e?"[Function: "+e.name+"]":"boolean"==typeof e||"number"==typeof e?e:"'"+e.toString()+"'"}function p(e){if("string"!=typeof e){for(var r=new Array(arguments.length),t=0;t<arguments.length;t++)r[t]=v(arguments[t]);return r.join(" ")}for(var s=/%[sdj%]/g,i=1,n=arguments,o=n.length,l=String(e).replace(s,function(e){if("%%"===e)return "%";if(i>=o)return e;switch(e){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(e){return "[Circular]"}default:return e}}),a=n[i];i<o;a=n[++i])l+=null===a||"object"!=typeof a?" "+a:" "+v(a);return l}function m(e,r){var t=e.split("\n");t[0]&&t[0].indexOf("call-stack-error")>=0&&t.shift();var s=t[r],i=null;if(s){var n=/^\s*(at|.*@)\s*(.+)?$/.exec(s);i=Array.isArray(n)&&n[2]?n[2]:s;}return i}Object.keys(o).forEach(function(e){l[o[e]]=e;});var y={};function d(e,r){if(r){if(y[r])return;y[r]=!0;}console.error(e+"\n");}function g(e){return y[e]}function w(){var e=[];return function(r,t){return t&&"object"==typeof t?-1!==e.indexOf(t)?"[Circular]":(e.push(t),t):t}}var b=/*#__PURE__*/function(){function e(){}return e.prototype.write=function(e){e.level<30?console.log(e):e.level<40?console.info(e):e.level<50?console.warn(e):console.error(e),e.err&&e.err.stack&&console.error(e.err.stack),e.obj&&console.log(e.obj);},e}(),j=/*#__PURE__*/function(){function e(r,t,s){var i,n,o,l,a=this;if(!(this instanceof e))return new e(r,t);if(void 0!==t&&(i=r,r=t,!(i instanceof e)))throw new TypeError("invalid Logger creation: do not pass a second arg");if(!r)throw new TypeError("options (object) is required");if(i){if(r.name)throw new TypeError("invalid options.name: child cannot set logger name")}else if(!r.name)throw new TypeError("options.name (string) is required");if(r.stream&&r.streams)throw new TypeError('cannot mix "streams" and "stream" options');if(r.streams&&!Array.isArray(r.streams))throw new TypeError("invalid options.streams: must be an array");if(r.serializers&&("object"!=typeof r.serializers||Array.isArray(r.serializers)))throw new TypeError("invalid options.serializers: must be an object");if(i&&s){this._level=i._level,this.streams=i.streams,this.serializers=i.serializers,this.src=i.src,n=this.fields={};var c=Object.keys(i.fields);for(l=0;l<c.length;l++)n[o=c[l]]=i.fields[o];var u=Object.keys(r);for(l=0;l<u.length;l++)n[o=u[l]]=r[o];}else {if(i){for(this._level=i._level,this.streams=[],l=0;l<i.streams.length;l++){var f=h(i.streams[l]);this.streams.push(f);}this.serializers=h(i.serializers),this.src=i.src,this.fields=h(i.fields),r.level&&this.level(r.level);}else this._level=Number.POSITIVE_INFINITY,this.streams=[],this.serializers=null,this.src=!1,this.fields={};r.stream?this.addStream({type:"stream",stream:r.stream,level:r.level}):r.streams?r.streams.forEach(function(e){a.addStream(e,r.level);}):i&&r.level?this.level(r.level):i||this.addStream({type:"raw",stream:new b,level:r.level}),r.serializers&&this.addSerializers(r.serializers),r.src&&(this.src=!0),delete(n=h(r)).stream,delete n.level,delete n.streams,delete n.serializers,delete n.src,this.serializers&&this._applySerializers(n),Object.keys(n).forEach(function(e){a.fields[e]=n[e];});}}var r=e.prototype;return r.addStream=function(e,r){void 0===r&&(r=30),(e=h(e)).type="raw",e.level=a(e.level||r),e.level<this._level&&(this._level=e.level),this.streams.push(e),delete this.haveNonRawStreams;},r.addSerializers=function(e){var r=this;this.serializers||(this.serializers={}),Object.keys(e).forEach(function(t){var s=e[t];if("function"!=typeof s)throw new TypeError(p('invalid serializer for "%s" field: must be a function',t));r.serializers[t]=s;});},r.child=function(e,r){return new this.constructor(this,e||{},r)},r.level=function(e){if(void 0===e)return this._level;for(var r=a(e),t=this.streams.length,s=0;s<t;s++)this.streams[s].level=r;this._level=r;},r.levels=function(e,r){if(void 0===e)return this.streams.map(function(e){return e.level});var t;if("number"==typeof e){if(void 0===(t=this.streams[e]))throw new Error("invalid stream index: "+e)}else {for(var s=this.streams.length,i=0;i<s;i++){var n=this.streams[i];if(n.name===e){t=n;break}}if(!t)throw new Error(p('no stream with name "%s"',e))}if(void 0===r)return t.level;var o=a(r);t.level=o,o<this._level&&(this._level=o);},r._applySerializers=function(e,r){var t=this;Object.keys(this.serializers).forEach(function(s){if(!(void 0===e[s]||r&&r[s]))try{e[s]=t.serializers[s](e[s]);}catch(r){d(p('bunyan: ERROR: Exception thrown from the "%s" Bunyan serializer. This should never happen. This is a bugin that serializer function.\n%s',s,r.stack||r)),e[s]=p('(Error in Bunyan log "%s" serializer broke field. See stderr for details.)',s);}});},r._emit=function(e,r){var t,s;if(void 0===this.haveNonRawStreams)for(this.haveNonRawStreams=!1,t=0;t<this.streams.length;t++)if(!this.streams[t].raw){this.haveNonRawStreams=!0;break}if(r||this.haveNonRawStreams)try{s=JSON.stringify(e,w())+"\n";}catch(r){var i=r.stack.split(/\n/g,2).join("\n");d('bunyan: ERROR: Exception in `JSON.stringify(rec)`. You can install the "safe-json-stringify" module to have Bunyan fallback to safer stringification. Record:\n'+function(e,r){return r||(r=" "),r+e.split(/\r?\n/g).join("\n"+r)}(p("%s\n%s",e,r.stack)),i),s=p("(Exception in JSON.stringify(rec): %j. See stderr for details.)\n",r.message);}if(r)return s;var n=e.level;for(t=0;t<this.streams.length;t++){var o=this.streams[t];o.level<=n&&o.stream.write(e);}return s},e}();function z(e){return function(){var r=this;function t(t){var n;t[0]instanceof Error?(s={err:r.serializers&&r.serializers.err?r.serializers.err(t[0]):k.err(t[0])},n={err:!0},i=1===t.length?[s.err.message]:Array.prototype.slice.call(t,1)):"object"!=typeof t[0]&&null!==t[0]||Array.isArray(t[0])?(s=null,i=Array.prototype.slice.call(t)):(s=t[0],i=1===t.length&&s.err&&s.err instanceof Error?[s.err.message]:Array.prototype.slice.call(t,1));var o=h(r.fields);o.level=e;var a=s?h(s):null;if(a&&(r.serializers&&r._applySerializers(a,n),Object.keys(a).forEach(function(e){o[e]=a[e];})),o.levelName=l[e],o.msg=i.length?p.apply(r,i):"",o.time||(o.time=new Date),r.src&&!o.src)try{throw new Error("call-stack-error")}catch(e){var c=e.stack?m(e.stack,2):"";c||g("src")||d("Unable to determine src line info","src"),o.src=c||"";}return o.v=1,o}var s=null,i=arguments,n=null;if(0===arguments.length)return this._level<=e;this._level>e||(n=t(i),this._emit(n));}}function S(e){var r=e.stack||e.toString();if(e.cause&&"function"==typeof e.cause){var t=e.cause();t&&(r+="\nCaused by: "+S(t));}return r}j.prototype.trace=z(10),j.prototype.debug=z(20),j.prototype.info=z(30),j.prototype.warn=z(40),j.prototype.error=z(50),j.prototype.fatal=z(60);var k={err:function(e){return e&&e.stack?{message:e.message,name:e.name,stack:S(e),code:e.code,signal:e.signal}:e}};function E(){return f(j,[].slice.call(arguments))}var A={levels:{trace:"color: DeepPink",debug:"color: GoldenRod",info:"color: DarkTurquoise",warn:"color: Purple",error:"color: Crimson",fatal:"color: Black"},def:"color: DimGray",msg:"color: SteelBlue",src:"color: DimGray; font-style: italic; font-size: 0.9em"},R=/*#__PURE__*/function(){function e(e){var r=void 0===e?{}:e,t=r.logByLevel,s=r.css,i=void 0===s?A:s;this.logByLevel=void 0!==t&&t,this.css=i;}return e.prototype.write=function(e){var r,t,s=this.css.def,i=this.css.msg,n=this.css.src,o=e.childName?e.name+"/"+e.childName:e.name,a=l[e.level],c=(Array(6-a.length).join(" ")+a).toUpperCase();this.logByLevel?(10===e.level?a="debug":60===e.level&&(a="error"),t="function"==typeof console[a]?console[a]:console.log):t=console.log,r=e.level<20?this.css.levels.trace:e.level<30?this.css.levels.debug:e.level<40?this.css.levels.info:e.level<50?this.css.levels.warn:e.level<60?this.css.levels.error:this.css.levels.fatal;var u=function(e,r){return Array(r+1-(e+"").length).join("0")+e},f=[];f.push("[%s:%s:%s:%s] %c%s%c: %s: %c%s "+(e.src?"%c%s":"")),f.push(u(e.time.getHours(),2)),f.push(u(e.time.getMinutes(),2)),f.push(u(e.time.getSeconds(),2)),f.push(u(e.time.getMilliseconds(),4)),f.push(r),f.push(c),f.push(s),f.push(o),f.push(i),f.push(e.msg),e.src&&(f.push(n),f.push(e.src)),e.obj&&(f.push("\n"),f.push(e.obj)),e.err&&e.err.stack&&(f.push("\n"),f.push(e.err.stack)),t.apply(console,f);},e.getDefaultCss=function(){return A},e}();
61
+
62
+ var __defProp$1 = Object.defineProperty;
63
+ var __defProps$1 = Object.defineProperties;
64
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
65
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
66
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
67
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
68
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
69
+ var __spreadValues$1 = (a, b) => {
70
+ for (var prop in b || (b = {}))
71
+ if (__hasOwnProp$7.call(b, prop))
72
+ __defNormalProp$1(a, prop, b[prop]);
73
+ if (__getOwnPropSymbols$7)
74
+ for (var prop of __getOwnPropSymbols$7(b)) {
75
+ if (__propIsEnum$7.call(b, prop))
76
+ __defNormalProp$1(a, prop, b[prop]);
596
77
  }
597
- );
598
- var t = e.adapter || wa.adapter;
599
- return t(e).then(function(a) {
600
- return Ye(e), a.data = Xe.call(
601
- e,
602
- a.data,
603
- a.headers,
604
- e.transformResponse
605
- ), a;
606
- }, function(a) {
607
- return Sa(a) || (Ye(e), a && a.response && (a.response.data = Xe.call(
608
- e,
609
- a.response.data,
610
- a.response.headers,
611
- e.transformResponse
612
- ))), Promise.reject(a);
613
- });
614
- }, T = k, Zt = function(e, t) {
615
- t = t || {};
616
- var n = {};
617
- function a(u, o) {
618
- return T.isPlainObject(u) && T.isPlainObject(o) ? T.merge(u, o) : T.isPlainObject(o) ? T.merge({}, o) : T.isArray(o) ? o.slice() : o;
619
- }
620
- function i(u) {
621
- if (T.isUndefined(t[u])) {
622
- if (!T.isUndefined(e[u]))
623
- return a(void 0, e[u]);
624
- } else
625
- return a(e[u], t[u]);
626
- }
627
- function s(u) {
628
- if (!T.isUndefined(t[u]))
629
- return a(void 0, t[u]);
630
- }
631
- function l(u) {
632
- if (T.isUndefined(t[u])) {
633
- if (!T.isUndefined(e[u]))
634
- return a(void 0, e[u]);
635
- } else
636
- return a(void 0, t[u]);
637
- }
638
- function c(u) {
639
- if (u in t)
640
- return a(e[u], t[u]);
641
- if (u in e)
642
- return a(void 0, e[u]);
643
- }
644
- var d = {
645
- url: s,
646
- method: s,
647
- data: s,
648
- baseURL: l,
649
- transformRequest: l,
650
- transformResponse: l,
651
- paramsSerializer: l,
652
- timeout: l,
653
- timeoutMessage: l,
654
- withCredentials: l,
655
- adapter: l,
656
- responseType: l,
657
- xsrfCookieName: l,
658
- xsrfHeaderName: l,
659
- onUploadProgress: l,
660
- onDownloadProgress: l,
661
- decompress: l,
662
- maxContentLength: l,
663
- maxBodyLength: l,
664
- transport: l,
665
- httpAgent: l,
666
- httpsAgent: l,
667
- cancelToken: l,
668
- socketPath: l,
669
- responseEncoding: l,
670
- validateStatus: c
671
- };
672
- return T.forEach(Object.keys(e).concat(Object.keys(t)), function(o) {
673
- var f = d[o] || i, p = f(o);
674
- T.isUndefined(p) && f !== c || (n[o] = p);
675
- }), n;
676
- }, Ze, lt;
677
- function en() {
678
- return lt || (lt = 1, Ze = {
679
- version: "0.26.1"
680
- }), Ze;
78
+ return a;
79
+ };
80
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
81
+ const streams = [];
82
+ if (process.env.NODE_ENV === "production") {
83
+ streams.push({
84
+ stream: new R()
85
+ });
681
86
  }
682
- var Aa = en().version, kr = {};
683
- ["object", "boolean", "number", "function", "string", "symbol"].forEach(function(r, e) {
684
- kr[r] = function(n) {
685
- return typeof n === r || "a" + (e < 1 ? "n " : " ") + r;
686
- };
87
+ const logger = E({
88
+ name: "shipengine",
89
+ serializers: __spreadProps$1(__spreadValues$1({}, k), {
90
+ req: (req) => ({
91
+ headers: req.headers,
92
+ method: req.method,
93
+ url: req.url
94
+ }),
95
+ res: (res) => ({
96
+ data: res.data,
97
+ headers: res.config.headers,
98
+ method: res.config.method,
99
+ statusCode: res.status,
100
+ url: res.config.url
101
+ })
102
+ }),
103
+ streams
687
104
  });
688
- var ct = {};
689
- kr.transitional = function(e, t, n) {
690
- function a(i, s) {
691
- return "[Axios v" + Aa + "] Transitional option '" + i + "'" + s + (n ? ". " + n : "");
692
- }
693
- return function(i, s, l) {
694
- if (e === !1)
695
- throw new Error(a(s, " has been removed" + (t ? " in " + t : "")));
696
- return t && !ct[s] && (ct[s] = !0, console.warn(
697
- a(
698
- s,
699
- " has been deprecated since v" + t + " and will be removed in the near future"
700
- )
701
- )), e ? e(i, s, l) : !0;
702
- };
703
- };
704
- function Oa(r, e, t) {
705
- if (typeof r != "object")
706
- throw new TypeError("options must be an object");
707
- for (var n = Object.keys(r), a = n.length; a-- > 0; ) {
708
- var i = n[a], s = e[i];
709
- if (s) {
710
- var l = r[i], c = l === void 0 || s(l, i, r);
711
- if (c !== !0)
712
- throw new TypeError("option " + i + " must be " + c);
713
- continue;
714
- }
715
- if (t !== !0)
716
- throw Error("Unknown option " + i);
717
- }
718
- }
719
- var Pa = {
720
- assertOptions: Oa,
721
- validators: kr
722
- }, rn = k, Ia = Vt, ft = ra, pt = Ea, Be = Zt, tn = Pa, oe = tn.validators;
723
- function be(r) {
724
- this.defaults = r, this.interceptors = {
725
- request: new ft(),
726
- response: new ft()
727
- };
728
- }
729
- be.prototype.request = function(e, t) {
730
- typeof e == "string" ? (t = t || {}, t.url = e) : t = e || {}, t = Be(this.defaults, t), t.method ? t.method = t.method.toLowerCase() : this.defaults.method ? t.method = this.defaults.method.toLowerCase() : t.method = "get";
731
- var n = t.transitional;
732
- n !== void 0 && tn.assertOptions(n, {
733
- silentJSONParsing: oe.transitional(oe.boolean),
734
- forcedJSONParsing: oe.transitional(oe.boolean),
735
- clarifyTimeoutError: oe.transitional(oe.boolean)
736
- }, !1);
737
- var a = [], i = !0;
738
- this.interceptors.request.forEach(function(p) {
739
- typeof p.runWhen == "function" && p.runWhen(t) === !1 || (i = i && p.synchronous, a.unshift(p.fulfilled, p.rejected));
740
- });
741
- var s = [];
742
- this.interceptors.response.forEach(function(p) {
743
- s.push(p.fulfilled, p.rejected);
744
- });
745
- var l;
746
- if (!i) {
747
- var c = [pt, void 0];
748
- for (Array.prototype.unshift.apply(c, a), c = c.concat(s), l = Promise.resolve(t); c.length; )
749
- l = l.then(c.shift(), c.shift());
750
- return l;
751
- }
752
- for (var d = t; a.length; ) {
753
- var u = a.shift(), o = a.shift();
754
- try {
755
- d = u(d);
756
- } catch (f) {
757
- o(f);
758
- break;
759
- }
760
- }
761
- try {
762
- l = pt(d);
763
- } catch (f) {
764
- return Promise.reject(f);
105
+
106
+ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => Promise.resolve().then(callbackFn).catch(function retry(error) {
107
+ retries -= 1;
108
+ if (retries > 0) {
109
+ return delay(timeoutBetweenAttempts).then(callbackFn).catch(retry);
765
110
  }
766
- for (; s.length; )
767
- l = l.then(s.shift(), s.shift());
768
- return l;
769
- };
770
- be.prototype.getUri = function(e) {
771
- return e = Be(this.defaults, e), Ia(e.url, e.params, e.paramsSerializer).replace(/^\?/, "");
772
- };
773
- rn.forEach(["delete", "get", "head", "options"], function(e) {
774
- be.prototype[e] = function(t, n) {
775
- return this.request(Be(n || {}, {
776
- method: e,
777
- url: t,
778
- data: (n || {}).data
779
- }));
780
- };
111
+ throw error;
781
112
  });
782
- rn.forEach(["post", "put", "patch"], function(e) {
783
- be.prototype[e] = function(t, n, a) {
784
- return this.request(Be(a || {}, {
785
- method: e,
786
- url: t,
787
- data: n
788
- }));
789
- };
790
- });
791
- var Ra = be, er, dt;
792
- function xa() {
793
- if (dt)
794
- return er;
795
- dt = 1;
796
- var r = ke();
797
- function e(t) {
798
- if (typeof t != "function")
799
- throw new TypeError("executor must be a function.");
800
- var n;
801
- this.promise = new Promise(function(s) {
802
- n = s;
803
- });
804
- var a = this;
805
- this.promise.then(function(i) {
806
- if (a._listeners) {
807
- var s, l = a._listeners.length;
808
- for (s = 0; s < l; s++)
809
- a._listeners[s](i);
810
- a._listeners = null;
113
+
114
+ const useGetAccountSettings = () => {
115
+ const { client } = useShipEngine();
116
+ return useQuery({
117
+ onError,
118
+ queryFn: () => client.accountSettings.get(),
119
+ queryKey: ["getAccountSettings"],
120
+ select: (result) => result.data
121
+ });
122
+ };
123
+
124
+ var __async$p = (__this, __arguments, generator) => {
125
+ return new Promise((resolve, reject) => {
126
+ var fulfilled = (value) => {
127
+ try {
128
+ step(generator.next(value));
129
+ } catch (e) {
130
+ reject(e);
811
131
  }
812
- }), this.promise.then = function(i) {
813
- var s, l = new Promise(function(c) {
814
- a.subscribe(c), s = c;
815
- }).then(i);
816
- return l.cancel = function() {
817
- a.unsubscribe(s);
818
- }, l;
819
- }, t(function(s) {
820
- a.reason || (a.reason = new r(s), n(a.reason));
821
- });
822
- }
823
- return e.prototype.throwIfRequested = function() {
824
- if (this.reason)
825
- throw this.reason;
826
- }, e.prototype.subscribe = function(n) {
827
- if (this.reason) {
828
- n(this.reason);
829
- return;
830
- }
831
- this._listeners ? this._listeners.push(n) : this._listeners = [n];
832
- }, e.prototype.unsubscribe = function(n) {
833
- if (this._listeners) {
834
- var a = this._listeners.indexOf(n);
835
- a !== -1 && this._listeners.splice(a, 1);
836
- }
837
- }, e.source = function() {
838
- var n, a = new e(function(s) {
839
- n = s;
840
- });
841
- return {
842
- token: a,
843
- cancel: n
844
132
  };
845
- }, er = e, er;
846
- }
847
- var rr, ht;
848
- function Ca() {
849
- return ht || (ht = 1, rr = function(e) {
850
- return function(n) {
851
- return e.apply(null, n);
133
+ var rejected = (value) => {
134
+ try {
135
+ step(generator.throw(value));
136
+ } catch (e) {
137
+ reject(e);
138
+ }
852
139
  };
853
- }), rr;
854
- }
855
- var tr, yt;
856
- function Fa() {
857
- if (yt)
858
- return tr;
859
- yt = 1;
860
- var r = k;
861
- return tr = function(t) {
862
- return r.isObject(t) && t.isAxiosError === !0;
863
- }, tr;
864
- }
865
- var vt = k, Na = Wt, Re = Ra, $a = Zt, _a = Dr;
866
- function nn(r) {
867
- var e = new Re(r), t = Na(Re.prototype.request, e);
868
- return vt.extend(t, Re.prototype, e), vt.extend(t, e), t.create = function(a) {
869
- return nn($a(r, a));
870
- }, t;
871
- }
872
- var G = nn(_a);
873
- G.Axios = Re;
874
- G.Cancel = ke();
875
- G.CancelToken = xa();
876
- G.isCancel = Yt();
877
- G.VERSION = en().version;
878
- G.all = function(e) {
879
- return Promise.all(e);
880
- };
881
- G.spread = Ca();
882
- G.isAxiosError = Fa();
883
- Ln.exports = G;
884
- xe.default = G;
885
- (function(r) {
886
- r.exports = xe;
887
- })(Bn);
888
- const mr = /* @__PURE__ */ kn(hr);
889
- var Ce = {}, Da = {
890
- get exports() {
891
- return Ce;
892
- },
893
- set exports(r) {
894
- Ce = r;
895
- }
140
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
141
+ step((generator = generator.apply(__this, __arguments)).next());
142
+ });
896
143
  };
897
- (function(r) {
898
- (function() {
899
- var e, t, n, a, i, s, l, c, d;
900
- t = {}, c = this, r !== null && r.exports ? r.exports = t : c.ipaddr = t, l = function(u, o, f, p) {
901
- var y, v;
902
- if (u.length !== o.length)
903
- throw new Error("ipaddr: cannot match CIDR for objects with different lengths");
904
- for (y = 0; p > 0; ) {
905
- if (v = f - p, v < 0 && (v = 0), u[y] >> v !== o[y] >> v)
906
- return !1;
907
- p -= f, y += 1;
908
- }
909
- return !0;
910
- }, t.subnetMatch = function(u, o, f) {
911
- var p, y, v, m, h;
912
- f == null && (f = "unicast");
913
- for (v in o)
914
- for (m = o[v], m[0] && !(m[0] instanceof Array) && (m = [m]), p = 0, y = m.length; p < y; p++)
915
- if (h = m[p], u.kind() === h[0].kind() && u.match.apply(u, h))
916
- return v;
917
- return f;
918
- }, t.IPv4 = function() {
919
- function u(o) {
920
- var f, p, y;
921
- if (o.length !== 4)
922
- throw new Error("ipaddr: ipv4 octet count should be 4");
923
- for (f = 0, p = o.length; f < p; f++)
924
- if (y = o[f], !(0 <= y && y <= 255))
925
- throw new Error("ipaddr: ipv4 octet should fit in 8 bits");
926
- this.octets = o;
144
+ const useUpdateAccountSettings = () => {
145
+ const { client } = useShipEngine();
146
+ return useMutation({
147
+ mutationFn: (settings) => __async$p(void 0, null, function* () {
148
+ const result = yield client.accountSettings.update(settings);
149
+ return result.data;
150
+ }),
151
+ mutationKey: ["useUpdateAccountSettings"],
152
+ onError
153
+ });
154
+ };
155
+
156
+ var __async$o = (__this, __arguments, generator) => {
157
+ return new Promise((resolve, reject) => {
158
+ var fulfilled = (value) => {
159
+ try {
160
+ step(generator.next(value));
161
+ } catch (e) {
162
+ reject(e);
927
163
  }
928
- return u.prototype.kind = function() {
929
- return "ipv4";
930
- }, u.prototype.toString = function() {
931
- return this.octets.join(".");
932
- }, u.prototype.toNormalizedString = function() {
933
- return this.toString();
934
- }, u.prototype.toByteArray = function() {
935
- return this.octets.slice(0);
936
- }, u.prototype.match = function(o, f) {
937
- var p;
938
- if (f === void 0 && (p = o, o = p[0], f = p[1]), o.kind() !== "ipv4")
939
- throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");
940
- return l(this.octets, o.octets, 8, f);
941
- }, u.prototype.SpecialRanges = {
942
- unspecified: [[new u([0, 0, 0, 0]), 8]],
943
- broadcast: [[new u([255, 255, 255, 255]), 32]],
944
- multicast: [[new u([224, 0, 0, 0]), 4]],
945
- linkLocal: [[new u([169, 254, 0, 0]), 16]],
946
- loopback: [[new u([127, 0, 0, 0]), 8]],
947
- carrierGradeNat: [[new u([100, 64, 0, 0]), 10]],
948
- private: [[new u([10, 0, 0, 0]), 8], [new u([172, 16, 0, 0]), 12], [new u([192, 168, 0, 0]), 16]],
949
- reserved: [[new u([192, 0, 0, 0]), 24], [new u([192, 0, 2, 0]), 24], [new u([192, 88, 99, 0]), 24], [new u([198, 51, 100, 0]), 24], [new u([203, 0, 113, 0]), 24], [new u([240, 0, 0, 0]), 4]]
950
- }, u.prototype.range = function() {
951
- return t.subnetMatch(this, this.SpecialRanges);
952
- }, u.prototype.toIPv4MappedAddress = function() {
953
- return t.IPv6.parse("::ffff:" + this.toString());
954
- }, u.prototype.prefixLengthFromSubnetMask = function() {
955
- var o, f, p, y, v, m, h;
956
- for (h = {
957
- 0: 8,
958
- 128: 7,
959
- 192: 6,
960
- 224: 5,
961
- 240: 4,
962
- 248: 3,
963
- 252: 2,
964
- 254: 1,
965
- 255: 0
966
- }, o = 0, v = !1, f = p = 3; p >= 0; f = p += -1)
967
- if (y = this.octets[f], y in h) {
968
- if (m = h[y], v && m !== 0)
969
- return null;
970
- m !== 8 && (v = !0), o += m;
971
- } else
972
- return null;
973
- return 32 - o;
974
- }, u;
975
- }(), n = "(0?\\d+|0x[a-f0-9]+)", a = {
976
- fourOctet: new RegExp("^" + n + "\\." + n + "\\." + n + "\\." + n + "$", "i"),
977
- longValue: new RegExp("^" + n + "$", "i")
978
- }, t.IPv4.parser = function(u) {
979
- var o, f, p, y, v;
980
- if (f = function(m) {
981
- return m[0] === "0" && m[1] !== "x" ? parseInt(m, 8) : parseInt(m);
982
- }, o = u.match(a.fourOctet))
983
- return function() {
984
- var m, h, g, A;
985
- for (g = o.slice(1, 6), A = [], m = 0, h = g.length; m < h; m++)
986
- p = g[m], A.push(f(p));
987
- return A;
988
- }();
989
- if (o = u.match(a.longValue)) {
990
- if (v = f(o[1]), v > 4294967295 || v < 0)
991
- throw new Error("ipaddr: address outside defined range");
992
- return function() {
993
- var m, h;
994
- for (h = [], y = m = 0; m <= 24; y = m += 8)
995
- h.push(v >> y & 255);
996
- return h;
997
- }().reverse();
998
- } else
999
- return null;
1000
- }, t.IPv6 = function() {
1001
- function u(o, f) {
1002
- var p, y, v, m, h, g;
1003
- if (o.length === 16)
1004
- for (this.parts = [], p = y = 0; y <= 14; p = y += 2)
1005
- this.parts.push(o[p] << 8 | o[p + 1]);
1006
- else if (o.length === 8)
1007
- this.parts = o;
1008
- else
1009
- throw new Error("ipaddr: ipv6 part count should be 8 or 16");
1010
- for (g = this.parts, v = 0, m = g.length; v < m; v++)
1011
- if (h = g[v], !(0 <= h && h <= 65535))
1012
- throw new Error("ipaddr: ipv6 part should fit in 16 bits");
1013
- f && (this.zoneId = f);
164
+ };
165
+ var rejected = (value) => {
166
+ try {
167
+ step(generator.throw(value));
168
+ } catch (e) {
169
+ reject(e);
1014
170
  }
1015
- return u.prototype.kind = function() {
1016
- return "ipv6";
1017
- }, u.prototype.toString = function() {
1018
- return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/, "::");
1019
- }, u.prototype.toRFC5952String = function() {
1020
- var o, f, p, y, v;
1021
- for (y = /((^|:)(0(:|$)){2,})/g, v = this.toNormalizedString(), o = 0, f = -1; p = y.exec(v); )
1022
- p[0].length > f && (o = p.index, f = p[0].length);
1023
- return f < 0 ? v : v.substring(0, o) + "::" + v.substring(o + f);
1024
- }, u.prototype.toByteArray = function() {
1025
- var o, f, p, y, v;
1026
- for (o = [], v = this.parts, f = 0, p = v.length; f < p; f++)
1027
- y = v[f], o.push(y >> 8), o.push(y & 255);
1028
- return o;
1029
- }, u.prototype.toNormalizedString = function() {
1030
- var o, f, p;
1031
- return o = function() {
1032
- var y, v, m, h;
1033
- for (m = this.parts, h = [], y = 0, v = m.length; y < v; y++)
1034
- f = m[y], h.push(f.toString(16));
1035
- return h;
1036
- }.call(this).join(":"), p = "", this.zoneId && (p = "%" + this.zoneId), o + p;
1037
- }, u.prototype.toFixedLengthString = function() {
1038
- var o, f, p;
1039
- return o = function() {
1040
- var y, v, m, h;
1041
- for (m = this.parts, h = [], y = 0, v = m.length; y < v; y++)
1042
- f = m[y], h.push(f.toString(16).padStart(4, "0"));
1043
- return h;
1044
- }.call(this).join(":"), p = "", this.zoneId && (p = "%" + this.zoneId), o + p;
1045
- }, u.prototype.match = function(o, f) {
1046
- var p;
1047
- if (f === void 0 && (p = o, o = p[0], f = p[1]), o.kind() !== "ipv6")
1048
- throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");
1049
- return l(this.parts, o.parts, 16, f);
1050
- }, u.prototype.SpecialRanges = {
1051
- unspecified: [new u([0, 0, 0, 0, 0, 0, 0, 0]), 128],
1052
- linkLocal: [new u([65152, 0, 0, 0, 0, 0, 0, 0]), 10],
1053
- multicast: [new u([65280, 0, 0, 0, 0, 0, 0, 0]), 8],
1054
- loopback: [new u([0, 0, 0, 0, 0, 0, 0, 1]), 128],
1055
- uniqueLocal: [new u([64512, 0, 0, 0, 0, 0, 0, 0]), 7],
1056
- ipv4Mapped: [new u([0, 0, 0, 0, 0, 65535, 0, 0]), 96],
1057
- rfc6145: [new u([0, 0, 0, 0, 65535, 0, 0, 0]), 96],
1058
- rfc6052: [new u([100, 65435, 0, 0, 0, 0, 0, 0]), 96],
1059
- "6to4": [new u([8194, 0, 0, 0, 0, 0, 0, 0]), 16],
1060
- teredo: [new u([8193, 0, 0, 0, 0, 0, 0, 0]), 32],
1061
- reserved: [[new u([8193, 3512, 0, 0, 0, 0, 0, 0]), 32]]
1062
- }, u.prototype.range = function() {
1063
- return t.subnetMatch(this, this.SpecialRanges);
1064
- }, u.prototype.isIPv4MappedAddress = function() {
1065
- return this.range() === "ipv4Mapped";
1066
- }, u.prototype.toIPv4Address = function() {
1067
- var o, f, p;
1068
- if (!this.isIPv4MappedAddress())
1069
- throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");
1070
- return p = this.parts.slice(-2), o = p[0], f = p[1], new t.IPv4([o >> 8, o & 255, f >> 8, f & 255]);
1071
- }, u.prototype.prefixLengthFromSubnetMask = function() {
1072
- var o, f, p, y, v, m, h;
1073
- for (h = {
1074
- 0: 16,
1075
- 32768: 15,
1076
- 49152: 14,
1077
- 57344: 13,
1078
- 61440: 12,
1079
- 63488: 11,
1080
- 64512: 10,
1081
- 65024: 9,
1082
- 65280: 8,
1083
- 65408: 7,
1084
- 65472: 6,
1085
- 65504: 5,
1086
- 65520: 4,
1087
- 65528: 3,
1088
- 65532: 2,
1089
- 65534: 1,
1090
- 65535: 0
1091
- }, o = 0, v = !1, f = p = 7; p >= 0; f = p += -1)
1092
- if (y = this.parts[f], y in h) {
1093
- if (m = h[y], v && m !== 0)
1094
- return null;
1095
- m !== 16 && (v = !0), o += m;
1096
- } else
1097
- return null;
1098
- return 128 - o;
1099
- }, u;
1100
- }(), i = "(?:[0-9a-f]+::?)+", d = "%[0-9a-z]{1,}", s = {
1101
- zoneIndex: new RegExp(d, "i"),
1102
- native: new RegExp("^(::)?(" + i + ")?([0-9a-f]+)?(::)?(" + d + ")?$", "i"),
1103
- transitional: new RegExp("^((?:" + i + ")|(?:::)(?:" + i + ")?)" + (n + "\\." + n + "\\." + n + "\\." + n) + ("(" + d + ")?$"), "i")
1104
- }, e = function(u, o) {
1105
- var f, p, y, v, m, h;
1106
- if (u.indexOf("::") !== u.lastIndexOf("::"))
1107
- return null;
1108
- for (h = (u.match(s.zoneIndex) || [])[0], h && (h = h.substring(1), u = u.replace(/%.+$/, "")), f = 0, p = -1; (p = u.indexOf(":", p + 1)) >= 0; )
1109
- f++;
1110
- if (u.substr(0, 2) === "::" && f--, u.substr(-2, 2) === "::" && f--, f > o)
1111
- return null;
1112
- for (m = o - f, v = ":"; m--; )
1113
- v += "0:";
1114
- return u = u.replace("::", v), u[0] === ":" && (u = u.slice(1)), u[u.length - 1] === ":" && (u = u.slice(0, -1)), o = function() {
1115
- var g, A, S, R;
1116
- for (S = u.split(":"), R = [], g = 0, A = S.length; g < A; g++)
1117
- y = S[g], R.push(parseInt(y, 16));
1118
- return R;
1119
- }(), {
1120
- parts: o,
1121
- zoneId: h
1122
- };
1123
- }, t.IPv6.parser = function(u) {
1124
- var o, f, p, y, v, m, h;
1125
- if (s.native.test(u))
1126
- return e(u, 8);
1127
- if ((y = u.match(s.transitional)) && (h = y[6] || "", o = e(y[1].slice(0, -1) + h, 6), o.parts)) {
1128
- for (m = [parseInt(y[2]), parseInt(y[3]), parseInt(y[4]), parseInt(y[5])], f = 0, p = m.length; f < p; f++)
1129
- if (v = m[f], !(0 <= v && v <= 255))
1130
- return null;
1131
- return o.parts.push(m[0] << 8 | m[1]), o.parts.push(m[2] << 8 | m[3]), {
1132
- parts: o.parts,
1133
- zoneId: o.zoneId
1134
- };
171
+ };
172
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
173
+ step((generator = generator.apply(__this, __arguments)).next());
174
+ });
175
+ };
176
+ const useParseAddress = () => {
177
+ const { client } = useShipEngine();
178
+ return useMutation({
179
+ mutationFn: (_0) => __async$o(void 0, [_0], function* ({ address, text }) {
180
+ const result = yield client.addresses.parse(text, address);
181
+ return result.data;
182
+ }),
183
+ mutationKey: ["useParseAddress"],
184
+ onError
185
+ });
186
+ };
187
+
188
+ var __async$n = (__this, __arguments, generator) => {
189
+ return new Promise((resolve, reject) => {
190
+ var fulfilled = (value) => {
191
+ try {
192
+ step(generator.next(value));
193
+ } catch (e) {
194
+ reject(e);
1135
195
  }
1136
- return null;
1137
- }, t.IPv4.isIPv4 = t.IPv6.isIPv6 = function(u) {
1138
- return this.parser(u) !== null;
1139
- }, t.IPv4.isValid = function(u) {
196
+ };
197
+ var rejected = (value) => {
1140
198
  try {
1141
- return new this(this.parser(u)), !0;
1142
- } catch {
1143
- return !1;
199
+ step(generator.throw(value));
200
+ } catch (e) {
201
+ reject(e);
1144
202
  }
1145
- }, t.IPv4.isValidFourPartDecimal = function(u) {
1146
- return !!(t.IPv4.isValid(u) && u.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/));
1147
- }, t.IPv6.isValid = function(u) {
1148
- var o;
1149
- if (typeof u == "string" && u.indexOf(":") === -1)
1150
- return !1;
203
+ };
204
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
205
+ step((generator = generator.apply(__this, __arguments)).next());
206
+ });
207
+ };
208
+ const useValidateAddresses = () => {
209
+ const { client } = useShipEngine();
210
+ return useMutation({
211
+ mutationFn: (addresses) => __async$n(void 0, null, function* () {
212
+ const result = yield client.addresses.validate(addresses);
213
+ return result.data;
214
+ }),
215
+ mutationKey: ["useValidateAddresses"],
216
+ onError
217
+ });
218
+ };
219
+
220
+ var __async$m = (__this, __arguments, generator) => {
221
+ return new Promise((resolve, reject) => {
222
+ var fulfilled = (value) => {
1151
223
  try {
1152
- return o = this.parser(u), new this(o.parts, o.zoneId), !0;
1153
- } catch {
1154
- return !1;
224
+ step(generator.next(value));
225
+ } catch (e) {
226
+ reject(e);
1155
227
  }
1156
- }, t.IPv4.parse = function(u) {
1157
- var o;
1158
- if (o = this.parser(u), o === null)
1159
- throw new Error("ipaddr: string is not formatted like ip address");
1160
- return new this(o);
1161
- }, t.IPv6.parse = function(u) {
1162
- var o;
1163
- if (o = this.parser(u), o.parts === null)
1164
- throw new Error("ipaddr: string is not formatted like ip address");
1165
- return new this(o.parts, o.zoneId);
1166
- }, t.IPv4.parseCIDR = function(u) {
1167
- var o, f, p;
1168
- if ((f = u.match(/^(.+)\/(\d+)$/)) && (o = parseInt(f[2]), o >= 0 && o <= 32))
1169
- return p = [this.parse(f[1]), o], Object.defineProperty(p, "toString", {
1170
- value: function() {
1171
- return this.join("/");
1172
- }
1173
- }), p;
1174
- throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range");
1175
- }, t.IPv4.subnetMaskFromPrefixLength = function(u) {
1176
- var o, f, p;
1177
- if (u = parseInt(u), u < 0 || u > 32)
1178
- throw new Error("ipaddr: invalid IPv4 prefix length");
1179
- for (p = [0, 0, 0, 0], f = 0, o = Math.floor(u / 8); f < o; )
1180
- p[f] = 255, f++;
1181
- return o < 4 && (p[o] = Math.pow(2, u % 8) - 1 << 8 - u % 8), new this(p);
1182
- }, t.IPv4.broadcastAddressFromCIDR = function(u) {
1183
- var o, f, p, y, v;
228
+ };
229
+ var rejected = (value) => {
1184
230
  try {
1185
- for (o = this.parseCIDR(u), p = o[0].toByteArray(), v = this.subnetMaskFromPrefixLength(o[1]).toByteArray(), y = [], f = 0; f < 4; )
1186
- y.push(parseInt(p[f], 10) | parseInt(v[f], 10) ^ 255), f++;
1187
- return new this(y);
1188
- } catch {
1189
- throw new Error("ipaddr: the address does not have IPv4 CIDR format");
231
+ step(generator.throw(value));
232
+ } catch (e) {
233
+ reject(e);
1190
234
  }
1191
- }, t.IPv4.networkAddressFromCIDR = function(u) {
1192
- var o, f, p, y, v;
235
+ };
236
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
237
+ step((generator = generator.apply(__this, __arguments)).next());
238
+ });
239
+ };
240
+ const useAddFunds = (carrierId) => {
241
+ const { client } = useShipEngine();
242
+ return useMutation({
243
+ mutationFn: (funds) => __async$m(void 0, null, function* () {
244
+ const result = yield client.carriers.addFunds(carrierId, funds);
245
+ return result.data;
246
+ }),
247
+ mutationKey: ["useAddFunds"],
248
+ onError
249
+ });
250
+ };
251
+
252
+ var __async$l = (__this, __arguments, generator) => {
253
+ return new Promise((resolve, reject) => {
254
+ var fulfilled = (value) => {
1193
255
  try {
1194
- for (o = this.parseCIDR(u), p = o[0].toByteArray(), v = this.subnetMaskFromPrefixLength(o[1]).toByteArray(), y = [], f = 0; f < 4; )
1195
- y.push(parseInt(p[f], 10) & parseInt(v[f], 10)), f++;
1196
- return new this(y);
1197
- } catch {
1198
- throw new Error("ipaddr: the address does not have IPv4 CIDR format");
256
+ step(generator.next(value));
257
+ } catch (e) {
258
+ reject(e);
1199
259
  }
1200
- }, t.IPv6.parseCIDR = function(u) {
1201
- var o, f, p;
1202
- if ((f = u.match(/^(.+)\/(\d+)$/)) && (o = parseInt(f[2]), o >= 0 && o <= 128))
1203
- return p = [this.parse(f[1]), o], Object.defineProperty(p, "toString", {
1204
- value: function() {
1205
- return this.join("/");
1206
- }
1207
- }), p;
1208
- throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range");
1209
- }, t.isValid = function(u) {
1210
- return t.IPv6.isValid(u) || t.IPv4.isValid(u);
1211
- }, t.parse = function(u) {
1212
- if (t.IPv6.isValid(u))
1213
- return t.IPv6.parse(u);
1214
- if (t.IPv4.isValid(u))
1215
- return t.IPv4.parse(u);
1216
- throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format");
1217
- }, t.parseCIDR = function(u) {
260
+ };
261
+ var rejected = (value) => {
1218
262
  try {
1219
- return t.IPv6.parseCIDR(u);
1220
- } catch {
1221
- try {
1222
- return t.IPv4.parseCIDR(u);
1223
- } catch {
1224
- throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format");
1225
- }
263
+ step(generator.throw(value));
264
+ } catch (e) {
265
+ reject(e);
1226
266
  }
1227
- }, t.fromByteArray = function(u) {
1228
- var o;
1229
- if (o = u.length, o === 4)
1230
- return new t.IPv4(u);
1231
- if (o === 16)
1232
- return new t.IPv6(u);
1233
- throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address");
1234
- }, t.process = function(u) {
1235
- var o;
1236
- return o = this.parse(u), o.kind() === "ipv6" && o.isIPv4MappedAddress() ? o.toIPv4Address() : o;
1237
267
  };
1238
- }).call(jt);
1239
- })(Da);
1240
- const an = (r) => Array.isArray(r) && r.every((e) => on(e)), on = (r) => !!r.errorCode, ka = async () => {
1241
- try {
1242
- const r = await mr.get("https://api.ipify.org/?format=json");
1243
- return r.data.ip && Ce.isValid(r.data.ip) ? Ce.parse(r.data.ip).toString() : void 0;
1244
- } catch {
1245
- return;
1246
- }
268
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
269
+ step((generator = generator.apply(__this, __arguments)).next());
270
+ });
1247
271
  };
1248
- class Ta {
1249
- constructor(e) {
1250
- this.client = e, this.list = () => this.client.get("/v1/carriers"), this.get = (t) => this.client.get(`/v1/carriers/${t}`), this.connect = async ({ carrierCode: t, ...n }) => {
1251
- const a = await ka();
1252
- return a ? await this.client.post(`/v1/registration/${t}`, {
1253
- ...n,
1254
- endUserIpAddress: a
1255
- }) : Promise.reject([new W("Unable to get IP address")]);
1256
- }, this.addFunds = (t, n) => this.client.put(`/v1/carriers/${t}/add_funds`, n), this.updateAutoFunding = (t, n) => this.client.post(
1257
- `/v1/carriers/${t}/auto_funding`,
1258
- n
1259
- ), this.getAutoFunding = (t) => this.client.get(
1260
- `/v1/carriers/${t}/auto_funding`
1261
- ), this.client = e;
1262
- }
1263
- }
1264
- var gr = { trace: 10, debug: 20, info: 30, warn: 40, error: 50, fatal: 60 }, Tr = {};
1265
- function nr(r) {
1266
- return typeof r == "string" ? gr[r.toLowerCase()] : r;
1267
- }
1268
- function Sr(r, e) {
1269
- return Sr = Object.setPrototypeOf || function(t, n) {
1270
- return t.__proto__ = n, t;
1271
- }, Sr(r, e);
1272
- }
1273
- function Ba() {
1274
- if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
1275
- return !1;
1276
- if (typeof Proxy == "function")
1277
- return !0;
1278
- try {
1279
- return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
1280
- })), !0;
1281
- } catch {
1282
- return !1;
1283
- }
1284
- }
1285
- function wr(r, e, t) {
1286
- return wr = Ba() ? Reflect.construct : function(n, a, i) {
1287
- var s = [null];
1288
- s.push.apply(s, a);
1289
- var l = new (Function.bind.apply(n, s))();
1290
- return i && Sr(l, i.prototype), l;
1291
- }, wr.apply(null, arguments);
1292
- }
1293
- function re(r) {
1294
- if (r == null)
1295
- return r;
1296
- if (Array.isArray(r))
1297
- return r.slice();
1298
- if (typeof r == "object") {
1299
- var e = {};
1300
- return Object.keys(r).forEach(function(t) {
1301
- e[t] = r[t];
1302
- }), e;
1303
- }
1304
- return r;
1305
- }
1306
- function br(r) {
1307
- return r === void 0 ? "undefined" : r === null ? "null" : Array.isArray(r) ? "[ " + r.map(function(e) {
1308
- return br(e);
1309
- }).join(", ") + " ]" : typeof r == "object" ? JSON.stringify(r) : typeof r == "function" ? "[Function: " + r.name + "]" : typeof r == "boolean" || typeof r == "number" ? r : "'" + r.toString() + "'";
1310
- }
1311
- function Z(r) {
1312
- if (typeof r != "string") {
1313
- for (var e = new Array(arguments.length), t = 0; t < arguments.length; t++)
1314
- e[t] = br(arguments[t]);
1315
- return e.join(" ");
1316
- }
1317
- for (var n = /%[sdj%]/g, a = 1, i = arguments, s = i.length, l = String(r).replace(n, function(d) {
1318
- if (d === "%%")
1319
- return "%";
1320
- if (a >= s)
1321
- return d;
1322
- switch (d) {
1323
- case "%s":
1324
- return String(i[a++]);
1325
- case "%d":
1326
- return Number(i[a++]);
1327
- case "%j":
1328
- try {
1329
- return JSON.stringify(i[a++]);
1330
- } catch {
1331
- return "[Circular]";
1332
- }
1333
- default:
1334
- return d;
1335
- }
1336
- }), c = i[a]; a < s; c = i[++a])
1337
- l += c === null || typeof c != "object" ? " " + c : " " + br(c);
1338
- return l;
1339
- }
1340
- function La(r, e) {
1341
- var t = r.split(`
1342
- `);
1343
- t[0] && t[0].indexOf("call-stack-error") >= 0 && t.shift();
1344
- var n = t[e], a = null;
1345
- if (n) {
1346
- var i = /^\s*(at|.*@)\s*(.+)?$/.exec(n);
1347
- a = Array.isArray(i) && i[2] ? i[2] : n;
1348
- }
1349
- return a;
1350
- }
1351
- Object.keys(gr).forEach(function(r) {
1352
- Tr[gr[r]] = r;
1353
- });
1354
- var Er = {};
1355
- function Ar(r, e) {
1356
- if (e) {
1357
- if (Er[e])
1358
- return;
1359
- Er[e] = !0;
1360
- }
1361
- console.error(r + `
1362
- `);
1363
- }
1364
- function Ua(r) {
1365
- return Er[r];
1366
- }
1367
- function qa() {
1368
- var r = [];
1369
- return function(e, t) {
1370
- return t && typeof t == "object" ? r.indexOf(t) !== -1 ? "[Circular]" : (r.push(t), t) : t;
1371
- };
1372
- }
1373
- var Ma = /* @__PURE__ */ function() {
1374
- function r() {
1375
- }
1376
- return r.prototype.write = function(e) {
1377
- e.level < 30 ? console.log(e) : e.level < 40 ? console.info(e) : e.level < 50 ? console.warn(e) : console.error(e), e.err && e.err.stack && console.error(e.err.stack), e.obj && console.log(e.obj);
1378
- }, r;
1379
- }(), ee = /* @__PURE__ */ function() {
1380
- function r(t, n, a) {
1381
- var i, s, l, c, d = this;
1382
- if (!(this instanceof r))
1383
- return new r(t, n);
1384
- if (n !== void 0 && (i = t, t = n, !(i instanceof r)))
1385
- throw new TypeError("invalid Logger creation: do not pass a second arg");
1386
- if (!t)
1387
- throw new TypeError("options (object) is required");
1388
- if (i) {
1389
- if (t.name)
1390
- throw new TypeError("invalid options.name: child cannot set logger name");
1391
- } else if (!t.name)
1392
- throw new TypeError("options.name (string) is required");
1393
- if (t.stream && t.streams)
1394
- throw new TypeError('cannot mix "streams" and "stream" options');
1395
- if (t.streams && !Array.isArray(t.streams))
1396
- throw new TypeError("invalid options.streams: must be an array");
1397
- if (t.serializers && (typeof t.serializers != "object" || Array.isArray(t.serializers)))
1398
- throw new TypeError("invalid options.serializers: must be an object");
1399
- if (i && a) {
1400
- this._level = i._level, this.streams = i.streams, this.serializers = i.serializers, this.src = i.src, s = this.fields = {};
1401
- var u = Object.keys(i.fields);
1402
- for (c = 0; c < u.length; c++)
1403
- s[l = u[c]] = i.fields[l];
1404
- var o = Object.keys(t);
1405
- for (c = 0; c < o.length; c++)
1406
- s[l = o[c]] = t[l];
1407
- } else {
1408
- if (i) {
1409
- for (this._level = i._level, this.streams = [], c = 0; c < i.streams.length; c++) {
1410
- var f = re(i.streams[c]);
1411
- this.streams.push(f);
1412
- }
1413
- this.serializers = re(i.serializers), this.src = i.src, this.fields = re(i.fields), t.level && this.level(t.level);
1414
- } else
1415
- this._level = Number.POSITIVE_INFINITY, this.streams = [], this.serializers = null, this.src = !1, this.fields = {};
1416
- t.stream ? this.addStream({ type: "stream", stream: t.stream, level: t.level }) : t.streams ? t.streams.forEach(function(p) {
1417
- d.addStream(p, t.level);
1418
- }) : i && t.level ? this.level(t.level) : i || this.addStream({ type: "raw", stream: new Ma(), level: t.level }), t.serializers && this.addSerializers(t.serializers), t.src && (this.src = !0), delete (s = re(t)).stream, delete s.level, delete s.streams, delete s.serializers, delete s.src, this.serializers && this._applySerializers(s), Object.keys(s).forEach(function(p) {
1419
- d.fields[p] = s[p];
1420
- });
1421
- }
1422
- }
1423
- var e = r.prototype;
1424
- return e.addStream = function(t, n) {
1425
- n === void 0 && (n = 30), (t = re(t)).type = "raw", t.level = nr(t.level || n), t.level < this._level && (this._level = t.level), this.streams.push(t), delete this.haveNonRawStreams;
1426
- }, e.addSerializers = function(t) {
1427
- var n = this;
1428
- this.serializers || (this.serializers = {}), Object.keys(t).forEach(function(a) {
1429
- var i = t[a];
1430
- if (typeof i != "function")
1431
- throw new TypeError(Z('invalid serializer for "%s" field: must be a function', a));
1432
- n.serializers[a] = i;
1433
- });
1434
- }, e.child = function(t, n) {
1435
- return new this.constructor(this, t || {}, n);
1436
- }, e.level = function(t) {
1437
- if (t === void 0)
1438
- return this._level;
1439
- for (var n = nr(t), a = this.streams.length, i = 0; i < a; i++)
1440
- this.streams[i].level = n;
1441
- this._level = n;
1442
- }, e.levels = function(t, n) {
1443
- if (t === void 0)
1444
- return this.streams.map(function(d) {
1445
- return d.level;
1446
- });
1447
- var a;
1448
- if (typeof t == "number") {
1449
- if ((a = this.streams[t]) === void 0)
1450
- throw new Error("invalid stream index: " + t);
1451
- } else {
1452
- for (var i = this.streams.length, s = 0; s < i; s++) {
1453
- var l = this.streams[s];
1454
- if (l.name === t) {
1455
- a = l;
1456
- break;
1457
- }
272
+ const useConnectCarrier = () => {
273
+ const { client } = useShipEngine();
274
+ return useMutation({
275
+ mutationFn: (params) => __async$l(void 0, null, function* () {
276
+ const result = yield client.carriers.connect(params);
277
+ return result.data;
278
+ }),
279
+ mutationKey: ["useConnectCarrier"],
280
+ onError
281
+ });
282
+ };
283
+
284
+ const useGetAutoFundingConfiguration = (carrierId) => {
285
+ const { client } = useShipEngine();
286
+ return useQuery({
287
+ enabled: carrierId !== void 0,
288
+ onError,
289
+ queryFn: () => {
290
+ if (carrierId)
291
+ return client.carriers.getAutoFunding(carrierId);
292
+ return Promise.reject(new Error("carrierId is required."));
293
+ },
294
+ queryKey: ["useGetAutoFundingConfiguration", carrierId],
295
+ select: (result) => result.data
296
+ });
297
+ };
298
+
299
+ const useGetCarrierById = (carrierId) => {
300
+ const { client } = useShipEngine();
301
+ return useQuery({
302
+ enabled: !!carrierId,
303
+ onError,
304
+ queryFn: () => {
305
+ if (carrierId)
306
+ return client.carriers.get(carrierId);
307
+ return Promise.reject(new Error("carrierId is require"));
308
+ },
309
+ queryKey: ["useGetCarrierById", carrierId],
310
+ select: (result) => result.data,
311
+ // Fresh for 5 minutes
312
+ staleTime: 5 * 60 * 1e3
313
+ });
314
+ };
315
+
316
+ const useGetCountriesByCarrier = (carrierId) => {
317
+ const { client } = useShipEngine();
318
+ return useQuery({
319
+ enabled: !!carrierId,
320
+ onError,
321
+ queryFn: () => {
322
+ if (carrierId)
323
+ return client.carriers.getCountries(carrierId);
324
+ return Promise.reject(new Error("carrierId is require"));
325
+ },
326
+ queryKey: ["useGetCountriesByCarrier", carrierId],
327
+ select: (result) => result.data.countries,
328
+ // Fresh for 5 minutes
329
+ staleTime: 5 * 60 * 1e3
330
+ });
331
+ };
332
+
333
+ const useGetCurrenciesByCarrier = (carrierId) => {
334
+ const { client } = useShipEngine();
335
+ return useQuery({
336
+ enabled: !!carrierId,
337
+ onError,
338
+ queryFn: () => {
339
+ if (carrierId)
340
+ return client.carriers.getCurrencies(carrierId);
341
+ return Promise.reject(new Error("carrierId is require"));
342
+ },
343
+ queryKey: ["useGetCurrenciesByCarrier", carrierId],
344
+ select: (result) => result.data.currencies,
345
+ // Fresh for 5 minutes
346
+ staleTime: 5 * 60 * 1e3
347
+ });
348
+ };
349
+
350
+ const useGetPackageRatingGroupByCarrier = (carrierId) => {
351
+ const { client } = useShipEngine();
352
+ return useQuery({
353
+ enabled: !!carrierId,
354
+ onError,
355
+ queryFn: () => {
356
+ if (carrierId)
357
+ return client.carriers.getPackageRatingGroup(carrierId);
358
+ return Promise.reject(new Error("carrierId is required"));
359
+ },
360
+ queryKey: ["useGetRatePackageFormatsByCarrier", carrierId],
361
+ select: (result) => result.data.packageRatingGroup,
362
+ // Fresh for 5 minutes
363
+ staleTime: 5 * 60 * 1e3
364
+ });
365
+ };
366
+
367
+ const useGetServicesByCarrier = (carrierId) => {
368
+ const { client } = useShipEngine();
369
+ return useQuery({
370
+ enabled: !!carrierId,
371
+ onError,
372
+ queryFn: () => {
373
+ if (carrierId)
374
+ return client.carriers.getServices(carrierId);
375
+ return Promise.reject(new Error("carrierId is required"));
376
+ },
377
+ queryKey: ["useGetServicesByCarrier", carrierId],
378
+ select: (result) => result.data.services,
379
+ // Fresh for 5 minutes
380
+ staleTime: 5 * 60 * 1e3
381
+ });
382
+ };
383
+
384
+ const useGetWalletHistory = ({
385
+ enabled,
386
+ page,
387
+ range
388
+ }) => {
389
+ const { client } = useShipEngine();
390
+ const [startDate, endDate] = range;
391
+ return useQuery({
392
+ enabled,
393
+ keepPreviousData: true,
394
+ // See https://react-query-v3.tanstack.com/guides/paginated-queries#better-paginated-queries-with-keeppreviousdata
395
+ onError,
396
+ queryFn: () => client.carriers.getWalletHistory(startDate, endDate, page),
397
+ queryKey: ["useGetWalletHistory", startDate, endDate, page],
398
+ select: (result) => result.data
399
+ });
400
+ };
401
+
402
+ const useListCarriers = () => {
403
+ const { client } = useShipEngine();
404
+ return useQuery({
405
+ onError,
406
+ queryFn: () => client.carriers.list(),
407
+ queryKey: ["useListCarriers"],
408
+ select: (result) => result.data.carriers
409
+ });
410
+ };
411
+
412
+ var __async$k = (__this, __arguments, generator) => {
413
+ return new Promise((resolve, reject) => {
414
+ var fulfilled = (value) => {
415
+ try {
416
+ step(generator.next(value));
417
+ } catch (e) {
418
+ reject(e);
1458
419
  }
1459
- if (!a)
1460
- throw new Error(Z('no stream with name "%s"', t));
1461
- }
1462
- if (n === void 0)
1463
- return a.level;
1464
- var c = nr(n);
1465
- a.level = c, c < this._level && (this._level = c);
1466
- }, e._applySerializers = function(t, n) {
1467
- var a = this;
1468
- Object.keys(this.serializers).forEach(function(i) {
1469
- if (!(t[i] === void 0 || n && n[i]))
1470
- try {
1471
- t[i] = a.serializers[i](t[i]);
1472
- } catch (s) {
1473
- Ar(Z(`bunyan: ERROR: Exception thrown from the "%s" Bunyan serializer. This should never happen. This is a bugin that serializer function.
1474
- %s`, i, s.stack || s)), t[i] = Z('(Error in Bunyan log "%s" serializer broke field. See stderr for details.)', i);
1475
- }
1476
- });
1477
- }, e._emit = function(t, n) {
1478
- var a, i;
1479
- if (this.haveNonRawStreams === void 0) {
1480
- for (this.haveNonRawStreams = !1, a = 0; a < this.streams.length; a++)
1481
- if (!this.streams[a].raw) {
1482
- this.haveNonRawStreams = !0;
1483
- break;
1484
- }
1485
- }
1486
- if (n || this.haveNonRawStreams)
420
+ };
421
+ var rejected = (value) => {
1487
422
  try {
1488
- i = JSON.stringify(t, qa()) + `
1489
- `;
1490
- } catch (d) {
1491
- var s = d.stack.split(/\n/g, 2).join(`
1492
- `);
1493
- Ar('bunyan: ERROR: Exception in `JSON.stringify(rec)`. You can install the "safe-json-stringify" module to have Bunyan fallback to safer stringification. Record:\n' + function(u, o) {
1494
- return o || (o = " "), o + u.split(/\r?\n/g).join(`
1495
- ` + o);
1496
- }(Z(`%s
1497
- %s`, t, d.stack)), s), i = Z(`(Exception in JSON.stringify(rec): %j. See stderr for details.)
1498
- `, d.message);
423
+ step(generator.throw(value));
424
+ } catch (e) {
425
+ reject(e);
1499
426
  }
1500
- if (n)
1501
- return i;
1502
- var l = t.level;
1503
- for (a = 0; a < this.streams.length; a++) {
1504
- var c = this.streams[a];
1505
- c.level <= l && c.stream.write(t);
1506
- }
1507
- return i;
1508
- }, r;
1509
- }();
1510
- function se(r) {
1511
- return function() {
1512
- var e = this;
1513
- function t(s) {
1514
- var l;
1515
- s[0] instanceof Error ? (n = { err: e.serializers && e.serializers.err ? e.serializers.err(s[0]) : Br.err(s[0]) }, l = { err: !0 }, a = s.length === 1 ? [n.err.message] : Array.prototype.slice.call(s, 1)) : typeof s[0] != "object" && s[0] !== null || Array.isArray(s[0]) ? (n = null, a = Array.prototype.slice.call(s)) : (n = s[0], a = s.length === 1 && n.err && n.err instanceof Error ? [n.err.message] : Array.prototype.slice.call(s, 1));
1516
- var c = re(e.fields);
1517
- c.level = r;
1518
- var d = n ? re(n) : null;
1519
- if (d && (e.serializers && e._applySerializers(d, l), Object.keys(d).forEach(function(o) {
1520
- c[o] = d[o];
1521
- })), c.levelName = Tr[r], c.msg = a.length ? Z.apply(e, a) : "", c.time || (c.time = new Date()), e.src && !c.src)
1522
- try {
1523
- throw new Error("call-stack-error");
1524
- } catch (o) {
1525
- var u = o.stack ? La(o.stack, 2) : "";
1526
- u || Ua("src") || Ar("Unable to determine src line info", "src"), c.src = u || "";
1527
- }
1528
- return c.v = 1, c;
427
+ };
428
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
429
+ step((generator = generator.apply(__this, __arguments)).next());
430
+ });
431
+ };
432
+ const useUpdateAutoFunding = (carrierId) => {
433
+ const { client } = useShipEngine();
434
+ const queryClient = useQueryClient();
435
+ return useMutation({
436
+ mutationFn: (options) => __async$k(void 0, null, function* () {
437
+ const result = yield client.carriers.updateAutoFunding(carrierId, options);
438
+ return result.data;
439
+ }),
440
+ mutationKey: ["useUpdateAutoFunding"],
441
+ onError,
442
+ onSuccess: (_) => {
443
+ queryClient.invalidateQueries(["useGetAutoFunding", carrierId], { exact: true });
1529
444
  }
1530
- var n = null, a = arguments, i = null;
1531
- if (arguments.length === 0)
1532
- return this._level <= r;
1533
- this._level > r || (i = t(a), this._emit(i));
1534
- };
1535
- }
1536
- function sn(r) {
1537
- var e = r.stack || r.toString();
1538
- if (r.cause && typeof r.cause == "function") {
1539
- var t = r.cause();
1540
- t && (e += `
1541
- Caused by: ` + sn(t));
1542
- }
1543
- return e;
1544
- }
1545
- ee.prototype.trace = se(10), ee.prototype.debug = se(20), ee.prototype.info = se(30), ee.prototype.warn = se(40), ee.prototype.error = se(50), ee.prototype.fatal = se(60);
1546
- var Br = { err: function(r) {
1547
- return r && r.stack ? { message: r.message, name: r.name, stack: sn(r), code: r.code, signal: r.signal } : r;
1548
- } };
1549
- function un() {
1550
- return wr(ee, [].slice.call(arguments));
1551
- }
1552
- var mt = { levels: { trace: "color: DeepPink", debug: "color: GoldenRod", info: "color: DarkTurquoise", warn: "color: Purple", error: "color: Crimson", fatal: "color: Black" }, def: "color: DimGray", msg: "color: SteelBlue", src: "color: DimGray; font-style: italic; font-size: 0.9em" }, ln = /* @__PURE__ */ function() {
1553
- function r(e) {
1554
- var t = e === void 0 ? {} : e, n = t.logByLevel, a = t.css, i = a === void 0 ? mt : a;
1555
- this.logByLevel = n !== void 0 && n, this.css = i;
1556
- }
1557
- return r.prototype.write = function(e) {
1558
- var t, n, a = this.css.def, i = this.css.msg, s = this.css.src, l = e.childName ? e.name + "/" + e.childName : e.name, c = Tr[e.level], d = (Array(6 - c.length).join(" ") + c).toUpperCase();
1559
- this.logByLevel ? (e.level === 10 ? c = "debug" : e.level === 60 && (c = "error"), n = typeof console[c] == "function" ? console[c] : console.log) : n = console.log, t = e.level < 20 ? this.css.levels.trace : e.level < 30 ? this.css.levels.debug : e.level < 40 ? this.css.levels.info : e.level < 50 ? this.css.levels.warn : e.level < 60 ? this.css.levels.error : this.css.levels.fatal;
1560
- var u = function(f, p) {
1561
- return Array(p + 1 - (f + "").length).join("0") + f;
1562
- }, o = [];
1563
- o.push("[%s:%s:%s:%s] %c%s%c: %s: %c%s " + (e.src ? "%c%s" : "")), o.push(u(e.time.getHours(), 2)), o.push(u(e.time.getMinutes(), 2)), o.push(u(e.time.getSeconds(), 2)), o.push(u(e.time.getMilliseconds(), 4)), o.push(t), o.push(d), o.push(a), o.push(l), o.push(i), o.push(e.msg), e.src && (o.push(s), o.push(e.src)), e.obj && (o.push(`
1564
- `), o.push(e.obj)), e.err && e.err.stack && (o.push(`
1565
- `), o.push(e.err.stack)), n.apply(console, o);
1566
- }, r.getDefaultCss = function() {
1567
- return mt;
1568
- }, r;
1569
- }(), me = {}, za = {
1570
- get exports() {
1571
- return me;
1572
- },
1573
- set exports(r) {
1574
- me = r;
1575
- }
445
+ });
446
+ };
447
+
448
+ const useGetZonesByCarrier = (carrierId) => {
449
+ const { client } = useShipEngine();
450
+ return useQuery({
451
+ enabled: !!carrierId,
452
+ onError,
453
+ queryFn: () => {
454
+ if (carrierId)
455
+ return client.carriers.getZones(carrierId);
456
+ return Promise.reject(new Error("carrierId is required"));
457
+ },
458
+ queryKey: ["useGetZonesByCarrier", carrierId],
459
+ select: (result) => result.data.zones,
460
+ // Fresh for 5 minutes
461
+ staleTime: 5 * 60 * 1e3
462
+ });
463
+ };
464
+
465
+ const useListCustomPackageTypes = () => {
466
+ const { client } = useShipEngine();
467
+ return useQuery({
468
+ onError,
469
+ queryFn: () => client.customPackages.list(),
470
+ queryKey: ["useListCustomPackageTypes"],
471
+ select: (result) => result.data.packages
472
+ });
1576
473
  };
1577
- (function(r) {
1578
- (function(e) {
1579
- var t = function(h, g, A) {
1580
- if (!d(g) || o(g) || f(g) || p(g) || c(g))
1581
- return g;
1582
- var S, R = 0, q = 0;
1583
- if (u(g))
1584
- for (S = [], q = g.length; R < q; R++)
1585
- S.push(t(h, g[R], A));
1586
- else {
1587
- S = {};
1588
- for (var $ in g)
1589
- Object.prototype.hasOwnProperty.call(g, $) && (S[h($, A)] = t(h, g[$], A));
474
+
475
+ var __async$j = (__this, __arguments, generator) => {
476
+ return new Promise((resolve, reject) => {
477
+ var fulfilled = (value) => {
478
+ try {
479
+ step(generator.next(value));
480
+ } catch (e) {
481
+ reject(e);
1590
482
  }
1591
- return S;
1592
- }, n = function(h, g) {
1593
- g = g || {};
1594
- var A = g.separator || "_", S = g.split || /(?=[A-Z])/;
1595
- return h.split(S).join(A);
1596
- }, a = function(h) {
1597
- return y(h) ? h : (h = h.replace(/[\-_\s]+(.)?/g, function(g, A) {
1598
- return A ? A.toUpperCase() : "";
1599
- }), h.substr(0, 1).toLowerCase() + h.substr(1));
1600
- }, i = function(h) {
1601
- var g = a(h);
1602
- return g.substr(0, 1).toUpperCase() + g.substr(1);
1603
- }, s = function(h, g) {
1604
- return n(h, g).toLowerCase();
1605
- }, l = Object.prototype.toString, c = function(h) {
1606
- return typeof h == "function";
1607
- }, d = function(h) {
1608
- return h === Object(h);
1609
- }, u = function(h) {
1610
- return l.call(h) == "[object Array]";
1611
- }, o = function(h) {
1612
- return l.call(h) == "[object Date]";
1613
- }, f = function(h) {
1614
- return l.call(h) == "[object RegExp]";
1615
- }, p = function(h) {
1616
- return l.call(h) == "[object Boolean]";
1617
- }, y = function(h) {
1618
- return h = h - 0, h === h;
1619
- }, v = function(h, g) {
1620
- var A = g && "process" in g ? g.process : g;
1621
- return typeof A != "function" ? h : function(S, R) {
1622
- return A(S, h, R);
1623
- };
1624
- }, m = {
1625
- camelize: a,
1626
- decamelize: s,
1627
- pascalize: i,
1628
- depascalize: s,
1629
- camelizeKeys: function(h, g) {
1630
- return t(v(a, g), h);
1631
- },
1632
- decamelizeKeys: function(h, g) {
1633
- return t(v(s, g), h, g);
1634
- },
1635
- pascalizeKeys: function(h, g) {
1636
- return t(v(i, g), h);
1637
- },
1638
- depascalizeKeys: function() {
1639
- return this.decamelizeKeys.apply(this, arguments);
483
+ };
484
+ var rejected = (value) => {
485
+ try {
486
+ step(generator.throw(value));
487
+ } catch (e) {
488
+ reject(e);
1640
489
  }
1641
490
  };
1642
- r.exports ? r.exports = m : e.humps = m;
1643
- })(jt);
1644
- })(za);
1645
- var ja = function() {
1646
- if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function")
1647
- return !1;
1648
- if (typeof Symbol.iterator == "symbol")
1649
- return !0;
1650
- var e = {}, t = Symbol("test"), n = Object(t);
1651
- if (typeof t == "string" || Object.prototype.toString.call(t) !== "[object Symbol]" || Object.prototype.toString.call(n) !== "[object Symbol]")
1652
- return !1;
1653
- var a = 42;
1654
- e[t] = a;
1655
- for (t in e)
1656
- return !1;
1657
- if (typeof Object.keys == "function" && Object.keys(e).length !== 0 || typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(e).length !== 0)
1658
- return !1;
1659
- var i = Object.getOwnPropertySymbols(e);
1660
- if (i.length !== 1 || i[0] !== t || !Object.prototype.propertyIsEnumerable.call(e, t))
1661
- return !1;
1662
- if (typeof Object.getOwnPropertyDescriptor == "function") {
1663
- var s = Object.getOwnPropertyDescriptor(e, t);
1664
- if (s.value !== a || s.enumerable !== !0)
1665
- return !1;
1666
- }
1667
- return !0;
1668
- }, gt = typeof Symbol < "u" && Symbol, Wa = ja, Ga = function() {
1669
- return typeof gt != "function" || typeof Symbol != "function" || typeof gt("foo") != "symbol" || typeof Symbol("bar") != "symbol" ? !1 : Wa();
1670
- }, Ka = "Function.prototype.bind called on incompatible ", ar = Array.prototype.slice, Ha = Object.prototype.toString, Va = "[object Function]", Ja = function(e) {
1671
- var t = this;
1672
- if (typeof t != "function" || Ha.call(t) !== Va)
1673
- throw new TypeError(Ka + t);
1674
- for (var n = ar.call(arguments, 1), a, i = function() {
1675
- if (this instanceof a) {
1676
- var u = t.apply(
1677
- this,
1678
- n.concat(ar.call(arguments))
1679
- );
1680
- return Object(u) === u ? u : this;
1681
- } else
1682
- return t.apply(
1683
- e,
1684
- n.concat(ar.call(arguments))
1685
- );
1686
- }, s = Math.max(0, t.length - n.length), l = [], c = 0; c < s; c++)
1687
- l.push("$" + c);
1688
- if (a = Function("binder", "return function (" + l.join(",") + "){ return binder.apply(this,arguments); }")(i), t.prototype) {
1689
- var d = function() {
491
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
492
+ step((generator = generator.apply(__this, __arguments)).next());
493
+ });
494
+ };
495
+ const useCreateFundingSource = () => {
496
+ const { client } = useShipEngine();
497
+ return useMutation({
498
+ mutationFn: (fundingSource) => __async$j(void 0, null, function* () {
499
+ const result = yield client.fundingSources.create(fundingSource);
500
+ return result.data;
501
+ }),
502
+ mutationKey: ["useCreateFundingSource"],
503
+ onError
504
+ });
505
+ };
506
+
507
+ var __async$i = (__this, __arguments, generator) => {
508
+ return new Promise((resolve, reject) => {
509
+ var fulfilled = (value) => {
510
+ try {
511
+ step(generator.next(value));
512
+ } catch (e) {
513
+ reject(e);
514
+ }
1690
515
  };
1691
- d.prototype = t.prototype, a.prototype = new d(), d.prototype = null;
1692
- }
1693
- return a;
1694
- }, Qa = Ja, Lr = Function.prototype.bind || Qa, Xa = Lr, Ya = Xa.call(Function.call, Object.prototype.hasOwnProperty), w, fe = SyntaxError, cn = Function, ce = TypeError, ir = function(r) {
1695
- try {
1696
- return cn('"use strict"; return (' + r + ").constructor;")();
1697
- } catch {
1698
- }
1699
- }, ne = Object.getOwnPropertyDescriptor;
1700
- if (ne)
1701
- try {
1702
- ne({}, "");
1703
- } catch {
1704
- ne = null;
1705
- }
1706
- var or = function() {
1707
- throw new ce();
1708
- }, Za = ne ? function() {
1709
- try {
1710
- return arguments.callee, or;
1711
- } catch {
1712
- try {
1713
- return ne(arguments, "callee").get;
1714
- } catch {
1715
- return or;
1716
- }
1717
- }
1718
- }() : or, ue = Ga(), z = Object.getPrototypeOf || function(r) {
1719
- return r.__proto__;
1720
- }, le = {}, ei = typeof Uint8Array > "u" ? w : z(Uint8Array), ae = {
1721
- "%AggregateError%": typeof AggregateError > "u" ? w : AggregateError,
1722
- "%Array%": Array,
1723
- "%ArrayBuffer%": typeof ArrayBuffer > "u" ? w : ArrayBuffer,
1724
- "%ArrayIteratorPrototype%": ue ? z([][Symbol.iterator]()) : w,
1725
- "%AsyncFromSyncIteratorPrototype%": w,
1726
- "%AsyncFunction%": le,
1727
- "%AsyncGenerator%": le,
1728
- "%AsyncGeneratorFunction%": le,
1729
- "%AsyncIteratorPrototype%": le,
1730
- "%Atomics%": typeof Atomics > "u" ? w : Atomics,
1731
- "%BigInt%": typeof BigInt > "u" ? w : BigInt,
1732
- "%BigInt64Array%": typeof BigInt64Array > "u" ? w : BigInt64Array,
1733
- "%BigUint64Array%": typeof BigUint64Array > "u" ? w : BigUint64Array,
1734
- "%Boolean%": Boolean,
1735
- "%DataView%": typeof DataView > "u" ? w : DataView,
1736
- "%Date%": Date,
1737
- "%decodeURI%": decodeURI,
1738
- "%decodeURIComponent%": decodeURIComponent,
1739
- "%encodeURI%": encodeURI,
1740
- "%encodeURIComponent%": encodeURIComponent,
1741
- "%Error%": Error,
1742
- "%eval%": eval,
1743
- // eslint-disable-line no-eval
1744
- "%EvalError%": EvalError,
1745
- "%Float32Array%": typeof Float32Array > "u" ? w : Float32Array,
1746
- "%Float64Array%": typeof Float64Array > "u" ? w : Float64Array,
1747
- "%FinalizationRegistry%": typeof FinalizationRegistry > "u" ? w : FinalizationRegistry,
1748
- "%Function%": cn,
1749
- "%GeneratorFunction%": le,
1750
- "%Int8Array%": typeof Int8Array > "u" ? w : Int8Array,
1751
- "%Int16Array%": typeof Int16Array > "u" ? w : Int16Array,
1752
- "%Int32Array%": typeof Int32Array > "u" ? w : Int32Array,
1753
- "%isFinite%": isFinite,
1754
- "%isNaN%": isNaN,
1755
- "%IteratorPrototype%": ue ? z(z([][Symbol.iterator]())) : w,
1756
- "%JSON%": typeof JSON == "object" ? JSON : w,
1757
- "%Map%": typeof Map > "u" ? w : Map,
1758
- "%MapIteratorPrototype%": typeof Map > "u" || !ue ? w : z((/* @__PURE__ */ new Map())[Symbol.iterator]()),
1759
- "%Math%": Math,
1760
- "%Number%": Number,
1761
- "%Object%": Object,
1762
- "%parseFloat%": parseFloat,
1763
- "%parseInt%": parseInt,
1764
- "%Promise%": typeof Promise > "u" ? w : Promise,
1765
- "%Proxy%": typeof Proxy > "u" ? w : Proxy,
1766
- "%RangeError%": RangeError,
1767
- "%ReferenceError%": ReferenceError,
1768
- "%Reflect%": typeof Reflect > "u" ? w : Reflect,
1769
- "%RegExp%": RegExp,
1770
- "%Set%": typeof Set > "u" ? w : Set,
1771
- "%SetIteratorPrototype%": typeof Set > "u" || !ue ? w : z((/* @__PURE__ */ new Set())[Symbol.iterator]()),
1772
- "%SharedArrayBuffer%": typeof SharedArrayBuffer > "u" ? w : SharedArrayBuffer,
1773
- "%String%": String,
1774
- "%StringIteratorPrototype%": ue ? z(""[Symbol.iterator]()) : w,
1775
- "%Symbol%": ue ? Symbol : w,
1776
- "%SyntaxError%": fe,
1777
- "%ThrowTypeError%": Za,
1778
- "%TypedArray%": ei,
1779
- "%TypeError%": ce,
1780
- "%Uint8Array%": typeof Uint8Array > "u" ? w : Uint8Array,
1781
- "%Uint8ClampedArray%": typeof Uint8ClampedArray > "u" ? w : Uint8ClampedArray,
1782
- "%Uint16Array%": typeof Uint16Array > "u" ? w : Uint16Array,
1783
- "%Uint32Array%": typeof Uint32Array > "u" ? w : Uint32Array,
1784
- "%URIError%": URIError,
1785
- "%WeakMap%": typeof WeakMap > "u" ? w : WeakMap,
1786
- "%WeakRef%": typeof WeakRef > "u" ? w : WeakRef,
1787
- "%WeakSet%": typeof WeakSet > "u" ? w : WeakSet
1788
- };
1789
- try {
1790
- null.error;
1791
- } catch (r) {
1792
- var ri = z(z(r));
1793
- ae["%Error.prototype%"] = ri;
1794
- }
1795
- var ti = function r(e) {
1796
- var t;
1797
- if (e === "%AsyncFunction%")
1798
- t = ir("async function () {}");
1799
- else if (e === "%GeneratorFunction%")
1800
- t = ir("function* () {}");
1801
- else if (e === "%AsyncGeneratorFunction%")
1802
- t = ir("async function* () {}");
1803
- else if (e === "%AsyncGenerator%") {
1804
- var n = r("%AsyncGeneratorFunction%");
1805
- n && (t = n.prototype);
1806
- } else if (e === "%AsyncIteratorPrototype%") {
1807
- var a = r("%AsyncGenerator%");
1808
- a && (t = z(a.prototype));
1809
- }
1810
- return ae[e] = t, t;
1811
- }, St = {
1812
- "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
1813
- "%ArrayPrototype%": ["Array", "prototype"],
1814
- "%ArrayProto_entries%": ["Array", "prototype", "entries"],
1815
- "%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
1816
- "%ArrayProto_keys%": ["Array", "prototype", "keys"],
1817
- "%ArrayProto_values%": ["Array", "prototype", "values"],
1818
- "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
1819
- "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
1820
- "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"],
1821
- "%BooleanPrototype%": ["Boolean", "prototype"],
1822
- "%DataViewPrototype%": ["DataView", "prototype"],
1823
- "%DatePrototype%": ["Date", "prototype"],
1824
- "%ErrorPrototype%": ["Error", "prototype"],
1825
- "%EvalErrorPrototype%": ["EvalError", "prototype"],
1826
- "%Float32ArrayPrototype%": ["Float32Array", "prototype"],
1827
- "%Float64ArrayPrototype%": ["Float64Array", "prototype"],
1828
- "%FunctionPrototype%": ["Function", "prototype"],
1829
- "%Generator%": ["GeneratorFunction", "prototype"],
1830
- "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"],
1831
- "%Int8ArrayPrototype%": ["Int8Array", "prototype"],
1832
- "%Int16ArrayPrototype%": ["Int16Array", "prototype"],
1833
- "%Int32ArrayPrototype%": ["Int32Array", "prototype"],
1834
- "%JSONParse%": ["JSON", "parse"],
1835
- "%JSONStringify%": ["JSON", "stringify"],
1836
- "%MapPrototype%": ["Map", "prototype"],
1837
- "%NumberPrototype%": ["Number", "prototype"],
1838
- "%ObjectPrototype%": ["Object", "prototype"],
1839
- "%ObjProto_toString%": ["Object", "prototype", "toString"],
1840
- "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
1841
- "%PromisePrototype%": ["Promise", "prototype"],
1842
- "%PromiseProto_then%": ["Promise", "prototype", "then"],
1843
- "%Promise_all%": ["Promise", "all"],
1844
- "%Promise_reject%": ["Promise", "reject"],
1845
- "%Promise_resolve%": ["Promise", "resolve"],
1846
- "%RangeErrorPrototype%": ["RangeError", "prototype"],
1847
- "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
1848
- "%RegExpPrototype%": ["RegExp", "prototype"],
1849
- "%SetPrototype%": ["Set", "prototype"],
1850
- "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
1851
- "%StringPrototype%": ["String", "prototype"],
1852
- "%SymbolPrototype%": ["Symbol", "prototype"],
1853
- "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
1854
- "%TypedArrayPrototype%": ["TypedArray", "prototype"],
1855
- "%TypeErrorPrototype%": ["TypeError", "prototype"],
1856
- "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
1857
- "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
1858
- "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
1859
- "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
1860
- "%URIErrorPrototype%": ["URIError", "prototype"],
1861
- "%WeakMapPrototype%": ["WeakMap", "prototype"],
1862
- "%WeakSetPrototype%": ["WeakSet", "prototype"]
1863
- }, Ee = Lr, Fe = Ya, ni = Ee.call(Function.call, Array.prototype.concat), ai = Ee.call(Function.apply, Array.prototype.splice), wt = Ee.call(Function.call, String.prototype.replace), Ne = Ee.call(Function.call, String.prototype.slice), ii = Ee.call(Function.call, RegExp.prototype.exec), oi = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, si = /\\(\\)?/g, ui = function(e) {
1864
- var t = Ne(e, 0, 1), n = Ne(e, -1);
1865
- if (t === "%" && n !== "%")
1866
- throw new fe("invalid intrinsic syntax, expected closing `%`");
1867
- if (n === "%" && t !== "%")
1868
- throw new fe("invalid intrinsic syntax, expected opening `%`");
1869
- var a = [];
1870
- return wt(e, oi, function(i, s, l, c) {
1871
- a[a.length] = l ? wt(c, si, "$1") : s || i;
1872
- }), a;
1873
- }, li = function(e, t) {
1874
- var n = e, a;
1875
- if (Fe(St, n) && (a = St[n], n = "%" + a[0] + "%"), Fe(ae, n)) {
1876
- var i = ae[n];
1877
- if (i === le && (i = ti(n)), typeof i > "u" && !t)
1878
- throw new ce("intrinsic " + e + " exists, but is not available. Please file an issue!");
1879
- return {
1880
- alias: a,
1881
- name: n,
1882
- value: i
516
+ var rejected = (value) => {
517
+ try {
518
+ step(generator.throw(value));
519
+ } catch (e) {
520
+ reject(e);
521
+ }
1883
522
  };
1884
- }
1885
- throw new fe("intrinsic " + e + " does not exist!");
1886
- }, Ur = function(e, t) {
1887
- if (typeof e != "string" || e.length === 0)
1888
- throw new ce("intrinsic name must be a non-empty string");
1889
- if (arguments.length > 1 && typeof t != "boolean")
1890
- throw new ce('"allowMissing" argument must be a boolean');
1891
- if (ii(/^%?[^%]*%?$/, e) === null)
1892
- throw new fe("`%` may not be present anywhere but at the beginning and end of the intrinsic name");
1893
- var n = ui(e), a = n.length > 0 ? n[0] : "", i = li("%" + a + "%", t), s = i.name, l = i.value, c = !1, d = i.alias;
1894
- d && (a = d[0], ai(n, ni([0, 1], d)));
1895
- for (var u = 1, o = !0; u < n.length; u += 1) {
1896
- var f = n[u], p = Ne(f, 0, 1), y = Ne(f, -1);
1897
- if ((p === '"' || p === "'" || p === "`" || y === '"' || y === "'" || y === "`") && p !== y)
1898
- throw new fe("property names with quotes must have matching quotes");
1899
- if ((f === "constructor" || !o) && (c = !0), a += "." + f, s = "%" + a + "%", Fe(ae, s))
1900
- l = ae[s];
1901
- else if (l != null) {
1902
- if (!(f in l)) {
1903
- if (!t)
1904
- throw new ce("base intrinsic for " + e + " exists, but the property is not available.");
1905
- return;
523
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
524
+ step((generator = generator.apply(__this, __arguments)).next());
525
+ });
526
+ };
527
+ const useFundingSourcesAddFunds = (fundingSourceId) => {
528
+ const { client } = useShipEngine();
529
+ return useMutation({
530
+ mutationFn: (funds) => __async$i(void 0, null, function* () {
531
+ const result = yield client.fundingSources.addFunds(funds, fundingSourceId);
532
+ return result.data;
533
+ }),
534
+ mutationKey: ["useFundingSourcesAddFunds"],
535
+ onError
536
+ });
537
+ };
538
+
539
+ const useGetFundingSourceById = (fundingSourceId) => {
540
+ const { client } = useShipEngine();
541
+ return useQuery({
542
+ onError,
543
+ queryFn: () => client.fundingSources.get(fundingSourceId),
544
+ queryKey: ["getFundingSourceById"],
545
+ select: (result) => result.data
546
+ });
547
+ };
548
+
549
+ const useListFundingSources = () => {
550
+ const { client } = useShipEngine();
551
+ return useQuery({
552
+ onError,
553
+ queryFn: () => client.fundingSources.list(),
554
+ queryKey: ["useListFundingSources"],
555
+ select: (result) => result.data.fundingSources
556
+ });
557
+ };
558
+
559
+ var __async$h = (__this, __arguments, generator) => {
560
+ return new Promise((resolve, reject) => {
561
+ var fulfilled = (value) => {
562
+ try {
563
+ step(generator.next(value));
564
+ } catch (e) {
565
+ reject(e);
1906
566
  }
1907
- if (ne && u + 1 >= n.length) {
1908
- var v = ne(l, f);
1909
- o = !!v, o && "get" in v && !("originalValue" in v.get) ? l = v.get : l = l[f];
1910
- } else
1911
- o = Fe(l, f), l = l[f];
1912
- o && !c && (ae[s] = l);
1913
- }
1914
- }
1915
- return l;
1916
- }, Or = {}, ci = {
1917
- get exports() {
1918
- return Or;
1919
- },
1920
- set exports(r) {
1921
- Or = r;
1922
- }
567
+ };
568
+ var rejected = (value) => {
569
+ try {
570
+ step(generator.throw(value));
571
+ } catch (e) {
572
+ reject(e);
573
+ }
574
+ };
575
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
576
+ step((generator = generator.apply(__this, __arguments)).next());
577
+ });
1923
578
  };
1924
- (function(r) {
1925
- var e = Lr, t = Ur, n = t("%Function.prototype.apply%"), a = t("%Function.prototype.call%"), i = t("%Reflect.apply%", !0) || e.call(a, n), s = t("%Object.getOwnPropertyDescriptor%", !0), l = t("%Object.defineProperty%", !0), c = t("%Math.max%");
1926
- if (l)
1927
- try {
1928
- l({}, "a", { value: 1 });
1929
- } catch {
1930
- l = null;
1931
- }
1932
- r.exports = function(o) {
1933
- var f = i(e, a, arguments);
1934
- if (s && l) {
1935
- var p = s(f, "length");
1936
- p.configurable && l(
1937
- f,
1938
- "length",
1939
- { value: 1 + c(0, o.length - (arguments.length - 1)) }
579
+ const useRegisterCarrier = () => {
580
+ const { client } = useShipEngine();
581
+ return useMutation({
582
+ mutationFn: (carrier) => __async$h(void 0, null, function* () {
583
+ const result = yield client.fundingSources.registerCarrier(carrier);
584
+ return result.data;
585
+ }),
586
+ mutationKey: ["useRegisterCarrier"],
587
+ onError
588
+ });
589
+ };
590
+
591
+ var __async$g = (__this, __arguments, generator) => {
592
+ return new Promise((resolve, reject) => {
593
+ var fulfilled = (value) => {
594
+ try {
595
+ step(generator.next(value));
596
+ } catch (e) {
597
+ reject(e);
598
+ }
599
+ };
600
+ var rejected = (value) => {
601
+ try {
602
+ step(generator.throw(value));
603
+ } catch (e) {
604
+ reject(e);
605
+ }
606
+ };
607
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
608
+ step((generator = generator.apply(__this, __arguments)).next());
609
+ });
610
+ };
611
+ const useUpdateFundingSource = () => {
612
+ const { client } = useShipEngine();
613
+ return useMutation({
614
+ mutationFn: (_0) => __async$g(void 0, [_0], function* ({
615
+ billingInfo,
616
+ creditCardInfo,
617
+ fundingSourceId
618
+ }) {
619
+ const result = yield client.fundingSources.update(
620
+ billingInfo,
621
+ creditCardInfo,
622
+ fundingSourceId
1940
623
  );
1941
- }
1942
- return f;
1943
- };
1944
- var d = function() {
1945
- return i(e, n, arguments);
1946
- };
1947
- l ? l(r.exports, "apply", { value: d }) : r.exports.apply = d;
1948
- })(ci);
1949
- var fn = Ur, pn = Or, fi = pn(fn("String.prototype.indexOf")), pi = function(e, t) {
1950
- var n = fn(e, !!t);
1951
- return typeof n == "function" && fi(e, ".prototype.") > -1 ? pn(n) : n;
1952
- };
1953
- const di = {}, hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1954
- __proto__: null,
1955
- default: di
1956
- }, Symbol.toStringTag, { value: "Module" })), yi = /* @__PURE__ */ Tn(hi);
1957
- var qr = typeof Map == "function" && Map.prototype, sr = Object.getOwnPropertyDescriptor && qr ? Object.getOwnPropertyDescriptor(Map.prototype, "size") : null, $e = qr && sr && typeof sr.get == "function" ? sr.get : null, bt = qr && Map.prototype.forEach, Mr = typeof Set == "function" && Set.prototype, ur = Object.getOwnPropertyDescriptor && Mr ? Object.getOwnPropertyDescriptor(Set.prototype, "size") : null, _e = Mr && ur && typeof ur.get == "function" ? ur.get : null, Et = Mr && Set.prototype.forEach, vi = typeof WeakMap == "function" && WeakMap.prototype, ge = vi ? WeakMap.prototype.has : null, mi = typeof WeakSet == "function" && WeakSet.prototype, Se = mi ? WeakSet.prototype.has : null, gi = typeof WeakRef == "function" && WeakRef.prototype, At = gi ? WeakRef.prototype.deref : null, Si = Boolean.prototype.valueOf, wi = Object.prototype.toString, bi = Function.prototype.toString, Ei = String.prototype.match, zr = String.prototype.slice, Q = String.prototype.replace, Ai = String.prototype.toUpperCase, Ot = String.prototype.toLowerCase, dn = RegExp.prototype.test, Pt = Array.prototype.concat, j = Array.prototype.join, Oi = Array.prototype.slice, It = Math.floor, Pr = typeof BigInt == "function" ? BigInt.prototype.valueOf : null, lr = Object.getOwnPropertySymbols, Ir = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? Symbol.prototype.toString : null, pe = typeof Symbol == "function" && typeof Symbol.iterator == "object", F = typeof Symbol == "function" && Symbol.toStringTag && (typeof Symbol.toStringTag === pe || "symbol") ? Symbol.toStringTag : null, hn = Object.prototype.propertyIsEnumerable, Rt = (typeof Reflect == "function" ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function(r) {
1958
- return r.__proto__;
1959
- } : null);
1960
- function xt(r, e) {
1961
- if (r === 1 / 0 || r === -1 / 0 || r !== r || r && r > -1e3 && r < 1e3 || dn.call(/e/, e))
1962
- return e;
1963
- var t = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
1964
- if (typeof r == "number") {
1965
- var n = r < 0 ? -It(-r) : It(r);
1966
- if (n !== r) {
1967
- var a = String(n), i = zr.call(e, a.length + 1);
1968
- return Q.call(a, t, "$&_") + "." + Q.call(Q.call(i, /([0-9]{3})/g, "$&_"), /_$/, "");
1969
- }
1970
- }
1971
- return Q.call(e, t, "$&_");
1972
- }
1973
- var Rr = yi, Ct = Rr.custom, Ft = vn(Ct) ? Ct : null, Pi = function r(e, t, n, a) {
1974
- var i = t || {};
1975
- if (J(i, "quoteStyle") && i.quoteStyle !== "single" && i.quoteStyle !== "double")
1976
- throw new TypeError('option "quoteStyle" must be "single" or "double"');
1977
- if (J(i, "maxStringLength") && (typeof i.maxStringLength == "number" ? i.maxStringLength < 0 && i.maxStringLength !== 1 / 0 : i.maxStringLength !== null))
1978
- throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
1979
- var s = J(i, "customInspect") ? i.customInspect : !0;
1980
- if (typeof s != "boolean" && s !== "symbol")
1981
- throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");
1982
- if (J(i, "indent") && i.indent !== null && i.indent !== " " && !(parseInt(i.indent, 10) === i.indent && i.indent > 0))
1983
- throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
1984
- if (J(i, "numericSeparator") && typeof i.numericSeparator != "boolean")
1985
- throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
1986
- var l = i.numericSeparator;
1987
- if (typeof e > "u")
1988
- return "undefined";
1989
- if (e === null)
1990
- return "null";
1991
- if (typeof e == "boolean")
1992
- return e ? "true" : "false";
1993
- if (typeof e == "string")
1994
- return gn(e, i);
1995
- if (typeof e == "number") {
1996
- if (e === 0)
1997
- return 1 / 0 / e > 0 ? "0" : "-0";
1998
- var c = String(e);
1999
- return l ? xt(e, c) : c;
2000
- }
2001
- if (typeof e == "bigint") {
2002
- var d = String(e) + "n";
2003
- return l ? xt(e, d) : d;
2004
- }
2005
- var u = typeof i.depth > "u" ? 5 : i.depth;
2006
- if (typeof n > "u" && (n = 0), n >= u && u > 0 && typeof e == "object")
2007
- return xr(e) ? "[Array]" : "[Object]";
2008
- var o = ji(i, n);
2009
- if (typeof a > "u")
2010
- a = [];
2011
- else if (mn(a, e) >= 0)
2012
- return "[Circular]";
2013
- function f(B, L, K) {
2014
- if (L && (a = Oi.call(a), a.push(L)), K) {
2015
- var ye = {
2016
- depth: i.depth
2017
- };
2018
- return J(i, "quoteStyle") && (ye.quoteStyle = i.quoteStyle), r(B, ye, n + 1, a);
2019
- }
2020
- return r(B, i, n + 1, a);
2021
- }
2022
- if (typeof e == "function" && !Nt(e)) {
2023
- var p = Di(e), y = Ae(e, f);
2024
- return "[Function" + (p ? ": " + p : " (anonymous)") + "]" + (y.length > 0 ? " { " + j.call(y, ", ") + " }" : "");
2025
- }
2026
- if (vn(e)) {
2027
- var v = pe ? Q.call(String(e), /^(Symbol\(.*\))_[^)]*$/, "$1") : Ir.call(e);
2028
- return typeof e == "object" && !pe ? ve(v) : v;
2029
- }
2030
- if (qi(e)) {
2031
- for (var m = "<" + Ot.call(String(e.nodeName)), h = e.attributes || [], g = 0; g < h.length; g++)
2032
- m += " " + h[g].name + "=" + yn(Ii(h[g].value), "double", i);
2033
- return m += ">", e.childNodes && e.childNodes.length && (m += "..."), m += "</" + Ot.call(String(e.nodeName)) + ">", m;
2034
- }
2035
- if (xr(e)) {
2036
- if (e.length === 0)
2037
- return "[]";
2038
- var A = Ae(e, f);
2039
- return o && !zi(A) ? "[" + Cr(A, o) + "]" : "[ " + j.call(A, ", ") + " ]";
2040
- }
2041
- if (xi(e)) {
2042
- var S = Ae(e, f);
2043
- return !("cause" in Error.prototype) && "cause" in e && !hn.call(e, "cause") ? "{ [" + String(e) + "] " + j.call(Pt.call("[cause]: " + f(e.cause), S), ", ") + " }" : S.length === 0 ? "[" + String(e) + "]" : "{ [" + String(e) + "] " + j.call(S, ", ") + " }";
2044
- }
2045
- if (typeof e == "object" && s) {
2046
- if (Ft && typeof e[Ft] == "function" && Rr)
2047
- return Rr(e, { depth: u - n });
2048
- if (s !== "symbol" && typeof e.inspect == "function")
2049
- return e.inspect();
2050
- }
2051
- if (ki(e)) {
2052
- var R = [];
2053
- return bt && bt.call(e, function(B, L) {
2054
- R.push(f(L, e, !0) + " => " + f(B, e));
2055
- }), $t("Map", $e.call(e), R, o);
2056
- }
2057
- if (Li(e)) {
2058
- var q = [];
2059
- return Et && Et.call(e, function(B) {
2060
- q.push(f(B, e));
2061
- }), $t("Set", _e.call(e), q, o);
2062
- }
2063
- if (Ti(e))
2064
- return cr("WeakMap");
2065
- if (Ui(e))
2066
- return cr("WeakSet");
2067
- if (Bi(e))
2068
- return cr("WeakRef");
2069
- if (Fi(e))
2070
- return ve(f(Number(e)));
2071
- if ($i(e))
2072
- return ve(f(Pr.call(e)));
2073
- if (Ni(e))
2074
- return ve(Si.call(e));
2075
- if (Ci(e))
2076
- return ve(f(String(e)));
2077
- if (!Ri(e) && !Nt(e)) {
2078
- var $ = Ae(e, f), V = Rt ? Rt(e) === Object.prototype : e instanceof Object || e.constructor === Object, U = e instanceof Object ? "" : "null prototype", O = !V && F && Object(e) === e && F in e ? zr.call(Y(e), 8, -1) : U ? "Object" : "", _ = V || typeof e.constructor != "function" ? "" : e.constructor.name ? e.constructor.name + " " : "", D = _ + (O || U ? "[" + j.call(Pt.call([], O || [], U || []), ": ") + "] " : "");
2079
- return $.length === 0 ? D + "{}" : o ? D + "{" + Cr($, o) + "}" : D + "{ " + j.call($, ", ") + " }";
2080
- }
2081
- return String(e);
624
+ return result.data;
625
+ }),
626
+ mutationKey: ["useUpdateFundingSource"],
627
+ onError
628
+ });
2082
629
  };
2083
- function yn(r, e, t) {
2084
- var n = (t.quoteStyle || e) === "double" ? '"' : "'";
2085
- return n + r + n;
2086
- }
2087
- function Ii(r) {
2088
- return Q.call(String(r), /"/g, "&quot;");
2089
- }
2090
- function xr(r) {
2091
- return Y(r) === "[object Array]" && (!F || !(typeof r == "object" && F in r));
2092
- }
2093
- function Ri(r) {
2094
- return Y(r) === "[object Date]" && (!F || !(typeof r == "object" && F in r));
2095
- }
2096
- function Nt(r) {
2097
- return Y(r) === "[object RegExp]" && (!F || !(typeof r == "object" && F in r));
2098
- }
2099
- function xi(r) {
2100
- return Y(r) === "[object Error]" && (!F || !(typeof r == "object" && F in r));
2101
- }
2102
- function Ci(r) {
2103
- return Y(r) === "[object String]" && (!F || !(typeof r == "object" && F in r));
2104
- }
2105
- function Fi(r) {
2106
- return Y(r) === "[object Number]" && (!F || !(typeof r == "object" && F in r));
2107
- }
2108
- function Ni(r) {
2109
- return Y(r) === "[object Boolean]" && (!F || !(typeof r == "object" && F in r));
2110
- }
2111
- function vn(r) {
2112
- if (pe)
2113
- return r && typeof r == "object" && r instanceof Symbol;
2114
- if (typeof r == "symbol")
2115
- return !0;
2116
- if (!r || typeof r != "object" || !Ir)
2117
- return !1;
2118
- try {
2119
- return Ir.call(r), !0;
2120
- } catch {
2121
- }
2122
- return !1;
2123
- }
2124
- function $i(r) {
2125
- if (!r || typeof r != "object" || !Pr)
2126
- return !1;
2127
- try {
2128
- return Pr.call(r), !0;
2129
- } catch {
2130
- }
2131
- return !1;
2132
- }
2133
- var _i = Object.prototype.hasOwnProperty || function(r) {
2134
- return r in this;
630
+
631
+ const useGetInsuranceAccount = (insuranceProvider) => {
632
+ const { client } = useShipEngine();
633
+ return useQuery({
634
+ enabled: insuranceProvider !== void 0,
635
+ onError,
636
+ queryFn: () => {
637
+ if (insuranceProvider)
638
+ return client.insurance.get(insuranceProvider);
639
+ return Promise.reject(new Error("insuranceProvider is required"));
640
+ },
641
+ queryKey: ["useGetInsuranceAccount", insuranceProvider],
642
+ select: (result) => result.data
643
+ });
2135
644
  };
2136
- function J(r, e) {
2137
- return _i.call(r, e);
2138
- }
2139
- function Y(r) {
2140
- return wi.call(r);
2141
- }
2142
- function Di(r) {
2143
- if (r.name)
2144
- return r.name;
2145
- var e = Ei.call(bi.call(r), /^function\s*([\w$]+)/);
2146
- return e ? e[1] : null;
2147
- }
2148
- function mn(r, e) {
2149
- if (r.indexOf)
2150
- return r.indexOf(e);
2151
- for (var t = 0, n = r.length; t < n; t++)
2152
- if (r[t] === e)
2153
- return t;
2154
- return -1;
2155
- }
2156
- function ki(r) {
2157
- if (!$e || !r || typeof r != "object")
2158
- return !1;
2159
- try {
2160
- $e.call(r);
2161
- try {
2162
- _e.call(r);
2163
- } catch {
2164
- return !0;
645
+
646
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
647
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
648
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
649
+ var __objRest$5 = (source, exclude) => {
650
+ var target = {};
651
+ for (var prop in source)
652
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
653
+ target[prop] = source[prop];
654
+ if (source != null && __getOwnPropSymbols$6)
655
+ for (var prop of __getOwnPropSymbols$6(source)) {
656
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
657
+ target[prop] = source[prop];
2165
658
  }
2166
- return r instanceof Map;
2167
- } catch {
2168
- }
2169
- return !1;
2170
- }
2171
- function Ti(r) {
2172
- if (!ge || !r || typeof r != "object")
2173
- return !1;
2174
- try {
2175
- ge.call(r, ge);
2176
- try {
2177
- Se.call(r, Se);
2178
- } catch {
2179
- return !0;
2180
- }
2181
- return r instanceof WeakMap;
2182
- } catch {
2183
- }
2184
- return !1;
2185
- }
2186
- function Bi(r) {
2187
- if (!At || !r || typeof r != "object")
2188
- return !1;
2189
- try {
2190
- return At.call(r), !0;
2191
- } catch {
2192
- }
2193
- return !1;
2194
- }
2195
- function Li(r) {
2196
- if (!_e || !r || typeof r != "object")
2197
- return !1;
2198
- try {
2199
- _e.call(r);
2200
- try {
2201
- $e.call(r);
2202
- } catch {
2203
- return !0;
2204
- }
2205
- return r instanceof Set;
2206
- } catch {
2207
- }
2208
- return !1;
2209
- }
2210
- function Ui(r) {
2211
- if (!Se || !r || typeof r != "object")
2212
- return !1;
2213
- try {
2214
- Se.call(r, Se);
2215
- try {
2216
- ge.call(r, ge);
2217
- } catch {
2218
- return !0;
2219
- }
2220
- return r instanceof WeakSet;
2221
- } catch {
2222
- }
2223
- return !1;
2224
- }
2225
- function qi(r) {
2226
- return !r || typeof r != "object" ? !1 : typeof HTMLElement < "u" && r instanceof HTMLElement ? !0 : typeof r.nodeName == "string" && typeof r.getAttribute == "function";
2227
- }
2228
- function gn(r, e) {
2229
- if (r.length > e.maxStringLength) {
2230
- var t = r.length - e.maxStringLength, n = "... " + t + " more character" + (t > 1 ? "s" : "");
2231
- return gn(zr.call(r, 0, e.maxStringLength), e) + n;
2232
- }
2233
- var a = Q.call(Q.call(r, /(['\\])/g, "\\$1"), /[\x00-\x1f]/g, Mi);
2234
- return yn(a, "single", e);
2235
- }
2236
- function Mi(r) {
2237
- var e = r.charCodeAt(0), t = {
2238
- 8: "b",
2239
- 9: "t",
2240
- 10: "n",
2241
- 12: "f",
2242
- 13: "r"
2243
- }[e];
2244
- return t ? "\\" + t : "\\x" + (e < 16 ? "0" : "") + Ai.call(e.toString(16));
2245
- }
2246
- function ve(r) {
2247
- return "Object(" + r + ")";
2248
- }
2249
- function cr(r) {
2250
- return r + " { ? }";
2251
- }
2252
- function $t(r, e, t, n) {
2253
- var a = n ? Cr(t, n) : j.call(t, ", ");
2254
- return r + " (" + e + ") {" + a + "}";
2255
- }
2256
- function zi(r) {
2257
- for (var e = 0; e < r.length; e++)
2258
- if (mn(r[e], `
2259
- `) >= 0)
2260
- return !1;
2261
- return !0;
2262
- }
2263
- function ji(r, e) {
2264
- var t;
2265
- if (r.indent === " ")
2266
- t = " ";
2267
- else if (typeof r.indent == "number" && r.indent > 0)
2268
- t = j.call(Array(r.indent + 1), " ");
2269
- else
2270
- return null;
2271
- return {
2272
- base: t,
2273
- prev: j.call(Array(e + 1), t)
2274
- };
2275
- }
2276
- function Cr(r, e) {
2277
- if (r.length === 0)
2278
- return "";
2279
- var t = `
2280
- ` + e.prev + e.base;
2281
- return t + j.call(r, "," + t) + `
2282
- ` + e.prev;
2283
- }
2284
- function Ae(r, e) {
2285
- var t = xr(r), n = [];
2286
- if (t) {
2287
- n.length = r.length;
2288
- for (var a = 0; a < r.length; a++)
2289
- n[a] = J(r, a) ? e(r[a], r) : "";
2290
- }
2291
- var i = typeof lr == "function" ? lr(r) : [], s;
2292
- if (pe) {
2293
- s = {};
2294
- for (var l = 0; l < i.length; l++)
2295
- s["$" + i[l]] = i[l];
2296
- }
2297
- for (var c in r)
2298
- J(r, c) && (t && String(Number(c)) === c && c < r.length || pe && s["$" + c] instanceof Symbol || (dn.call(/[^\w$]/, c) ? n.push(e(c, r) + ": " + e(r[c], r)) : n.push(c + ": " + e(r[c], r))));
2299
- if (typeof lr == "function")
2300
- for (var d = 0; d < i.length; d++)
2301
- hn.call(r, i[d]) && n.push("[" + e(i[d]) + "]: " + e(r[i[d]], r));
2302
- return n;
2303
- }
2304
- var jr = Ur, he = pi, Wi = Pi, Gi = jr("%TypeError%"), Oe = jr("%WeakMap%", !0), Pe = jr("%Map%", !0), Ki = he("WeakMap.prototype.get", !0), Hi = he("WeakMap.prototype.set", !0), Vi = he("WeakMap.prototype.has", !0), Ji = he("Map.prototype.get", !0), Qi = he("Map.prototype.set", !0), Xi = he("Map.prototype.has", !0), Wr = function(r, e) {
2305
- for (var t = r, n; (n = t.next) !== null; t = n)
2306
- if (n.key === e)
2307
- return t.next = n.next, n.next = r.next, r.next = n, n;
2308
- }, Yi = function(r, e) {
2309
- var t = Wr(r, e);
2310
- return t && t.value;
2311
- }, Zi = function(r, e, t) {
2312
- var n = Wr(r, e);
2313
- n ? n.value = t : r.next = {
2314
- // eslint-disable-line no-param-reassign
2315
- key: e,
2316
- next: r.next,
2317
- value: t
2318
- };
2319
- }, eo = function(r, e) {
2320
- return !!Wr(r, e);
2321
- }, ro = function() {
2322
- var e, t, n, a = {
2323
- assert: function(i) {
2324
- if (!a.has(i))
2325
- throw new Gi("Side channel does not contain " + Wi(i));
659
+ return target;
660
+ };
661
+ var __async$f = (__this, __arguments, generator) => {
662
+ return new Promise((resolve, reject) => {
663
+ var fulfilled = (value) => {
664
+ try {
665
+ step(generator.next(value));
666
+ } catch (e) {
667
+ reject(e);
668
+ }
669
+ };
670
+ var rejected = (value) => {
671
+ try {
672
+ step(generator.throw(value));
673
+ } catch (e) {
674
+ reject(e);
675
+ }
676
+ };
677
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
678
+ step((generator = generator.apply(__this, __arguments)).next());
679
+ });
680
+ };
681
+ const useCreateLabel = () => {
682
+ const { client } = useShipEngine();
683
+ return useMutation({
684
+ mutationFn: (_a) => __async$f(void 0, null, function* () {
685
+ var _b = _a, { rateId } = _b, options = __objRest$5(_b, ["rateId"]);
686
+ const result = yield client.labels.createByRateId(rateId, options);
687
+ return result.data;
688
+ }),
689
+ mutationKey: ["useCreateLabel"],
690
+ onError
691
+ });
692
+ };
693
+
694
+ const useGetLabel = (labelId) => {
695
+ const { client } = useShipEngine();
696
+ return useQuery({
697
+ enabled: labelId !== void 0,
698
+ onError,
699
+ queryFn: () => {
700
+ if (labelId)
701
+ return client.labels.get(labelId);
702
+ return Promise.reject(new Error("labelId is require"));
2326
703
  },
2327
- get: function(i) {
2328
- if (Oe && i && (typeof i == "object" || typeof i == "function")) {
2329
- if (e)
2330
- return Ki(e, i);
2331
- } else if (Pe) {
2332
- if (t)
2333
- return Ji(t, i);
2334
- } else if (n)
2335
- return Yi(n, i);
704
+ queryKey: ["useGetLabel", labelId],
705
+ select: (result) => result.data
706
+ });
707
+ };
708
+
709
+ const useListLabels = (params) => {
710
+ const { client } = useShipEngine();
711
+ return useQuery({
712
+ enabled: params && Object.values(params).some((v) => v !== void 0),
713
+ onError,
714
+ queryFn: () => client.labels.list(params),
715
+ queryKey: ["useListLabels", params],
716
+ select: (result) => result.data.labels
717
+ });
718
+ };
719
+
720
+ var __async$e = (__this, __arguments, generator) => {
721
+ return new Promise((resolve, reject) => {
722
+ var fulfilled = (value) => {
723
+ try {
724
+ step(generator.next(value));
725
+ } catch (e) {
726
+ reject(e);
727
+ }
728
+ };
729
+ var rejected = (value) => {
730
+ try {
731
+ step(generator.throw(value));
732
+ } catch (e) {
733
+ reject(e);
734
+ }
735
+ };
736
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
737
+ step((generator = generator.apply(__this, __arguments)).next());
738
+ });
739
+ };
740
+ const useVoidLabel = () => {
741
+ const { client } = useShipEngine();
742
+ return useMutation({
743
+ mutationFn: (labelId) => __async$e(void 0, null, function* () {
744
+ const result = yield client.labels.void(labelId);
745
+ return result.data;
746
+ }),
747
+ mutationKey: ["useVoidLabel"],
748
+ onError
749
+ });
750
+ };
751
+
752
+ const useListOrderSources = () => {
753
+ const { client } = useShipEngine();
754
+ return useQuery({
755
+ onError,
756
+ queryFn: () => client.orderSources.list(),
757
+ queryKey: ["useListOrderSources"],
758
+ select: (result) => result.data.orderSources
759
+ });
760
+ };
761
+
762
+ var __async$d = (__this, __arguments, generator) => {
763
+ return new Promise((resolve, reject) => {
764
+ var fulfilled = (value) => {
765
+ try {
766
+ step(generator.next(value));
767
+ } catch (e) {
768
+ reject(e);
769
+ }
770
+ };
771
+ var rejected = (value) => {
772
+ try {
773
+ step(generator.throw(value));
774
+ } catch (e) {
775
+ reject(e);
776
+ }
777
+ };
778
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
779
+ step((generator = generator.apply(__this, __arguments)).next());
780
+ });
781
+ };
782
+ const useRefreshOrderSourceAsync = () => {
783
+ const { client } = useShipEngine();
784
+ return useMutation({
785
+ mutationFn: (orderSourceId) => __async$d(void 0, null, function* () {
786
+ const result = yield client.orderSources.refresh(orderSourceId);
787
+ return result.data;
788
+ }),
789
+ mutationKey: ["useRefreshOrderSourceAsync"]
790
+ });
791
+ };
792
+ const useRefreshOrderSource = () => {
793
+ const { client } = useShipEngine();
794
+ const { mutateAsync: refreshOrderSourceAsync } = useRefreshOrderSourceAsync();
795
+ return useMutation({
796
+ mutationFn: (orderSourceId) => __async$d(void 0, null, function* () {
797
+ yield refreshOrderSourceAsync(orderSourceId);
798
+ const waitResult = yield retryUntil(() => __async$d(void 0, null, function* () {
799
+ const { data: checkResult } = yield client.orderSources.get(orderSourceId);
800
+ if (["preparing_update", "updating"].includes(checkResult.refreshInfo.status)) {
801
+ throw new SE.CodedError("Order source is still refreshing");
802
+ }
803
+ return checkResult;
804
+ }), 20);
805
+ return waitResult;
806
+ }),
807
+ mutationKey: ["useRefreshOrderSource"],
808
+ onError
809
+ });
810
+ };
811
+
812
+ var __async$c = (__this, __arguments, generator) => {
813
+ return new Promise((resolve, reject) => {
814
+ var fulfilled = (value) => {
815
+ try {
816
+ step(generator.next(value));
817
+ } catch (e) {
818
+ reject(e);
819
+ }
820
+ };
821
+ var rejected = (value) => {
822
+ try {
823
+ step(generator.throw(value));
824
+ } catch (e) {
825
+ reject(e);
826
+ }
827
+ };
828
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
829
+ step((generator = generator.apply(__this, __arguments)).next());
830
+ });
831
+ };
832
+ const useCreateRateCard = () => {
833
+ const { client } = useShipEngine();
834
+ return useMutation({
835
+ mutationFn: (rateCard) => __async$c(void 0, null, function* () {
836
+ const result = yield client.rateCards.create(rateCard);
837
+ return result.data;
838
+ }),
839
+ mutationKey: ["useCreateRateCard"],
840
+ onError
841
+ });
842
+ };
843
+
844
+ const useDownloadRateCard = (rateCardId) => {
845
+ const { client } = useShipEngine();
846
+ return useQuery({
847
+ enabled: !!rateCardId.length,
848
+ onError,
849
+ queryFn: () => {
850
+ return client.rateCards.download(rateCardId);
2336
851
  },
2337
- has: function(i) {
2338
- if (Oe && i && (typeof i == "object" || typeof i == "function")) {
2339
- if (e)
2340
- return Vi(e, i);
2341
- } else if (Pe) {
2342
- if (t)
2343
- return Xi(t, i);
2344
- } else if (n)
2345
- return eo(n, i);
2346
- return !1;
852
+ queryKey: ["useDownloadRateCard", rateCardId]
853
+ });
854
+ };
855
+
856
+ const useGetRateCardById = (rateCardId) => {
857
+ const { client } = useShipEngine();
858
+ return useQuery({
859
+ enabled: !!rateCardId,
860
+ onError,
861
+ queryFn: () => {
862
+ return client.rateCards.get(rateCardId);
2347
863
  },
2348
- set: function(i, s) {
2349
- Oe && i && (typeof i == "object" || typeof i == "function") ? (e || (e = new Oe()), Hi(e, i, s)) : Pe ? (t || (t = new Pe()), Qi(t, i, s)) : (n || (n = { key: {}, next: null }), Zi(n, i, s));
2350
- }
2351
- };
2352
- return a;
2353
- }, to = String.prototype.replace, no = /%20/g, fr = {
2354
- RFC1738: "RFC1738",
2355
- RFC3986: "RFC3986"
2356
- }, Gr = {
2357
- default: fr.RFC3986,
2358
- formatters: {
2359
- RFC1738: function(r) {
2360
- return to.call(r, no, "+");
864
+ queryKey: ["useGetRateCardById", rateCardId],
865
+ select: (result) => result.data
866
+ });
867
+ };
868
+
869
+ const useListRateCards = (carrierIds) => {
870
+ const { client } = useShipEngine();
871
+ return useQuery({
872
+ enabled: !!carrierIds.length,
873
+ onError,
874
+ queryFn: () => {
875
+ return client.rateCards.list(carrierIds);
2361
876
  },
2362
- RFC3986: function(r) {
2363
- return String(r);
2364
- }
2365
- },
2366
- RFC1738: fr.RFC1738,
2367
- RFC3986: fr.RFC3986
2368
- }, ao = Gr, pr = Object.prototype.hasOwnProperty, te = Array.isArray, M = function() {
2369
- for (var r = [], e = 0; e < 256; ++e)
2370
- r.push("%" + ((e < 16 ? "0" : "") + e.toString(16)).toUpperCase());
2371
- return r;
2372
- }(), io = function(e) {
2373
- for (; e.length > 1; ) {
2374
- var t = e.pop(), n = t.obj[t.prop];
2375
- if (te(n)) {
2376
- for (var a = [], i = 0; i < n.length; ++i)
2377
- typeof n[i] < "u" && a.push(n[i]);
2378
- t.obj[t.prop] = a;
2379
- }
2380
- }
2381
- }, Sn = function(e, t) {
2382
- for (var n = t && t.plainObjects ? /* @__PURE__ */ Object.create(null) : {}, a = 0; a < e.length; ++a)
2383
- typeof e[a] < "u" && (n[a] = e[a]);
2384
- return n;
2385
- }, oo = function r(e, t, n) {
2386
- if (!t)
2387
- return e;
2388
- if (typeof t != "object") {
2389
- if (te(e))
2390
- e.push(t);
2391
- else if (e && typeof e == "object")
2392
- (n && (n.plainObjects || n.allowPrototypes) || !pr.call(Object.prototype, t)) && (e[t] = !0);
2393
- else
2394
- return [e, t];
2395
- return e;
2396
- }
2397
- if (!e || typeof e != "object")
2398
- return [e].concat(t);
2399
- var a = e;
2400
- return te(e) && !te(t) && (a = Sn(e, n)), te(e) && te(t) ? (t.forEach(function(i, s) {
2401
- if (pr.call(e, s)) {
2402
- var l = e[s];
2403
- l && typeof l == "object" && i && typeof i == "object" ? e[s] = r(l, i, n) : e.push(i);
2404
- } else
2405
- e[s] = i;
2406
- }), e) : Object.keys(t).reduce(function(i, s) {
2407
- var l = t[s];
2408
- return pr.call(i, s) ? i[s] = r(i[s], l, n) : i[s] = l, i;
2409
- }, a);
2410
- }, so = function(e, t) {
2411
- return Object.keys(t).reduce(function(n, a) {
2412
- return n[a] = t[a], n;
2413
- }, e);
2414
- }, uo = function(r, e, t) {
2415
- var n = r.replace(/\+/g, " ");
2416
- if (t === "iso-8859-1")
2417
- return n.replace(/%[0-9a-f]{2}/gi, unescape);
2418
- try {
2419
- return decodeURIComponent(n);
2420
- } catch {
2421
- return n;
2422
- }
2423
- }, lo = function(e, t, n, a, i) {
2424
- if (e.length === 0)
2425
- return e;
2426
- var s = e;
2427
- if (typeof e == "symbol" ? s = Symbol.prototype.toString.call(e) : typeof e != "string" && (s = String(e)), n === "iso-8859-1")
2428
- return escape(s).replace(/%u[0-9a-f]{4}/gi, function(u) {
2429
- return "%26%23" + parseInt(u.slice(2), 16) + "%3B";
2430
- });
2431
- for (var l = "", c = 0; c < s.length; ++c) {
2432
- var d = s.charCodeAt(c);
2433
- if (d === 45 || d === 46 || d === 95 || d === 126 || d >= 48 && d <= 57 || d >= 65 && d <= 90 || d >= 97 && d <= 122 || i === ao.RFC1738 && (d === 40 || d === 41)) {
2434
- l += s.charAt(c);
2435
- continue;
2436
- }
2437
- if (d < 128) {
2438
- l = l + M[d];
2439
- continue;
2440
- }
2441
- if (d < 2048) {
2442
- l = l + (M[192 | d >> 6] + M[128 | d & 63]);
2443
- continue;
2444
- }
2445
- if (d < 55296 || d >= 57344) {
2446
- l = l + (M[224 | d >> 12] + M[128 | d >> 6 & 63] + M[128 | d & 63]);
2447
- continue;
2448
- }
2449
- c += 1, d = 65536 + ((d & 1023) << 10 | s.charCodeAt(c) & 1023), l += M[240 | d >> 18] + M[128 | d >> 12 & 63] + M[128 | d >> 6 & 63] + M[128 | d & 63];
2450
- }
2451
- return l;
2452
- }, co = function(e) {
2453
- for (var t = [{ obj: { o: e }, prop: "o" }], n = [], a = 0; a < t.length; ++a)
2454
- for (var i = t[a], s = i.obj[i.prop], l = Object.keys(s), c = 0; c < l.length; ++c) {
2455
- var d = l[c], u = s[d];
2456
- typeof u == "object" && u !== null && n.indexOf(u) === -1 && (t.push({ obj: s, prop: d }), n.push(u));
2457
- }
2458
- return io(t), e;
2459
- }, fo = function(e) {
2460
- return Object.prototype.toString.call(e) === "[object RegExp]";
2461
- }, po = function(e) {
2462
- return !e || typeof e != "object" ? !1 : !!(e.constructor && e.constructor.isBuffer && e.constructor.isBuffer(e));
2463
- }, ho = function(e, t) {
2464
- return [].concat(e, t);
2465
- }, yo = function(e, t) {
2466
- if (te(e)) {
2467
- for (var n = [], a = 0; a < e.length; a += 1)
2468
- n.push(t(e[a]));
2469
- return n;
2470
- }
2471
- return t(e);
2472
- }, wn = {
2473
- arrayToObject: Sn,
2474
- assign: so,
2475
- combine: ho,
2476
- compact: co,
2477
- decode: uo,
2478
- encode: lo,
2479
- isBuffer: po,
2480
- isRegExp: fo,
2481
- maybeMap: yo,
2482
- merge: oo
2483
- }, bn = ro, Fr = wn, we = Gr, vo = Object.prototype.hasOwnProperty, _t = {
2484
- brackets: function(e) {
2485
- return e + "[]";
2486
- },
2487
- comma: "comma",
2488
- indices: function(e, t) {
2489
- return e + "[" + t + "]";
2490
- },
2491
- repeat: function(e) {
2492
- return e;
2493
- }
2494
- }, H = Array.isArray, mo = String.prototype.split, go = Array.prototype.push, En = function(r, e) {
2495
- go.apply(r, H(e) ? e : [e]);
2496
- }, So = Date.prototype.toISOString, Dt = we.default, x = {
2497
- addQueryPrefix: !1,
2498
- allowDots: !1,
2499
- charset: "utf-8",
2500
- charsetSentinel: !1,
2501
- delimiter: "&",
2502
- encode: !0,
2503
- encoder: Fr.encode,
2504
- encodeValuesOnly: !1,
2505
- format: Dt,
2506
- formatter: we.formatters[Dt],
2507
- // deprecated
2508
- indices: !1,
2509
- serializeDate: function(e) {
2510
- return So.call(e);
2511
- },
2512
- skipNulls: !1,
2513
- strictNullHandling: !1
2514
- }, wo = function(e) {
2515
- return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "symbol" || typeof e == "bigint";
2516
- }, dr = {}, bo = function r(e, t, n, a, i, s, l, c, d, u, o, f, p, y, v, m) {
2517
- for (var h = e, g = m, A = 0, S = !1; (g = g.get(dr)) !== void 0 && !S; ) {
2518
- var R = g.get(e);
2519
- if (A += 1, typeof R < "u") {
2520
- if (R === A)
2521
- throw new RangeError("Cyclic object value");
2522
- S = !0;
2523
- }
2524
- typeof g.get(dr) > "u" && (A = 0);
2525
- }
2526
- if (typeof c == "function" ? h = c(t, h) : h instanceof Date ? h = o(h) : n === "comma" && H(h) && (h = Fr.maybeMap(h, function(Le) {
2527
- return Le instanceof Date ? o(Le) : Le;
2528
- })), h === null) {
2529
- if (i)
2530
- return l && !y ? l(t, x.encoder, v, "key", f) : t;
2531
- h = "";
2532
- }
2533
- if (wo(h) || Fr.isBuffer(h)) {
2534
- if (l) {
2535
- var q = y ? t : l(t, x.encoder, v, "key", f);
2536
- if (n === "comma" && y) {
2537
- for (var $ = mo.call(String(h), ","), V = "", U = 0; U < $.length; ++U)
2538
- V += (U === 0 ? "" : ",") + p(l($[U], x.encoder, v, "value", f));
2539
- return [p(q) + (a && H(h) && $.length === 1 ? "[]" : "") + "=" + V];
877
+ queryKey: ["useListRateCards", carrierIds],
878
+ select: (result) => result.data.rateCards
879
+ });
880
+ };
881
+
882
+ var __async$b = (__this, __arguments, generator) => {
883
+ return new Promise((resolve, reject) => {
884
+ var fulfilled = (value) => {
885
+ try {
886
+ step(generator.next(value));
887
+ } catch (e) {
888
+ reject(e);
2540
889
  }
2541
- return [p(q) + "=" + p(l(h, x.encoder, v, "value", f))];
2542
- }
2543
- return [p(t) + "=" + p(String(h))];
2544
- }
2545
- var O = [];
2546
- if (typeof h > "u")
2547
- return O;
2548
- var _;
2549
- if (n === "comma" && H(h))
2550
- _ = [{ value: h.length > 0 ? h.join(",") || null : void 0 }];
2551
- else if (H(c))
2552
- _ = c;
2553
- else {
2554
- var D = Object.keys(h);
2555
- _ = d ? D.sort(d) : D;
2556
- }
2557
- for (var B = a && H(h) && h.length === 1 ? t + "[]" : t, L = 0; L < _.length; ++L) {
2558
- var K = _[L], ye = typeof K == "object" && typeof K.value < "u" ? K.value : h[K];
2559
- if (!(s && ye === null)) {
2560
- var In = H(h) ? typeof n == "function" ? n(B, K) : B : B + (u ? "." + K : "[" + K + "]");
2561
- m.set(e, A);
2562
- var Kr = bn();
2563
- Kr.set(dr, m), En(O, r(
2564
- ye,
2565
- In,
2566
- n,
2567
- a,
2568
- i,
2569
- s,
2570
- l,
2571
- c,
2572
- d,
2573
- u,
2574
- o,
2575
- f,
2576
- p,
2577
- y,
2578
- v,
2579
- Kr
2580
- ));
2581
- }
2582
- }
2583
- return O;
2584
- }, Eo = function(e) {
2585
- if (!e)
2586
- return x;
2587
- if (e.encoder !== null && typeof e.encoder < "u" && typeof e.encoder != "function")
2588
- throw new TypeError("Encoder has to be a function.");
2589
- var t = e.charset || x.charset;
2590
- if (typeof e.charset < "u" && e.charset !== "utf-8" && e.charset !== "iso-8859-1")
2591
- throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
2592
- var n = we.default;
2593
- if (typeof e.format < "u") {
2594
- if (!vo.call(we.formatters, e.format))
2595
- throw new TypeError("Unknown format option provided.");
2596
- n = e.format;
2597
- }
2598
- var a = we.formatters[n], i = x.filter;
2599
- return (typeof e.filter == "function" || H(e.filter)) && (i = e.filter), {
2600
- addQueryPrefix: typeof e.addQueryPrefix == "boolean" ? e.addQueryPrefix : x.addQueryPrefix,
2601
- allowDots: typeof e.allowDots > "u" ? x.allowDots : !!e.allowDots,
2602
- charset: t,
2603
- charsetSentinel: typeof e.charsetSentinel == "boolean" ? e.charsetSentinel : x.charsetSentinel,
2604
- delimiter: typeof e.delimiter > "u" ? x.delimiter : e.delimiter,
2605
- encode: typeof e.encode == "boolean" ? e.encode : x.encode,
2606
- encoder: typeof e.encoder == "function" ? e.encoder : x.encoder,
2607
- encodeValuesOnly: typeof e.encodeValuesOnly == "boolean" ? e.encodeValuesOnly : x.encodeValuesOnly,
2608
- filter: i,
2609
- format: n,
2610
- formatter: a,
2611
- serializeDate: typeof e.serializeDate == "function" ? e.serializeDate : x.serializeDate,
2612
- skipNulls: typeof e.skipNulls == "boolean" ? e.skipNulls : x.skipNulls,
2613
- sort: typeof e.sort == "function" ? e.sort : null,
2614
- strictNullHandling: typeof e.strictNullHandling == "boolean" ? e.strictNullHandling : x.strictNullHandling
2615
- };
2616
- }, Ao = function(r, e) {
2617
- var t = r, n = Eo(e), a, i;
2618
- typeof n.filter == "function" ? (i = n.filter, t = i("", t)) : H(n.filter) && (i = n.filter, a = i);
2619
- var s = [];
2620
- if (typeof t != "object" || t === null)
2621
- return "";
2622
- var l;
2623
- e && e.arrayFormat in _t ? l = e.arrayFormat : e && "indices" in e ? l = e.indices ? "indices" : "repeat" : l = "indices";
2624
- var c = _t[l];
2625
- if (e && "commaRoundTrip" in e && typeof e.commaRoundTrip != "boolean")
2626
- throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
2627
- var d = c === "comma" && e && e.commaRoundTrip;
2628
- a || (a = Object.keys(t)), n.sort && a.sort(n.sort);
2629
- for (var u = bn(), o = 0; o < a.length; ++o) {
2630
- var f = a[o];
2631
- n.skipNulls && t[f] === null || En(s, bo(
2632
- t[f],
2633
- f,
2634
- c,
2635
- d,
2636
- n.strictNullHandling,
2637
- n.skipNulls,
2638
- n.encode ? n.encoder : null,
2639
- n.filter,
2640
- n.sort,
2641
- n.allowDots,
2642
- n.serializeDate,
2643
- n.format,
2644
- n.formatter,
2645
- n.encodeValuesOnly,
2646
- n.charset,
2647
- u
2648
- ));
2649
- }
2650
- var p = s.join(n.delimiter), y = n.addQueryPrefix === !0 ? "?" : "";
2651
- return n.charsetSentinel && (n.charset === "iso-8859-1" ? y += "utf8=%26%2310003%3B&" : y += "utf8=%E2%9C%93&"), p.length > 0 ? y + p : "";
2652
- }, de = wn, Nr = Object.prototype.hasOwnProperty, Oo = Array.isArray, P = {
2653
- allowDots: !1,
2654
- allowPrototypes: !1,
2655
- allowSparse: !1,
2656
- arrayLimit: 20,
2657
- charset: "utf-8",
2658
- charsetSentinel: !1,
2659
- comma: !1,
2660
- decoder: de.decode,
2661
- delimiter: "&",
2662
- depth: 5,
2663
- ignoreQueryPrefix: !1,
2664
- interpretNumericEntities: !1,
2665
- parameterLimit: 1e3,
2666
- parseArrays: !0,
2667
- plainObjects: !1,
2668
- strictNullHandling: !1
2669
- }, Po = function(r) {
2670
- return r.replace(/&#(\d+);/g, function(e, t) {
2671
- return String.fromCharCode(parseInt(t, 10));
2672
- });
2673
- }, An = function(r, e) {
2674
- return r && typeof r == "string" && e.comma && r.indexOf(",") > -1 ? r.split(",") : r;
2675
- }, Io = "utf8=%26%2310003%3B", Ro = "utf8=%E2%9C%93", xo = function(e, t) {
2676
- var n = {}, a = t.ignoreQueryPrefix ? e.replace(/^\?/, "") : e, i = t.parameterLimit === 1 / 0 ? void 0 : t.parameterLimit, s = a.split(t.delimiter, i), l = -1, c, d = t.charset;
2677
- if (t.charsetSentinel)
2678
- for (c = 0; c < s.length; ++c)
2679
- s[c].indexOf("utf8=") === 0 && (s[c] === Ro ? d = "utf-8" : s[c] === Io && (d = "iso-8859-1"), l = c, c = s.length);
2680
- for (c = 0; c < s.length; ++c)
2681
- if (c !== l) {
2682
- var u = s[c], o = u.indexOf("]="), f = o === -1 ? u.indexOf("=") : o + 1, p, y;
2683
- f === -1 ? (p = t.decoder(u, P.decoder, d, "key"), y = t.strictNullHandling ? null : "") : (p = t.decoder(u.slice(0, f), P.decoder, d, "key"), y = de.maybeMap(
2684
- An(u.slice(f + 1), t),
2685
- function(v) {
2686
- return t.decoder(v, P.decoder, d, "value");
2687
- }
2688
- )), y && t.interpretNumericEntities && d === "iso-8859-1" && (y = Po(y)), u.indexOf("[]=") > -1 && (y = Oo(y) ? [y] : y), Nr.call(n, p) ? n[p] = de.combine(n[p], y) : n[p] = y;
2689
- }
2690
- return n;
2691
- }, Co = function(r, e, t, n) {
2692
- for (var a = n ? e : An(e, t), i = r.length - 1; i >= 0; --i) {
2693
- var s, l = r[i];
2694
- if (l === "[]" && t.parseArrays)
2695
- s = [].concat(a);
2696
- else {
2697
- s = t.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
2698
- var c = l.charAt(0) === "[" && l.charAt(l.length - 1) === "]" ? l.slice(1, -1) : l, d = parseInt(c, 10);
2699
- !t.parseArrays && c === "" ? s = { 0: a } : !isNaN(d) && l !== c && String(d) === c && d >= 0 && t.parseArrays && d <= t.arrayLimit ? (s = [], s[d] = a) : c !== "__proto__" && (s[c] = a);
2700
- }
2701
- a = s;
2702
- }
2703
- return a;
2704
- }, Fo = function(e, t, n, a) {
2705
- if (e) {
2706
- var i = n.allowDots ? e.replace(/\.([^.[]+)/g, "[$1]") : e, s = /(\[[^[\]]*])/, l = /(\[[^[\]]*])/g, c = n.depth > 0 && s.exec(i), d = c ? i.slice(0, c.index) : i, u = [];
2707
- if (d) {
2708
- if (!n.plainObjects && Nr.call(Object.prototype, d) && !n.allowPrototypes)
2709
- return;
2710
- u.push(d);
2711
- }
2712
- for (var o = 0; n.depth > 0 && (c = l.exec(i)) !== null && o < n.depth; ) {
2713
- if (o += 1, !n.plainObjects && Nr.call(Object.prototype, c[1].slice(1, -1)) && !n.allowPrototypes)
2714
- return;
2715
- u.push(c[1]);
2716
- }
2717
- return c && u.push("[" + i.slice(c.index) + "]"), Co(u, t, n, a);
2718
- }
2719
- }, No = function(e) {
2720
- if (!e)
2721
- return P;
2722
- if (e.decoder !== null && e.decoder !== void 0 && typeof e.decoder != "function")
2723
- throw new TypeError("Decoder has to be a function.");
2724
- if (typeof e.charset < "u" && e.charset !== "utf-8" && e.charset !== "iso-8859-1")
2725
- throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
2726
- var t = typeof e.charset > "u" ? P.charset : e.charset;
2727
- return {
2728
- allowDots: typeof e.allowDots > "u" ? P.allowDots : !!e.allowDots,
2729
- allowPrototypes: typeof e.allowPrototypes == "boolean" ? e.allowPrototypes : P.allowPrototypes,
2730
- allowSparse: typeof e.allowSparse == "boolean" ? e.allowSparse : P.allowSparse,
2731
- arrayLimit: typeof e.arrayLimit == "number" ? e.arrayLimit : P.arrayLimit,
2732
- charset: t,
2733
- charsetSentinel: typeof e.charsetSentinel == "boolean" ? e.charsetSentinel : P.charsetSentinel,
2734
- comma: typeof e.comma == "boolean" ? e.comma : P.comma,
2735
- decoder: typeof e.decoder == "function" ? e.decoder : P.decoder,
2736
- delimiter: typeof e.delimiter == "string" || de.isRegExp(e.delimiter) ? e.delimiter : P.delimiter,
2737
- // eslint-disable-next-line no-implicit-coercion, no-extra-parens
2738
- depth: typeof e.depth == "number" || e.depth === !1 ? +e.depth : P.depth,
2739
- ignoreQueryPrefix: e.ignoreQueryPrefix === !0,
2740
- interpretNumericEntities: typeof e.interpretNumericEntities == "boolean" ? e.interpretNumericEntities : P.interpretNumericEntities,
2741
- parameterLimit: typeof e.parameterLimit == "number" ? e.parameterLimit : P.parameterLimit,
2742
- parseArrays: e.parseArrays !== !1,
2743
- plainObjects: typeof e.plainObjects == "boolean" ? e.plainObjects : P.plainObjects,
2744
- strictNullHandling: typeof e.strictNullHandling == "boolean" ? e.strictNullHandling : P.strictNullHandling
2745
- };
2746
- }, $o = function(r, e) {
2747
- var t = No(e);
2748
- if (r === "" || r === null || typeof r > "u")
2749
- return t.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
2750
- for (var n = typeof r == "string" ? xo(r, t) : r, a = t.plainObjects ? /* @__PURE__ */ Object.create(null) : {}, i = Object.keys(n), s = 0; s < i.length; ++s) {
2751
- var l = i[s], c = Fo(l, n[l], t, typeof r == "string");
2752
- a = de.merge(a, c, t);
2753
- }
2754
- return t.allowSparse === !0 ? a : de.compact(a);
2755
- }, _o = Ao, Do = $o, ko = Gr, To = {
2756
- formats: ko,
2757
- parse: Do,
2758
- stringify: _o
2759
- };
2760
- class Bo {
2761
- constructor(e) {
2762
- this.client = e, this.list = () => this.client.get("/v1/packages"), this.client = e;
2763
- }
2764
- }
2765
- class Lo {
2766
- constructor(e) {
2767
- this.client = e, this.get = (t) => this.client.get(`/v1/insurance/${t}/balance`), this.client = e;
2768
- }
2769
- }
2770
- class Uo {
2771
- constructor(e) {
2772
- this.client = e, this.get = (t) => this.client.get(`/v1/labels/${t}`), this.list = (t = {}) => this.client.get("/v1/labels", { params: t }), this.createByRateId = (t, n) => this.client.post(`/v1/labels/rates/${t}`, n), this.void = (t) => this.client.put(`/v1/labels/${t}/void`), this.client = e;
2773
- }
2774
- }
2775
- class qo {
2776
- constructor(e) {
2777
- this.client = e, this.list = () => this.client.get("/v-beta/order_sources"), this.get = (t) => this.client.get(`/v-beta/order_sources/${t}`), this.refresh = (t) => this.client.put(`/v-beta/order_sources/${t}/refresh`), this.client = e;
2778
- }
2779
- }
2780
- class Mo {
2781
- constructor(e) {
2782
- this.client = e, this.calculateByShipmentId = (t, n) => this.client.post("/v1/rates", {
2783
- rateOptions: n,
2784
- shipmentId: t
2785
- }), this.client = e;
2786
- }
2787
- }
2788
- class zo {
2789
- constructor(e) {
2790
- this.client = e, this.list = (t = {}) => this.client.post("/v-beta/shipments/list", t), this.get = (t) => this.client.get(`/v-beta/shipments/${t}`), this.create = (t, n) => this.client.post(
2791
- `/v-beta/shipments/sales_order/${t}`,
2792
- n
2793
- ), this.update = (t, n) => this.client.put(`/v-beta/shipments/${t}`, n), this.client = e;
2794
- }
2795
- }
2796
- class jo {
2797
- constructor(e) {
2798
- this.client = e, this.list = (t = {}) => this.client.get("/v-beta/sales_orders", { params: t }), this.get = (t) => this.client.get(`/v-beta/sales_orders/${t}`), this.notifyShipped = (t, n) => this.client.post(`/v-beta/sales_orders/${t}/notify`, n), this.client = e;
2799
- }
2800
- }
2801
- class Wo {
2802
- constructor(e) {
2803
- this.client = e, this.list = () => this.client.get("/v1/warehouses"), this.create = (t) => this.client.post("/v1/warehouses", t), this.update = (t, n) => this.client.put(`/v1/warehouses/${t}`, n), this.delete = (t) => this.client.delete(`/v1/warehouses/${t}`), this.client = e;
2804
- }
2805
- }
2806
- const kt = un({
2807
- name: "shipengine-api",
2808
- serializers: {
2809
- ...Br,
2810
- req: (r) => ({
2811
- headers: r.headers,
2812
- method: r.method,
2813
- url: r.url
890
+ };
891
+ var rejected = (value) => {
892
+ try {
893
+ step(generator.throw(value));
894
+ } catch (e) {
895
+ reject(e);
896
+ }
897
+ };
898
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
899
+ step((generator = generator.apply(__this, __arguments)).next());
900
+ });
901
+ };
902
+ const usePublishRateCard = () => {
903
+ const { client } = useShipEngine();
904
+ return useMutation({
905
+ mutationFn: (rateCardId) => __async$b(void 0, null, function* () {
906
+ return yield client.rateCards.publish(rateCardId);
2814
907
  }),
2815
- res: (r) => ({
2816
- data: r.data,
2817
- headers: r.config.headers,
2818
- method: r.config.method,
2819
- statusCode: r.status,
2820
- url: r.config.url
2821
- })
2822
- },
2823
- streams: [
2824
- {
2825
- stream: new ln()
2826
- }
2827
- ]
2828
- }), Go = (r) => !!r.errors && an(r.errors);
2829
- class Tt {
2830
- constructor(e, { baseURL: t, headers: n, getToken: a }) {
2831
- const i = mr.create({
2832
- baseURL: t,
2833
- headers: {
2834
- ...n,
2835
- Authorization: `Bearer ${e}`,
2836
- "Content-Type": "application/json"
2837
- },
2838
- paramsSerializer: (s) => To.stringify(me.decamelizeKeys(s), { arrayFormat: "brackets" }),
2839
- transformRequest: [(s) => me.decamelizeKeys(s), (s) => JSON.stringify(s)],
2840
- transformResponse: [
2841
- (s) => {
2842
- if (s)
2843
- return JSON.parse(s);
2844
- },
2845
- (s) => me.camelizeKeys(s)
2846
- ]
2847
- });
2848
- i.interceptors.response.use(
2849
- (s) => (kt.info(
2850
- { req: s.config, res: s },
2851
- "%s %s: %s %s",
2852
- s.config.method?.toUpperCase(),
2853
- s.config.url,
2854
- s.status,
2855
- s.statusText
2856
- ), s),
2857
- async (s) => {
2858
- if (kt.error(
2859
- { err: s, req: s.config, res: s.response },
2860
- "%s %s: %s %s - %s",
2861
- s.config?.method?.toUpperCase(),
2862
- s.config?.url,
2863
- s.response?.status,
2864
- s.response?.statusText,
2865
- s.message
2866
- ), s.response?.status === 401) {
2867
- const l = await a(), c = s.config;
2868
- return c && (c.headers ||= {}, c.headers.Authorization = `Bearer ${l}`), mr(c);
2869
- }
2870
- return s.response?.data ? Go(s.response.data) ? Promise.reject(
2871
- s.response.data.errors.map((l) => W.fromObject(l))
2872
- ) : an(s.response.data) ? Promise.reject(s.response.data.map((l) => W.fromObject(l))) : on(s.response.data) ? Promise.reject([W.fromObject(s.response.data)]) : Promise.reject([new W(s.response.data)]) : Promise.reject([new W(s.message)]);
908
+ mutationKey: ["usePublishRateCard"],
909
+ onError
910
+ });
911
+ };
912
+
913
+ var __async$a = (__this, __arguments, generator) => {
914
+ return new Promise((resolve, reject) => {
915
+ var fulfilled = (value) => {
916
+ try {
917
+ step(generator.next(value));
918
+ } catch (e) {
919
+ reject(e);
2873
920
  }
2874
- ), this.client = i;
2875
- }
2876
- set token(e) {
2877
- this.client.defaults.headers.common.Authorization = `Bearer ${e}`;
2878
- }
2879
- get accountSettings() {
2880
- return new _n(this.client);
2881
- }
2882
- get addresses() {
2883
- return new Dn(this.client);
2884
- }
2885
- get carriers() {
2886
- return new Ta(this.client);
2887
- }
2888
- get customPackages() {
2889
- return new Bo(this.client);
2890
- }
2891
- get insurance() {
2892
- return new Lo(this.client);
2893
- }
2894
- get labels() {
2895
- return new Uo(this.client);
2896
- }
2897
- get orderSources() {
2898
- return new qo(this.client);
2899
- }
2900
- get rates() {
2901
- return new Mo(this.client);
2902
- }
2903
- get salesOrderShipments() {
2904
- return new zo(this.client);
2905
- }
2906
- get salesOrders() {
2907
- return new jo(this.client);
2908
- }
2909
- get warehouses() {
2910
- return new Wo(this.client);
2911
- }
2912
- }
2913
- const On = Fn(void 0), Zo = ({ baseURL: r, children: e, headers: t, getToken: n }) => {
2914
- const [a, i] = Nn(() => {
2915
- const l = n();
2916
- if (typeof l == "string")
2917
- return new Tt(l, {
2918
- baseURL: r,
2919
- getToken: n,
2920
- headers: t ?? {}
2921
- });
2922
- l.then(
2923
- (c) => i(
2924
- new Tt(c, {
2925
- baseURL: r,
2926
- getToken: n,
2927
- headers: t ?? {}
2928
- })
2929
- )
2930
- );
2931
- }), s = new Rn();
2932
- return a ? /* @__PURE__ */ Ue(On.Provider, { value: { client: a }, children: /* @__PURE__ */ Ue(xn, { client: s, children: e }) }) : /* @__PURE__ */ Ue(
2933
- "div",
2934
- {
2935
- style: {
2936
- alignItems: "center",
2937
- display: "flex",
2938
- height: "100%",
2939
- justifyContent: "center",
2940
- width: "100%"
2941
- },
2942
- children: "Loading..."
2943
- }
2944
- );
2945
- }, E = () => {
2946
- const r = $n(On);
2947
- if (!r)
2948
- throw new Error("useShipEngine must be called within a ShipEngineProvider");
2949
- return r;
2950
- }, Ko = (r) => new Promise((e) => {
2951
- setTimeout(() => e(!0), r);
2952
- }), b = (r) => r.forEach(console.log), Pn = [];
2953
- process.env.NODE_ENV === "production" && Pn.push({
2954
- stream: new ln()
2955
- });
2956
- const es = un({
2957
- name: "shipengine",
2958
- serializers: {
2959
- ...Br,
2960
- req: (r) => ({
2961
- headers: r.headers,
2962
- method: r.method,
2963
- url: r.url
921
+ };
922
+ var rejected = (value) => {
923
+ try {
924
+ step(generator.throw(value));
925
+ } catch (e) {
926
+ reject(e);
927
+ }
928
+ };
929
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
930
+ step((generator = generator.apply(__this, __arguments)).next());
931
+ });
932
+ };
933
+ const useUpdateRateCard = () => {
934
+ const { client } = useShipEngine();
935
+ return useMutation({
936
+ mutationFn: (rateCard) => __async$a(void 0, null, function* () {
937
+ const result = yield client.rateCards.update(rateCard);
938
+ return result.data;
2964
939
  }),
2965
- res: (r) => ({
2966
- data: r.data,
2967
- headers: r.config.headers,
2968
- method: r.config.method,
2969
- statusCode: r.status,
2970
- url: r.config.url
2971
- })
2972
- },
2973
- streams: Pn
2974
- }), Ho = (r, e = 10, t = 1e3) => Promise.resolve().then(r).catch(function n(a) {
2975
- if (e -= 1, e > 0)
2976
- return Ko(t).then(r).catch(n);
2977
- throw a;
2978
- }), rs = (r) => {
2979
- const { client: e } = E();
2980
- return I({
2981
- mutationFn: async (t) => (await e.carriers.addFunds(r, t)).data,
2982
- mutationKey: ["useAddFunds"],
2983
- onError: b
940
+ mutationKey: ["useUpdateRateCard"],
941
+ onError
942
+ });
943
+ };
944
+
945
+ var __async$9 = (__this, __arguments, generator) => {
946
+ return new Promise((resolve, reject) => {
947
+ var fulfilled = (value) => {
948
+ try {
949
+ step(generator.next(value));
950
+ } catch (e) {
951
+ reject(e);
952
+ }
953
+ };
954
+ var rejected = (value) => {
955
+ try {
956
+ step(generator.throw(value));
957
+ } catch (e) {
958
+ reject(e);
959
+ }
960
+ };
961
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
962
+ step((generator = generator.apply(__this, __arguments)).next());
963
+ });
964
+ };
965
+ const useUploadRateCard = () => {
966
+ const { client } = useShipEngine();
967
+ return useMutation({
968
+ mutationFn: (_0) => __async$9(void 0, [_0], function* ({ rateCardId, file }) {
969
+ const result = yield client.rateCards.upload(rateCardId, file);
970
+ return result.data;
971
+ }),
972
+ mutationKey: ["useUploadRateCard"],
973
+ onError
974
+ });
975
+ };
976
+
977
+ var __async$8 = (__this, __arguments, generator) => {
978
+ return new Promise((resolve, reject) => {
979
+ var fulfilled = (value) => {
980
+ try {
981
+ step(generator.next(value));
982
+ } catch (e) {
983
+ reject(e);
984
+ }
985
+ };
986
+ var rejected = (value) => {
987
+ try {
988
+ step(generator.throw(value));
989
+ } catch (e) {
990
+ reject(e);
991
+ }
992
+ };
993
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
994
+ step((generator = generator.apply(__this, __arguments)).next());
995
+ });
996
+ };
997
+ const useDeleteRateCard = () => {
998
+ const { client } = useShipEngine();
999
+ return useMutation({
1000
+ mutationFn: (rateCardId) => __async$8(void 0, null, function* () {
1001
+ const result = yield client.rateCards.delete(rateCardId);
1002
+ return result.data;
1003
+ }),
1004
+ mutationKey: ["useDeleteRateCard"],
1005
+ onError
2984
1006
  });
2985
- }, ts = () => {
2986
- const { client: r } = E();
2987
- return I({
2988
- mutationFn: async ({ rateOptions: e, shipmentId: t }) => (await r.rates.calculateByShipmentId(t, e)).data,
1007
+ };
1008
+
1009
+ var __async$7 = (__this, __arguments, generator) => {
1010
+ return new Promise((resolve, reject) => {
1011
+ var fulfilled = (value) => {
1012
+ try {
1013
+ step(generator.next(value));
1014
+ } catch (e) {
1015
+ reject(e);
1016
+ }
1017
+ };
1018
+ var rejected = (value) => {
1019
+ try {
1020
+ step(generator.throw(value));
1021
+ } catch (e) {
1022
+ reject(e);
1023
+ }
1024
+ };
1025
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1026
+ step((generator = generator.apply(__this, __arguments)).next());
1027
+ });
1028
+ };
1029
+ const useCalculateRates = () => {
1030
+ const { client } = useShipEngine();
1031
+ return useMutation({
1032
+ mutationFn: (_0) => __async$7(void 0, [_0], function* ({ rateOptions, shipmentId }) {
1033
+ const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
1034
+ return result.data;
1035
+ }),
2989
1036
  mutationKey: ["useCalculateRates"],
2990
- onError: b
1037
+ onError
2991
1038
  });
2992
- }, ns = () => {
2993
- const { client: r } = E();
2994
- return I({
2995
- mutationFn: async (e) => (await r.carriers.connect(e)).data,
2996
- mutationKey: ["useConnectCarrier"],
2997
- onError: b
1039
+ };
1040
+
1041
+ const useGetSalesOrder = (salesOrderId) => {
1042
+ const { client } = useShipEngine();
1043
+ return useQuery({
1044
+ enabled: salesOrderId !== void 0,
1045
+ onError,
1046
+ queryFn: () => {
1047
+ if (salesOrderId)
1048
+ return client.salesOrders.get(salesOrderId);
1049
+ return Promise.reject(new Error("salesOrderId is required"));
1050
+ },
1051
+ queryKey: ["useGetSalesOrder", salesOrderId],
1052
+ select: (result) => result.data
2998
1053
  });
2999
- }, as = () => {
3000
- const { client: r } = E();
3001
- return I({
3002
- mutationFn: async ({ rateId: e, ...t }) => (await r.labels.createByRateId(e, t)).data,
3003
- mutationKey: ["useCreateLabel"],
3004
- onError: b
1054
+ };
1055
+
1056
+ const useListSalesOrders = (params = {}) => {
1057
+ const { client } = useShipEngine();
1058
+ return useQuery({
1059
+ enabled: params && Object.values(params).some((v) => v !== void 0),
1060
+ onError,
1061
+ queryFn: () => client.salesOrders.list(params),
1062
+ queryKey: ["useListSalesOrders", params],
1063
+ select: (result) => result.data.salesOrders
3005
1064
  });
3006
- }, is = () => {
3007
- const { client: r } = E();
3008
- return I({
3009
- mutationFn: async ({ salesOrderId: e, ...t }) => (await r.salesOrderShipments.create(e, t)).data,
3010
- mutationKey: ["useCreateSalesOrderShipment"],
3011
- onError: b
1065
+ };
1066
+
1067
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1068
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1069
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1070
+ var __objRest$4 = (source, exclude) => {
1071
+ var target = {};
1072
+ for (var prop in source)
1073
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1074
+ target[prop] = source[prop];
1075
+ if (source != null && __getOwnPropSymbols$5)
1076
+ for (var prop of __getOwnPropSymbols$5(source)) {
1077
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1078
+ target[prop] = source[prop];
1079
+ }
1080
+ return target;
1081
+ };
1082
+ var __async$6 = (__this, __arguments, generator) => {
1083
+ return new Promise((resolve, reject) => {
1084
+ var fulfilled = (value) => {
1085
+ try {
1086
+ step(generator.next(value));
1087
+ } catch (e) {
1088
+ reject(e);
1089
+ }
1090
+ };
1091
+ var rejected = (value) => {
1092
+ try {
1093
+ step(generator.throw(value));
1094
+ } catch (e) {
1095
+ reject(e);
1096
+ }
1097
+ };
1098
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1099
+ step((generator = generator.apply(__this, __arguments)).next());
3012
1100
  });
3013
- }, os = () => {
3014
- const { client: r } = E();
3015
- return I({
3016
- mutationFn: async (e) => (await r.warehouses.create(e)).data,
3017
- mutationKey: ["useCreateWarehouse"],
3018
- onError: b
1101
+ };
1102
+ const useNotifySalesOrderShipped = () => {
1103
+ const { client } = useShipEngine();
1104
+ return useMutation({
1105
+ mutationFn: (_a) => __async$6(void 0, null, function* () {
1106
+ var _b = _a, { salesOrderId } = _b, tracking = __objRest$4(_b, ["salesOrderId"]);
1107
+ const result = yield client.salesOrders.notifyShipped(salesOrderId, tracking);
1108
+ return result.data;
1109
+ }),
1110
+ mutationKey: ["useNotifySalesOrder"],
1111
+ onError
3019
1112
  });
3020
- }, ss = () => {
3021
- const { client: r } = E();
3022
- return I({
3023
- mutationFn: async ({ warehouseId: e }) => (await r.warehouses.delete(e)).data,
3024
- mutationKey: ["useDeleteWarehouse"],
3025
- onError: b
1113
+ };
1114
+
1115
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1116
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1117
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1118
+ var __objRest$3 = (source, exclude) => {
1119
+ var target = {};
1120
+ for (var prop in source)
1121
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1122
+ target[prop] = source[prop];
1123
+ if (source != null && __getOwnPropSymbols$4)
1124
+ for (var prop of __getOwnPropSymbols$4(source)) {
1125
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1126
+ target[prop] = source[prop];
1127
+ }
1128
+ return target;
1129
+ };
1130
+ var __async$5 = (__this, __arguments, generator) => {
1131
+ return new Promise((resolve, reject) => {
1132
+ var fulfilled = (value) => {
1133
+ try {
1134
+ step(generator.next(value));
1135
+ } catch (e) {
1136
+ reject(e);
1137
+ }
1138
+ };
1139
+ var rejected = (value) => {
1140
+ try {
1141
+ step(generator.throw(value));
1142
+ } catch (e) {
1143
+ reject(e);
1144
+ }
1145
+ };
1146
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1147
+ step((generator = generator.apply(__this, __arguments)).next());
3026
1148
  });
3027
- }, us = () => {
3028
- const { client: r } = E();
3029
- return N({
3030
- onError: b,
3031
- queryFn: () => r.accountSettings.get(),
3032
- queryKey: ["getAccountSettings"],
3033
- select: (e) => e.data
3034
- });
3035
- }, ls = (r) => {
3036
- const { client: e } = E();
3037
- return N({
3038
- enabled: r !== void 0,
3039
- onError: b,
3040
- queryFn: () => r ? e.carriers.getAutoFunding(r) : Promise.reject(new Error("carrierId is required.")),
3041
- queryKey: ["useGetAutoFundingConfiguration", r],
3042
- select: (t) => t.data
3043
- });
3044
- }, cs = (r) => {
3045
- const { client: e } = E();
3046
- return N({
3047
- enabled: !!r,
3048
- onError: b,
3049
- queryFn: () => r ? e.carriers.get(r) : Promise.reject(new Error("carrierId is require")),
3050
- queryKey: ["useGetCarrierById", r],
3051
- select: (t) => t.data,
3052
- // Fresh for 5 minutes
3053
- staleTime: 5 * 60 * 1e3
1149
+ };
1150
+ const useCreateSalesOrderShipment = () => {
1151
+ const { client } = useShipEngine();
1152
+ return useMutation({
1153
+ mutationFn: (_a) => __async$5(void 0, null, function* () {
1154
+ var _b = _a, { salesOrderId } = _b, shipment = __objRest$3(_b, ["salesOrderId"]);
1155
+ const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
1156
+ return result.data;
1157
+ }),
1158
+ mutationKey: ["useCreateSalesOrderShipment"],
1159
+ onError
3054
1160
  });
3055
- }, fs = (r) => {
3056
- const { client: e } = E();
3057
- return N({
3058
- enabled: r !== void 0,
3059
- onError: b,
3060
- queryFn: () => r ? e.insurance.get(r) : Promise.reject(new Error("insuranceProvider is required")),
3061
- queryKey: ["useGetInsuranceAccount", r],
3062
- select: (t) => t.data
3063
- });
3064
- }, ps = (r) => {
3065
- const { client: e } = E();
3066
- return N({
3067
- enabled: r !== void 0,
3068
- onError: b,
3069
- queryFn: () => r ? e.labels.get(r) : Promise.reject(new Error("labelId is require")),
3070
- queryKey: ["useGetLabel", r],
3071
- select: (t) => t.data
3072
- });
3073
- }, ds = (r) => {
3074
- const { client: e } = E();
3075
- return N({
3076
- enabled: r !== void 0,
3077
- onError: b,
3078
- queryFn: () => r ? e.salesOrders.get(r) : Promise.reject(new Error("salesOrderId is required")),
3079
- queryKey: ["useGetSalesOrder", r],
3080
- select: (t) => t.data
3081
- });
3082
- }, hs = (r) => {
3083
- const { client: e } = E();
3084
- return N({
3085
- enabled: r !== void 0,
3086
- onError: b,
3087
- queryFn: () => r ? e.salesOrderShipments.get(r) : Promise.reject(new Error("shipmentId is required")),
3088
- queryKey: ["useGetSalesOrderShipment", r],
3089
- select: (t) => t.data
3090
- });
3091
- }, ys = (r) => {
3092
- const { client: e } = E();
3093
- return N({
3094
- enabled: r !== void 0,
3095
- onError: b,
3096
- queryFn: () => r ? e.salesOrderShipments.get(r) : Promise.reject(new Error("shipmentId is required")),
3097
- queryKey: ["useGetShipment", r],
3098
- select: (t) => t.data
3099
- });
3100
- }, vs = () => ({
3101
- links: {
3102
- transactionHistoryReport: "http://link.to.entire.dataset.as.csv"
3103
- },
3104
- page: 1,
3105
- pages: 4,
3106
- total: 275,
3107
- transactions: [
3108
- {
3109
- amount: 50.65,
3110
- balance: 10,
3111
- carrierId: "string",
3112
- carrierProvider: "string carrier name",
3113
- labelId: "string",
3114
- transactionDate: "",
3115
- transactionId: "string",
3116
- transactionType: "fund"
1161
+ };
1162
+
1163
+ const useGetSalesOrderShipment = (shipmentId) => {
1164
+ const { client } = useShipEngine();
1165
+ return useQuery({
1166
+ enabled: shipmentId !== void 0,
1167
+ onError,
1168
+ queryFn: () => {
1169
+ if (shipmentId)
1170
+ return client.salesOrderShipments.get(shipmentId);
1171
+ return Promise.reject(new Error("shipmentId is required"));
3117
1172
  },
3118
- {
3119
- amount: 50.65,
3120
- balance: 10,
3121
- carrierId: "string",
3122
- carrierProvider: "string carrier name",
3123
- labelId: "string",
3124
- transactionDate: "",
3125
- transactionId: "string",
3126
- transactionType: "purchase"
1173
+ queryKey: ["useGetSalesOrderShipment", shipmentId],
1174
+ select: (result) => result.data
1175
+ });
1176
+ };
1177
+
1178
+ const useListSalesOrderShipments = (params) => {
1179
+ const { client } = useShipEngine();
1180
+ return useQuery({
1181
+ enabled: params && Object.values(params).some((v) => v !== void 0),
1182
+ onError,
1183
+ queryFn: () => client.salesOrderShipments.list(params),
1184
+ queryKey: ["useListSalesOrderShipments", params],
1185
+ select: (result) => result.data.shipments
1186
+ });
1187
+ };
1188
+
1189
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1190
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1191
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1192
+ var __objRest$2 = (source, exclude) => {
1193
+ var target = {};
1194
+ for (var prop in source)
1195
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
1196
+ target[prop] = source[prop];
1197
+ if (source != null && __getOwnPropSymbols$3)
1198
+ for (var prop of __getOwnPropSymbols$3(source)) {
1199
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
1200
+ target[prop] = source[prop];
3127
1201
  }
3128
- ]
3129
- }), ms = () => {
3130
- const { client: r } = E();
3131
- return N({
3132
- onError: b,
3133
- queryFn: () => r.carriers.list(),
3134
- queryKey: ["useListCarriers"],
3135
- select: (e) => e.data.carriers
1202
+ return target;
1203
+ };
1204
+ var __async$4 = (__this, __arguments, generator) => {
1205
+ return new Promise((resolve, reject) => {
1206
+ var fulfilled = (value) => {
1207
+ try {
1208
+ step(generator.next(value));
1209
+ } catch (e) {
1210
+ reject(e);
1211
+ }
1212
+ };
1213
+ var rejected = (value) => {
1214
+ try {
1215
+ step(generator.throw(value));
1216
+ } catch (e) {
1217
+ reject(e);
1218
+ }
1219
+ };
1220
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1221
+ step((generator = generator.apply(__this, __arguments)).next());
3136
1222
  });
3137
- }, gs = () => {
3138
- const { client: r } = E();
3139
- return N({
3140
- onError: b,
3141
- queryFn: () => r.customPackages.list(),
3142
- queryKey: ["useListCustomPackageTypes"],
3143
- select: (e) => e.data.packages
3144
- });
3145
- }, Ss = (r) => {
3146
- const { client: e } = E();
3147
- return N({
3148
- enabled: r && Object.values(r).some((t) => t !== void 0),
3149
- onError: b,
3150
- queryFn: () => e.labels.list(r),
3151
- queryKey: ["useListLabels", r],
3152
- select: (t) => t.data.labels
3153
- });
3154
- }, ws = () => {
3155
- const { client: r } = E();
3156
- return N({
3157
- onError: b,
3158
- queryFn: () => r.orderSources.list(),
3159
- queryKey: ["useListOrderSources"],
3160
- select: (e) => e.data.orderSources
3161
- });
3162
- }, bs = (r) => {
3163
- const { client: e } = E();
3164
- return N({
3165
- enabled: r && Object.values(r).some((t) => t !== void 0),
3166
- onError: b,
3167
- queryFn: () => e.salesOrderShipments.list(r),
3168
- queryKey: ["useListSalesOrderShipments", r],
3169
- select: (t) => t.data.shipments
3170
- });
3171
- }, Es = (r = {}) => {
3172
- const { client: e } = E();
3173
- return N({
3174
- enabled: r && Object.values(r).some((t) => t !== void 0),
3175
- onError: b,
3176
- queryFn: () => e.salesOrders.list(r),
3177
- queryKey: ["useListSalesOrders", r],
3178
- select: (t) => t.data.salesOrders
3179
- });
3180
- }, As = () => {
3181
- const { client: r } = E();
3182
- return N({
3183
- onError: b,
3184
- queryFn: () => r.warehouses.list(),
3185
- queryKey: ["useListWarehouses"],
3186
- select: (e) => e.data.warehouses
1223
+ };
1224
+ const useUpdateSalesOrderShipment = () => {
1225
+ const { client } = useShipEngine();
1226
+ return useMutation({
1227
+ mutationFn: (_a) => __async$4(void 0, null, function* () {
1228
+ var _b = _a, { shipmentId } = _b, shipment = __objRest$2(_b, ["shipmentId"]);
1229
+ const result = yield client.salesOrderShipments.update(shipmentId, shipment);
1230
+ return result.data;
1231
+ }),
1232
+ mutationKey: ["useUpdateSalesOrderShipment"],
1233
+ onError
3187
1234
  });
3188
- }, Os = () => {
3189
- const { client: r } = E();
3190
- return I({
3191
- mutationFn: async ({ salesOrderId: e, ...t }) => (await r.salesOrders.notifyShipped(e, t)).data,
3192
- mutationKey: ["useNotifySalesOrder"],
3193
- onError: b
1235
+ };
1236
+
1237
+ var __defProp = Object.defineProperty;
1238
+ var __defProps = Object.defineProperties;
1239
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1240
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1241
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1242
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1243
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1244
+ var __spreadValues = (a, b) => {
1245
+ for (var prop in b || (b = {}))
1246
+ if (__hasOwnProp$2.call(b, prop))
1247
+ __defNormalProp(a, prop, b[prop]);
1248
+ if (__getOwnPropSymbols$2)
1249
+ for (var prop of __getOwnPropSymbols$2(b)) {
1250
+ if (__propIsEnum$2.call(b, prop))
1251
+ __defNormalProp(a, prop, b[prop]);
1252
+ }
1253
+ return a;
1254
+ };
1255
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1256
+ var __async$3 = (__this, __arguments, generator) => {
1257
+ return new Promise((resolve, reject) => {
1258
+ var fulfilled = (value) => {
1259
+ try {
1260
+ step(generator.next(value));
1261
+ } catch (e) {
1262
+ reject(e);
1263
+ }
1264
+ };
1265
+ var rejected = (value) => {
1266
+ try {
1267
+ step(generator.throw(value));
1268
+ } catch (e) {
1269
+ reject(e);
1270
+ }
1271
+ };
1272
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1273
+ step((generator = generator.apply(__this, __arguments)).next());
3194
1274
  });
3195
- }, Ps = () => {
3196
- const { client: r } = E();
3197
- return I({
3198
- mutationFn: async ({ address: e, text: t }) => (await r.addresses.parse(t, e)).data,
3199
- mutationKey: ["useParseAddress"],
3200
- onError: b
1275
+ };
1276
+ const useCreateShipment = () => {
1277
+ const { client } = useShipEngine();
1278
+ return useMutation({
1279
+ mutationFn: (shipment) => __async$3(void 0, null, function* () {
1280
+ var _a;
1281
+ if (shipment.warehouseId === void 0) {
1282
+ throw new SE.CodedError("errorMessages.noWarehouses", {
1283
+ errorCode: "unknown",
1284
+ errorSource: "client",
1285
+ errorType: "business_rules"
1286
+ });
1287
+ }
1288
+ const shipTo = (_a = shipment.shipTo) != null ? _a : {
1289
+ addressLine1: "",
1290
+ cityLocality: "",
1291
+ countryCode: "",
1292
+ name: "",
1293
+ phone: "",
1294
+ postalCode: "",
1295
+ stateProvince: ""
1296
+ };
1297
+ return (yield client.shipments.create(__spreadProps(__spreadValues({}, shipment), {
1298
+ shipTo
1299
+ }))).data;
1300
+ }),
1301
+ mutationKey: ["useCreateShipment"],
1302
+ onError
3201
1303
  });
3202
- }, Vo = () => {
3203
- const { client: r } = E();
3204
- return I({
3205
- mutationFn: async (e) => (await r.orderSources.refresh(e)).data,
3206
- mutationKey: ["useRefreshOrderSourceAsync"]
1304
+ };
1305
+
1306
+ const useGetShipmentRates = (shipmentId, createdAtStart) => {
1307
+ const { client } = useShipEngine();
1308
+ return useQuery({
1309
+ enabled: shipmentId !== void 0,
1310
+ onError,
1311
+ queryFn: () => {
1312
+ if (shipmentId) {
1313
+ return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
1314
+ }
1315
+ return Promise.reject(new Error("shipmentId is required"));
1316
+ },
1317
+ queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
1318
+ select: (result) => result.data
3207
1319
  });
3208
- }, Is = () => {
3209
- const { client: r } = E(), { mutateAsync: e } = Vo();
3210
- return I({
3211
- mutationFn: async (t) => (await e(t), await Ho(async () => {
3212
- const { data: a } = await r.orderSources.get(t);
3213
- if (["preparing_update", "updating"].includes(a.refreshInfo.status))
3214
- throw new W("Order source is still refreshing");
3215
- return a;
3216
- }, 20)),
3217
- mutationKey: ["useRefreshOrderSource"],
3218
- onError: b
3219
- });
3220
- }, Rs = () => I({
3221
- mutationFn: async (r) => (await Promise.resolve({
3222
- data: { defaultLabelLayout: "4x6", dimension: "inch", weight: "ounce" },
3223
- errors: [],
3224
- isLoading: !1,
3225
- isValidating: !1
3226
- })).data,
3227
- mutationKey: ["useUpdateAccountSettings"],
3228
- onError: b
3229
- }), xs = (r) => {
3230
- const { client: e } = E(), t = Cn();
3231
- return I({
3232
- mutationFn: async (n) => (await e.carriers.updateAutoFunding(r, n)).data,
3233
- mutationKey: ["useUpdateAutoFunding"],
3234
- onError: b,
3235
- onSuccess: (n) => {
3236
- t.invalidateQueries(["useGetAutoFunding", r], { exact: !0 });
1320
+ };
1321
+
1322
+ const useGetShipment = (shipmentId) => {
1323
+ const { client } = useShipEngine();
1324
+ return useQuery({
1325
+ enabled: shipmentId !== void 0,
1326
+ onError,
1327
+ queryFn: () => {
1328
+ if (!shipmentId) {
1329
+ return Promise.reject(new Error("shipmentId is required"));
1330
+ }
1331
+ return client.salesOrderShipments.get(shipmentId);
1332
+ },
1333
+ queryKey: ["useGetShipment", shipmentId],
1334
+ select: (result) => result.data
1335
+ });
1336
+ };
1337
+
1338
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1339
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1340
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1341
+ var __objRest$1 = (source, exclude) => {
1342
+ var target = {};
1343
+ for (var prop in source)
1344
+ if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
1345
+ target[prop] = source[prop];
1346
+ if (source != null && __getOwnPropSymbols$1)
1347
+ for (var prop of __getOwnPropSymbols$1(source)) {
1348
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
1349
+ target[prop] = source[prop];
3237
1350
  }
1351
+ return target;
1352
+ };
1353
+ const useListShipments = (_params) => {
1354
+ const _a = _params || {}, { enabled = true } = _a, params = __objRest$1(_a, ["enabled"]);
1355
+ const { client } = useShipEngine();
1356
+ return useQuery({
1357
+ enabled,
1358
+ onError,
1359
+ queryFn: () => client.shipments.list(params),
1360
+ queryKey: ["useListShipments", params],
1361
+ select: (result) => result.data
3238
1362
  });
3239
- }, Cs = () => I({
3240
- mutationFn: async (r) => (await Promise.resolve({
3241
- data: {},
3242
- errors: [],
3243
- isLoading: !1,
3244
- isValidating: !1
3245
- })).data,
3246
- mutationKey: ["useUpdateBilling"],
3247
- onError: b
3248
- }), Fs = () => {
3249
- const { client: r } = E();
3250
- return I({
3251
- mutationFn: async ({ shipmentId: e, ...t }) => (await r.salesOrderShipments.update(e, t)).data,
3252
- mutationKey: ["useUpdateSalesOrderShipment"],
3253
- onError: b
1363
+ };
1364
+
1365
+ var __async$2 = (__this, __arguments, generator) => {
1366
+ return new Promise((resolve, reject) => {
1367
+ var fulfilled = (value) => {
1368
+ try {
1369
+ step(generator.next(value));
1370
+ } catch (e) {
1371
+ reject(e);
1372
+ }
1373
+ };
1374
+ var rejected = (value) => {
1375
+ try {
1376
+ step(generator.throw(value));
1377
+ } catch (e) {
1378
+ reject(e);
1379
+ }
1380
+ };
1381
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1382
+ step((generator = generator.apply(__this, __arguments)).next());
3254
1383
  });
3255
- }, Ns = () => {
3256
- const { client: r } = E();
3257
- return I({
3258
- mutationFn: async ({ warehouseId: e, ...t }) => (await r.warehouses.update(e, t)).data,
3259
- mutationKey: ["useUpdateWarehouse"],
3260
- onError: b
1384
+ };
1385
+ const useCreateWarehouse = () => {
1386
+ const { client } = useShipEngine();
1387
+ return useMutation({
1388
+ mutationFn: (data) => __async$2(void 0, null, function* () {
1389
+ const result = yield client.warehouses.create(data);
1390
+ return result.data;
1391
+ }),
1392
+ mutationKey: ["useCreateWarehouse"],
1393
+ onError
3261
1394
  });
3262
- }, $s = () => {
3263
- const { client: r } = E();
3264
- return I({
3265
- mutationFn: async (e) => (await r.addresses.validate(e)).data,
3266
- mutationKey: ["useValidateAddresses"],
3267
- onError: b
1395
+ };
1396
+
1397
+ var __async$1 = (__this, __arguments, generator) => {
1398
+ return new Promise((resolve, reject) => {
1399
+ var fulfilled = (value) => {
1400
+ try {
1401
+ step(generator.next(value));
1402
+ } catch (e) {
1403
+ reject(e);
1404
+ }
1405
+ };
1406
+ var rejected = (value) => {
1407
+ try {
1408
+ step(generator.throw(value));
1409
+ } catch (e) {
1410
+ reject(e);
1411
+ }
1412
+ };
1413
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1414
+ step((generator = generator.apply(__this, __arguments)).next());
1415
+ });
1416
+ };
1417
+ const useDeleteWarehouse = () => {
1418
+ const { client } = useShipEngine();
1419
+ return useMutation({
1420
+ mutationFn: (_0) => __async$1(void 0, [_0], function* ({ warehouseId }) {
1421
+ const result = yield client.warehouses.delete(warehouseId);
1422
+ return result.data;
1423
+ }),
1424
+ mutationKey: ["useDeleteWarehouse"],
1425
+ onError
1426
+ });
1427
+ };
1428
+
1429
+ const useListWarehouses = (options) => {
1430
+ var _a;
1431
+ const { client } = useShipEngine();
1432
+ return useQuery({
1433
+ enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
1434
+ onError,
1435
+ queryFn: () => client.warehouses.list(),
1436
+ queryKey: ["useListWarehouses"],
1437
+ select: (result) => result.data.warehouses
1438
+ });
1439
+ };
1440
+
1441
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1442
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1443
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
1444
+ var __objRest = (source, exclude) => {
1445
+ var target = {};
1446
+ for (var prop in source)
1447
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
1448
+ target[prop] = source[prop];
1449
+ if (source != null && __getOwnPropSymbols)
1450
+ for (var prop of __getOwnPropSymbols(source)) {
1451
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
1452
+ target[prop] = source[prop];
1453
+ }
1454
+ return target;
1455
+ };
1456
+ var __async = (__this, __arguments, generator) => {
1457
+ return new Promise((resolve, reject) => {
1458
+ var fulfilled = (value) => {
1459
+ try {
1460
+ step(generator.next(value));
1461
+ } catch (e) {
1462
+ reject(e);
1463
+ }
1464
+ };
1465
+ var rejected = (value) => {
1466
+ try {
1467
+ step(generator.throw(value));
1468
+ } catch (e) {
1469
+ reject(e);
1470
+ }
1471
+ };
1472
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1473
+ step((generator = generator.apply(__this, __arguments)).next());
1474
+ });
1475
+ };
1476
+ const useUpdateWarehouse = () => {
1477
+ const { client } = useShipEngine();
1478
+ return useMutation({
1479
+ mutationFn: (_a) => __async(void 0, null, function* () {
1480
+ var _b = _a, { warehouseId } = _b, warehouse = __objRest(_b, ["warehouseId"]);
1481
+ const result = yield client.warehouses.update(warehouseId, warehouse);
1482
+ return result.data;
1483
+ }),
1484
+ mutationKey: ["useUpdateWarehouse"],
1485
+ onError
3268
1486
  });
3269
- }, _s = () => {
3270
- const { client: r } = E();
3271
- return I({
3272
- mutationFn: async (e) => (await r.labels.void(e)).data,
3273
- mutationKey: ["useVoidLabel"],
3274
- onError: b
3275
- });
3276
- };
3277
- export {
3278
- _n as AccountSettingsAPI,
3279
- Dn as AddressesAPI,
3280
- Ta as CarriersAPI,
3281
- W as CodedError,
3282
- Ut as ConfirmationType,
3283
- Bt as CreditCardVendor,
3284
- Lt as Currency,
3285
- Bo as CustomPackagesAPI,
3286
- qt as CustomsContentsType,
3287
- Mt as CustomsNonDeliveryType,
3288
- Lo as InsuranceAPI,
3289
- zt as InsuranceProviderType,
3290
- Uo as LabelsAPI,
3291
- qo as OrderSourcesAPI,
3292
- Mo as RatesAPI,
3293
- Yo as SE,
3294
- zo as SalesOrderShipmentsAPI,
3295
- jo as SalesOrdersAPI,
3296
- Zo as ShipEngine,
3297
- Tt as ShipEngineAPI,
3298
- On as ShipEngineContext,
3299
- Wo as WarehousesAPI,
3300
- Ko as delay,
3301
- on as isCodedError,
3302
- an as isCodedErrors,
3303
- es as logger,
3304
- b as onError,
3305
- Ho as retryUntil,
3306
- rs as useAddFunds,
3307
- ts as useCalculateRates,
3308
- ns as useConnectCarrier,
3309
- as as useCreateLabel,
3310
- is as useCreateSalesOrderShipment,
3311
- os as useCreateWarehouse,
3312
- ss as useDeleteWarehouse,
3313
- us as useGetAccountSettings,
3314
- ls as useGetAutoFundingConfiguration,
3315
- cs as useGetCarrierById,
3316
- fs as useGetInsuranceAccount,
3317
- ps as useGetLabel,
3318
- ds as useGetSalesOrder,
3319
- hs as useGetSalesOrderShipment,
3320
- ys as useGetShipment,
3321
- vs as useGetWalletTransactionHistory,
3322
- ms as useListCarriers,
3323
- gs as useListCustomPackageTypes,
3324
- Ss as useListLabels,
3325
- ws as useListOrderSources,
3326
- bs as useListSalesOrderShipments,
3327
- Es as useListSalesOrders,
3328
- As as useListWarehouses,
3329
- Os as useNotifySalesOrderShipped,
3330
- Ps as useParseAddress,
3331
- Is as useRefreshOrderSource,
3332
- Vo as useRefreshOrderSourceAsync,
3333
- E as useShipEngine,
3334
- Rs as useUpdateAccountSettings,
3335
- xs as useUpdateAutoFunding,
3336
- Cs as useUpdateBilling,
3337
- Fs as useUpdateSalesOrderShipment,
3338
- Ns as useUpdateWarehouse,
3339
- $s as useValidateAddresses,
3340
- _s as useVoidLabel
3341
1487
  };
1488
+
1489
+ export { ShipEngine, ShipEngineContext, delay, logger, onError, retryUntil, useAddFunds, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateRateCard, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteRateCard, useDeleteWarehouse, useDownloadRateCard, useFundingSourcesAddFunds, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetCountriesByCarrier, useGetCurrenciesByCarrier, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetPackageRatingGroupByCarrier, useGetRateCardById, useGetSalesOrder, useGetSalesOrderShipment, useGetServicesByCarrier, useGetShipment, useGetShipmentRates, useGetWalletHistory, useGetZonesByCarrier, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListRateCards, useListSalesOrderShipments, useListSalesOrders, useListShipments, useListWarehouses, useNotifySalesOrderShipped, useParseAddress, usePublishRateCard, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateRateCard, useUpdateSalesOrderShipment, useUpdateWarehouse, useUploadRateCard, useValidateAddresses, useVoidLabel };