@commercetools/ts-client 2.1.6 → 3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @commercetools/ts-client
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#896](https://github.com/commercetools/commercetools-sdk-typescript/pull/896) [`f9b8cb6`](https://github.com/commercetools/commercetools-sdk-typescript/commit/f9b8cb605d99fe5ece13bdc3c152eb4818e19b3b) Thanks [@lojzatran](https://github.com/lojzatran)! - Remove support of nodejs 16
8
+
9
+ ## 2.1.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [#887](https://github.com/commercetools/commercetools-sdk-typescript/pull/887) [`3ee183a`](https://github.com/commercetools/commercetools-sdk-typescript/commit/3ee183a3329012b4bcfe6eb7a6b0044232bbdb5d) Thanks [@lojzatran](https://github.com/lojzatran)! - fix(SUPPORT-30038): clone deep the request object
14
+
3
15
  ## 2.1.6
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -26,7 +26,6 @@ import {
26
26
  ClientBuilder,
27
27
  } from '@commercetools/ts-client'
28
28
  import { createApiBuilderFromCtpClient } from '@commercetools/platform-sdk'
29
- import fetch from 'node-fetch'
30
29
 
31
30
  const projectKey = 'mc-project-key'
32
31
  const authMiddlewareOptions = {
@@ -2,14 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var fetch$1 = require('node-fetch');
6
- var AbortController = require('abort-controller');
7
-
8
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
-
10
- var fetch__default = /*#__PURE__*/_interopDefault(fetch$1);
11
- var AbortController__default = /*#__PURE__*/_interopDefault(AbortController);
12
-
13
5
  function _toPrimitive(t, r) {
14
6
  if ("object" != typeof t || !t) return t;
15
7
  var e = t[Symbol.toPrimitive];
@@ -192,7 +184,7 @@ async function executor(request) {
192
184
  });
193
185
  }
194
186
  function initializeAbortController() {
195
- const abortController = (getAbortController ? getAbortController() : null) || new AbortController__default["default"]();
187
+ const abortController = (getAbortController ? getAbortController() : null) || new AbortController();
196
188
  rest.abortController = abortController;
197
189
  rest.signal = abortController.signal;
198
190
  return abortController;
@@ -216,7 +208,9 @@ async function executor(request) {
216
208
  };
217
209
  }
218
210
  } catch (e) {
219
- if (e.name.includes('AbortError') && retryWhenAborted) {
211
+ // in nodejs v18, the error is AbortError, in nodejs v20, the error is TimeoutError
212
+ // https://github.com/nodejs/undici/issues/2590
213
+ if ((e.name.includes('AbortError') || e.name.includes('TimeoutError')) && retryWhenAborted) {
220
214
  return {
221
215
  _response: e,
222
216
  shouldRetry: true
@@ -313,7 +307,13 @@ function getHeaders(headers) {
313
307
 
314
308
  // Tmp fix for Firefox until it supports iterables
315
309
  if (!headers.forEach) return parse(headers);
316
- return headers.forEach((value, name) => value);
310
+
311
+ // whatwg-fetch
312
+ const map = {};
313
+ headers.forEach((value, name) => {
314
+ return map[name] = value;
315
+ });
316
+ return map;
317
317
  }
318
318
 
319
319
  function isBuffer(obj) {
@@ -321,7 +321,7 @@ function isBuffer(obj) {
321
321
  }
322
322
 
323
323
  function maskAuthData(request) {
324
- const _request = Object.assign({}, request);
324
+ const _request = JSON.parse(JSON.stringify(request));
325
325
  if (_request?.headers) {
326
326
  if (_request.headers.Authorization) {
327
327
  _request.headers['Authorization'] = 'Bearer ********';
@@ -760,7 +760,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
760
760
  request,
761
761
  tokenCache,
762
762
  tokenCacheKey,
763
- httpClient: options.httpClient || fetch__default["default"],
763
+ httpClient: options.httpClient || fetch,
764
764
  httpClientOptions: options.httpClientOptions,
765
765
  ...buildRequestForAnonymousSessionFlow(options),
766
766
  userOption: options,
@@ -815,7 +815,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
815
815
  tokenCache,
816
816
  tokenCacheKey,
817
817
  tokenCacheObject,
818
- httpClient: options.httpClient || fetch__default["default"],
818
+ httpClient: options.httpClient || fetch,
819
819
  httpClientOptions: options.httpClientOptions,
820
820
  ...buildRequestForClientCredentialsFlow(options),
821
821
  next
@@ -891,7 +891,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
891
891
  request,
892
892
  tokenCache,
893
893
  tokenCacheKey,
894
- httpClient: options.httpClient || fetch__default["default"],
894
+ httpClient: options.httpClient || fetch,
895
895
  httpClientOptions: options.httpClientOptions,
896
896
  ...buildRequestForPasswordFlow(options),
897
897
  userOption: options,
@@ -1271,9 +1271,9 @@ function createQueueMiddleware$1({
1271
1271
 
1272
1272
  var packageJson = {
1273
1273
  name: "@commercetools/ts-client",
1274
- version: "2.1.6",
1274
+ version: "3.0.0",
1275
1275
  engines: {
1276
- node: ">=14"
1276
+ node: ">=18"
1277
1277
  },
1278
1278
  description: "commercetools Composable Commerce TypeScript SDK client.",
1279
1279
  keywords: [
@@ -1304,9 +1304,7 @@ var packageJson = {
1304
1304
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
1305
1305
  },
1306
1306
  dependencies: {
1307
- "abort-controller": "3.0.0",
1308
- buffer: "^6.0.3",
1309
- "node-fetch": "^2.6.1"
1307
+ buffer: "^6.0.3"
1310
1308
  },
1311
1309
  files: [
1312
1310
  "dist",
@@ -1323,7 +1321,7 @@ var packageJson = {
1323
1321
  "common-tags": "1.8.2",
1324
1322
  dotenv: "16.4.5",
1325
1323
  jest: "29.7.0",
1326
- nock: "12.0.3",
1324
+ nock: "^14.0.0-beta.19",
1327
1325
  "organize-imports-cli": "0.10.0"
1328
1326
  },
1329
1327
  scripts: {
@@ -1558,11 +1556,11 @@ class ClientBuilder {
1558
1556
  host: oauthUri,
1559
1557
  projectKey: projectKey || this.projectKey,
1560
1558
  credentials,
1561
- httpClient: httpClient || fetch__default["default"],
1559
+ httpClient: httpClient || fetch,
1562
1560
  scopes
1563
1561
  }).withHttpMiddleware({
1564
1562
  host: baseUri,
1565
- httpClient: httpClient || fetch__default["default"]
1563
+ httpClient: httpClient || fetch
1566
1564
  });
1567
1565
  }
1568
1566
  withAuthMiddleware(authMiddleware) {
@@ -1583,7 +1581,7 @@ class ClientBuilder {
1583
1581
  },
1584
1582
  oauthUri: options.oauthUri || null,
1585
1583
  scopes: options.scopes,
1586
- httpClient: options.httpClient || fetch__default["default"],
1584
+ httpClient: options.httpClient || fetch,
1587
1585
  ...options
1588
1586
  }));
1589
1587
  }
@@ -1599,7 +1597,7 @@ class ClientBuilder {
1599
1597
  password: options.credentials.user.password || null
1600
1598
  }
1601
1599
  },
1602
- httpClient: options.httpClient || fetch__default["default"],
1600
+ httpClient: options.httpClient || fetch,
1603
1601
  ...options
1604
1602
  }));
1605
1603
  }
@@ -1612,7 +1610,7 @@ class ClientBuilder {
1612
1610
  clientSecret: options.credentials.clientSecret || null,
1613
1611
  anonymousId: options.credentials.anonymousId || null
1614
1612
  },
1615
- httpClient: options.httpClient || fetch__default["default"],
1613
+ httpClient: options.httpClient || fetch,
1616
1614
  ...options
1617
1615
  }));
1618
1616
  }
@@ -1624,7 +1622,7 @@ class ClientBuilder {
1624
1622
  clientId: options.credentials.clientId || null,
1625
1623
  clientSecret: options.credentials.clientSecret || null
1626
1624
  },
1627
- httpClient: options.httpClient || fetch__default["default"],
1625
+ httpClient: options.httpClient || fetch,
1628
1626
  refreshToken: options.refreshToken || null,
1629
1627
  ...options
1630
1628
  }));
@@ -1638,7 +1636,7 @@ class ClientBuilder {
1638
1636
  withHttpMiddleware(options) {
1639
1637
  this.httpMiddleware = createHttpMiddleware({
1640
1638
  host: options.host || CTP_API_URL,
1641
- httpClient: options.httpClient || fetch__default["default"],
1639
+ httpClient: options.httpClient || fetch,
1642
1640
  ...options
1643
1641
  });
1644
1642
  return this;
@@ -1,6 +1,3 @@
1
- import fetch$1 from 'node-fetch';
2
- import AbortController from 'abort-controller';
3
-
4
1
  function _toPrimitive(t, r) {
5
2
  if ("object" != typeof t || !t) return t;
6
3
  var e = t[Symbol.toPrimitive];
@@ -207,7 +204,9 @@ async function executor(request) {
207
204
  };
208
205
  }
209
206
  } catch (e) {
210
- if (e.name.includes('AbortError') && retryWhenAborted) {
207
+ // in nodejs v18, the error is AbortError, in nodejs v20, the error is TimeoutError
208
+ // https://github.com/nodejs/undici/issues/2590
209
+ if ((e.name.includes('AbortError') || e.name.includes('TimeoutError')) && retryWhenAborted) {
211
210
  return {
212
211
  _response: e,
213
212
  shouldRetry: true
@@ -304,7 +303,13 @@ function getHeaders(headers) {
304
303
 
305
304
  // Tmp fix for Firefox until it supports iterables
306
305
  if (!headers.forEach) return parse(headers);
307
- return headers.forEach((value, name) => value);
306
+
307
+ // whatwg-fetch
308
+ const map = {};
309
+ headers.forEach((value, name) => {
310
+ return map[name] = value;
311
+ });
312
+ return map;
308
313
  }
309
314
 
310
315
  function isBuffer(obj) {
@@ -312,7 +317,7 @@ function isBuffer(obj) {
312
317
  }
313
318
 
314
319
  function maskAuthData(request) {
315
- const _request = Object.assign({}, request);
320
+ const _request = JSON.parse(JSON.stringify(request));
316
321
  if (_request?.headers) {
317
322
  if (_request.headers.Authorization) {
318
323
  _request.headers['Authorization'] = 'Bearer ********';
@@ -751,7 +756,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
751
756
  request,
752
757
  tokenCache,
753
758
  tokenCacheKey,
754
- httpClient: options.httpClient || fetch$1,
759
+ httpClient: options.httpClient || fetch,
755
760
  httpClientOptions: options.httpClientOptions,
756
761
  ...buildRequestForAnonymousSessionFlow(options),
757
762
  userOption: options,
@@ -806,7 +811,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
806
811
  tokenCache,
807
812
  tokenCacheKey,
808
813
  tokenCacheObject,
809
- httpClient: options.httpClient || fetch$1,
814
+ httpClient: options.httpClient || fetch,
810
815
  httpClientOptions: options.httpClientOptions,
811
816
  ...buildRequestForClientCredentialsFlow(options),
812
817
  next
@@ -882,7 +887,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
882
887
  request,
883
888
  tokenCache,
884
889
  tokenCacheKey,
885
- httpClient: options.httpClient || fetch$1,
890
+ httpClient: options.httpClient || fetch,
886
891
  httpClientOptions: options.httpClientOptions,
887
892
  ...buildRequestForPasswordFlow(options),
888
893
  userOption: options,
@@ -1262,9 +1267,9 @@ function createQueueMiddleware$1({
1262
1267
 
1263
1268
  var packageJson = {
1264
1269
  name: "@commercetools/ts-client",
1265
- version: "2.1.6",
1270
+ version: "3.0.0",
1266
1271
  engines: {
1267
- node: ">=14"
1272
+ node: ">=18"
1268
1273
  },
1269
1274
  description: "commercetools Composable Commerce TypeScript SDK client.",
1270
1275
  keywords: [
@@ -1295,9 +1300,7 @@ var packageJson = {
1295
1300
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
1296
1301
  },
1297
1302
  dependencies: {
1298
- "abort-controller": "3.0.0",
1299
- buffer: "^6.0.3",
1300
- "node-fetch": "^2.6.1"
1303
+ buffer: "^6.0.3"
1301
1304
  },
1302
1305
  files: [
1303
1306
  "dist",
@@ -1314,7 +1317,7 @@ var packageJson = {
1314
1317
  "common-tags": "1.8.2",
1315
1318
  dotenv: "16.4.5",
1316
1319
  jest: "29.7.0",
1317
- nock: "12.0.3",
1320
+ nock: "^14.0.0-beta.19",
1318
1321
  "organize-imports-cli": "0.10.0"
1319
1322
  },
1320
1323
  scripts: {
@@ -1549,11 +1552,11 @@ class ClientBuilder {
1549
1552
  host: oauthUri,
1550
1553
  projectKey: projectKey || this.projectKey,
1551
1554
  credentials,
1552
- httpClient: httpClient || fetch$1,
1555
+ httpClient: httpClient || fetch,
1553
1556
  scopes
1554
1557
  }).withHttpMiddleware({
1555
1558
  host: baseUri,
1556
- httpClient: httpClient || fetch$1
1559
+ httpClient: httpClient || fetch
1557
1560
  });
1558
1561
  }
1559
1562
  withAuthMiddleware(authMiddleware) {
@@ -1574,7 +1577,7 @@ class ClientBuilder {
1574
1577
  },
1575
1578
  oauthUri: options.oauthUri || null,
1576
1579
  scopes: options.scopes,
1577
- httpClient: options.httpClient || fetch$1,
1580
+ httpClient: options.httpClient || fetch,
1578
1581
  ...options
1579
1582
  }));
1580
1583
  }
@@ -1590,7 +1593,7 @@ class ClientBuilder {
1590
1593
  password: options.credentials.user.password || null
1591
1594
  }
1592
1595
  },
1593
- httpClient: options.httpClient || fetch$1,
1596
+ httpClient: options.httpClient || fetch,
1594
1597
  ...options
1595
1598
  }));
1596
1599
  }
@@ -1603,7 +1606,7 @@ class ClientBuilder {
1603
1606
  clientSecret: options.credentials.clientSecret || null,
1604
1607
  anonymousId: options.credentials.anonymousId || null
1605
1608
  },
1606
- httpClient: options.httpClient || fetch$1,
1609
+ httpClient: options.httpClient || fetch,
1607
1610
  ...options
1608
1611
  }));
1609
1612
  }
@@ -1615,7 +1618,7 @@ class ClientBuilder {
1615
1618
  clientId: options.credentials.clientId || null,
1616
1619
  clientSecret: options.credentials.clientSecret || null
1617
1620
  },
1618
- httpClient: options.httpClient || fetch$1,
1621
+ httpClient: options.httpClient || fetch,
1619
1622
  refreshToken: options.refreshToken || null,
1620
1623
  ...options
1621
1624
  }));
