@simpleapps-com/augur-utils 2026.11.3 → 2026.11.4

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/EXPORTS.md CHANGED
@@ -16,7 +16,7 @@
16
16
  | `breadcrumbLd` | const | A breadcrumb trail's BreadcrumbList as text. |
17
17
  | `buildCheckoutPayload` | function | Builds the oe_hdr + oe_line payload required by the commerce checkout API from cart data. |
18
18
  | `buildImageLoader` | function | Returns a loader function compatible with Next.js `<Image loader={...}>`. |
19
- | `buildTrackingData` | function | Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and prices. |
19
+ | `buildTrackingData` | function | Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and each line's own price. |
20
20
  | `CACHE_CONFIG` | const | Centralized cache configuration for React Query (TanStack Query) |
21
21
  | `categorySortBy` | function | serializeCategoryFilters' sortBy: the prefix applied only when both are non-empty. |
22
22
  | `cleanMoney` | function | Remove JS float noise from a money product or sum. |
@@ -42,6 +42,8 @@
42
42
  | `idRef` | const | A reference to another node by its @id, as JSON text. |
43
43
  | `isAddressDifferent` | function | Compares a user-entered address with a SmartyStreets-validated address. Returns true if any field differs (case-insensitive for address/city, exact match for state abbreviation and zip code). |
44
44
  | `isServerRuntime` | function | Returns true when running outside a browser (Node SSR, edge, Deno). Mirrors `isServer` in `@tanstack/query-core` (`build/modern/utils.js`). Evaluated per call, not at module scope, so `"use client"` modules that also run during SSR resolve correctly on each pass. |
45
+ | `lineHasQuantity` | function | Whether a cart line has a quantity (augur always stores one; the type allows null). |
46
+ | `linePriceAt` | function | Line `i`'s unit price from the per-line list (cart order): its own, fetched at its own quantity, so one item on two lines (two units of measure) keeps two prices; 0 past the end. |
45
47
  | `millis` | const | `n` milliseconds, for a duration under a second. |
46
48
  | `millisOf` | const | `n` as `Millis`, or null unless it is a safe integer at least 0. |
47
49
  | `minusMillis` | const | A reading less a duration, never below 0. |
@@ -49,6 +51,10 @@
49
51
  | `nodeHead` | const | The schema.org context and a node's type: its first two members, as JSON text. |
50
52
  | `normalizePath` | function | Normalizes an image path by: 1. Returning it as-is if it starts with `http` (external URL). 2. Stripping configured prefixes (defaults: `/images`, `images`). 3. Prepending `defaultPath` for bare filenames (no `/`). 4. Stripping leading slashes. |
51
53
  | `paginateOffset` | function | Returns a copy of filters with offset adjusted for the given page. |