@@ -1629,7 +1632,7 @@ class ClientBuilder {
1629
1632
  withHttpMiddleware(options) {
1630
1633
  this.httpMiddleware = createHttpMiddleware({
1631
1634
  host: options.host || CTP_API_URL,
1632
- httpClient: options.httpClient || fetch$1,
1635
+ httpClient: options.httpClient || fetch,
1633
1636
  ...options
1634
1637
  });
1635
1638
  return this;
@@ -2,14 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var fetch$1 = require('node-fetch');
6
- var AbortController = require('abort-controller');
7
-
8
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
-
10
- var fetch__default = /*#__PURE__*/_interopDefault(fetch$1);
11
- var AbortController__default = /*#__PURE__*/_interopDefault(AbortController);
12
-
13
5
  function _toPrimitive(t, r) {
14
6
  if ("object" != typeof t || !t) return t;
15
7
  var e = t[Symbol.toPrimitive];
@@ -192,7 +184,7 @@ async function executor(request) {
192
184
  });
193
185
  }
194
186
  function initializeAbortController() {
195
- const abortController = (getAbortController ? getAbortController() : null) || new AbortController__default["default"]();
187
+ const abortController = (getAbortController ? getAbortController() : null) || new AbortController();
196
188
  rest.abortController = abortController;
197
189
  rest.signal = abortController.signal;
198
190
  return abortController;
@@ -216,7 +208,9 @@ async function executor(request) {
216
208
  };
217
209
  }
218
210
  } catch (e) {
219
- if (e.name.includes('AbortError') && retryWhenAborted) {
211
+ // in nodejs v18, the error is AbortError, in nodejs v20, the error is TimeoutError
212
+ // https://github.com/nodejs/undici/issues/2590
213
+ if ((e.name.includes('AbortError') || e.name.includes('TimeoutError')) && retryWhenAborted) {
220
214
  return {
221
215
  _response: e,
222
216
  shouldRetry: true
@@ -313,7 +307,13 @@ function getHeaders(headers) {
313
307
 
314
308
  // Tmp fix for Firefox until it supports iterables
315
309
  if (!headers.forEach) return parse(headers);
316
- return headers.forEach((value, name) => value);
310
+
311
+ // whatwg-fetch
312
+ const map = {};
313
+ headers.forEach((value, name) => {
314
+ return map[name] = value;
315
+ });
316
+ return map;
317
317
  }
318
318
 
319
319
  function isBuffer(obj) {
@@ -321,7 +321,7 @@ function isBuffer(obj) {
321
321
  }
322
322
 
323
323
  function maskAuthData(request) {
324
- const _request = Object.assign({}, request);
324
+ const _request = JSON.parse(JSON.stringify(request));
325
325
  if (_request?.headers) {
326
326
  if (_request.headers.Authorization) {
327
327
  _request.headers['Authorization'] = 'Bearer ********';
@@ -760,7 +760,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
760
760
  request,
761
761
  tokenCache,
762
762
  tokenCacheKey,
763
- httpClient: options.httpClient || fetch__default["default"],
763
+ httpClient: options.httpClient || fetch,
764
764
  httpClientOptions: options.httpClientOptions,
765
765
  ...buildRequestForAnonymousSessionFlow(options),
766
766
  userOption: options,
@@ -815,7 +815,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
815
815
  tokenCache,
816
816
  tokenCacheKey,
817
817
  tokenCacheObject,
818
- httpClient: options.httpClient || fetch__default["default"],
818
+ httpClient: options.httpClient || fetch,
819
819
  httpClientOptions: options.httpClientOptions,
820
820
  ...buildRequestForClientCredentialsFlow(options),
821
821
  next
@@ -891,7 +891,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
891
891
  request,
892
892
  tokenCache,
893
893
  tokenCacheKey,
894
- httpClient: options.httpClient || fetch__default["default"],
894
+ httpClient: options.httpClient || fetch,
895
895
  httpClientOptions: options.httpClientOptions,
896
896
  ...buildRequestForPasswordFlow(options),
897
897
  userOption: options,
@@ -1271,9 +1271,9 @@ function createQueueMiddleware$1({
1271
1271
 
1272
1272
  var packageJson = {
1273
1273
  name: "@commercetools/ts-client",
1274
- version: "2.1.6",
1274
+ version: "3.0.0",
1275
1275
  engines: {
1276
- node: ">=14"
1276
+ node: ">=18"
1277
1277
  },
1278
1278
  description: "commercetools Composable Commerce TypeScript SDK client.",
1279
1279
  keywords: [
@@ -1304,9 +1304,7 @@ var packageJson = {
1304
1304
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
1305
1305
  },
1306
1306
  dependencies: {
1307
- "abort-controller": "3.0.0",
1308
- buffer: "^6.0.3",
1309
- "node-fetch": "^2.6.1"
1307
+ buffer: "^6.0.3"
1310
1308
  },
1311
1309
  files: [
1312
1310
  "dist",
@@ -1323,7 +1321,7 @@ var packageJson = {
1323
1321
  "common-tags": "1.8.2",
1324
1322
  dotenv: "16.4.5",
1325
1323
  jest: "29.7.0",
1326
- nock: "12.0.3",
1324
+ nock: "^14.0.0-beta.19",
1327
1325
  "organize-imports-cli": "0.10.0"
1328
1326
  },
1329
1327
  scripts: {
@@ -1558,11 +1556,11 @@ class ClientBuilder {
1558
1556
  host: oauthUri,
1559
1557
  projectKey: projectKey || this.projectKey,
1560
1558
  credentials,
1561
- httpClient: httpClient || fetch__default["default"],
1559
+ httpClient: httpClient || fetch,
1562
1560
  scopes
1563
1561
  }).withHttpMiddleware({
1564
1562
  host: baseUri,
1565
- httpClient: httpClient || fetch__default["default"]
1563
+ httpClient: httpClient || fetch
1566
1564
  });
1567
1565
  }
1568
1566
  withAuthMiddleware(authMiddleware) {
@@ -1583,7 +1581,7 @@ class ClientBuilder {
1583
1581
  },
1584
1582
  oauthUri: options.oauthUri || null,
1585
1583
  scopes: options.scopes,
1586
- httpClient: options.httpClient || fetch__default["default"],
1584
+ httpClient: options.httpClient || fetch,
1587
1585
  ...options
1588
1586
  }));
1589
1587
  }
@@ -1599,7 +1597,7 @@ class ClientBuilder {
1599
1597
  password: options.credentials.user.password || null
1600
1598
  }
1601
1599
  },
1602
- httpClient: options.httpClient || fetch__default["default"],
1600
+ httpClient: options.httpClient || fetch,
1603
1601
  ...options
1604
1602
  }));
1605
1603
  }
@@ -1612,7 +1610,7 @@ class ClientBuilder {
1612
1610
  clientSecret: options.credentials.clientSecret || null,
1613
1611
  anonymousId: options.credentials.anonymousId || null
1614
1612
  },
1615
- httpClient: options.httpClient || fetch__default["default"],
1613
+ httpClient: options.httpClient || fetch,
1616
1614
  ...options
1617
1615
  }));
1618
1616
  }
@@ -1624,7 +1622,7 @@ class ClientBuilder {
1624
1622
  clientId: options.credentials.clientId || null,
1625
1623
  clientSecret: options.credentials.clientSecret || null
1626
1624
  },
1627
- httpClient: options.httpClient || fetch__default["default"],
1625
+ httpClient: options.httpClient || fetch,
1628
1626
  refreshToken: options.refreshToken || null,
1629
1627
  ...options
1630
1628
  }));
@@ -1638,7 +1636,7 @@ class ClientBuilder {
1638
1636
  withHttpMiddleware(options) {
1639
1637
  this.httpMiddleware = createHttpMiddleware({
1640
1638
  host: options.host || CTP_API_URL,
1641
- httpClient: options.httpClient || fetch__default["default"],
1639
+ httpClient: options.httpClient || fetch,
1642
1640
  ...options
1643
1641
  });
1644
1642
  return this;
@@ -2,14 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var fetch$1 = require('node-fetch');
6
- var AbortController = require('abort-controller');
7
-
8
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
-
10
- var fetch__default = /*#__PURE__*/_interopDefault(fetch$1);
11
- var AbortController__default = /*#__PURE__*/_interopDefault(AbortController);
12
-
13
5
  function _toPrimitive(t, r) {
14
6
  if ("object" != typeof t || !t) return t;
15
7
  var e = t[Symbol.toPrimitive];
@@ -192,7 +184,7 @@ async function executor(request) {
192
184
  });
193
185
  }
194
186
  function initializeAbortController() {
195
- const abortController = (getAbortController ? getAbortController() : null) || new AbortController__default["default"]();
187
+ const abortController = (getAbortController ? getAbortController() : null) || new AbortController();
196
188
  rest.abortController = abortController;
197
189
  rest.signal = abortController.signal;
198
190
  return abortController;
@@ -216,7 +208,9 @@ async function executor(request) {
216
208
  };
217
209
  }
218
210
  } catch (e) {
219
- if (e.name.includes('AbortError') && retryWhenAborted) {
211
+ // in nodejs v18, the error is AbortError, in nodejs v20, the error is TimeoutError
212
+ // https://github.com/nodejs/undici/issues/2590
213
+ if ((e.name.includes('AbortError') || e.name.includes('TimeoutError')) && retryWhenAborted) {
220
214
  return {
221
215
  _response: e,
222
216
  shouldRetry: true
@@ -313,7 +307,13 @@ function getHeaders(headers) {
313
307
 
314
308
  // Tmp fix for Firefox until it supports iterables
315
309
  if (!headers.forEach) return parse(headers);
316
- return headers.forEach((value, name) => value);
310
+
311
+ // whatwg-fetch
312
+ const map = {};
313
+ headers.forEach((value, name) => {
314
+ return map[name] = value;
315
+ });
316
+ return map;
317
317
  }
318
318
 
319
319
  function isBuffer(obj) {
@@ -321,7 +321,7 @@ function isBuffer(obj) {
321
321
  }
322
322
 
323
323
  function maskAuthData(request) {
324
- const _request = Object.assign({}, request);
324
+ const _request = JSON.parse(JSON.stringify(request));
325
325
  if (_request?.headers) {
326
326
  if (_request.headers.Authorization) {
327
327
  _request.headers['Authorization'] = 'Bearer ********';
@@ -760,7 +760,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
760
760
  request,
761
761
  tokenCache,
762
762
  tokenCacheKey,
763
- httpClient: options.httpClient || fetch__default["default"],
763
+ httpClient: options.httpClient || fetch,
764
764
  httpClientOptions: options.httpClientOptions,
765
765
  ...buildRequestForAnonymousSessionFlow(options),
766
766
  userOption: options,
@@ -815,7 +815,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
815
815
  tokenCache,
816
816
  tokenCacheKey,
817
817
  tokenCacheObject,
818
- httpClient: options.httpClient || fetch__default["default"],
818
+ httpClient: options.httpClient || fetch,
819
819
  httpClientOptions: options.httpClientOptions,
820
820
  ...buildRequestForClientCredentialsFlow(options),
821
821
  next
@@ -891,7 +891,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
891
891
  request,
892
892
  tokenCache,
893
893
  tokenCacheKey,
894
- httpClient: options.httpClient || fetch__default["default"],
894
+ httpClient: options.httpClient || fetch,
895
895
  httpClientOptions: options.httpClientOptions,
896
896
  ...buildRequestForPasswordFlow(options),
897
897
  userOption: options,
@@ -1271,9 +1271,9 @@ function createQueueMiddleware$1({
1271
1271
 
1272
1272
  var packageJson = {
1273
1273
  name: "@commercetools/ts-client",
1274
- version: "2.1.6",
1274
+ version: "3.0.0",
1275
1275
  engines: {
1276
- node: ">=14"
1276
+ node: ">=18"
1277
1277
  },
1278
1278
  description: "commercetools Composable Commerce TypeScript SDK client.",
1279
1279
  keywords: [
@@ -1304,9 +1304,7 @@ var packageJson = {
1304
1304
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
1305
1305
  },
1306
1306
  dependencies: {
1307
- "abort-controller": "3.0.0",
1308
- buffer: "^6.0.3",
1309
- "node-fetch": "^2.6.1"
1307
+ buffer: "^6.0.3"
1310
1308
  },
1311
1309
  files: [
1312
1310
  "dist",
@@ -1323,7 +1321,7 @@ var packageJson = {
1323
1321
  "common-tags": "1.8.2",
1324
1322
  dotenv: "16.4.5",
1325
1323
  jest: "29.7.0",
1326
- nock: "12.0.3",
1324
+ nock: "^14.0.0-beta.19",
1327
1325
  "organize-imports-cli": "0.10.0"
1328
1326
  },
1329
1327
  scripts: {
@@ -1558,11 +1556,11 @@ class ClientBuilder {
1558
1556
  host: oauthUri,
1559
1557
  projectKey: projectKey || this.projectKey,
1560
1558
  credentials,
1561
- httpClient: httpClient || fetch__default["default"],
1559
+ httpClient: httpClient || fetch,
1562
1560
  scopes
1563
1561
  }).withHttpMiddleware({
1564
1562
  host: baseUri,
1565
- httpClient: httpClient || fetch__default["default"]
1563
+ httpClient: httpClient || fetch
1566
1564
  });
1567
1565
  }
1568
1566
  withAuthMiddleware(authMiddleware) {
@@ -1583,7 +1581,7 @@ class ClientBuilder {
1583
1581
  },
1584
1582
  oauthUri: options.oauthUri || null,
1585
1583
  scopes: options.scopes,
1586
- httpClient: options.httpClient || fetch__default["default"],
1584
+ httpClient: options.httpClient || fetch,
1587
1585
  ...options
1588
1586
  }));
1589
1587
  }
@@ -1599,7 +1597,7 @@ class ClientBuilder {
1599
1597
  password: options.credentials.user.password || null
1600
1598
  }
1601
1599
  },
1602
- httpClient: options.httpClient || fetch__default["default"],
1600
+ httpClient: options.httpClient || fetch,
1603
1601
  ...options
1604
1602
  }));
1605
1603
  }
@@ -1612,7 +1610,7 @@ class ClientBuilder {
1612
1610
  clientSecret: options.credentials.clientSecret || null,
1613
1611
  anonymousId: options.credentials.anonymousId || null
1614
1612
  },
1615
- httpClient: options.httpClient || fetch__default["default"],
1613
+ httpClient: options.httpClient || fetch,
1616
1614
  ...options
1617
1615
  }));
1618
1616
  }
@@ -1624,7 +1622,7 @@ class ClientBuilder {
1624
1622
  clientId: options.credentials.clientId || null,
1625
1623
  clientSecret: options.credentials.clientSecret || null
1626
1624
  },
1627
- httpClient: options.httpClient || fetch__default["default"],
1625
+ httpClient: options.httpClient || fetch,
1628
1626
  refreshToken: options.refreshToken || null,
1629
1627
  ...options
1630
1628
  }));
@@ -1638,7 +1636,7 @@ class ClientBuilder {
1638
1636
  withHttpMiddleware(options) {
1639
1637
  this.httpMiddleware = createHttpMiddleware({
1640
1638
  host: options.host || CTP_API_URL,
1641
- httpClient: options.httpClient || fetch__default["default"],
1639
+ httpClient: options.httpClient || fetch,
1642
1640
  ...options
1643
1641
  });
1644
1642
  return this;
@@ -1,6 +1,3 @@
1
- import fetch$1 from 'node-fetch';
2
- import AbortController from 'abort-controller';
3
-
4
1
  function _toPrimitive(t, r) {
5
2
  if ("object" != typeof t || !t) return t;
6
3
  var e = t[Symbol.toPrimitive];
@@ -207,7 +204,9 @@ async function executor(request) {
207
204
  };
208
205
  }
209
206
  } catch (e) {
210
- if (e.name.includes('AbortError') && retryWhenAborted) {
207
+ // in nodejs v18, the error is AbortError, in nodejs v20, the error is TimeoutError
208
+ // https://github.com/nodejs/undici/issues/2590
209
+ if ((e.name.includes('AbortError') || e.name.includes('TimeoutError')) && retryWhenAborted) {
211
210
  return {
212
211
  _response: e,
213
212
  shouldRetry: true
@@ -304,7 +303,13 @@ function getHeaders(headers) {
304
303
 
305
304
  // Tmp fix for Firefox until it supports iterables
306
305
  if (!headers.forEach) return parse(headers);
307
- return headers.forEach((value, name) => value);
306
+
307
+ // whatwg-fetch
308
+ const map = {};
309
+ headers.forEach((value, name) => {
310
+ return map[name] = value;
311
+ });
312
+ return map;
308
313
  }
309
314
 
310
315
  function isBuffer(obj) {
@@ -312,7 +317,7 @@ function isBuffer(obj) {
312
317
  }
313
318
 
314
319
  function maskAuthData(request) {
315
- const _request = Object.assign({}, request);
320
+ const _request = JSON.parse(JSON.stringify(request));
316
321
  if (_request?.headers) {
317
322
  if (_request.headers.Authorization) {
318
323
  _request.headers['Authorization'] = 'Bearer ********';
@@ -751,7 +756,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
751
756
  request,
752
757
  tokenCache,
753
758
  tokenCacheKey,
754
- httpClient: options.httpClient || fetch$1,
759
+ httpClient: options.httpClient || fetch,
755
760
  httpClientOptions: options.httpClientOptions,
756
761
  ...buildRequestForAnonymousSessionFlow(options),
757
762
  userOption: options,
@@ -806,7 +811,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
806
811
  tokenCache,
807
812
  tokenCacheKey,
808
813
  tokenCacheObject,
809
- httpClient: options.httpClient || fetch$1,
814
+ httpClient: options.httpClient || fetch,
810
815
  httpClientOptions: options.httpClientOptions,
811
816
  ...buildRequestForClientCredentialsFlow(options),
812
817
  next
@@ -882,7 +887,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
882
887
  request,
883
888
  tokenCache,
884
889
  tokenCacheKey,
885
- httpClient: options.httpClient || fetch$1,
890
+ httpClient: options.httpClient || fetch,
886
891
  httpClientOptions: options.httpClientOptions,
887
892
  ...buildRequestForPasswordFlow(options),
888
893
  userOption: options,
@@ -1262,9 +1267,9 @@ function createQueueMiddleware$1({
1262
1267
 
1263
1268
  var packageJson = {
1264
1269
  name: "@commercetools/ts-client",
1265
- version: "2.1.6",
1270
+ version: "3.0.0",
1266
1271
  engines: {
1267
- node: ">=14"
1272
+ node: ">=18"
1268
1273
  },
1269
1274
  description: "commercetools Composable Commerce TypeScript SDK client.",
1270
1275
  keywords: [
@@ -1295,9 +1300,7 @@ var packageJson = {
1295
1300
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
1296
1301
  },
1297
1302
  dependencies: {
1298
- "abort-controller": "3.0.0",
1299
- buffer: "^6.0.3",
1300
- "node-fetch": "^2.6.1"
1303
+ buffer: "^6.0.3"
1301
1304
  },
1302
1305
  files: [
1303
1306
  "dist",
@@ -1314,7 +1317,7 @@ var packageJson = {
1314
1317
  "common-tags": "1.8.2",
1315
1318
  dotenv: "16.4.5",
1316
1319
  jest: "29.7.0",
1317
- nock: "12.0.3",
1320
+ nock: "^14.0.0-beta.19",
1318
1321
  "organize-imports-cli": "0.10.0"
1319
1322
  },
1320
1323
  scripts: {
@@ -1549,11 +1552,11 @@ class ClientBuilder {
1549
1552
  host: oauthUri,
1550
1553
  projectKey: projectKey || this.projectKey,
1551
1554
  credentials,
1552
- httpClient: httpClient || fetch$1,
1555
+ httpClient: httpClient || fetch,
1553
1556
  scopes
1554
1557
  }).withHttpMiddleware({
1555
1558
  host: baseUri,
1556
- httpClient: httpClient || fetch$1
1559
+ httpClient: httpClient || fetch
1557
1560
  });
1558
1561
  }
1559
1562
  withAuthMiddleware(authMiddleware) {
@@ -1574,7 +1577,7 @@ class ClientBuilder {
1574
1577
  },
1575
1578
  oauthUri: options.oauthUri || null,
1576
1579
  scopes: options.scopes,
1577
- httpClient: options.httpClient || fetch$1,
1580
+ httpClient: options.httpClient || fetch,
1578
1581
  ...options
1579
1582
  }));
1580
1583
  }
@@ -1590,7 +1593,7 @@ class ClientBuilder {
1590
1593
  password: options.credentials.user.password || null
1591
1594
  }
1592
1595
  },
1593
- httpClient: options.httpClient || fetch$1,
1596
+ httpClient: options.httpClient || fetch,
1594
1597
  ...options
1595
1598
  }));
1596
1599
  }
@@ -1603,7 +1606,7 @@ class ClientBuilder {
1603
1606
  clientSecret: options.credentials.clientSecret || null,
1604
1607
  anonymousId: options.credentials.anonymousId || null
1605
1608
  },
1606
- httpClient: options.httpClient || fetch$1,
1609
+ httpClient: options.httpClient || fetch,
1607
1610
  ...options
1608
1611
  }));
1609
1612
  }
@@ -1615,7 +1618,7 @@ class ClientBuilder {
1615
1618
  clientId: options.credentials.clientId || null,
1616
1619
  clientSecret: options.credentials.clientSecret || null
1617
1620
  },
1618
- httpClient: options.httpClient || fetch$1,
1621
+ httpClient: options.httpClient || fetch,
1619
1622
  refreshToken: options.refreshToken || null,
1620
1623
  ...options
1621
1624
  }));