54
+ | `priceQueryRuns` | function | Whether a line's price query runs: a customer, an itemId, and a quantity (the price engine is never asked for a quantity nobody entered). |
55
+ | `priceQueryUnit` | function | The unit of measure a line's price query asks for: the line's own, so a CASE/6 line is priced per case, not as one EACH (the price engine prices a query without a unit in the item's default selling unit); null for a missing or blank unit (a line saved before the client required one). |
56
+ | `pricingLoadingFrom` | function | Cart pricing is loading when any query that runs is loading. |
57
+ | `pricingSettledFrom` | function | Cart pricing is settled when every query that runs has succeeded: a line whose query never runs (no quantity, no itemId, no customer) can't hold it back (its query stays pending and idle). |
52
58
  | `pushTrackingData` | function | Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern. |
53
59
  | `resolveGcTime` | function | Returns the React Query `gcTime` to use for a query built in this runtime. On the server returns `Infinity`, which query-core treats as "schedule no GC timer", so a per-request QueryClient is freed when the request ends. A finite value would start a timer that pins the whole request cache. In the browser returns `clientGcTime` unchanged. The result is a `number`, not `Millis`: `Infinity` is no whole number of milliseconds. |
54
60
  | `resolveStock` | function | Pure stock resolution -- usable in hooks AND server components. |
package/README.md CHANGED
@@ -23,8 +23,15 @@ pnpm add @simpleapps-com/augur-utils
23
23
  ## Development
24
24
 
25
25
  TypeScript in `src/`, built to `dist/` (ESM and CJS) by tsup. The decisions are proved
26
- (`src/rules.ts`, `src/price-outcome.ts`, `src/image-rules.ts`, `src/json-ld-rules.ts`; model
27
- `models/AugurUtils.dfy`, links `models/links/augur-utils-*.dfy`); the rest is tested at 100%.
26
+ (`src/rules.ts`, `src/price-outcome.ts`, `src/image-rules.ts`, `src/json-ld-rules.ts`,
27
+ `src/cart-line-rules.ts`; model `models/AugurUtils.dfy`, links `models/links/augur-utils-*.dfy`);
28
+ the rest is tested at 100%.
29
+
30
+ Cart-line pricing (#93) lives in `src/cart-line-rules.ts`: `lineHasQuantity`, `priceQueryRuns`
31
+ (augur never stores a null quantity, `models/AugurCommerceCartLine.dfy`; the type allows one, and
32
+ such a line is not priced), `pricingSettledFrom` / `pricingLoadingFrom` (over the prices that are
33
+ fetched) and `linePriceAt` (each line's own price, so one item on two lines keeps two).
34
+ `buildTrackingData` takes `getLineUnitPrice(index)`, a price per line.
28
35
 
29
36
  `CACHE_CONFIG`'s tiers are server-safe (#94): each `gcTime` is a getter through
30
37
  `resolveGcTime` (`src/runtime.ts`, the proved `gcTimeFor` in `src/rules.ts`), so it is
@@ -52,13 +52,18 @@ export interface BuildTrackingDataInput {
52
52
  itemDesc?: string;
53
53
  classId5?: string;
54
54
  }>;
55
- getUnitPrice: (itemId: string) => number;
55
+ /**
56
+ * Unit price of the line at `index` in `cartLines` (useCartPricing's `getLineUnitPrice`). Per
57
+ * line, not per item: one item on two lines (two units of measure) has two prices.
58
+ */
59
+ getLineUnitPrice: (index: number) => number;
56
60
  currency?: string;
57
61
  }
58
62
  /**
59
- * Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and prices.
63
+ * Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and each line's own
64
+ * price.
60
65
  */
61
- export declare function buildTrackingData({ cartLines, itemDetails, getUnitPrice, currency, }: BuildTrackingDataInput): TrackingData;
66
+ export declare function buildTrackingData({ cartLines, itemDetails, getLineUnitPrice, currency, }: BuildTrackingDataInput): TrackingData;
62
67
  /**
63
68
  * Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern.
64
69
  */
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,SAAS,CAAC,EAAE,MAAM,CAAC,M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;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAa,GACd,EAAE,mBAAmB,GAAG,IAAI,CAkB5B;AAMD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE;;;OAGG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,QAAgB,GACjB,EAAE,sBAAsB,GAAG,YAAY,CAwBvC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAYzD"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Whether a cart line has a quantity (augur always stores one; the type allows null).
3
+ *
4
+ * @ensures result ⟺ quantity ≠ null, the model's LineHasQuantity
5
+ */
6
+ export declare function lineHasQuantity(quantity: number | null): boolean;
7
+ /**
8
+ * Whether a line's price query runs: a customer, an itemId, and a quantity (the price engine is
9
+ * never asked for a quantity nobody entered).
10
+ *
11
+ * @ensures result ⟺ hasCustomer ∧ hasItemId ∧ quantity ≠ null, the model's PriceQueryRuns over
12
+ * LineHasQuantity
13
+ */
14
+ export declare function priceQueryRuns(hasCustomer: boolean, hasItemId: boolean, quantity: number | null): boolean;
15
+ /**
16
+ * The unit of measure a line's price query asks for: the line's own, so a CASE/6 line is priced per
17
+ * case, not as one EACH (the price engine prices a query without a unit in the item's default
18
+ * selling unit); null for a missing or blank unit (a line saved before the client required one).
19
+ *
20
+ * @ensures result = unitOfMeasure when it is set and not blank, else null: the model's QueryUnit
21
+ */
22
+ export declare function priceQueryUnit(unitOfMeasure: string | null): string | null;
23
+ /**
24
+ * Cart pricing is settled when every query that runs has succeeded: a line whose query never runs
25
+ * (no quantity, no itemId, no customer) can't hold it back (its query stays pending and idle).
26
+ *
27
+ * @ensures exactly the model's PricingSettledFrom
28
+ */
29
+ export declare function pricingSettledFrom(succeeded: boolean[], runs: boolean[], i: number): boolean;
30
+ /**
31
+ * Cart pricing is loading when any query that runs is loading.
32
+ *
33
+ * @ensures exactly the model's PricingLoadingFrom
34
+ */
35
+ export declare function pricingLoadingFrom(loading: boolean[], runs: boolean[], i: number): boolean;
36
+ /**
37
+ * Line `i`'s unit price from the per-line list (cart order): its own, fetched at its own quantity,
38
+ * so one item on two lines (two units of measure) keeps two prices; 0 past the end.
39
+ *
40
+ * @ensures result = unitPrices[i] when i < |unitPrices|, else 0, the model's LinePriceAt
41
+ */
42
+ export declare function linePriceAt(unitPrices: number[], i: number): number;
43
+ //# sourceMappingURL=cart-line-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart-line-rules.d.ts","sourceRoot":"","sources":["../src/cart-line-rules.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAIhE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAIT;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAI1E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAW5F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAW1F;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAMnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"date-helpers.d.ts","sourceRoot":"","sources":["../src/date-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAgBlE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYxD"}
1
+ {"version":3,"file":"date-helpers.d.ts","sourceRoot":"","sources":["../src/date-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAgBlE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD"}
package/dist/index.cjs CHANGED
@@ -92,6 +92,14 @@ function availabilityOf(isInStock, isDiscontinued) {
92
92
  if (isDiscontinued) return "OutOfStock";
93
93
  return "BackOrder";
94
94
  }
95
+ function presentIndexFrom(present, i) {
96
+ if (i === present.length) return -1;
97
+ if (present[i] === true) return i;
98
+ return presentIndexFrom(present, i + 1);
99
+ }
100
+ function leadDateText(from, hasTo, to) {
101
+ return hasTo ? from + " - " + to : from;
102
+ }
95
103
  function takerOf(taker) {
96
104
  return _nullishCoalesce(taker, () => ( "ESTORE"));
97
105
  }
@@ -191,11 +199,12 @@ function getPaymentStatus(invoice) {
191
199
  function str(value) {
192
200
  return String(value).trim();
193
201
  }
202
+ function presence(raw, keys) {
203
+ return keys.map((k) => raw[k] != null);
204
+ }
194
205
  function firstPresent(raw, keys) {
195
- for (const k of keys) {
196
- if (raw[k] != null) return raw[k];
197
- }
198
- return "";
206
+ const index = presentIndexFrom(presence(raw, keys), 0);
207
+ return index < 0 ? "" : raw[keys[index]];
199
208
  }
200
209
  function pick(raw, keys) {
201
210
  return str(firstPresent(raw, keys));
@@ -225,7 +234,7 @@ var MAIL_FIELDS = {
225
234
  country: ["mailCountry", "mail_country", "country"]
226
235
  };
227
236
  function transformShipToAddress(raw) {
228
- const isPhys = PHYS_MARKERS.some((k) => raw[k] != null);
237
+ const isPhys = presentIndexFrom(presence(raw, PHYS_MARKERS), 0) >= 0;
229
238
  const f = isPhys ? PHYS_FIELDS : MAIL_FIELDS;
230
239
  const address = {
231
240
  shipToId: firstPresent(raw, ["shipToId", "ship_to_id", "id"]),
@@ -242,6 +251,48 @@ function transformShipToAddress(raw) {
242
251
  return address;
243
252
  }
244
253
 
254
+ // ../utils/src/strings.ts
255
+ function codeAt(s, i) {
256
+ return i >= 0 && i < s.length ? s.charCodeAt(i) : -1;
257
+ }
258
+ function indexOfCode(s, code, from) {
259
+ const c = codeAt(s, from);
260
+ if (c === code) return from;
261
+ if (c === -1) return -1;
262
+ return indexOfCode(s, code, from + 1);
263
+ }
264
+ function startsWithAt(s, x, pos) {
265
+ const at = Math.min(pos, s.length);
266
+ return s.slice(at, Math.min(at + x.length, s.length)) === x;
267
+ }
268
+ function isBlank(s) {
269
+ return s.trim() === "";
270
+ }
271
+
272
+ // src/cart-line-rules.ts
273
+ function lineHasQuantity(quantity) {
274
+ return quantity !== null;
275
+ }
276
+ function priceQueryRuns(hasCustomer, hasItemId, quantity) {
277
+ return hasCustomer && hasItemId && lineHasQuantity(quantity);
278
+ }
279
+ function priceQueryUnit(unitOfMeasure) {
280
+ return unitOfMeasure !== null && !isBlank(unitOfMeasure) ? unitOfMeasure : null;
281
+ }
282
+ function pricingSettledFrom(succeeded, runs, i) {
283
+ if (i === succeeded.length) return true;
284
+ if (runs[i] === true && succeeded[i] !== true) return false;
285
+ return pricingSettledFrom(succeeded, runs, i + 1);
286
+ }
287
+ function pricingLoadingFrom(loading, runs, i) {
288
+ if (i === loading.length) return false;
289
+ if (runs[i] === true && loading[i] === true) return true;
290
+ return pricingLoadingFrom(loading, runs, i + 1);
291
+ }
292
+ function linePriceAt(unitPrices, i) {
293
+ return i < unitPrices.length ? unitPrices[i] : 0;
294
+ }
295
+
245
296
  // src/build-checkout-payload.ts
246
297
  function buildCheckoutPayload(input) {
247
298
  const oe_hdr = {
@@ -376,21 +427,6 @@ var SCHEMA_URLS = {
376
427
  BackOrder: "https://schema.org/BackOrder"
377
428
  };
378
429
 
379
- // ../utils/src/strings.ts
380
- function codeAt(s, i) {
381
- return i >= 0 && i < s.length ? s.charCodeAt(i) : -1;
382
- }
383
- function indexOfCode(s, code, from) {
384
- const c = codeAt(s, from);
385
- if (c === code) return from;
386
- if (c === -1) return -1;
387
- return indexOfCode(s, code, from + 1);
388
- }
389
- function startsWithAt(s, x, pos) {
390
- const at = Math.min(pos, s.length);
391
- return s.slice(at, Math.min(at + x.length, s.length)) === x;
392
- }
393
-
394
430
  // ../utils/src/lists.ts
395
431
  function joinFrom(xs, sep, i) {
396
432
  if (i >= xs.length) return "";
@@ -1015,12 +1051,8 @@ function getBusinessDay(businessDaysFromNow) {
1015
1051
  function getShippingLeadDate(days3) {
1016
1052
  const config = shippingLeadOf(days3);
1017
1053
  if (!config) return "";
1018
- const fromDate = getBusinessDay(config.from);
1019
- if (config.to) {
1020
- const toDate = getBusinessDay(config.to);
1021
- return `${fromDate} - ${toDate}`;
1022
- }
1023
- return fromDate;
1054
+ const hasTo = config.to !== 0;
1055
+ return leadDateText(getBusinessDay(config.from), hasTo, hasTo ? getBusinessDay(config.to) : "");
1024
1056
  }
1025
1057
 
1026
1058
  // src/transforms.ts
@@ -1114,13 +1146,13 @@ function trackViewItem({
1114
1146
  function buildTrackingData({
1115
1147
  cartLines,
1116
1148
  itemDetails,
1117
- getUnitPrice,
1149
+ getLineUnitPrice,
1118
1150
  currency = "USD"
1119
1151
  }) {
1120
1152
  let total = 0;
1121
1153
  const items = cartLines.map((line, index) => {
1122
1154
  const details = itemDetails[line.itemId];
1123
- const price = getUnitPrice(line.itemId);
1155
+ const price = getLineUnitPrice(index);
1124
1156
  total = cleanMoney(total + cleanMoney(price * line.quantity));
1125
1157
  return {
1126
1158
  item_id: line.itemId,
@@ -1217,5 +1249,11 @@ function pushTrackingData(data) {
1217
1249
 
1218
1250
 
1219
1251
 
1220
- exports.BLUR_DATA_URL = BLUR_DATA_URL; exports.BillingAddressInvoiceSchema = BillingAddressInvoiceSchema; exports.BillingAddressSchema = BillingAddressSchema; exports.CACHE_CONFIG = CACHE_CONFIG; exports.CONTIGUOUS_STATES = CONTIGUOUS_STATES; exports.ShippingAddressSchema = ShippingAddressSchema; exports.US_STATES = US_STATES; exports.US_STATES_FULL = US_STATES_FULL; exports.US_TERRITORIES = US_TERRITORIES; exports.VALIDATION_PATTERNS = VALIDATION_PATTERNS; exports.addMillis = addMillis2; exports.breadcrumbLd = breadcrumbLd2; exports.buildCheckoutPayload = buildCheckoutPayload; exports.buildImageLoader = buildImageLoader; exports.buildTrackingData = buildTrackingData; exports.categorySortBy = categorySortBy; exports.cleanMoney = cleanMoney; exports.cn = _chunk5UMFBGVAcjs.cn; exports.createImageConfig = createImageConfig; exports.days = days2; exports.derivePrice = derivePrice; exports.faqLd = faqLd2; exports.floorSeconds = floorSeconds2; exports.formatPrice = formatPrice; exports.generateBreadcrumbJsonLd = generateBreadcrumbJsonLd; exports.generateProductJsonLd = generateProductJsonLd; exports.getBusinessDay = getBusinessDay; exports.getDefaultImageUrl = getDefaultImageUrl; exports.getImageSrcSet = getImageSrcSet; exports.getImageUrl = getImageUrl; exports.getPaymentStatus = getPaymentStatus; exports.getSchemaAvailability = getSchemaAvailability; exports.getShippingLeadDate = getShippingLeadDate; exports.hasPriceBreaks = hasPriceBreaks; exports.hours = hours2; exports.idRef = idRef2; exports.isAddressDifferent = isAddressDifferent; exports.isServerRuntime = isServerRuntime; exports.millis = millis2; exports.millisOf = millisOf2; exports.minusMillis = minusMillis2; exports.minutes = minutes2; exports.nodeHead = nodeHead2; exports.normalizePath = normalizePath; exports.paginateOffset = paginateOffset; exports.pushTrackingData = pushTrackingData; exports.resolveGcTime = resolveGcTime; exports.resolveStock = resolveStock; exports.roundHalfAway = roundHalfAway; exports.sanitizeHtmlImages = sanitizeHtmlImages; exports.seconds = seconds2; exports.secondsOf = secondsOf2; exports.serializeCategoryFilters = serializeCategoryFilters; exports.serializeSearchParams = serializeSearchParams; exports.serializeTransforms = serializeTransforms; exports.tierBrowserGcTime = tierBrowserGcTime; exports.tierStaleTime = tierStaleTime; exports.toMillis = toMillis2; exports.trackAddToCart = trackAddToCart; exports.trackViewItem = trackViewItem; exports.transformShipToAddress = transformShipToAddress; exports.unwrap = unwrap; exports.unwrapOr = unwrapOr; exports.wholeSeconds = wholeSeconds2;
1252
+
1253
+
1254
+
1255
+
1256
+
1257
+
1258
+ exports.BLUR_DATA_URL = BLUR_DATA_URL; exports.BillingAddressInvoiceSchema = BillingAddressInvoiceSchema; exports.BillingAddressSchema = BillingAddressSchema; exports.CACHE_CONFIG = CACHE_CONFIG; exports.CONTIGUOUS_STATES = CONTIGUOUS_STATES; exports.ShippingAddressSchema = ShippingAddressSchema; exports.US_STATES = US_STATES; exports.US_STATES_FULL = US_STATES_FULL; exports.US_TERRITORIES = US_TERRITORIES; exports.VALIDATION_PATTERNS = VALIDATION_PATTERNS; exports.addMillis = addMillis2; exports.breadcrumbLd = breadcrumbLd2; exports.buildCheckoutPayload = buildCheckoutPayload; exports.buildImageLoader = buildImageLoader; exports.buildTrackingData = buildTrackingData; exports.categorySortBy = categorySortBy; exports.cleanMoney = cleanMoney; exports.cn = _chunk5UMFBGVAcjs.cn; exports.createImageConfig = createImageConfig; exports.days = days2; exports.derivePrice = derivePrice; exports.faqLd = faqLd2; exports.floorSeconds = floorSeconds2; exports.formatPrice = formatPrice; exports.generateBreadcrumbJsonLd = generateBreadcrumbJsonLd; exports.generateProductJsonLd = generateProductJsonLd; exports.getBusinessDay = getBusinessDay; exports.getDefaultImageUrl = getDefaultImageUrl; exports.getImageSrcSet = getImageSrcSet; exports.getImageUrl = getImageUrl; exports.getPaymentStatus = getPaymentStatus; exports.getSchemaAvailability = getSchemaAvailability; exports.getShippingLeadDate = getShippingLeadDate; exports.hasPriceBreaks = hasPriceBreaks; exports.hours = hours2; exports.idRef = idRef2; exports.isAddressDifferent = isAddressDifferent; exports.isServerRuntime = isServerRuntime; exports.lineHasQuantity = lineHasQuantity; exports.linePriceAt = linePriceAt; exports.millis = millis2; exports.millisOf = millisOf2; exports.minusMillis = minusMillis2; exports.minutes = minutes2; exports.nodeHead = nodeHead2; exports.normalizePath = normalizePath; exports.paginateOffset = paginateOffset; exports.priceQueryRuns = priceQueryRuns; exports.priceQueryUnit = priceQueryUnit; exports.pricingLoadingFrom = pricingLoadingFrom; exports.pricingSettledFrom = pricingSettledFrom; exports.pushTrackingData = pushTrackingData; exports.resolveGcTime = resolveGcTime; exports.resolveStock = resolveStock; exports.roundHalfAway = roundHalfAway; exports.sanitizeHtmlImages = sanitizeHtmlImages; exports.seconds = seconds2; exports.secondsOf = secondsOf2; exports.serializeCategoryFilters = serializeCategoryFilters; exports.serializeSearchParams = serializeSearchParams; exports.serializeTransforms = serializeTransforms; exports.tierBrowserGcTime = tierBrowserGcTime; exports.tierStaleTime = tierStaleTime; exports.toMillis = toMillis2; exports.trackAddToCart = trackAddToCart; exports.trackViewItem = trackViewItem; exports.transformShipToAddress = transformShipToAddress; exports.unwrap = unwrap; exports.unwrapOr = unwrapOr; exports.wholeSeconds = wholeSeconds2;
1221
1259
  //# sourceMappingURL=index.cjs.map