@@ -1629,7 +1632,7 @@ class ClientBuilder {
1629
1632
  withHttpMiddleware(options) {
1630
1633
  this.httpMiddleware = createHttpMiddleware({
1631
1634
  host: options.host || CTP_API_URL,
1632
- httpClient: options.httpClient || fetch$1,
1635
+ httpClient: options.httpClient || fetch,
1633
1636
  ...options
1634
1637
  });
1635
1638
  return this;
@@ -1,4 +1,4 @@
1
- var window;(window||={})["@commercetools/ts-client"]=(()=>{var Dt=Object.create;var Ee=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Kt=Object.getOwnPropertyNames;var zt=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),_e=(r,e)=>{for(var t in e)Ee(r,t,{get:e[t],enumerable:!0})},it=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Kt(e))!Gt.call(r,n)&&n!==t&&Ee(r,n,{get:()=>e[n],enumerable:!(i=$t(e,n))||i.enumerable});return r};var ue=(r,e,t)=>(t=r!=null?Dt(zt(r)):{},it(e||!r||!r.__esModule?Ee(t,"default",{value:r,enumerable:!0}):t,r)),Qt=r=>it(Ee({},"__esModule",{value:!0}),r);var ce=le((Q,nt)=>{"use strict";var Jt=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},q=Jt();nt.exports=Q=q.fetch;q.fetch&&(Q.default=q.fetch.bind(q));Q.Headers=q.Headers;Q.Request=q.Request;Q.Response=q.Response});var at=le(Ae=>{"use strict";Ae.byteLength=Yt;Ae.toByteArray=Wt;Ae.fromByteArray=er;var b=[],R=[],Vt=typeof Uint8Array<"u"?Uint8Array:Array,je="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(L=0,ot=je.length;L<ot;++L)b[L]=je[L],R[je.charCodeAt(L)]=L;var L,ot;R[45]=62;R[95]=63;function st(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function Yt(r){var e=st(r),t=e[0],i=e[1];return(t+i)*3/4-i}function vt(r,e,t){return(e+t)*3/4-t}function Wt(r){var e,t=st(r),i=t[0],n=t[1],o=new Vt(vt(r,i,n)),s=0,l=n>0?i-4:i,u;for(u=0;u<l;u+=4)e=R[r.charCodeAt(u)]<<18|R[r.charCodeAt(u+1)]<<12|R[r.charCodeAt(u+2)]<<6|R[r.charCodeAt(u+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return n===2&&(e=R[r.charCodeAt(u)]<<2|R[r.charCodeAt(u+1)]>>4,o[s++]=e&255),n===1&&(e=R[r.charCodeAt(u)]<<10|R[r.charCodeAt(u+1)]<<4|R[r.charCodeAt(u+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Xt(r){return b[r>>18&63]+b[r>>12&63]+b[r>>6&63]+b[r&63]}function Zt(r,e,t){for(var i,n=[],o=e;o<t;o+=3)i=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),n.push(Xt(i));return n.join("")}function er(r){for(var e,t=r.length,i=t%3,n=[],o=16383,s=0,l=t-i;s<l;s+=o)n.push(Zt(r,s,s+o>l?l:s+o));return i===1?(e=r[t-1],n.push(b[e>>2]+b[e<<4&63]+"==")):i===2&&(e=(r[t-2]<<8)+r[t-1],n.push(b[e>>10]+b[e>>4&63]+b[e<<2&63]+"=")),n.join("")}});var lt=le(qe=>{qe.read=function(r,e,t,i,n){var o,s,l=n*8-i-1,u=(1<<l)-1,d=u>>1,c=-7,h=t?n-1:0,w=t?-1:1,p=r[e+h];for(h+=w,o=p&(1<<-c)-1,p>>=-c,c+=l;c>0;o=o*256+r[e+h],h+=w,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=s*256+r[e+h],h+=w,c-=8);if(o===0)o=1-d;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-d}return(p?-1:1)*s*Math.pow(2,o-i)};qe.write=function(r,e,t,i,n,o){var s,l,u,d=o*8-n-1,c=(1<<d)-1,h=c>>1,w=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:o-1,f=i?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+h>=1?e+=w/u:e+=w*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=c?(l=0,s=c):s+h>=1?(l=(e*u-1)*Math.pow(2,n),s=s+h):(l=e*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;r[t+p]=l&255,p+=f,l/=256,n-=8);for(s=s<<n|l,d+=n;d>0;r[t+p]=s&255,p+=f,s/=256,d-=8);r[t+p-f]|=S*128}});var Bt=le(v=>{"use strict";var Le=at(),V=lt(),ut=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;v.Buffer=a;v.SlowBuffer=sr;v.INSPECT_MAX_BYTES=50;var Re=2147483647;v.kMaxLength=Re;a.TYPED_ARRAY_SUPPORT=tr();!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function tr(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}});Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function k(r){if(r>Re)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,a.prototype),e}function a(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ke(r)}return pt(r,e,t)}a.poolSize=8192;function pt(r,e,t){if(typeof r=="string")return ir(r,e);if(ArrayBuffer.isView(r))return nr(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(T(r,ArrayBuffer)||r&&T(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(T(r,SharedArrayBuffer)||r&&T(r.buffer,SharedArrayBuffer)))return De(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return a.from(i,e,t);let n=or(r);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return a.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}a.from=function(r,e,t){return pt(r,e,t)};Object.setPrototypeOf(a.prototype,Uint8Array.prototype);Object.setPrototypeOf(a,Uint8Array);function ft(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function rr(r,e,t){return ft(r),r<=0?k(r):e!==void 0?typeof t=="string"?k(r).fill(e,t):k(r).fill(e):k(r)}a.alloc=function(r,e,t){return rr(r,e,t)};function Ke(r){return ft(r),k(r<0?0:ze(r)|0)}a.allocUnsafe=function(r){return Ke(r)};a.allocUnsafeSlow=function(r){return Ke(r)};function ir(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=wt(r,e)|0,i=k(t),n=i.write(r,e);return n!==t&&(i=i.slice(0,n)),i}function He(r){let e=r.length<0?0:ze(r.length)|0,t=k(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function nr(r){if(T(r,Uint8Array)){let e=new Uint8Array(r);return De(e.buffer,e.byteOffset,e.byteLength)}return He(r)}function De(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,a.prototype),i}function or(r){if(a.isBuffer(r)){let e=ze(r.length)|0,t=k(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Qe(r.length)?k(0):He(r);if(r.type==="Buffer"&&Array.isArray(r.data))return He(r.data)}function ze(r){if(r>=Re)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Re.toString(16)+" bytes");return r|0}function sr(r){return+r!=r&&(r=0),a.alloc(+r)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype};a.compare=function(e,t){if(T(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,n=t.length;for(let o=0,s=Math.min(i,n);o<s;++o)if(e[o]!==t[o]){i=e[o],n=t[o];break}return i<n?-1:n<i?1:0};a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let n=a.allocUnsafe(t),o=0;for(i=0;i<e.length;++i){let s=e[i];if(T(s,Uint8Array))o+s.length>n.length?(a.isBuffer(s)||(s=a.from(s)),s.copy(n,o)):Uint8Array.prototype.set.call(n,s,o);else if(a.isBuffer(s))s.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return n};function wt(r,e){if(a.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||T(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return $e(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Rt(r).length;default:if(n)return i?-1:$e(r).length;e=(""+e).toLowerCase(),n=!0}}a.byteLength=wt;function ar(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return yr(this,e,t);case"utf8":case"utf-8":return yt(this,e,t);case"ascii":return wr(this,e,t);case"latin1":case"binary":return mr(this,e,t);case"base64":return pr(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gr(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}a.prototype._isBuffer=!0;function H(r,e,t){let i=r[e];r[e]=r[t],r[t]=i}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)H(this,t,t+1);return this};a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)H(this,t,t+3),H(this,t+1,t+2);return this};a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)H(this,t,t+7),H(this,t+1,t+6),H(this,t+2,t+5),H(this,t+3,t+4);return this};a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?yt(this,0,e):ar.apply(this,arguments)};a.prototype.toLocaleString=a.prototype.toString;a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0};a.prototype.inspect=function(){let e="",t=v.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};ut&&(a.prototype[ut]=a.prototype.inspect);a.prototype.compare=function(e,t,i,n,o){if(T(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||i>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=i)return 0;if(n>=o)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,o>>>=0,this===e)return 0;let s=o-n,l=i-t,u=Math.min(s,l),d=this.slice(n,o),c=e.slice(t,i);for(let h=0;h<u;++h)if(d[h]!==c[h]){s=d[h],l=c[h];break}return s<l?-1:l<s?1:0};function mt(r,e,t,i,n){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Qe(t)&&(t=n?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(n)return-1;t=r.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=a.from(e,i)),a.isBuffer(e))return e.length===0?-1:ct(r,e,t,i,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ct(r,[e],t,i,n);throw new TypeError("val must be string, number or Buffer")}function ct(r,e,t,i,n){let o=1,s=r.length,l=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,l/=2,t/=2}function u(c,h){return o===1?c[h]:c.readUInt16BE(h*o)}let d;if(n){let c=-1;for(d=t;d<s;d++)if(u(r,d)===u(e,c===-1?0:d-c)){if(c===-1&&(c=d),d-c+1===l)return c*o}else c!==-1&&(d-=d-c),c=-1}else for(t+l>s&&(t=s-l),d=t;d>=0;d--){let c=!0;for(let h=0;h<l;h++)if(u(r,d+h)!==u(e,h)){c=!1;break}if(c)return d}return-1}a.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1};a.prototype.indexOf=function(e,t,i){return mt(this,e,t,i,!0)};a.prototype.lastIndexOf=function(e,t,i){return mt(this,e,t,i,!1)};function lr(r,e,t,i){t=Number(t)||0;let n=r.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;let o=e.length;i>o/2&&(i=o/2);let s;for(s=0;s<i;++s){let l=parseInt(e.substr(s*2,2),16);if(Qe(l))return s;r[t+s]=l}return s}function ur(r,e,t,i){return Be($e(e,r.length-t),r,t,i)}function cr(r,e,t,i){return Be(Er(e),r,t,i)}function dr(r,e,t,i){return Be(Rt(e),r,t,i)}function hr(r,e,t,i){return Be(Ar(e,r.length-t),r,t,i)}a.prototype.write=function(e,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((i===void 0||i>o)&&(i=o),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return lr(this,e,t,i);case"utf8":case"utf-8":return ur(this,e,t,i);case"ascii":case"latin1":case"binary":return cr(this,e,t,i);case"base64":return dr(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hr(this,e,t,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function pr(r,e,t){return e===0&&t===r.length?Le.fromByteArray(r):Le.fromByteArray(r.slice(e,t))}function yt(r,e,t){t=Math.min(r.length,t);let i=[],n=e;for(;n<t;){let o=r[n],s=null,l=o>239?4:o>223?3:o>191?2:1;if(n+l<=t){let u,d,c,h;switch(l){case 1:o<128&&(s=o);break;case 2:u=r[n+1],(u&192)===128&&(h=(o&31)<<6|u&63,h>127&&(s=h));break;case 3:u=r[n+1],d=r[n+2],(u&192)===128&&(d&192)===128&&(h=(o&15)<<12|(u&63)<<6|d&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:u=r[n+1],d=r[n+2],c=r[n+3],(u&192)===128&&(d&192)===128&&(c&192)===128&&(h=(o&15)<<18|(u&63)<<12|(d&63)<<6|c&63,h>65535&&h<1114112&&(s=h))}}s===null?(s=65533,l=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|s&1023),i.push(s),n+=l}return fr(i)}var dt=4096;function fr(r){let e=r.length;if(e<=dt)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=dt));return t}function wr(r,e,t){let i="";t=Math.min(r.length,t);for(let n=e;n<t;++n)i+=String.fromCharCode(r[n]&127);return i}function mr(r,e,t){let i="";t=Math.min(r.length,t);for(let n=e;n<t;++n)i+=String.fromCharCode(r[n]);return i}function yr(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let n="";for(let o=e;o<t;++o)n+=Rr[r[o]];return n}function gr(r,e,t){let i=r.slice(e,t),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}a.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let n=this.subarray(e,t);return Object.setPrototypeOf(n,a.prototype),n};function m(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e],o=1,s=0;for(;++s<t&&(o*=256);)n+=this[e+s]*o;return n};a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e+--t],o=1;for(;t>0&&(o*=256);)n+=this[e+--t]*o;return n};a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||m(e,1,this.length),this[e]};a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||m(e,2,this.length),this[e]|this[e+1]<<8};a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||m(e,2,this.length),this[e]<<8|this[e+1]};a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||m(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};a.prototype.readBigUInt64LE=N(function(e){e=e>>>0,Y(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let n=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});a.prototype.readBigUInt64BE=N(function(e){e=e>>>0,Y(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let n=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});a.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e],o=1,s=0;for(;++s<t&&(o*=256);)n+=this[e+s]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};a.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=t,o=1,s=this[e+--n];for(;n>0&&(o*=256);)s+=this[e+--n]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s};a.prototype.readInt8=function(e,t){return e=e>>>0,t||m(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};a.prototype.readInt16LE=function(e,t){e=e>>>0,t||m(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};a.prototype.readInt16BE=function(e,t){e=e>>>0,t||m(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};a.prototype.readBigInt64LE=N(function(e){e=e>>>0,Y(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let n=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});a.prototype.readBigInt64BE=N(function(e){e=e>>>0,Y(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let n=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)});a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||m(e,4,this.length),V.read(this,e,!0,23,4)};a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||m(e,4,this.length),V.read(this,e,!1,23,4)};a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||m(e,8,this.length),V.read(this,e,!0,52,8)};a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||m(e,8,this.length),V.read(this,e,!1,52,8)};function y(r,e,t,i,n,o){if(!a.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){let l=Math.pow(2,8*i)-1;y(this,e,t,i,l,0)}let o=1,s=0;for(this[t]=e&255;++s<i&&(o*=256);)this[t+s]=e/o&255;return t+i};a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){let l=Math.pow(2,8*i)-1;y(this,e,t,i,l,0)}let o=i-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+i};a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,1,255,0),this[t]=e&255,t+1};a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function gt(r,e,t,i,n){At(e,i,n,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function xt(r,e,t,i,n){At(e,i,n,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}a.prototype.writeBigUInt64LE=N(function(e,t=0){return gt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeBigUInt64BE=N(function(e,t=0){return xt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t=t>>>0,!n){let u=Math.pow(2,8*i-1);y(this,e,t,i,u-1,-u)}let o=0,s=1,l=0;for(this[t]=e&255;++o<i&&(s*=256);)e<0&&l===0&&this[t+o-1]!==0&&(l=1),this[t+o]=(e/s>>0)-l&255;return t+i};a.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t=t>>>0,!n){let u=Math.pow(2,8*i-1);y(this,e,t,i,u-1,-u)}let o=i-1,s=1,l=0;for(this[t+o]=e&255;--o>=0&&(s*=256);)e<0&&l===0&&this[t+o+1]!==0&&(l=1),this[t+o]=(e/s>>0)-l&255;return t+i};a.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};a.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};a.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};a.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};a.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};a.prototype.writeBigInt64LE=N(function(e,t=0){return gt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});a.prototype.writeBigInt64BE=N(function(e,t=0){return xt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Mt(r,e,t,i,n,o){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ct(r,e,t,i,n){return e=+e,t=t>>>0,n||Mt(r,e,t,4,34028234663852886e22,-34028234663852886e22),V.write(r,e,t,i,23,4),t+4}a.prototype.writeFloatLE=function(e,t,i){return Ct(this,e,t,!0,i)};a.prototype.writeFloatBE=function(e,t,i){return Ct(this,e,t,!1,i)};function Et(r,e,t,i,n){return e=+e,t=t>>>0,n||Mt(r,e,t,8,17976931348623157e292,-17976931348623157e292),V.write(r,e,t,i,52,8),t+8}a.prototype.writeDoubleLE=function(e,t,i){return Et(this,e,t,!0,i)};a.prototype.writeDoubleBE=function(e,t,i){return Et(this,e,t,!1,i)};a.prototype.copy=function(e,t,i,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);let o=n-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(e,this.subarray(i,n),t),o};a.prototype.fill=function(e,t,i,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){let s=e.charCodeAt(0);(n==="utf8"&&s<128||n==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<i;++o)this[o]=e;else{let s=a.isBuffer(e)?e:a.from(e,n),l=s.length;if(l===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=s[o%l]}return this};var J={};function Ge(r,e,t){J[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Ge("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ge("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Ge("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=ht(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=ht(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i},RangeError);function ht(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function xr(r,e,t){Y(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&de(e,r.length-(t+1))}function At(r,e,t,i,n,o){if(r>t||r<e){let s=typeof e=="bigint"?"n":"",l;throw o>3?e===0||e===BigInt(0)?l=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:l=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:l=`>= ${e}${s} and <= ${t}${s}`,new J.ERR_OUT_OF_RANGE("value",l,r)}xr(i,n,o)}function Y(r,e){if(typeof r!="number")throw new J.ERR_INVALID_ARG_TYPE(e,"number",r)}function de(r,e,t){throw Math.floor(r)!==r?(Y(r,t),new J.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Mr=/[^+/0-9A-Za-z-_]/g;function Cr(r){if(r=r.split("=")[0],r=r.trim().replace(Mr,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function $e(r,e){e=e||1/0;let t,i=r.length,n=null,o=[];for(let s=0;s<i;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function Er(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Ar(r,e){let t,i,n,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),i=t>>8,n=t%256,o.push(n),o.push(i);return o}function Rt(r){return Le.toByteArray(Cr(r))}function Be(r,e,t,i){let n;for(n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function T(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Qe(r){return r!==r}var Rr=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let n=0;n<16;++n)e[i+n]=r[t]+r[n]}return e}();function N(r){return typeof BigInt>"u"?Br:r}function Br(){throw new Error("BigInt not supported")}});var Ft=le((yi,be)=>{"use strict";var{AbortController:It,AbortSignal:Lr}=typeof self<"u"?self:typeof window<"u"?window:void 0;be.exports=It;be.exports.AbortSignal=Lr;be.exports.default=It});var ai={};_e(ai,{ClientBuilder:()=>oe,Process:()=>Ne,createAuthMiddlewareForAnonymousSessionFlow:()=>ee,createAuthMiddlewareForClientCredentialsFlow:()=>te,createAuthMiddlewareForExistingTokenFlow:()=>re,createAuthMiddlewareForPasswordFlow:()=>ie,createAuthMiddlewareForRefreshTokenFlow:()=>ne,createClient:()=>$,createConcurrentModificationMiddleware:()=>pe,createCorrelationIdMiddleware:()=>fe,createHttpMiddleware:()=>we,createLoggerMiddleware:()=>me,createQueueMiddleware:()=>ye,createUserAgentMiddleware:()=>ge});var j=ue(ce());var rt={};_e(rt,{createAuthMiddlewareForAnonymousSessionFlow:()=>ee,createAuthMiddlewareForClientCredentialsFlow:()=>te,createAuthMiddlewareForExistingTokenFlow:()=>re,createAuthMiddlewareForPasswordFlow:()=>ie,createAuthMiddlewareForRefreshTokenFlow:()=>ne,createConcurrentModificationMiddleware:()=>pe,createCorrelationIdMiddleware:()=>fe,createErrorMiddleware:()=>tt,createHttpMiddleware:()=>we,createLoggerMiddleware:()=>me,createQueueMiddleware:()=>ye,createUserAgentMiddleware:()=>ge});var Pt=ue(ce());var br=Bt().Buffer;function W(r){return r&&(typeof r=="string"||r instanceof Uint8Array)?br.byteLength(r).toString():r&&typeof r=="object"?new TextEncoder().encode(JSON.stringify(r)).length.toString():"0"}var B={};_e(B,{CONCURRENCT_REQUEST:()=>Ir,CTP_API_URL:()=>Fr,CTP_AUTH_URL:()=>Ur,DEFAULT_HEADERS:()=>Je,HEADERS_CONTENT_TYPES:()=>Tr});var Tr=["application/json","application/graphql"],Ir=20,Fr="https://api.europe-west1.gcp.commercetools.com",Ur="https://auth.europe-west1.gcp.commercetools.com",Je=["content-type","access-control-allow-origin","access-control-allow-headers","access-control-allow-methods","access-control-expose-headers","access-control-max-ag","x-correlation-id","server-timing","date","server","transfer-encoding","access-control-max-age","content-encoding","x-envoy-upstream-service-time","via","alt-svc","connection"];function O(r,e,t={}){this.status=this.statusCode=this.code=r,this.message=e,Object.assign(this,t),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function bt(...r){O.call(this,0,...r)}function Tt(...r){O.call(this,...r)}function kr(...r){O.call(this,400,...r)}function Or(...r){O.call(this,401,...r)}function Sr(...r){O.call(this,403,...r)}function Pr(...r){O.call(this,404,...r)}function Nr(...r){O.call(this,409,...r)}function _r(...r){O.call(this,500,...r)}function jr(...r){O.call(this,503,...r)}function Ve(r){switch(r){case 0:return bt;case 400:return kr;case 401:return Or;case 403:return Sr;case 404:return Pr;case 409:return Nr;case 500:return _r;case 503:return jr;default:return}}function qr({statusCode:r,message:e,...t}){let i=e||"Unexpected non-JSON error response";r===404&&(i=`URI not found: ${t.originalRequest?.uri||t.uri}`);let n=Ve(r);return n?new n(i,t):new Tt(r,i,t)}var X=qr;var Ut=ue(Ft());function Hr(r,e){return[503,...r].includes(e?.status||e?.statusCode)}async function Dr(r,e){async function t(){return await r({...e,headers:{...e.headers}})}return t().catch(i=>Promise.reject(i))}async function Z(r){let{url:e,httpClient:t,...i}=r;return await Dr(async o=>{let{enableRetry:s,retryConfig:l,timeout:u,getAbortController:d}=i,{retryCodes:c=[],maxDelay:h=1/0,maxRetries:w=3,backoff:p=!0,retryDelay:f=200,retryOnAbort:S=!0}=l||{},x,M,C=0,K;Ye(c);async function P(){return t(e,{...o,...i,headers:{...i.headers,"Accept-Encoding":"application/json"},...i.body?{data:i.body}:{},withCredentials:o.credentialsMode==="include"})}function xe(){let A=(d?d():null)||new Ut.default;return i.abortController=A,i.signal=A.signal,A}async function z(){let A=async(Ce,Ht)=>{let ae={};if(u){let G=xe();K=setTimeout(()=>{G.abort(),G=xe()},u)}try{if(ae=await P(),ae.status>399&&Hr(Ce,ae))return{_response:ae,shouldRetry:!0}}catch(G){if(G.name.includes("AbortError")&&Ht)return{_response:G,shouldRetry:!0};throw G}finally{clearTimeout(K)}return{_response:ae,shouldRetry:!1}},{_response:se,shouldRetry:Me}=await A(c,S);for(;s&&Me&&C<w;){C++,await Ie(Te({retryCount:C,retryDelay:f,maxRetries:w,backoff:p,maxDelay:h}));let Ce=await A(c,S);se=Ce._response,Me=Ce.shouldRetry}return se}let E=await z();try{E.text&&typeof E.text=="function"?(x=await E.text()||E[Object.getOwnPropertySymbols(E)[1]],M=JSON.parse(x)):M=E.data||E}catch(A){throw A}return{data:M,retryCount:C,statusCode:E.status||E.statusCode||M.statusCode,headers:E.headers}},{validateStatus:o=>!0})}function Fe(){return("1000000-1000-4000-8000"+-1e11).replace(/[018]/g,r=>(parseInt(r)^Math.floor(Math.random()*256)&15>>parseInt(r)/4).toString(16))}function $r(r){return Je.reduce((e,t)=>{let i=r[t]?r[t]:typeof r.get=="function"?r.get(t):null;return i&&(e[t]=i),e},{})}function I(r){if(!r)return null;if(r.raw&&typeof r.raw=="function")return r.raw();if(!r.forEach)return $r(r);let e={};return r.forEach((t,i)=>e[i]=t)}function he(r){return r!=null&&r.constructor!=null&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function D(r){let e=Object.assign({},r);return e?.headers&&(e.headers.Authorization&&(e.headers.Authorization="Bearer ********"),e.headers.authorization&&(e.headers.authorization="Bearer ********")),e}function g(r,e){return{...e,headers:{...e.headers,Authorization:`Bearer ${r}`}}}var ve=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function Te({retryCount:r,retryDelay:e,backoff:t,maxDelay:i}){return t&&r!==0?Math.min(Math.round((Math.random()+1)*e*2**r),i):e}Math.min(Math.round((Math.random()+1)*200*2**10),1/0);function Ie(r){return new Promise(e=>{setTimeout(e,r)})}function F(r){if(!r?.credentials?.clientId||!r.projectKey||!r.host)throw new Error("Missing required options.");return{clientId:r.credentials.clientId,host:r.host,projectKey:r.projectKey}}function Ue(r){return Date.now()+r*1e3-5*60*1e3}function U(r){let e=r;return{get:t=>e,set:(t,i)=>{e=t}}}function kt(r){return typeof r<"u"&&r!==null}function Kr(r){return kt(r)?typeof r=="string"?r:Object.fromEntries(Object.entries(r).filter(([e,t])=>![null,void 0,""].includes(t))):""}function zr(r){let e={},t=new URLSearchParams(r);for(let i of t.keys())t.getAll(i).length>1?e[i]=t.getAll(i):e[i]=t.get(i);return e}function Gr(r){if(r=Kr(r),!r)return"";let e=new URLSearchParams(r);for(let[t,i]of Object.entries(r))Array.isArray(i)&&(e.delete(t),i.filter(kt).forEach(n=>e.append(t,n)));return e.toString()}function We(r,e=zr){return e(r)}function ke(r,e=Gr){return e(r)}var Qr=()=>typeof window<"u"&&window.document&&window.document.nodeType===9;function Jr(){if(Qr())return window.navigator.userAgent;let r=process?.version.slice(1)||"unknow",e=`(${process.platform}; ${process.arch})`;return`node.js/${r} ${e}`}function Oe(r){let e=null,t=null;if(!r)throw new Error("Missing required option `name`");let i=r.version?`${r.name}/${r.version}`:r.name;r.libraryName&&!r.libraryVersion?e=r.libraryName:r.libraryName&&r.libraryVersion&&(e=`${r.libraryName}/${r.libraryVersion}`),r.contactUrl&&!r.contactEmail?t=`(+${r.contactUrl})`:!r.contactUrl&&r.contactEmail?t=`(+${r.contactEmail})`:r.contactUrl&&r.contactEmail&&(t=`(+${r.contactUrl}; +${r.contactEmail})`);let n=Jr(),o=r.customAgent||"";return[i,n,e,t,o].filter(Boolean).join(" ")}function Xe(r){if(!r.host)throw new Error("Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`");if(!r.httpClient&&typeof r.httpClient!="function")throw new Error("An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(r.httpClientOptions&&Object.prototype.toString.call(r.httpClientOptions)!=="[object Object]")throw new Error("`httpClientOptions` must be an object type")}function Ye(r){if(!Array.isArray(r))throw new Error("`retryCodes` option must be an array of retry status (error) codes and/or messages.")}function Ze(r){if(!r)throw new Error("Missing required options");if(r.middlewares&&!Array.isArray(r.middlewares))throw new Error("Middlewares should be an array");if(!r.middlewares||!Array.isArray(r.middlewares)||!r.middlewares.length)throw new Error("You need to provide at least one middleware")}function Se(r,e,t={allowedMethods:ve}){if(!e)throw new Error(`The "${r}" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(typeof e.uri!="string")throw new Error(`The "${r}" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(!t.allowedMethods.includes(e.method))throw new Error(`The "${r}" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`)}function et(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:t}=r.credentials||{};if(!(e&&t))throw new Error("Missing required credentials (clientId, clientSecret)");let i=r.scopes?r.scopes.join(" "):void 0,n=btoa(`${e}:${t}`),o=r.oauthUri||"/oauth/token",s=r.host.replace(/\/$/,"")+o,l=`grant_type=client_credentials${i?`&scope=${i}`:""}`;return{url:s,body:l,basicAuth:n}}function Ot(r){if(!r)throw new Error("Missing required options");if(!r.projectKey)throw new Error("Missing required option (projectKey)");let e=r.projectKey;r.oauthUri=r.oauthUri||`/oauth/${e}/anonymous/token`;let t=et(r);return r.credentials.anonymousId&&(t.body+=`&anonymous_id=${r.credentials.anonymousId}`),{...t}}function Pe(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");if(!r.refreshToken)throw new Error("Missing required option (refreshToken)");let{clientId:e,clientSecret:t}=r.credentials;if(!(e&&t))throw new Error("Missing required credentials (clientId, clientSecret)");let i=btoa(`${e}:${t}`),n=r.oauthUri||"/oauth/token",o=r.host.replace(/\/$/,"")+n,s=`grant_type=refresh_token&refresh_token=${encodeURIComponent(r.refreshToken)}`;return{basicAuth:i,url:o,body:s}}function St(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:t,user:i}=r.credentials,n=r.projectKey;if(!(e&&t&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");let{username:o,password:s}=i;if(!(o&&s))throw new Error("Missing required user credentials (username, password)");let l=(r.scopes||[]).join(" "),u=l?`&scope=${l}`:"",d=btoa(`${e}:${t}`),c=r.oauthUri||`/oauth/${n}/customers/token`,h=r.host.replace(/\/$/,"")+c,w=`grant_type=password&username=${encodeURIComponent(o)}&password=${encodeURIComponent(s)}${u}`;return{basicAuth:d,url:h,body:w}}async function _(r){let{httpClient:e,httpClientOptions:t,tokenCache:i,userOption:n,tokenCacheObject:o}=r,s=r.url,l=r.body,u=r.basicAuth;if(!e||typeof e!="function")throw new Error("an `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(o&&o.refreshToken&&(!o.token||o.token&&Date.now()>o.expirationTime)){if(!n)throw new Error("Missing required options.");let c={...Pe({...n,refreshToken:o.refreshToken})};s=c.url,l=c.body,u=c.basicAuth}let d;try{if(d=await Z({url:s,method:"POST",headers:{Authorization:`Basic ${u}`,"Content-Type":"application/x-www-form-urlencoded","Content-Length":W(l)},httpClient:e,httpClientOptions:t,body:l}),d.statusCode>=200&&d.statusCode<300){let{access_token:c,expires_in:h,refresh_token:w}=d?.data,p=Ue(h);return i.set({token:c,expirationTime:p,refreshToken:w}),Promise.resolve(!0)}throw X({code:d.data.error,statusCode:d.data.statusCode,message:d.data.message,error:d.data.errors})}catch(c){throw c}}function ee(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(g(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,httpClient:r.httpClient||Pt.default,httpClientOptions:r.httpClientOptions,...Ot(r),userOption:r,next:o};return i?await i:(i=_(l),await i,i=null),t=e.get(n),o(g(t.token,s))}}var Nt=ue(ce());function te(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(g(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,tokenCacheObject:t,httpClient:r.httpClient||Nt.default,httpClientOptions:r.httpClientOptions,...et(r),next:o};return i?await i:(i=_(l),await i,i=null),t=e.get(n),o(g(t.token,s))}}function re(r,e){return t=>async i=>{if(typeof r!="string")throw new Error("authorization must be a string");let n=e?.force===void 0?!0:e.force;if(!r||i.headers&&(i.headers.Authorization||i.headers.authorization)&&n===!1)return t(i);let o={...i,headers:{...i.headers,Authorization:r}};return t(o)}}var _t=ue(ce());function ie(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(g(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,httpClient:r.httpClient||_t.default,httpClientOptions:r.httpClientOptions,...St(r),userOption:r,next:o};return i?await i:(i=_(l),await i,i=null),t=e.get(n),o(g(t.token,s))}}function ne(r){let e=r.tokenCache||U({token:"",tokenCacheKey:null}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(g(t.token,s));let l={request:s,tokenCache:e,httpClient:r.httpClient||fetch,httpClientOptions:r.httpClientOptions,...Pe(r),next:o};return i?await i:(i=_(l),await i,i=null),t=e.get(n),o(g(t.token,s))}}function pe(r){return e=>async t=>{let i=await e(t);if(i.statusCode==409){let n=i.error.body?.errors?.[0]?.currentVersion;if(n)return r&&typeof r=="function"?t.body=await r(n,t,i):t.body=typeof t.body=="string"?{...JSON.parse(t.body),version:n}:{...t.body,version:n},e(t)}return i}}function fe(r){return e=>t=>{let i={...t,headers:{...t.headers,"X-Correlation-ID":r.generate&&typeof r.generate=="function"?r.generate():Fe()}};return e(i)}}function tt(r){return e=>async t=>{let i=await e(t);if(i.error){let{error:n}=i;return{...i,statusCode:n.statusCode||0,headers:n.headers||I({}),error:{...n,body:n.data||n}}}return i}}async function Vr({url:r,httpClient:e,clientOptions:t}){let{request:i,maskSensitiveHeaderData:n,includeRequestInErrorResponse:o,includeResponseHeaders:s}=t;try{let l=await Z({url:r,...t,httpClient:e,method:t.method,...t.body?{body:t.body}:{}});if(s||(l.headers=null),l.statusCode>=200&&l.statusCode<300)return t.method=="HEAD"?{body:null,statusCode:l.statusCode,retryCount:l.retryCount,headers:I(l.headers)}:{body:l.data,statusCode:l.statusCode,retryCount:l.retryCount,headers:I(l.headers)};let u=X({message:l?.data?.message||l?.message,statusCode:l.statusCode||l?.data?.statusCode,headers:I(l.headers),method:t.method,body:l.data,retryCount:l.retryCount,...o?{originalRequest:n?D(i):i}:{uri:i.uri}});return{body:l.data,code:l.statusCode,statusCode:l.statusCode,headers:I(l.headers),error:u}}catch(l){let u=s?I(l.response?.headers):null,d=l.response?.status||l.response?.data0||0,c=l.response?.data?.message;throw{body:null,error:X({statusCode:d,code:d,status:d,message:c||l.message,headers:u,body:l.response?.data||l,error:l.response?.data,...o?{originalRequest:n?D(i):i}:{uri:i.uri}})}}}function we(r){Xe(r);let{host:e,credentialsMode:t,httpClient:i,timeout:n,enableRetry:o,retryConfig:s,getAbortController:l,includeOriginalRequest:u,includeRequestInErrorResponse:d=!0,includeResponseHeaders:c=!0,maskSensitiveHeaderData:h,httpClientOptions:w}=r;return p=>async f=>{let S=e.replace(/\/$/,"")+f.uri,x={...f.headers};Object.prototype.hasOwnProperty.call(x,"Content-Type")||Object.prototype.hasOwnProperty.call(x,"content-type")||(x["Content-Type"]="application/json"),x["Content-Type"]===null&&delete x["Content-Type"];let M=B.HEADERS_CONTENT_TYPES.indexOf(x["Content-Type"])>-1&&typeof f.body=="string"||he(f.body)?f.body:JSON.stringify(f.body||void 0);M&&(typeof M=="string"||he(M))&&(x["Content-Length"]=W(M));let C={enableRetry:o,retryConfig:s,request:f,method:f.method,headers:x,includeRequestInErrorResponse:d,maskSensitiveHeaderData:h,includeResponseHeaders:c,...w};t&&(C.credentialsMode=t),n&&(C.timeout=n,C.getAbortController=l),M&&(C.body=M);let K=await Vr({url:S,clientOptions:C,httpClient:i}),P={...f,includeOriginalRequest:u,maskSensitiveHeaderData:h,response:K};return p(P)}}function me(r){return e=>async t=>{let i=await e(t),n=Object.assign({},i),{loggerFn:o=console.log}=r||{};return o&&typeof o=="function"&&o(i),n}}function ye({concurrency:r=20}){let e=0,t=[],i=()=>0>=r?Promise.resolve():new Promise(o=>{let s=()=>{e<r?(e++,o()):t.push(s)};s()}),n=()=>{if(e--,t.length>0){let o=t.shift();o&&o()}};return o=>s=>i().then(()=>{let l={...s,resolve(u){s.resolve(u),n()},reject(u){s.reject(u),n()}};return o(l).finally(()=>{n()})})}var jt={name:"@commercetools/ts-client",version:"2.1.6",engines:{node:">=14"},description:"commercetools Composable Commerce TypeScript SDK client.",keywords:["commercetools","composable commerce","sdk","typescript","client","middleware","http","oauth","auth"],homepage:"https://github.com/commercetools/commercetools-sdk-typescript",license:"MIT",directories:{lib:"lib",test:"test"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/commercetools/commercetools-sdk-typescript.git"},bugs:{url:"https://github.com/commercetools/commercetools-sdk-typescript/issues"},dependencies:{"abort-controller":"3.0.0",buffer:"^6.0.3","node-fetch":"^2.6.1"},files:["dist","CHANGELOG.md"],author:"Chukwuemeka Ajima <meeky.ae@gmail.com>",main:"dist/commercetools-ts-client.cjs.js",module:"dist/commercetools-ts-client.esm.js",browser:{"./dist/commercetools-ts-client.cjs.js":"./dist/commercetools-ts-client.browser.cjs.js","./dist/commercetools-ts-client.esm.js":"./dist/commercetools-ts-client.browser.esm.js"},devDependencies:{"common-tags":"1.8.2",dotenv:"16.4.5",jest:"29.7.0",nock:"12.0.3","organize-imports-cli":"0.10.0"},scripts:{organize_imports:"find src -type f -name '*.ts' | xargs organize-imports-cli",postbuild:"yarn organize_imports",post_process_generate:"yarn organize_imports",docs:"typedoc --out docs"}};function ge(r){return e=>async t=>{let i=Oe({...r,name:`${r.name?r.name+"/":""}commercetools-sdk-javascript-v3/${jt.version}`}),n={...t,headers:{...t.headers,"User-Agent":i}};return e(n)}}function vr({middlewares:r}){return r.length===1?r[0]:r.slice().reduce((t,i)=>(...n)=>t(i.apply(null,n)))}var qt;function Ne(r,e,t){if(Se("process",r,{allowedMethods:["GET"]}),typeof e!="function")throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');let i={total:Number.POSITIVE_INFINITY,accumulate:!0,...t};return new Promise((n,o)=>{let s,l="";if(r&&r.uri){let[p,f]=r.uri.split("?");s=p,l=f}let d={limit:20,...{...We(l)}},c=i.total,h=!1,w=async(p,f=[])=>{let S=d.limit<c?d.limit:c,x=ke({...d,limit:S}),M={sort:"id asc",withTotal:!1,...p?{where:`id > "${p}"`}:{}},C=ke(M),K={...r,uri:`${s}?${C}&${x}`};try{let P=await $(qt).execute(K),{results:xe,count:z}=P?.body||{};if(!z&&h)return n(f||[]);let E=await Promise.resolve(e(P)),A;if(h=!0,i.accumulate&&(A=f.concat(E||[])),c-=z,z<d.limit||!c)return n(A||[]);let se=xe[z-1],Me=se&&se.id;w(Me,A)}catch(P){o(P)}};w()})}function $(r){qt=r,Ze(r);let e=!1,t={async resolve(n){let{response:o,includeOriginalRequest:s,maskSensitiveHeaderData:l,...u}=n,{retryCount:d,...c}=o;return e=l,{body:null,error:null,reject:n.reject,resolve:n.resolve,...c,...s?{originalRequest:u}:{},...o?.retryCount?{retryCount:o.retryCount}:{}}}},i=vr(r)(t.resolve);return{process:Ne,execute(n){return Se("exec",n),new Promise(async(o,s)=>{try{let l=await i({reject:s,resolve:o,...n});if(l.error)return s(l.error);l.originalRequest&&e&&(l.originalRequest=D(l.originalRequest)),o(l)}catch(l){s(l)}})}}}var{createAuthMiddlewareForPasswordFlow:Wr,createAuthMiddlewareForAnonymousSessionFlow:Xr,createAuthMiddlewareForClientCredentialsFlow:Zr,createAuthMiddlewareForRefreshTokenFlow:ei,createAuthMiddlewareForExistingTokenFlow:ti,createCorrelationIdMiddleware:ri,createHttpMiddleware:ii,createLoggerMiddleware:ni,createQueueMiddleware:oi,createUserAgentMiddleware:Lt,createConcurrentModificationMiddleware:si}=rt,oe=class{projectKey;authMiddleware;httpMiddleware;userAgentMiddleware;correlationIdMiddleware;loggerMiddleware;queueMiddleware;concurrentMiddleware;telemetryMiddleware;beforeMiddleware;afterMiddleware;middlewares=[];constructor(){this.userAgentMiddleware=Lt({})}withProjectKey(e){return this.projectKey=e,this}defaultClient(e,t,i,n,o,s){return this.withClientCredentialsFlow({host:i,projectKey:n||this.projectKey,credentials:t,httpClient:s||j.default,scopes:o}).withHttpMiddleware({host:e,httpClient:s||j.default})}withAuthMiddleware(e){return this.authMiddleware=e,this}withMiddleware(e){return this.middlewares.push(e),this}withClientCredentialsFlow(e){return this.withAuthMiddleware(Zr({host:e.host||B.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},oauthUri:e.oauthUri||null,scopes:e.scopes,httpClient:e.httpClient||j.default,...e}))}withPasswordFlow(e){return this.withAuthMiddleware(Wr({host:e.host||B.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,user:{username:e.credentials.user.username||null,password:e.credentials.user.password||null}},httpClient:e.httpClient||j.default,...e}))}withAnonymousSessionFlow(e){return this.withAuthMiddleware(Xr({host:e.host||B.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,anonymousId:e.credentials.anonymousId||null},httpClient:e.httpClient||j.default,...e}))}withRefreshTokenFlow(e){return this.withAuthMiddleware(ei({host:e.host||B.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},httpClient:e.httpClient||j.default,refreshToken:e.refreshToken||null,...e}))}withExistingTokenFlow(e,t){return this.withAuthMiddleware(ti(e,{force:t.force||!0,...t}))}withHttpMiddleware(e){return this.httpMiddleware=ii({host:e.host||B.CTP_API_URL,httpClient:e.httpClient||j.default,...e}),this}withUserAgentMiddleware(e){return this.userAgentMiddleware=Lt(e),this}withQueueMiddleware(e){return this.queueMiddleware=oi({concurrency:e.concurrency||B.CONCURRENCT_REQUEST,...e}),this}withLoggerMiddleware(e){return this.loggerMiddleware=ni(e),this}withCorrelationIdMiddleware(e){return this.correlationIdMiddleware=ri({generate:e?.generate,...e}),this}withConcurrentModificationMiddleware(e){return this.concurrentMiddleware=si(e?.concurrentModificationHandlerFn),this}withTelemetryMiddleware(e){let{createTelemetryMiddleware:t,...i}=e;return this.withUserAgentMiddleware({customAgent:i?.userAgent||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=t(i),this}withBeforeExecutionMiddleware(e){let{middleware:t,...i}=e||{};return this.beforeMiddleware=e.middleware(i),this}withAfterExecutionMiddleware(e){let{middleware:t,...i}=e||{};return this.afterMiddleware=e.middleware(i),this}build(){let e=this.middlewares.slice();return this.telemetryMiddleware&&e.push(this.telemetryMiddleware),this.correlationIdMiddleware&&e.push(this.correlationIdMiddleware),this.userAgentMiddleware&&e.push(this.userAgentMiddleware),this.authMiddleware&&e.push(this.authMiddleware),this.beforeMiddleware&&e.push(this.beforeMiddleware),this.queueMiddleware&&e.push(this.queueMiddleware),this.loggerMiddleware&&e.push(this.loggerMiddleware),this.concurrentMiddleware&&e.push(this.concurrentMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.afterMiddleware&&e.push(this.afterMiddleware),$({middlewares:e})}};return Qt(ai);})();
1
+ var window;(window||={})["@commercetools/ts-client"]=(()=>{var Ie=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var Fe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ue=(r,e)=>{for(var t in e)Ie(r,t,{get:e[t],enumerable:!0})},Ut=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of It(e))!Ft.call(r,n)&&n!==t&&Ie(r,n,{get:()=>e[n],enumerable:!(i=bt(e,n))||i.enumerable});return r};var kt=r=>Ut(Ie({},"__esModule",{value:!0}),r);var Ze=Fe(me=>{"use strict";me.byteLength=St;me.toByteArray=Nt;me.fromByteArray=qt;var T=[],R=[],Ot=typeof Uint8Array<"u"?Uint8Array:Array,ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(q=0,ve=ke.length;q<ve;++q)T[q]=ke[q],R[ke.charCodeAt(q)]=q;var q,ve;R[45]=62;R[95]=63;function Xe(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function St(r){var e=Xe(r),t=e[0],i=e[1];return(t+i)*3/4-i}function Pt(r,e,t){return(e+t)*3/4-t}function Nt(r){var e,t=Xe(r),i=t[0],n=t[1],o=new Ot(Pt(r,i,n)),s=0,l=n>0?i-4:i,u;for(u=0;u<l;u+=4)e=R[r.charCodeAt(u)]<<18|R[r.charCodeAt(u+1)]<<12|R[r.charCodeAt(u+2)]<<6|R[r.charCodeAt(u+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return n===2&&(e=R[r.charCodeAt(u)]<<2|R[r.charCodeAt(u+1)]>>4,o[s++]=e&255),n===1&&(e=R[r.charCodeAt(u)]<<10|R[r.charCodeAt(u+1)]<<4|R[r.charCodeAt(u+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function _t(r){return T[r>>18&63]+T[r>>12&63]+T[r>>6&63]+T[r&63]}function jt(r,e,t){for(var i,n=[],o=e;o<t;o+=3)i=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),n.push(_t(i));return n.join("")}function qt(r){for(var e,t=r.length,i=t%3,n=[],o=16383,s=0,l=t-i;s<l;s+=o)n.push(jt(r,s,s+o>l?l:s+o));return i===1?(e=r[t-1],n.push(T[e>>2]+T[e<<4&63]+"==")):i===2&&(e=(r[t-2]<<8)+r[t-1],n.push(T[e>>10]+T[e>>4&63]+T[e<<2&63]+"=")),n.join("")}});var et=Fe(Oe=>{Oe.read=function(r,e,t,i,n){var o,s,l=n*8-i-1,u=(1<<l)-1,d=u>>1,c=-7,h=t?n-1:0,w=t?-1:1,p=r[e+h];for(h+=w,o=p&(1<<-c)-1,p>>=-c,c+=l;c>0;o=o*256+r[e+h],h+=w,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=s*256+r[e+h],h+=w,c-=8);if(o===0)o=1-d;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-d}return(p?-1:1)*s*Math.pow(2,o-i)};Oe.write=function(r,e,t,i,n,o){var s,l,u,d=o*8-n-1,c=(1<<d)-1,h=c>>1,w=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:o-1,f=i?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+h>=1?e+=w/u:e+=w*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=c?(l=0,s=c):s+h>=1?(l=(e*u-1)*Math.pow(2,n),s=s+h):(l=e*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;r[t+p]=l&255,p+=f,l/=256,n-=8);for(s=s<<n|l,d+=n;d>0;r[t+p]=s&255,p+=f,s/=256,d-=8);r[t+p-f]|=S*128}});var yt=Fe(J=>{"use strict";var Se=Ze(),G=et(),tt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;J.Buffer=a;J.SlowBuffer=zt;J.INSPECT_MAX_BYTES=50;var ye=2147483647;J.kMaxLength=ye;a.TYPED_ARRAY_SUPPORT=Lt();!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Lt(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}});Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function k(r){if(r>ye)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,a.prototype),e}function a(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return je(r)}return ot(r,e,t)}a.poolSize=8192;function ot(r,e,t){if(typeof r=="string")return Dt(r,e);if(ArrayBuffer.isView(r))return $t(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(b(r,ArrayBuffer)||r&&b(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(b(r,SharedArrayBuffer)||r&&b(r.buffer,SharedArrayBuffer)))return Ne(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return a.from(i,e,t);let n=Kt(r);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return a.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}a.from=function(r,e,t){return ot(r,e,t)};Object.setPrototypeOf(a.prototype,Uint8Array.prototype);Object.setPrototypeOf(a,Uint8Array);function st(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Ht(r,e,t){return st(r),r<=0?k(r):e!==void 0?typeof t=="string"?k(r).fill(e,t):k(r).fill(e):k(r)}a.alloc=function(r,e,t){return Ht(r,e,t)};function je(r){return st(r),k(r<0?0:qe(r)|0)}a.allocUnsafe=function(r){return je(r)};a.allocUnsafeSlow=function(r){return je(r)};function Dt(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=at(r,e)|0,i=k(t),n=i.write(r,e);return n!==t&&(i=i.slice(0,n)),i}function Pe(r){let e=r.length<0?0:qe(r.length)|0,t=k(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function $t(r){if(b(r,Uint8Array)){let e=new Uint8Array(r);return Ne(e.buffer,e.byteOffset,e.byteLength)}return Pe(r)}function Ne(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,a.prototype),i}function Kt(r){if(a.isBuffer(r)){let e=qe(r.length)|0,t=k(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||He(r.length)?k(0):Pe(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Pe(r.data)}function qe(r){if(r>=ye)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye.toString(16)+" bytes");return r|0}function zt(r){return+r!=r&&(r=0),a.alloc(+r)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype};a.compare=function(e,t){if(b(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),b(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,n=t.length;for(let o=0,s=Math.min(i,n);o<s;++o)if(e[o]!==t[o]){i=e[o],n=t[o];break}return i<n?-1:n<i?1:0};a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let n=a.allocUnsafe(t),o=0;for(i=0;i<e.length;++i){let s=e[i];if(b(s,Uint8Array))o+s.length>n.length?(a.isBuffer(s)||(s=a.from(s)),s.copy(n,o)):Uint8Array.prototype.set.call(n,s,o);else if(a.isBuffer(s))s.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return n};function at(r,e){if(a.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||b(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return _e(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return mt(r).length;default:if(n)return i?-1:_e(r).length;e=(""+e).toLowerCase(),n=!0}}a.byteLength=at;function Gt(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return tr(this,e,t);case"utf8":case"utf-8":return ut(this,e,t);case"ascii":return Zt(this,e,t);case"latin1":case"binary":return er(this,e,t);case"base64":return vt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return rr(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}a.prototype._isBuffer=!0;function L(r,e,t){let i=r[e];r[e]=r[t],r[t]=i}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)L(this,t,t+1);return this};a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)L(this,t,t+3),L(this,t+1,t+2);return this};a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)L(this,t,t+7),L(this,t+1,t+6),L(this,t+2,t+5),L(this,t+3,t+4);return this};a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ut(this,0,e):Gt.apply(this,arguments)};a.prototype.toLocaleString=a.prototype.toString;a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0};a.prototype.inspect=function(){let e="",t=J.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};tt&&(a.prototype[tt]=a.prototype.inspect);a.prototype.compare=function(e,t,i,n,o){if(b(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||i>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=i)return 0;if(n>=o)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,o>>>=0,this===e)return 0;let s=o-n,l=i-t,u=Math.min(s,l),d=this.slice(n,o),c=e.slice(t,i);for(let h=0;h<u;++h)if(d[h]!==c[h]){s=d[h],l=c[h];break}return s<l?-1:l<s?1:0};function lt(r,e,t,i,n){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,He(t)&&(t=n?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(n)return-1;t=r.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=a.from(e,i)),a.isBuffer(e))return e.length===0?-1:rt(r,e,t,i,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):rt(r,[e],t,i,n);throw new TypeError("val must be string, number or Buffer")}function rt(r,e,t,i,n){let o=1,s=r.length,l=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,l/=2,t/=2}function u(c,h){return o===1?c[h]:c.readUInt16BE(h*o)}let d;if(n){let c=-1;for(d=t;d<s;d++)if(u(r,d)===u(e,c===-1?0:d-c)){if(c===-1&&(c=d),d-c+1===l)return c*o}else c!==-1&&(d-=d-c),c=-1}else for(t+l>s&&(t=s-l),d=t;d>=0;d--){let c=!0;for(let h=0;h<l;h++)if(u(r,d+h)!==u(e,h)){c=!1;break}if(c)return d}return-1}a.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1};a.prototype.indexOf=function(e,t,i){return lt(this,e,t,i,!0)};a.prototype.lastIndexOf=function(e,t,i){return lt(this,e,t,i,!1)};function Qt(r,e,t,i){t=Number(t)||0;let n=r.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;let o=e.length;i>o/2&&(i=o/2);let s;for(s=0;s<i;++s){let l=parseInt(e.substr(s*2,2),16);if(He(l))return s;r[t+s]=l}return s}function Jt(r,e,t,i){return ge(_e(e,r.length-t),r,t,i)}function Vt(r,e,t,i){return ge(sr(e),r,t,i)}function Yt(r,e,t,i){return ge(mt(e),r,t,i)}function Wt(r,e,t,i){return ge(ar(e,r.length-t),r,t,i)}a.prototype.write=function(e,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((i===void 0||i>o)&&(i=o),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return Qt(this,e,t,i);case"utf8":case"utf-8":return Jt(this,e,t,i);case"ascii":case"latin1":case"binary":return Vt(this,e,t,i);case"base64":return Yt(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wt(this,e,t,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function vt(r,e,t){return e===0&&t===r.length?Se.fromByteArray(r):Se.fromByteArray(r.slice(e,t))}function ut(r,e,t){t=Math.min(r.length,t);let i=[],n=e;for(;n<t;){let o=r[n],s=null,l=o>239?4:o>223?3:o>191?2:1;if(n+l<=t){let u,d,c,h;switch(l){case 1:o<128&&(s=o);break;case 2:u=r[n+1],(u&192)===128&&(h=(o&31)<<6|u&63,h>127&&(s=h));break;case 3:u=r[n+1],d=r[n+2],(u&192)===128&&(d&192)===128&&(h=(o&15)<<12|(u&63)<<6|d&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:u=r[n+1],d=r[n+2],c=r[n+3],(u&192)===128&&(d&192)===128&&(c&192)===128&&(h=(o&15)<<18|(u&63)<<12|(d&63)<<6|c&63,h>65535&&h<1114112&&(s=h))}}s===null?(s=65533,l=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|s&1023),i.push(s),n+=l}return Xt(i)}var it=4096;function Xt(r){let e=r.length;if(e<=it)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=it));return t}function Zt(r,e,t){let i="";t=Math.min(r.length,t);for(let n=e;n<t;++n)i+=String.fromCharCode(r[n]&127);return i}function er(r,e,t){let i="";t=Math.min(r.length,t);for(let n=e;n<t;++n)i+=String.fromCharCode(r[n]);return i}function tr(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let n="";for(let o=e;o<t;++o)n+=lr[r[o]];return n}function rr(r,e,t){let i=r.slice(e,t),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}a.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let n=this.subarray(e,t);return Object.setPrototypeOf(n,a.prototype),n};function m(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e],o=1,s=0;for(;++s<t&&(o*=256);)n+=this[e+s]*o;return n};a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e+--t],o=1;for(;t>0&&(o*=256);)n+=this[e+--t]*o;return n};a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||m(e,1,this.length),this[e]};a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||m(e,2,this.length),this[e]|this[e+1]<<8};a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||m(e,2,this.length),this[e]<<8|this[e+1]};a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||m(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};a.prototype.readBigUInt64LE=N(function(e){e=e>>>0,Q(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&oe(e,this.length-8);let n=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});a.prototype.readBigUInt64BE=N(function(e){e=e>>>0,Q(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&oe(e,this.length-8);let n=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});a.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=this[e],o=1,s=0;for(;++s<t&&(o*=256);)n+=this[e+s]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};a.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||m(e,t,this.length);let n=t,o=1,s=this[e+--n];for(;n>0&&(o*=256);)s+=this[e+--n]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s};a.prototype.readInt8=function(e,t){return e=e>>>0,t||m(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};a.prototype.readInt16LE=function(e,t){e=e>>>0,t||m(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};a.prototype.readInt16BE=function(e,t){e=e>>>0,t||m(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||m(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};a.prototype.readBigInt64LE=N(function(e){e=e>>>0,Q(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&oe(e,this.length-8);let n=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});a.prototype.readBigInt64BE=N(function(e){e=e>>>0,Q(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&oe(e,this.length-8);let n=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)});a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||m(e,4,this.length),G.read(this,e,!0,23,4)};a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||m(e,4,this.length),G.read(this,e,!1,23,4)};a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||m(e,8,this.length),G.read(this,e,!0,52,8)};a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||m(e,8,this.length),G.read(this,e,!1,52,8)};function y(r,e,t,i,n,o){if(!a.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){let l=Math.pow(2,8*i)-1;y(this,e,t,i,l,0)}let o=1,s=0;for(this[t]=e&255;++s<i&&(o*=256);)this[t+s]=e/o&255;return t+i};a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){let l=Math.pow(2,8*i)-1;y(this,e,t,i,l,0)}let o=i-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+i};a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,1,255,0),this[t]=e&255,t+1};a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ct(r,e,t,i,n){wt(e,i,n,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function dt(r,e,t,i,n){wt(e,i,n,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}a.prototype.writeBigUInt64LE=N(function(e,t=0){return ct(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeBigUInt64BE=N(function(e,t=0){return dt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t=t>>>0,!n){let u=Math.pow(2,8*i-1);y(this,e,t,i,u-1,-u)}let o=0,s=1,l=0;for(this[t]=e&255;++o<i&&(s*=256);)e<0&&l===0&&this[t+o-1]!==0&&(l=1),this[t+o]=(e/s>>0)-l&255;return t+i};a.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t=t>>>0,!n){let u=Math.pow(2,8*i-1);y(this,e,t,i,u-1,-u)}let o=i-1,s=1,l=0;for(this[t+o]=e&255;--o>=0&&(s*=256);)e<0&&l===0&&this[t+o+1]!==0&&(l=1),this[t+o]=(e/s>>0)-l&255;return t+i};a.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};a.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};a.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};a.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};a.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||y(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};a.prototype.writeBigInt64LE=N(function(e,t=0){return ct(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});a.prototype.writeBigInt64BE=N(function(e,t=0){return dt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ht(r,e,t,i,n,o){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function pt(r,e,t,i,n){return e=+e,t=t>>>0,n||ht(r,e,t,4,34028234663852886e22,-34028234663852886e22),G.write(r,e,t,i,23,4),t+4}a.prototype.writeFloatLE=function(e,t,i){return pt(this,e,t,!0,i)};a.prototype.writeFloatBE=function(e,t,i){return pt(this,e,t,!1,i)};function ft(r,e,t,i,n){return e=+e,t=t>>>0,n||ht(r,e,t,8,17976931348623157e292,-17976931348623157e292),G.write(r,e,t,i,52,8),t+8}a.prototype.writeDoubleLE=function(e,t,i){return ft(this,e,t,!0,i)};a.prototype.writeDoubleBE=function(e,t,i){return ft(this,e,t,!1,i)};a.prototype.copy=function(e,t,i,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);let o=n-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(e,this.subarray(i,n),t),o};a.prototype.fill=function(e,t,i,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){let s=e.charCodeAt(0);(n==="utf8"&&s<128||n==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<i;++o)this[o]=e;else{let s=a.isBuffer(e)?e:a.from(e,n),l=s.length;if(l===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=s[o%l]}return this};var z={};function Le(r,e,t){z[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Le("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Le("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Le("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=nt(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=nt(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i},RangeError);function nt(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function ir(r,e,t){Q(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&oe(e,r.length-(t+1))}function wt(r,e,t,i,n,o){if(r>t||r<e){let s=typeof e=="bigint"?"n":"",l;throw o>3?e===0||e===BigInt(0)?l=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:l=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:l=`>= ${e}${s} and <= ${t}${s}`,new z.ERR_OUT_OF_RANGE("value",l,r)}ir(i,n,o)}function Q(r,e){if(typeof r!="number")throw new z.ERR_INVALID_ARG_TYPE(e,"number",r)}function oe(r,e,t){throw Math.floor(r)!==r?(Q(r,t),new z.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new z.ERR_BUFFER_OUT_OF_BOUNDS:new z.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var nr=/[^+/0-9A-Za-z-_]/g;function or(r){if(r=r.split("=")[0],r=r.trim().replace(nr,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function _e(r,e){e=e||1/0;let t,i=r.length,n=null,o=[];for(let s=0;s<i;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function sr(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function ar(r,e){let t,i,n,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),i=t>>8,n=t%256,o.push(n),o.push(i);return o}function mt(r){return Se.toByteArray(or(r))}function ge(r,e,t,i){let n;for(n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function b(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function He(r){return r!==r}var lr=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let n=0;n<16;++n)e[i+n]=r[t]+r[n]}return e}();function N(r){return typeof BigInt>"u"?ur:r}function ur(){throw new Error("BigInt not supported")}});var zr={};Ue(zr,{ClientBuilder:()=>re,Process:()=>be,createAuthMiddlewareForAnonymousSessionFlow:()=>v,createAuthMiddlewareForClientCredentialsFlow:()=>X,createAuthMiddlewareForExistingTokenFlow:()=>Z,createAuthMiddlewareForPasswordFlow:()=>ee,createAuthMiddlewareForRefreshTokenFlow:()=>te,createClient:()=>D,createConcurrentModificationMiddleware:()=>ae,createCorrelationIdMiddleware:()=>le,createHttpMiddleware:()=>ue,createLoggerMiddleware:()=>ce,createQueueMiddleware:()=>de,createUserAgentMiddleware:()=>he});var We={};Ue(We,{createAuthMiddlewareForAnonymousSessionFlow:()=>v,createAuthMiddlewareForClientCredentialsFlow:()=>X,createAuthMiddlewareForExistingTokenFlow:()=>Z,createAuthMiddlewareForPasswordFlow:()=>ee,createAuthMiddlewareForRefreshTokenFlow:()=>te,createConcurrentModificationMiddleware:()=>ae,createCorrelationIdMiddleware:()=>le,createErrorMiddleware:()=>Ye,createHttpMiddleware:()=>ue,createLoggerMiddleware:()=>ce,createQueueMiddleware:()=>de,createUserAgentMiddleware:()=>he});var cr=yt().Buffer;function V(r){return r&&(typeof r=="string"||r instanceof Uint8Array)?cr.byteLength(r).toString():r&&typeof r=="object"?new TextEncoder().encode(JSON.stringify(r)).length.toString():"0"}var B={};Ue(B,{CONCURRENCT_REQUEST:()=>hr,CTP_API_URL:()=>pr,CTP_AUTH_URL:()=>fr,DEFAULT_HEADERS:()=>De,HEADERS_CONTENT_TYPES:()=>dr});var dr=["application/json","application/graphql"],hr=20,pr="https://api.europe-west1.gcp.commercetools.com",fr="https://auth.europe-west1.gcp.commercetools.com",De=["content-type","access-control-allow-origin","access-control-allow-headers","access-control-allow-methods","access-control-expose-headers","access-control-max-ag","x-correlation-id","server-timing","date","server","transfer-encoding","access-control-max-age","content-encoding","x-envoy-upstream-service-time","via","alt-svc","connection"];function O(r,e,t={}){this.status=this.statusCode=this.code=r,this.message=e,Object.assign(this,t),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function gt(...r){O.call(this,0,...r)}function xt(...r){O.call(this,...r)}function wr(...r){O.call(this,400,...r)}function mr(...r){O.call(this,401,...r)}function yr(...r){O.call(this,403,...r)}function gr(...r){O.call(this,404,...r)}function xr(...r){O.call(this,409,...r)}function Mr(...r){O.call(this,500,...r)}function Cr(...r){O.call(this,503,...r)}function $e(r){switch(r){case 0:return gt;case 400:return wr;case 401:return mr;case 403:return yr;case 404:return gr;case 409:return xr;case 500:return Mr;case 503:return Cr;default:return}}function Er({statusCode:r,message:e,...t}){let i=e||"Unexpected non-JSON error response";r===404&&(i=`URI not found: ${t.originalRequest?.uri||t.uri}`);let n=$e(r);return n?new n(i,t):new xt(r,i,t)}var Y=Er;function Ar(r,e){return[503,...r].includes(e?.status||e?.statusCode)}async function Rr(r,e){async function t(){return await r({...e,headers:{...e.headers}})}return t().catch(i=>Promise.reject(i))}async function W(r){let{url:e,httpClient:t,...i}=r;return await Rr(async o=>{let{enableRetry:s,retryConfig:l,timeout:u,getAbortController:d}=i,{retryCodes:c=[],maxDelay:h=1/0,maxRetries:w=3,backoff:p=!0,retryDelay:f=200,retryOnAbort:S=!0}=l||{},x,M,C=0,$;Ke(c);async function P(){return t(e,{...o,...i,headers:{...i.headers,"Accept-Encoding":"application/json"},...i.body?{data:i.body}:{},withCredentials:o.credentialsMode==="include"})}function pe(){let A=(d?d():null)||new AbortController;return i.abortController=A,i.signal=A.signal,A}async function K(){let A=async(we,Tt)=>{let ne={};if(u){let j=pe();$=setTimeout(()=>{j.abort(),j=pe()},u)}try{if(ne=await P(),ne.status>399&&Ar(we,ne))return{_response:ne,shouldRetry:!0}}catch(j){if((j.name.includes("AbortError")||j.name.includes("TimeoutError"))&&Tt)return{_response:j,shouldRetry:!0};throw j}finally{clearTimeout($)}return{_response:ne,shouldRetry:!1}},{_response:ie,shouldRetry:fe}=await A(c,S);for(;s&&fe&&C<w;){C++,await Me(xe({retryCount:C,retryDelay:f,maxRetries:w,backoff:p,maxDelay:h}));let we=await A(c,S);ie=we._response,fe=we.shouldRetry}return ie}let E=await K();try{E.text&&typeof E.text=="function"?(x=await E.text()||E[Object.getOwnPropertySymbols(E)[1]],M=JSON.parse(x)):M=E.data||E}catch(A){throw A}return{data:M,retryCount:C,statusCode:E.status||E.statusCode||M.statusCode,headers:E.headers}},{validateStatus:o=>!0})}function Ce(){return("1000000-1000-4000-8000"+-1e11).replace(/[018]/g,r=>(parseInt(r)^Math.floor(Math.random()*256)&15>>parseInt(r)/4).toString(16))}function Br(r){return De.reduce((e,t)=>{let i=r[t]?r[t]:typeof r.get=="function"?r.get(t):null;return i&&(e[t]=i),e},{})}function I(r){if(!r)return null;if(r.raw&&typeof r.raw=="function")return r.raw();if(!r.forEach)return Br(r);let e={};return r.forEach((t,i)=>e[i]=t),e}function se(r){return r!=null&&r.constructor!=null&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function H(r){let e=JSON.parse(JSON.stringify(r));return e?.headers&&(e.headers.Authorization&&(e.headers.Authorization="Bearer ********"),e.headers.authorization&&(e.headers.authorization="Bearer ********")),e}function g(r,e){return{...e,headers:{...e.headers,Authorization:`Bearer ${r}`}}}var ze=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function xe({retryCount:r,retryDelay:e,backoff:t,maxDelay:i}){return t&&r!==0?Math.min(Math.round((Math.random()+1)*e*2**r),i):e}Math.min(Math.round((Math.random()+1)*200*2**10),1/0);function Me(r){return new Promise(e=>{setTimeout(e,r)})}function F(r){if(!r?.credentials?.clientId||!r.projectKey||!r.host)throw new Error("Missing required options.");return{clientId:r.credentials.clientId,host:r.host,projectKey:r.projectKey}}function Ee(r){return Date.now()+r*1e3-5*60*1e3}function U(r){let e=r;return{get:t=>e,set:(t,i)=>{e=t}}}function Mt(r){return typeof r<"u"&&r!==null}function Tr(r){return Mt(r)?typeof r=="string"?r:Object.fromEntries(Object.entries(r).filter(([e,t])=>![null,void 0,""].includes(t))):""}function br(r){let e={},t=new URLSearchParams(r);for(let i of t.keys())t.getAll(i).length>1?e[i]=t.getAll(i):e[i]=t.get(i);return e}function Ir(r){if(r=Tr(r),!r)return"";let e=new URLSearchParams(r);for(let[t,i]of Object.entries(r))Array.isArray(i)&&(e.delete(t),i.filter(Mt).forEach(n=>e.append(t,n)));return e.toString()}function Ge(r,e=br){return e(r)}function Ae(r,e=Ir){return e(r)}var Fr=()=>typeof window<"u"&&window.document&&window.document.nodeType===9;function Ur(){if(Fr())return window.navigator.userAgent;let r=process?.version.slice(1)||"unknow",e=`(${process.platform}; ${process.arch})`;return`node.js/${r} ${e}`}function Re(r){let e=null,t=null;if(!r)throw new Error("Missing required option `name`");let i=r.version?`${r.name}/${r.version}`:r.name;r.libraryName&&!r.libraryVersion?e=r.libraryName:r.libraryName&&r.libraryVersion&&(e=`${r.libraryName}/${r.libraryVersion}`),r.contactUrl&&!r.contactEmail?t=`(+${r.contactUrl})`:!r.contactUrl&&r.contactEmail?t=`(+${r.contactEmail})`:r.contactUrl&&r.contactEmail&&(t=`(+${r.contactUrl}; +${r.contactEmail})`);let n=Ur(),o=r.customAgent||"";return[i,n,e,t,o].filter(Boolean).join(" ")}function Qe(r){if(!r.host)throw new Error("Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`");if(!r.httpClient&&typeof r.httpClient!="function")throw new Error("An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(r.httpClientOptions&&Object.prototype.toString.call(r.httpClientOptions)!=="[object Object]")throw new Error("`httpClientOptions` must be an object type")}function Ke(r){if(!Array.isArray(r))throw new Error("`retryCodes` option must be an array of retry status (error) codes and/or messages.")}function Je(r){if(!r)throw new Error("Missing required options");if(r.middlewares&&!Array.isArray(r.middlewares))throw new Error("Middlewares should be an array");if(!r.middlewares||!Array.isArray(r.middlewares)||!r.middlewares.length)throw new Error("You need to provide at least one middleware")}function Be(r,e,t={allowedMethods:ze}){if(!e)throw new Error(`The "${r}" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(typeof e.uri!="string")throw new Error(`The "${r}" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(!t.allowedMethods.includes(e.method))throw new Error(`The "${r}" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`)}function Ve(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:t}=r.credentials||{};if(!(e&&t))throw new Error("Missing required credentials (clientId, clientSecret)");let i=r.scopes?r.scopes.join(" "):void 0,n=btoa(`${e}:${t}`),o=r.oauthUri||"/oauth/token",s=r.host.replace(/\/$/,"")+o,l=`grant_type=client_credentials${i?`&scope=${i}`:""}`;return{url:s,body:l,basicAuth:n}}function Ct(r){if(!r)throw new Error("Missing required options");if(!r.projectKey)throw new Error("Missing required option (projectKey)");let e=r.projectKey;r.oauthUri=r.oauthUri||`/oauth/${e}/anonymous/token`;let t=Ve(r);return r.credentials.anonymousId&&(t.body+=`&anonymous_id=${r.credentials.anonymousId}`),{...t}}function Te(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");if(!r.refreshToken)throw new Error("Missing required option (refreshToken)");let{clientId:e,clientSecret:t}=r.credentials;if(!(e&&t))throw new Error("Missing required credentials (clientId, clientSecret)");let i=btoa(`${e}:${t}`),n=r.oauthUri||"/oauth/token",o=r.host.replace(/\/$/,"")+n,s=`grant_type=refresh_token&refresh_token=${encodeURIComponent(r.refreshToken)}`;return{basicAuth:i,url:o,body:s}}function Et(r){if(!r)throw new Error("Missing required options");if(!r.host)throw new Error("Missing required option (host)");if(!r.projectKey)throw new Error("Missing required option (projectKey)");if(!r.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:t,user:i}=r.credentials,n=r.projectKey;if(!(e&&t&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");let{username:o,password:s}=i;if(!(o&&s))throw new Error("Missing required user credentials (username, password)");let l=(r.scopes||[]).join(" "),u=l?`&scope=${l}`:"",d=btoa(`${e}:${t}`),c=r.oauthUri||`/oauth/${n}/customers/token`,h=r.host.replace(/\/$/,"")+c,w=`grant_type=password&username=${encodeURIComponent(o)}&password=${encodeURIComponent(s)}${u}`;return{basicAuth:d,url:h,body:w}}async function _(r){let{httpClient:e,httpClientOptions:t,tokenCache:i,userOption:n,tokenCacheObject:o}=r,s=r.url,l=r.body,u=r.basicAuth;if(!e||typeof e!="function")throw new Error("an `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(o&&o.refreshToken&&(!o.token||o.token&&Date.now()>o.expirationTime)){if(!n)throw new Error("Missing required options.");let c={...Te({...n,refreshToken:o.refreshToken})};s=c.url,l=c.body,u=c.basicAuth}let d;try{if(d=await W({url:s,method:"POST",headers:{Authorization:`Basic ${u}`,"Content-Type":"application/x-www-form-urlencoded","Content-Length":V(l)},httpClient:e,httpClientOptions:t,body:l}),d.statusCode>=200&&d.statusCode<300){let{access_token:c,expires_in:h,refresh_token:w}=d?.data,p=Ee(h);return i.set({token:c,expirationTime:p,refreshToken:w}),Promise.resolve(!0)}throw Y({code:d.data.error,statusCode:d.data.statusCode,message:d.data.message,error:d.data.errors})}catch(c){throw c}}function v(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(g(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,httpClient:r.httpClient||fetch,httpClientOptions:r.httpClientOptions,...Ct(r),userOption:r,next:o};return i?await i:(i=_(l),await i,i=null),t=e.get(n),o(g(t.token,s))}}function X(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(g(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,tokenCacheObject:t,httpClient:r.httpClient||fetch,httpClientOptions:r.httpClientOptions,...Ve(r),next:o};return i?await i:(i=_(l),await i,i=null),t=e.get(n),o(g(t.token,s))}}function Z(r,e){return t=>async i=>{if(typeof r!="string")throw new Error("authorization must be a string");let n=e?.force===void 0?!0:e.force;if(!r||i.headers&&(i.headers.Authorization||i.headers.authorization)&&n===!1)return t(i);let o={...i,headers:{...i.headers,Authorization:r}};return t(o)}}function ee(r){let e=r.tokenCache||U({token:"",expirationTime:-1}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(g(t.token,s));let l={request:s,tokenCache:e,tokenCacheKey:n,httpClient:r.httpClient||fetch,httpClientOptions:r.httpClientOptions,...Et(r),userOption:r,next:o};return i?await i:(i=_(l),await i,i=null),t=e.get(n),o(g(t.token,s))}}function te(r){let e=r.tokenCache||U({token:"",tokenCacheKey:null}),t,i=null,n=F(r);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(t=e.get(n),t&&t.token&&Date.now()<t.expirationTime)return o(g(t.token,s));let l={request:s,tokenCache:e,httpClient:r.httpClient||fetch,httpClientOptions:r.httpClientOptions,...Te(r),next:o};return i?await i:(i=_(l),await i,i=null),t=e.get(n),o(g(t.token,s))}}function ae(r){return e=>async t=>{let i=await e(t);if(i.statusCode==409){let n=i.error.body?.errors?.[0]?.currentVersion;if(n)return r&&typeof r=="function"?t.body=await r(n,t,i):t.body=typeof t.body=="string"?{...JSON.parse(t.body),version:n}:{...t.body,version:n},e(t)}return i}}function le(r){return e=>t=>{let i={...t,headers:{...t.headers,"X-Correlation-ID":r.generate&&typeof r.generate=="function"?r.generate():Ce()}};return e(i)}}function Ye(r){return e=>async t=>{let i=await e(t);if(i.error){let{error:n}=i;return{...i,statusCode:n.statusCode||0,headers:n.headers||I({}),error:{...n,body:n.data||n}}}return i}}async function kr({url:r,httpClient:e,clientOptions:t}){let{request:i,maskSensitiveHeaderData:n,includeRequestInErrorResponse:o,includeResponseHeaders:s}=t;try{let l=await W({url:r,...t,httpClient:e,method:t.method,...t.body?{body:t.body}:{}});if(s||(l.headers=null),l.statusCode>=200&&l.statusCode<300)return t.method=="HEAD"?{body:null,statusCode:l.statusCode,retryCount:l.retryCount,headers:I(l.headers)}:{body:l.data,statusCode:l.statusCode,retryCount:l.retryCount,headers:I(l.headers)};let u=Y({message:l?.data?.message||l?.message,statusCode:l.statusCode||l?.data?.statusCode,headers:I(l.headers),method:t.method,body:l.data,retryCount:l.retryCount,...o?{originalRequest:n?H(i):i}:{uri:i.uri}});return{body:l.data,code:l.statusCode,statusCode:l.statusCode,headers:I(l.headers),error:u}}catch(l){let u=s?I(l.response?.headers):null,d=l.response?.status||l.response?.data0||0,c=l.response?.data?.message;throw{body:null,error:Y({statusCode:d,code:d,status:d,message:c||l.message,headers:u,body:l.response?.data||l,error:l.response?.data,...o?{originalRequest:n?H(i):i}:{uri:i.uri}})}}}function ue(r){Qe(r);let{host:e,credentialsMode:t,httpClient:i,timeout:n,enableRetry:o,retryConfig:s,getAbortController:l,includeOriginalRequest:u,includeRequestInErrorResponse:d=!0,includeResponseHeaders:c=!0,maskSensitiveHeaderData:h,httpClientOptions:w}=r;return p=>async f=>{let S=e.replace(/\/$/,"")+f.uri,x={...f.headers};Object.prototype.hasOwnProperty.call(x,"Content-Type")||Object.prototype.hasOwnProperty.call(x,"content-type")||(x["Content-Type"]="application/json"),x["Content-Type"]===null&&delete x["Content-Type"];let M=B.HEADERS_CONTENT_TYPES.indexOf(x["Content-Type"])>-1&&typeof f.body=="string"||se(f.body)?f.body:JSON.stringify(f.body||void 0);M&&(typeof M=="string"||se(M))&&(x["Content-Length"]=V(M));let C={enableRetry:o,retryConfig:s,request:f,method:f.method,headers:x,includeRequestInErrorResponse:d,maskSensitiveHeaderData:h,includeResponseHeaders:c,...w};t&&(C.credentialsMode=t),n&&(C.timeout=n,C.getAbortController=l),M&&(C.body=M);let $=await kr({url:S,clientOptions:C,httpClient:i}),P={...f,includeOriginalRequest:u,maskSensitiveHeaderData:h,response:$};return p(P)}}function ce(r){return e=>async t=>{let i=await e(t),n=Object.assign({},i),{loggerFn:o=console.log}=r||{};return o&&typeof o=="function"&&o(i),n}}function de({concurrency:r=20}){let e=0,t=[],i=()=>0>=r?Promise.resolve():new Promise(o=>{let s=()=>{e<r?(e++,o()):t.push(s)};s()}),n=()=>{if(e--,t.length>0){let o=t.shift();o&&o()}};return o=>s=>i().then(()=>{let l={...s,resolve(u){s.resolve(u),n()},reject(u){s.reject(u),n()}};return o(l).finally(()=>{n()})})}var At={name:"@commercetools/ts-client",version:"3.0.0",engines:{node:">=18"},description:"commercetools Composable Commerce TypeScript SDK client.",keywords:["commercetools","composable commerce","sdk","typescript","client","middleware","http","oauth","auth"],homepage:"https://github.com/commercetools/commercetools-sdk-typescript",license:"MIT",directories:{lib:"lib",test:"test"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/commercetools/commercetools-sdk-typescript.git"},bugs:{url:"https://github.com/commercetools/commercetools-sdk-typescript/issues"},dependencies:{buffer:"^6.0.3"},files:["dist","CHANGELOG.md"],author:"Chukwuemeka Ajima <meeky.ae@gmail.com>",main:"dist/commercetools-ts-client.cjs.js",module:"dist/commercetools-ts-client.esm.js",browser:{"./dist/commercetools-ts-client.cjs.js":"./dist/commercetools-ts-client.browser.cjs.js","./dist/commercetools-ts-client.esm.js":"./dist/commercetools-ts-client.browser.esm.js"},devDependencies:{"common-tags":"1.8.2",dotenv:"16.4.5",jest:"29.7.0",nock:"^14.0.0-beta.19","organize-imports-cli":"0.10.0"},scripts:{organize_imports:"find src -type f -name '*.ts' | xargs organize-imports-cli",postbuild:"yarn organize_imports",post_process_generate:"yarn organize_imports",docs:"typedoc --out docs"}};function he(r){return e=>async t=>{let i=Re({...r,name:`${r.name?r.name+"/":""}commercetools-sdk-javascript-v3/${At.version}`}),n={...t,headers:{...t.headers,"User-Agent":i}};return e(n)}}function Sr({middlewares:r}){return r.length===1?r[0]:r.slice().reduce((t,i)=>(...n)=>t(i.apply(null,n)))}var Rt;function be(r,e,t){if(Be("process",r,{allowedMethods:["GET"]}),typeof e!="function")throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');let i={total:Number.POSITIVE_INFINITY,accumulate:!0,...t};return new Promise((n,o)=>{let s,l="";if(r&&r.uri){let[p,f]=r.uri.split("?");s=p,l=f}let d={limit:20,...{...Ge(l)}},c=i.total,h=!1,w=async(p,f=[])=>{let S=d.limit<c?d.limit:c,x=Ae({...d,limit:S}),M={sort:"id asc",withTotal:!1,...p?{where:`id > "${p}"`}:{}},C=Ae(M),$={...r,uri:`${s}?${C}&${x}`};try{let P=await D(Rt).execute($),{results:pe,count:K}=P?.body||{};if(!K&&h)return n(f||[]);let E=await Promise.resolve(e(P)),A;if(h=!0,i.accumulate&&(A=f.concat(E||[])),c-=K,K<d.limit||!c)return n(A||[]);let ie=pe[K-1],fe=ie&&ie.id;w(fe,A)}catch(P){o(P)}};w()})}function D(r){Rt=r,Je(r);let e=!1,t={async resolve(n){let{response:o,includeOriginalRequest:s,maskSensitiveHeaderData:l,...u}=n,{retryCount:d,...c}=o;return e=l,{body:null,error:null,reject:n.reject,resolve:n.resolve,...c,...s?{originalRequest:u}:{},...o?.retryCount?{retryCount:o.retryCount}:{}}}},i=Sr(r)(t.resolve);return{process:be,execute(n){return Be("exec",n),new Promise(async(o,s)=>{try{let l=await i({reject:s,resolve:o,...n});if(l.error)return s(l.error);l.originalRequest&&e&&(l.originalRequest=H(l.originalRequest)),o(l)}catch(l){s(l)}})}}}var{createAuthMiddlewareForPasswordFlow:Pr,createAuthMiddlewareForAnonymousSessionFlow:Nr,createAuthMiddlewareForClientCredentialsFlow:_r,createAuthMiddlewareForRefreshTokenFlow:jr,createAuthMiddlewareForExistingTokenFlow:qr,createCorrelationIdMiddleware:Lr,createHttpMiddleware:Hr,createLoggerMiddleware:Dr,createQueueMiddleware:$r,createUserAgentMiddleware:Bt,createConcurrentModificationMiddleware:Kr}=We,re=class{projectKey;authMiddleware;httpMiddleware;userAgentMiddleware;correlationIdMiddleware;loggerMiddleware;queueMiddleware;concurrentMiddleware;telemetryMiddleware;beforeMiddleware;afterMiddleware;middlewares=[];constructor(){this.userAgentMiddleware=Bt({})}withProjectKey(e){return this.projectKey=e,this}defaultClient(e,t,i,n,o,s){return this.withClientCredentialsFlow({host:i,projectKey:n||this.projectKey,credentials:t,httpClient:s||fetch,scopes:o}).withHttpMiddleware({host:e,httpClient:s||fetch})}withAuthMiddleware(e){return this.authMiddleware=e,this}withMiddleware(e){return this.middlewares.push(e),this}withClientCredentialsFlow(e){return this.withAuthMiddleware(_r({host:e.host||B.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},oauthUri:e.oauthUri||null,scopes:e.scopes,httpClient:e.httpClient||fetch,...e}))}withPasswordFlow(e){return this.withAuthMiddleware(Pr({host:e.host||B.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,user:{username:e.credentials.user.username||null,password:e.credentials.user.password||null}},httpClient:e.httpClient||fetch,...e}))}withAnonymousSessionFlow(e){return this.withAuthMiddleware(Nr({host:e.host||B.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,anonymousId:e.credentials.anonymousId||null},httpClient:e.httpClient||fetch,...e}))}withRefreshTokenFlow(e){return this.withAuthMiddleware(jr({host:e.host||B.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},httpClient:e.httpClient||fetch,refreshToken:e.refreshToken||null,...e}))}withExistingTokenFlow(e,t){return this.withAuthMiddleware(qr(e,{force:t.force||!0,...t}))}withHttpMiddleware(e){return this.httpMiddleware=Hr({host:e.host||B.CTP_API_URL,httpClient:e.httpClient||fetch,...e}),this}withUserAgentMiddleware(e){return this.userAgentMiddleware=Bt(e),this}withQueueMiddleware(e){return this.queueMiddleware=$r({concurrency:e.concurrency||B.CONCURRENCT_REQUEST,...e}),this}withLoggerMiddleware(e){return this.loggerMiddleware=Dr(e),this}withCorrelationIdMiddleware(e){return this.correlationIdMiddleware=Lr({generate:e?.generate,...e}),this}withConcurrentModificationMiddleware(e){return this.concurrentMiddleware=Kr(e?.concurrentModificationHandlerFn),this}withTelemetryMiddleware(e){let{createTelemetryMiddleware:t,...i}=e;return this.withUserAgentMiddleware({customAgent:i?.userAgent||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=t(i),this}withBeforeExecutionMiddleware(e){let{middleware:t,...i}=e||{};return this.beforeMiddleware=e.middleware(i),this}withAfterExecutionMiddleware(e){let{middleware:t,...i}=e||{};return this.afterMiddleware=e.middleware(i),this}build(){let e=this.middlewares.slice();return this.telemetryMiddleware&&e.push(this.telemetryMiddleware),this.correlationIdMiddleware&&e.push(this.correlationIdMiddleware),this.userAgentMiddleware&&e.push(this.userAgentMiddleware),this.authMiddleware&&e.push(this.authMiddleware),this.beforeMiddleware&&e.push(this.beforeMiddleware),this.queueMiddleware&&e.push(this.queueMiddleware),this.loggerMiddleware&&e.push(this.loggerMiddleware),this.concurrentMiddleware&&e.push(this.concurrentMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.afterMiddleware&&e.push(this.afterMiddleware),D({middlewares:e})}};return kt(zr);})();
2
2
  /*! Bundled license information:
3
3
 
4
4
  ieee754/index.js:
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"../../../../src/client","sources":["builder.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,gCAAgC,EAChC,MAAM,EACN,uCAAuC,EACvC,8BAA8B,EAC9B,WAAW,EACX,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EAEV,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EACjB,0BAAsB;AAiBvB,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,UAAU,CAAoB;IAEtC,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,oBAAoB,CAAsB;IAClD,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAE7C,OAAO,CAAC,WAAW,CAAwB;;IAMpC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa;IAK1C,aAAa,CAClB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,EACxB,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACtB,UAAU,CAAC,EAAE,QAAQ,GACpB,aAAa;IAahB,OAAO,CAAC,kBAAkB;IAKnB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa;IAKrD,yBAAyB,CAC9B,OAAO,EAAE,qBAAqB,GAC7B,aAAa;IAiBT,gBAAgB,CACrB,OAAO,EAAE,6BAA6B,GACrC,aAAa;IAmBT,wBAAwB,CAC7B,OAAO,EAAE,qBAAqB,GAC7B,aAAa;IAgBT,oBAAoB,CACzB,OAAO,EAAE,4BAA4B,GACpC,aAAa;IAgBT,qBAAqB,CAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,8BAA8B,GACvC,aAAa;IAST,kBAAkB,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa;IAUjE,uBAAuB,CAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa;IAMT,mBAAmB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,aAAa;IASpE,oBAAoB,CAAC,OAAO,CAAC,EAAE,uBAAuB;IAMtD,2BAA2B,CAChC,OAAO,CAAC,EAAE,8BAA8B,GACvC,aAAa;IAST,oCAAoC,CACzC,OAAO,CAAC,EAAE,uCAAuC,GAChD,aAAa;IAQT,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,EACvD,OAAO,EAAE,CAAC,GACT,aAAa;IAUT,6BAA6B,CAClC,OAAO,EAAE,gCAAgC;IAOpC,4BAA4B,CACjC,OAAO,EAAE,+BAA+B;IAO1C,KAAK,IAAI,MAAM;CAiBhB"}
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"../../../../src/client","sources":["builder.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,gCAAgC,EAChC,MAAM,EACN,uCAAuC,EACvC,8BAA8B,EAC9B,WAAW,EACX,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EAEV,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EACjB,0BAAsB;AAiBvB,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,UAAU,CAAoB;IAEtC,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,oBAAoB,CAAsB;IAClD,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAE7C,OAAO,CAAC,WAAW,CAAwB;;IAMpC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa;IAK1C,aAAa,CAClB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,EACxB,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACtB,UAAU,CAAC,EAAE,QAAQ,GACpB,aAAa;IAahB,OAAO,CAAC,kBAAkB;IAKnB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa;IAKrD,yBAAyB,CAC9B,OAAO,EAAE,qBAAqB,GAC7B,aAAa;IAiBT,gBAAgB,CACrB,OAAO,EAAE,6BAA6B,GACrC,aAAa;IAmBT,wBAAwB,CAC7B,OAAO,EAAE,qBAAqB,GAC7B,aAAa;IAgBT,oBAAoB,CACzB,OAAO,EAAE,4BAA4B,GACpC,aAAa;IAgBT,qBAAqB,CAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,8BAA8B,GACvC,aAAa;IAST,kBAAkB,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa;IAUjE,uBAAuB,CAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa;IAMT,mBAAmB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,aAAa;IASpE,oBAAoB,CAAC,OAAO,CAAC,EAAE,uBAAuB;IAMtD,2BAA2B,CAChC,OAAO,CAAC,EAAE,8BAA8B,GACvC,aAAa;IAST,oCAAoC,CACzC,OAAO,CAAC,EAAE,uCAAuC,GAChD,aAAa;IAQT,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,EACvD,OAAO,EAAE,CAAC,GACT,aAAa;IAUT,6BAA6B,CAClC,OAAO,EAAE,gCAAgC;IAOpC,4BAA4B,CACjC,OAAO,EAAE,+BAA+B;IAO1C,KAAK,IAAI,MAAM;CAiBhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"anonymous-session-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["anonymous-session-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,2CAA2C,CACjE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA+DZ"}
1
+ {"version":3,"file":"anonymous-session-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["anonymous-session-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,2CAA2C,CACjE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA+DZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"client-credentials-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["client-credentials-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,4CAA4C,CAClE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA+DZ"}
1
+ {"version":3,"file":"client-credentials-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["client-credentials-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,4CAA4C,CAClE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA+DZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"password-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["password-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAIV,6BAA6B,EAE9B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,OAAO,EAAE,6BAA6B,GACrC,UAAU,CA6DZ"}
1
+ {"version":3,"file":"password-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["password-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,6BAA6B,EAE9B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,OAAO,EAAE,6BAA6B,GACrC,UAAU,CA6DZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-http-middleware.d.ts","sourceRoot":"../../../../src/middleware","sources":["create-http-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,qBAAqB,EAGrB,UAAU,EAMX,0BAAsB;AAmHvB,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA2FZ"}
1
+ {"version":3,"file":"create-http-middleware.d.ts","sourceRoot":"../../../../src/middleware","sources":["create-http-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,qBAAqB,EAGrB,UAAU,EAMX,0BAAsB;AAmHvB,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA2FZ"}
@@ -1,5 +1,3 @@
1
- import AbortController, {AbortSignal} from 'abort-controller'
2
-
3
1
  export type Nullable<T> = T | null
4
2
  export type Keys = string | number | symbol
5
3
  export type JsonObject<T = unknown> = { [key in Keys]: T }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@commercetools/ts-client",
3
- "version": "2.1.6",
3
+ "version": "3.0.0",
4
4
  "engines": {
5
- "node": ">=14"
5
+ "node": ">=18"
6
6
  },
7
7
  "description": "commercetools Composable Commerce TypeScript SDK client.",
8
8
  "keywords": [
@@ -33,9 +33,7 @@
33
33
  "url": "https://github.com/commercetools/commercetools-sdk-typescript/issues"
34
34
  },
35
35
  "dependencies": {
36
- "abort-controller": "3.0.0",
37
- "buffer": "^6.0.3",
38
- "node-fetch": "^2.6.1"
36
+ "buffer": "^6.0.3"
39
37
  },
40
38
  "files": ["dist", "CHANGELOG.md"],
41
39
  "author": "Chukwuemeka Ajima <meeky.ae@gmail.com>",
@@ -49,7 +47,7 @@
49
47
  "common-tags": "1.8.2",
50
48
  "dotenv": "16.4.5",
51
49
  "jest": "29.7.0",
52
- "nock": "12.0.3",
50
+ "nock": "^14.0.0-beta.19",
53
51
  "organize-imports-cli": "0.10.0"
54
52
  },
55
53
  "scripts": {