@zenky/storefront-vue 0.11.0 → 0.12.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 +70 -0
- package/dist/cart/index.js +5 -5
- package/dist/chunk-6HOKVW4M.js +134 -0
- package/dist/chunk-6HOKVW4M.js.map +1 -0
- package/dist/{chunk-KK645XNR.js → chunk-CQDOEP6T.js} +4 -127
- package/dist/chunk-CQDOEP6T.js.map +1 -0
- package/dist/{chunk-5KCBZJV3.js → chunk-IEHN2WNU.js} +6 -6
- package/dist/{chunk-5KCBZJV3.js.map → chunk-IEHN2WNU.js.map} +1 -1
- package/dist/chunk-JY3UJRMF.js +59 -0
- package/dist/chunk-JY3UJRMF.js.map +1 -0
- package/dist/{chunk-RURXGVWW.js → chunk-UJKWKD3W.js} +4 -56
- package/dist/chunk-UJKWKD3W.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -8
- package/dist/products/index.d.ts +2 -1
- package/dist/products/index.js +2 -1
- package/dist/seo/index.d.ts +44 -16
- package/dist/seo/index.js +338 -104
- package/dist/seo/index.js.map +1 -1
- package/dist/stores/index.js +2 -2
- package/dist/utils/index.js +2 -1
- package/docs/architecture.md +5 -3
- package/docs/consumer-setup.md +1 -1
- package/package.json +1 -1
- package/dist/chunk-KK645XNR.js.map +0 -1
- package/dist/chunk-RURXGVWW.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -206,6 +206,76 @@ All notable changes to this project are documented in this file. The format foll
|
|
|
206
206
|
`register()` returning `true` left the user believing they were signed in when they
|
|
207
207
|
weren't. This path now performs a real `login()` with the same password instead.
|
|
208
208
|
|
|
209
|
+
## 0.12.0 - 2026-10-19
|
|
210
|
+
|
|
211
|
+
Needs `@zenky/storefront-api` `^1.7.0` (peer dependency).
|
|
212
|
+
|
|
213
|
+
Changes the result of `buildOrganizationSchema`: one `@graph` instead of a single
|
|
214
|
+
`LocalBusiness` node, see the first entry under Changed.
|
|
215
|
+
|
|
216
|
+
### Added
|
|
217
|
+
|
|
218
|
+
- `buildLocationsSchema` (`/seo`) — `@graph` with the store's `Organization` and one node
|
|
219
|
+
per stock that has an address, for a page that lists the chain's locations. Each
|
|
220
|
+
location gets a page-independent `@id` (`{origin}/#location-{stockId}`, the fragment is
|
|
221
|
+
`locationAnchorId(stockId)` so a consumer can put the same id on the rendered card),
|
|
222
|
+
`parentOrganization`, a `PostalAddress` whose `streetAddress` drops the city already
|
|
223
|
+
carried by `addressLocality` (a leading "г {city}," or a trailing ", {city}"),
|
|
224
|
+
`addressCountry` from `store.settings.country`, `geo` plus a Yandex Maps `hasMap` link,
|
|
225
|
+
the first phone of the stock → city → store, the store logo as `image`, and an optional
|
|
226
|
+
`url` from `options.locationUrl(stock)`. Names lose zero-width characters and repeated
|
|
227
|
+
spaces.
|
|
228
|
+
- Location `@type` (`BUSINESS_TYPES`, `isBusinessType`, `BusinessType`): without
|
|
229
|
+
`options.businessType` it is guessed from the stock name — «ресторан», «кафе», «бар»,
|
|
230
|
+
«паб», «пиццерия», «кофейня», «бистро» and their English counterparts give
|
|
231
|
+
`Restaurant`, anything else `LocalBusiness`; an explicit type applies to every location
|
|
232
|
+
except the ones named as pickup/issue points («самовывоз», «выдача», "pick-up"), which
|
|
233
|
+
stay `LocalBusiness`.
|
|
234
|
+
- `buildBreadcrumbListSchema` (`/seo`) — `BreadcrumbList` from `BreadcrumbItem[]`, paths
|
|
235
|
+
resolved against the origin, empty labels dropped. The category and collection builders
|
|
236
|
+
use it.
|
|
237
|
+
- `buildOrganizationReference` (`/seo`) — a minimal `Organization` node with the same
|
|
238
|
+
`@id`, for `offers.seller` or any link to the store from a page that does not carry the
|
|
239
|
+
full graph.
|
|
240
|
+
- Schema id helpers (`/seo`): `organizationSchemaId`, `webSiteSchemaId`,
|
|
241
|
+
`locationSchemaId`, `locationAnchorId`, `productSchemaId`.
|
|
242
|
+
- `normalizeSchemaText` / `htmlToPlainText` (`/seo`) — plain text for structured data and
|
|
243
|
+
microdata: invisible characters removed, whitespace collapsed; the HTML variant keeps
|
|
244
|
+
words from adjacent blocks apart and decodes common entities.
|
|
245
|
+
- `buildProductOffer` (`/seo`) — the `Offer` / `AggregateOffer` of the product JSON-LD as a
|
|
246
|
+
typed record (`ProductOffer`), so microdata rendered next to it repeats exactly the same
|
|
247
|
+
price and availability.
|
|
248
|
+
- `getRequiredModifiersMinCost` (`/products`) — the cheapest mandatory modifier cost,
|
|
249
|
+
extracted from `useProductPricing` so the card price and the `Offer` price come from the
|
|
250
|
+
same code.
|
|
251
|
+
|
|
252
|
+
### Changed
|
|
253
|
+
|
|
254
|
+
- `buildOrganizationSchema(store, origin, options?)` returns one `@graph` —
|
|
255
|
+
`Organization` (`{origin}/#organization`: name, url, logo, phones, email, `sameAs`, city
|
|
256
|
+
address for a single-city store), `WebSite` (`publisher` → the organization, optional
|
|
257
|
+
`inLanguage`), and the location nodes described above. It used to return a single
|
|
258
|
+
`LocalBusiness` built from the first stock of the default city, so a chain of seven
|
|
259
|
+
locations was described as one of them; a store without an addressed stock now gets a
|
|
260
|
+
plain `Organization`. Consumers that read fields of the returned node must switch to
|
|
261
|
+
`@graph`.
|
|
262
|
+
- `buildProductSchema(product, currency, options?)` takes `{ url, stockId, seller }`:
|
|
263
|
+
`@id` (`{url}#product`), `url`, `offers.url`, `offers.seller`; the price resolves for
|
|
264
|
+
the given stock and includes the mandatory modifiers minimum, exactly like the product
|
|
265
|
+
card. `availability` is always `InStock`: a storefront renders only what the resolved
|
|
266
|
+
stock catalog sells and the backend checks sellability at checkout, while the old guess
|
|
267
|
+
from `variant.remainders` marked orderable products `OutOfStock`. Adds `sku`,
|
|
268
|
+
`category`, and `weight` (`QuantitativeValue`, `GRM`/`KGM`), strips HTML from
|
|
269
|
+
`description`, uses an `AggregateOffer` (`lowPrice`/`highPrice`) for several variants,
|
|
270
|
+
and omits `offers` when the price is zero instead of advertising the product as free.
|
|
271
|
+
Without options the output keeps its previous shape apart from the plain-text
|
|
272
|
+
description and the constant availability.
|
|
273
|
+
- Opening hours in location nodes: days with identical hours are grouped into one
|
|
274
|
+
`OpeningHoursSpecification` with a `dayOfWeek` array, split shifts produce one entry
|
|
275
|
+
each (the old builder kept only the first shift), round-the-clock days ("00:00-00:00",
|
|
276
|
+
«круглосуточно», "24/7", «24 часа») become 00:00–23:59, "24:00" closes at 23:59, and
|
|
277
|
+
malformed times are skipped.
|
|
278
|
+
|
|
209
279
|
## 0.11.0 - 2026-10-07
|
|
210
280
|
|
|
211
281
|
Needs `@zenky/storefront-api` `^1.7.0` (peer dependency).
|
package/dist/cart/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from '../chunk-
|
|
2
|
-
|
|
1
|
+
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from '../chunk-IEHN2WNU.js';
|
|
2
|
+
export { useCartCredentials } from '../chunk-QFKA2R6D.js';
|
|
3
3
|
export { getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getValidationErrors, logCartError } from '../chunk-TE42OCFK.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-544USTPB.js';
|
|
5
5
|
import '../chunk-TIQ7AJLY.js';
|
|
6
6
|
import '../chunk-FS2UNPTY.js';
|
|
7
7
|
import '../chunk-2Y6QTHXI.js';
|
|
8
|
-
|
|
9
|
-
import '../chunk-
|
|
8
|
+
import '../chunk-5QCUH3FF.js';
|
|
9
|
+
import '../chunk-4JCJHAL3.js';
|
|
10
10
|
import '../chunk-TXR76IDL.js';
|
|
11
11
|
import '../chunk-IOYYCA75.js';
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { UnitType } from '@zenky/storefront-api';
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
|
|
4
|
+
// src/products/formatWeight.ts
|
|
5
|
+
var UNIT_LABELS = {
|
|
6
|
+
[UnitType.Gram]: "\u0433",
|
|
7
|
+
[UnitType.Kilogram]: "\u043A\u0433",
|
|
8
|
+
[UnitType.Meter]: "\u043C",
|
|
9
|
+
[UnitType.Piece]: "\u0433"
|
|
10
|
+
};
|
|
11
|
+
function getWeightFromDimensions(variants) {
|
|
12
|
+
if (!variants?.length) return null;
|
|
13
|
+
const dimension = variants[0]?.dimensions?.find((d) => d.dimension === "weight");
|
|
14
|
+
return dimension?.value ?? null;
|
|
15
|
+
}
|
|
16
|
+
function getVariantWeight(variant) {
|
|
17
|
+
if (!variant) return null;
|
|
18
|
+
return variant.dimensions?.find((d) => d.dimension === "weight")?.value ?? null;
|
|
19
|
+
}
|
|
20
|
+
function getProductWeight(product) {
|
|
21
|
+
return product.weight ?? getWeightFromDimensions(product.variants) ?? null;
|
|
22
|
+
}
|
|
23
|
+
function toGrams(weight, unitType) {
|
|
24
|
+
if (!weight) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (unitType === UnitType.Kilogram) {
|
|
28
|
+
return weight * 1e3;
|
|
29
|
+
}
|
|
30
|
+
if (unitType === UnitType.Meter) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return weight;
|
|
34
|
+
}
|
|
35
|
+
function formatWeight(weight, unitType) {
|
|
36
|
+
if (!weight) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const label = UNIT_LABELS[unitType];
|
|
40
|
+
return `${weight} ${label}`;
|
|
41
|
+
}
|
|
42
|
+
function resolveVariantPrice(variant, stockId) {
|
|
43
|
+
if (variant.prices?.length) {
|
|
44
|
+
if (stockId) {
|
|
45
|
+
const stockEntry = variant.prices.find((p) => p.stock_id === stockId);
|
|
46
|
+
if (stockEntry) {
|
|
47
|
+
return {
|
|
48
|
+
price: stockEntry.price,
|
|
49
|
+
originalPrice: stockEntry.original_price,
|
|
50
|
+
discount: stockEntry.discount
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const globalEntry = variant.prices.find((p) => p.stock_id === null);
|
|
55
|
+
if (globalEntry) {
|
|
56
|
+
return {
|
|
57
|
+
price: globalEntry.price,
|
|
58
|
+
originalPrice: globalEntry.original_price,
|
|
59
|
+
discount: globalEntry.discount
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
price: variant.price,
|
|
65
|
+
originalPrice: variant.original_price ?? null,
|
|
66
|
+
discount: variant.discount ?? null
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function getRequiredModifiersMinCost(product) {
|
|
70
|
+
let total = 0;
|
|
71
|
+
for (const groupEntry of product.modifiers_groups ?? []) {
|
|
72
|
+
const group = groupEntry.group;
|
|
73
|
+
for (const modEntry of group.modifiers) {
|
|
74
|
+
if (modEntry.is_required && modEntry.modifier.price) {
|
|
75
|
+
total += modEntry.modifier.price * Math.max(modEntry.min_quantity ?? 0, 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (groupEntry.is_required && group.modifiers.length && !group.modifiers.some((m) => m.is_required)) {
|
|
79
|
+
const cheapest = group.modifiers.reduce(
|
|
80
|
+
(min, m) => (m.modifier.price ?? 0) < (min.modifier.price ?? 0) ? m : min
|
|
81
|
+
);
|
|
82
|
+
total += (cheapest.modifier.price ?? 0) * Math.max(cheapest.min_quantity ?? 0, 1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return total;
|
|
86
|
+
}
|
|
87
|
+
function useProductPricing(product, stockId) {
|
|
88
|
+
const variants = computed(() => product.value.variants ?? []);
|
|
89
|
+
const currentStockId = computed(() => stockId?.value ?? null);
|
|
90
|
+
const resolvedPrices = computed(
|
|
91
|
+
() => variants.value.map((v) => resolveVariantPrice(v, currentStockId.value))
|
|
92
|
+
);
|
|
93
|
+
const minRequiredModifiersCost = computed(
|
|
94
|
+
() => getRequiredModifiersMinCost(product.value)
|
|
95
|
+
);
|
|
96
|
+
const displayPrice = computed(() => {
|
|
97
|
+
if (!resolvedPrices.value.length) {
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
return Math.min(...resolvedPrices.value.map((r) => r.price)) + minRequiredModifiersCost.value;
|
|
101
|
+
});
|
|
102
|
+
const originalDisplayPrice = computed(() => {
|
|
103
|
+
if (!resolvedPrices.value.length) return null;
|
|
104
|
+
const cheapest = resolvedPrices.value.reduce((min, r) => r.price < min.price ? r : min);
|
|
105
|
+
let originalVariantPrice = null;
|
|
106
|
+
if (cheapest.originalPrice && cheapest.originalPrice > cheapest.price) {
|
|
107
|
+
originalVariantPrice = cheapest.originalPrice;
|
|
108
|
+
} else if (cheapest.discount && cheapest.discount.difference > 0) {
|
|
109
|
+
originalVariantPrice = cheapest.price + cheapest.discount.difference;
|
|
110
|
+
}
|
|
111
|
+
if (!originalVariantPrice) return null;
|
|
112
|
+
return originalVariantPrice + minRequiredModifiersCost.value;
|
|
113
|
+
});
|
|
114
|
+
const hasDifferentPrices = computed(() => {
|
|
115
|
+
if (resolvedPrices.value.length <= 1) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const prices = new Set(resolvedPrices.value.map((r) => r.price));
|
|
119
|
+
return prices.size > 1;
|
|
120
|
+
});
|
|
121
|
+
const needsSelection = computed(() => {
|
|
122
|
+
if (variants.value.length > 1) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
const mods = product.value.modifiers;
|
|
126
|
+
const groups = product.value.modifiers_groups;
|
|
127
|
+
return Array.isArray(mods) && mods.length > 0 || Array.isArray(groups) && groups.length > 0;
|
|
128
|
+
});
|
|
129
|
+
return { displayPrice, originalDisplayPrice, hasDifferentPrices, needsSelection };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { formatWeight, getProductWeight, getRequiredModifiersMinCost, getVariantWeight, resolveVariantPrice, toGrams, useProductPricing };
|
|
133
|
+
//# sourceMappingURL=chunk-6HOKVW4M.js.map
|
|
134
|
+
//# sourceMappingURL=chunk-6HOKVW4M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/products/formatWeight.ts","../src/products/useProductPricing.ts"],"names":[],"mappings":";;;;AAIA,IAAM,WAAA,GAAwC;AAAA,EAC1C,CAAC,QAAA,CAAS,IAAI,GAAG,QAAA;AAAA,EACjB,CAAC,QAAA,CAAS,QAAQ,GAAG,cAAA;AAAA,EACrB,CAAC,QAAA,CAAS,KAAK,GAAG,QAAA;AAAA,EAClB,CAAC,QAAA,CAAS,KAAK,GAAG;AACtB,CAAA;AAEA,SAAS,wBAAwB,QAAA,EAAuD;AACpF,EAAA,IAAI,CAAC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AAO,OAAO,IAAA,GAAO,CAAA;AAAA,EACzB,CAAC,CAAA;AAED,EAAA,MAAM,cAAA,GAAiB,SAAkB,MAAM;AAC3C,IAAA,IAAI,QAAA,CAAS,KAAA,CAAM,MAAA,GAAS,CAAA,EAAG;AAC3B,MAAA,OAAO,IAAA;AAAA,IACX;AAEA,IAAA,MAAM,IAAA,GAAO,QAAQ,KAAA,CAAM,SAAA;AAC3B,IAAA,MAAM,MAAA,GAAS,QAAQ,KAAA,CAAM,gBAAA;AAE7B,IAAA,OACK,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,IAAK,IAAA,CAAK,MAAA,GAAS,CAAA,IAAO,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,IAAK,MAAA,CAAO,MAAA,GAAS,CAAA;AAAA,EAE9F,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,YAAA,EAAc,oBAAA,EAAsB,kBAAA,EAAoB,cAAA,EAAe;AACpF","file":"chunk-6HOKVW4M.js","sourcesContent":["import { UnitType } from '@zenky/storefront-api'\n\nimport type { Product, ProductVariant } from '@zenky/storefront-api'\n\nconst UNIT_LABELS: Record<UnitType, string> = {\n [UnitType.Gram]: 'г',\n [UnitType.Kilogram]: 'кг',\n [UnitType.Meter]: 'м',\n [UnitType.Piece]: 'г',\n} as const\n\nfunction getWeightFromDimensions(variants: ProductVariant[] | undefined): number | null {\n if (!variants?.length) return null\n\n const dimension = variants[0]?.dimensions?.find((d) => d.dimension === 'weight')\n\n return dimension?.value ?? null\n}\n\nexport function getVariantWeight(variant: ProductVariant | null | undefined): number | null {\n if (!variant) return null\n\n return variant.dimensions?.find((d) => d.dimension === 'weight')?.value ?? null\n}\n\nexport function getProductWeight(product: Product): number | null {\n return product.weight ?? getWeightFromDimensions(product.variants) ?? null\n}\n\nexport function toGrams(weight: number | null, unitType: UnitType): number | null {\n if (!weight) {\n return null\n }\n\n if (unitType === UnitType.Kilogram) {\n return weight * 1000\n }\n\n if (unitType === UnitType.Meter) {\n return null\n }\n\n return weight\n}\n\nexport function formatWeight(weight: number | null, unitType: UnitType): string | null {\n if (!weight) {\n return null\n }\n\n const label = UNIT_LABELS[unitType]\n\n return `${weight} ${label}`\n}\n","import { computed, type ComputedRef } from 'vue'\n\nimport type { Discount, Product, ProductVariant } from '@zenky/storefront-api'\n\nexport interface ResolvedPrice {\n price: number\n originalPrice: number | null\n discount: Discount | null\n}\n\n/**\n * Resolves a variant's price, accounting for stock.\n * Priority: prices[stockId] → prices[null] → top-level price.\n */\nexport function resolveVariantPrice(\n variant: ProductVariant,\n stockId?: string | null\n): ResolvedPrice {\n if (variant.prices?.length) {\n // 1. Exact match by stock\n if (stockId) {\n const stockEntry = variant.prices.find((p) => p.stock_id === stockId)\n\n if (stockEntry) {\n return {\n price: stockEntry.price,\n originalPrice: stockEntry.original_price,\n discount: stockEntry.discount,\n }\n }\n }\n\n // 2. Global price (stock_id = null)\n const globalEntry = variant.prices.find((p) => p.stock_id === null)\n\n if (globalEntry) {\n return {\n price: globalEntry.price,\n originalPrice: globalEntry.original_price,\n discount: globalEntry.discount,\n }\n }\n }\n\n // 3. Fallback — the variant's top-level fields\n return {\n price: variant.price,\n originalPrice: variant.original_price ?? null,\n discount: variant.discount ?? null,\n }\n}\n\n// Minimum required modifier cost that's always added to the price:\n// 1. modEntry.is_required — the modifier is always sent to the API (can't be removed)\n// 2. groupEntry.is_required — the user must pick at least one from the group →\n// add the cheapest price in the group (if no is_required modifier already covers it)\nexport function getRequiredModifiersMinCost(product: Product): number {\n let total = 0\n\n for (const groupEntry of product.modifiers_groups ?? []) {\n const group = groupEntry.group\n\n for (const modEntry of group.modifiers) {\n if (modEntry.is_required && modEntry.modifier.price) {\n total += modEntry.modifier.price * Math.max(modEntry.min_quantity ?? 0, 1)\n }\n }\n\n if (\n groupEntry.is_required &&\n group.modifiers.length &&\n !group.modifiers.some((m) => m.is_required)\n ) {\n const cheapest = group.modifiers.reduce((min, m) =>\n (m.modifier.price ?? 0) < (min.modifier.price ?? 0) ? m : min\n )\n total += (cheapest.modifier.price ?? 0) * Math.max(cheapest.min_quantity ?? 0, 1)\n }\n }\n\n return total\n}\n\nexport function useProductPricing(\n product: ComputedRef<Product>,\n stockId?: ComputedRef<string | null | undefined>\n): {\n displayPrice: ComputedRef<number>\n originalDisplayPrice: ComputedRef<number | null>\n hasDifferentPrices: ComputedRef<boolean>\n needsSelection: ComputedRef<boolean>\n} {\n const variants = computed(() => product.value.variants ?? [])\n const currentStockId = computed(() => stockId?.value ?? null)\n\n const resolvedPrices = computed(() =>\n variants.value.map((v) => resolveVariantPrice(v, currentStockId.value))\n )\n\n const minRequiredModifiersCost = computed<number>(() =>\n getRequiredModifiersMinCost(product.value)\n )\n\n const displayPrice = computed<number>(() => {\n if (!resolvedPrices.value.length) {\n return 0\n }\n\n return (\n Math.min(...resolvedPrices.value.map((r) => r.price)) + minRequiredModifiersCost.value\n )\n })\n\n // Price without the discount: original_price of the cheapest variant + required modifiers.\n // null if there is no discount.\n // original_price can be null even when a discount exists — then compute it via discount.difference.\n const originalDisplayPrice = computed<number | null>(() => {\n if (!resolvedPrices.value.length) return null\n\n // Find the variant with the minimum price (the same one that determines displayPrice)\n const cheapest = resolvedPrices.value.reduce((min, r) => (r.price < min.price ? r : min))\n\n // Priority: original_price, then compute via discount\n let originalVariantPrice: number | null = null\n\n if (cheapest.originalPrice && cheapest.originalPrice > cheapest.price) {\n originalVariantPrice = cheapest.originalPrice\n } else if (cheapest.discount && cheapest.discount.difference > 0) {\n originalVariantPrice = cheapest.price + cheapest.discount.difference\n }\n\n if (!originalVariantPrice) return null\n\n return originalVariantPrice + minRequiredModifiersCost.value\n })\n\n const hasDifferentPrices = computed<boolean>(() => {\n if (resolvedPrices.value.length <= 1) {\n return false\n }\n\n const prices = new Set(resolvedPrices.value.map((r) => r.price))\n\n return prices.size > 1\n })\n\n const needsSelection = computed<boolean>(() => {\n if (variants.value.length > 1) {\n return true\n }\n\n const mods = product.value.modifiers\n const groups = product.value.modifiers_groups\n\n return (\n (Array.isArray(mods) && mods.length > 0) || (Array.isArray(groups) && groups.length > 0)\n )\n })\n\n return { displayPrice, originalDisplayPrice, hasDifferentPrices, needsSelection }\n}\n"]}
|
|
@@ -1,48 +1,11 @@
|
|
|
1
|
+
import { resolveVariantPrice } from './chunk-6HOKVW4M.js';
|
|
1
2
|
import { createDebounce } from './chunk-XUGXLJZB.js';
|
|
2
3
|
import { createRuntimeState } from './chunk-5QCUH3FF.js';
|
|
3
4
|
import { useCatalogStore } from './chunk-4JCJHAL3.js';
|
|
4
5
|
import { useRuntime, useAuthStore, useCartStore } from './chunk-TXR76IDL.js';
|
|
5
6
|
import { useStoreProfileStore } from './chunk-IOYYCA75.js';
|
|
6
|
-
import { UnitType } from '@zenky/storefront-api';
|
|
7
7
|
import { computed, ref, watch } from 'vue';
|
|
8
8
|
|
|
9
|
-
var UNIT_LABELS = {
|
|
10
|
-
[UnitType.Gram]: "\u0433",
|
|
11
|
-
[UnitType.Kilogram]: "\u043A\u0433",
|
|
12
|
-
[UnitType.Meter]: "\u043C",
|
|
13
|
-
[UnitType.Piece]: "\u0433"
|
|
14
|
-
};
|
|
15
|
-
function getWeightFromDimensions(variants) {
|
|
16
|
-
if (!variants?.length) return null;
|
|
17
|
-
const dimension = variants[0]?.dimensions?.find((d) => d.dimension === "weight");
|
|
18
|
-
return dimension?.value ?? null;
|
|
19
|
-
}
|
|
20
|
-
function getVariantWeight(variant) {
|
|
21
|
-
if (!variant) return null;
|
|
22
|
-
return variant.dimensions?.find((d) => d.dimension === "weight")?.value ?? null;
|
|
23
|
-
}
|
|
24
|
-
function getProductWeight(product) {
|
|
25
|
-
return product.weight ?? getWeightFromDimensions(product.variants) ?? null;
|
|
26
|
-
}
|
|
27
|
-
function toGrams(weight, unitType) {
|
|
28
|
-
if (!weight) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
if (unitType === UnitType.Kilogram) {
|
|
32
|
-
return weight * 1e3;
|
|
33
|
-
}
|
|
34
|
-
if (unitType === UnitType.Meter) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return weight;
|
|
38
|
-
}
|
|
39
|
-
function formatWeight(weight, unitType) {
|
|
40
|
-
if (!weight) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const label = UNIT_LABELS[unitType];
|
|
44
|
-
return `${weight} ${label}`;
|
|
45
|
-
}
|
|
46
9
|
function useProductsByCategory(products, categories) {
|
|
47
10
|
const grouped = computed(() => {
|
|
48
11
|
if (!categories.value.length || !products.value.length) {
|
|
@@ -105,92 +68,6 @@ function useProductVariantModifiers(variant) {
|
|
|
105
68
|
});
|
|
106
69
|
return { modifiersModel, selectedModifiersHash, hasAnyModifier };
|
|
107
70
|
}
|
|
108
|
-
function resolveVariantPrice(variant, stockId) {
|
|
109
|
-
if (variant.prices?.length) {
|
|
110
|
-
if (stockId) {
|
|
111
|
-
const stockEntry = variant.prices.find((p) => p.stock_id === stockId);
|
|
112
|
-
if (stockEntry) {
|
|
113
|
-
return {
|
|
114
|
-
price: stockEntry.price,
|
|
115
|
-
originalPrice: stockEntry.original_price,
|
|
116
|
-
discount: stockEntry.discount
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const globalEntry = variant.prices.find((p) => p.stock_id === null);
|
|
121
|
-
if (globalEntry) {
|
|
122
|
-
return {
|
|
123
|
-
price: globalEntry.price,
|
|
124
|
-
originalPrice: globalEntry.original_price,
|
|
125
|
-
discount: globalEntry.discount
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
price: variant.price,
|
|
131
|
-
originalPrice: variant.original_price ?? null,
|
|
132
|
-
discount: variant.discount ?? null
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function useProductPricing(product, stockId) {
|
|
136
|
-
const variants = computed(() => product.value.variants ?? []);
|
|
137
|
-
const currentStockId = computed(() => stockId?.value ?? null);
|
|
138
|
-
const resolvedPrices = computed(
|
|
139
|
-
() => variants.value.map((v) => resolveVariantPrice(v, currentStockId.value))
|
|
140
|
-
);
|
|
141
|
-
const minRequiredModifiersCost = computed(() => {
|
|
142
|
-
let total = 0;
|
|
143
|
-
for (const groupEntry of product.value.modifiers_groups ?? []) {
|
|
144
|
-
const group = groupEntry.group;
|
|
145
|
-
for (const modEntry of group.modifiers) {
|
|
146
|
-
if (modEntry.is_required && modEntry.modifier.price) {
|
|
147
|
-
total += modEntry.modifier.price * Math.max(modEntry.min_quantity ?? 0, 1);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (groupEntry.is_required && group.modifiers.length && !group.modifiers.some((m) => m.is_required)) {
|
|
151
|
-
const cheapest = group.modifiers.reduce(
|
|
152
|
-
(min, m) => (m.modifier.price ?? 0) < (min.modifier.price ?? 0) ? m : min
|
|
153
|
-
);
|
|
154
|
-
total += (cheapest.modifier.price ?? 0) * Math.max(cheapest.min_quantity ?? 0, 1);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return total;
|
|
158
|
-
});
|
|
159
|
-
const displayPrice = computed(() => {
|
|
160
|
-
if (!resolvedPrices.value.length) {
|
|
161
|
-
return 0;
|
|
162
|
-
}
|
|
163
|
-
return Math.min(...resolvedPrices.value.map((r) => r.price)) + minRequiredModifiersCost.value;
|
|
164
|
-
});
|
|
165
|
-
const originalDisplayPrice = computed(() => {
|
|
166
|
-
if (!resolvedPrices.value.length) return null;
|
|
167
|
-
const cheapest = resolvedPrices.value.reduce((min, r) => r.price < min.price ? r : min);
|
|
168
|
-
let originalVariantPrice = null;
|
|
169
|
-
if (cheapest.originalPrice && cheapest.originalPrice > cheapest.price) {
|
|
170
|
-
originalVariantPrice = cheapest.originalPrice;
|
|
171
|
-
} else if (cheapest.discount && cheapest.discount.difference > 0) {
|
|
172
|
-
originalVariantPrice = cheapest.price + cheapest.discount.difference;
|
|
173
|
-
}
|
|
174
|
-
if (!originalVariantPrice) return null;
|
|
175
|
-
return originalVariantPrice + minRequiredModifiersCost.value;
|
|
176
|
-
});
|
|
177
|
-
const hasDifferentPrices = computed(() => {
|
|
178
|
-
if (resolvedPrices.value.length <= 1) {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
const prices = new Set(resolvedPrices.value.map((r) => r.price));
|
|
182
|
-
return prices.size > 1;
|
|
183
|
-
});
|
|
184
|
-
const needsSelection = computed(() => {
|
|
185
|
-
if (variants.value.length > 1) {
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
const mods = product.value.modifiers;
|
|
189
|
-
const groups = product.value.modifiers_groups;
|
|
190
|
-
return Array.isArray(mods) && mods.length > 0 || Array.isArray(groups) && groups.length > 0;
|
|
191
|
-
});
|
|
192
|
-
return { displayPrice, originalDisplayPrice, hasDifferentPrices, needsSelection };
|
|
193
|
-
}
|
|
194
71
|
function getDefaultOptionsModel(product) {
|
|
195
72
|
const model = {};
|
|
196
73
|
if (!product.variants?.length) {
|
|
@@ -787,6 +664,6 @@ function filterProductBadges(badges, visibility) {
|
|
|
787
664
|
);
|
|
788
665
|
}
|
|
789
666
|
|
|
790
|
-
export { canAddDirectly, filterProductBadges, findProductInCatalog,
|
|
791
|
-
//# sourceMappingURL=chunk-
|
|
792
|
-
//# sourceMappingURL=chunk-
|
|
667
|
+
export { canAddDirectly, filterProductBadges, findProductInCatalog, getProductBadgeAccent, getProductBadgeLayout, toProductBadgeViews, usePriceRecalculation, useProductDetail, useProductList, useProductVariant, useProductVariantModifiers, useProductVariantSelector, useProductsByCategory, useRelatedProducts };
|
|
668
|
+
//# sourceMappingURL=chunk-CQDOEP6T.js.map
|
|
669
|
+
//# sourceMappingURL=chunk-CQDOEP6T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/products/useProductsByCategory.ts","../src/products/useProductVariantModifiers.ts","../src/products/useProductVariant.ts","../src/products/usePriceRecalculation.ts","../src/products/useProductVariantSelector.ts","../src/products/useRelatedProducts.ts","../src/products/findProductInCatalog.ts","../src/products/useProductDetail.ts","../src/products/useProductList.ts","../src/utils/color.ts","../src/products/badges.ts"],"names":["computed","ref","watch","channel"],"mappings":";;;;;;;;AAYO,SAAS,qBAAA,CACZ,UACA,UAAA,EAGF;AACE,EAAA,MAAM,OAAA,GAAU,SAAiC,MAAM;AACnD,IAAA,IAAI,CAAC,UAAA,CAAW,KAAA,CAAM,UAAU,CAAC,QAAA,CAAS,MAAM,MAAA,EAAQ;AACpD,MAAA,OAAO,EAAC;AAAA,IACZ;AAEA,IAAA,MAAM,kBAAA,uBAAyB,GAAA,EAAuB;AAEtD,IAAA,KAAA,MAAW,OAAA,IAAW,SAAS,KAAA,EAAO;AAClC,MAAA,KAAA,MAAW,QAAA,IAAY,QAAQ,UAAA,EAAY;AACvC,QAAA,MAAM,WAAW,kBAAA,CAAmB,GAAA,CAAI,QAAA,CAAS,EAAE,KAAK,EAAC;AACzD,QAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AACrB,QAAA,kBAAA,CAAmB,GAAA,CAAI,QAAA,CAAS,EAAA,EAAI,QAAQ,CAAA;AAAA,MAChD;AAAA,IACJ;AAEA,IAAA,OAAO,iBAAA,CAAkB,UAAA,CAAW,KAAK,CAAA,CACpC,OAAO,CAAC,QAAA,KAAa,kBAAA,CAAmB,GAAA,CAAI,SAAS,EAAE,CAAC,CAAA,CACxD,GAAA,CAAI,CAAC,QAAA,MAAc;AAAA,MAChB,IAAI,QAAA,CAAS,EAAA;AAAA,MACb,SAAS,QAAA,CAAS,QAAA;AAAA,MAClB,MAAM,QAAA,CAAS,IAAA;AAAA,MACf,MAAM,QAAA,CAAS,IAAA;AAAA,MACf,UAAU,kBAAA,CAAmB,GAAA,CAAI,QAAA,CAAS,EAAE,KAAK;AAAC,KACtD,CAAE,CAAA;AAAA,EACV,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAA,EAAQ;AACrB;AAEA,SAAS,kBAAkB,UAAA,EAAgD;AACvE,EAAA,MAAM,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A,EAChE;AAEA,EAAA,OAAO,SAAA,CAAU,MAAA,CAAO,IAAI,CAAA,IAAK,SAAA,CAAU,OAAO,UAAU,CAAA,GAAI,MAAA,CAAO,IAAA,GAAO,MAAA,CAAO,UAAA;AACzF;AAQO,SAAS,sBAAsB,MAAA,EAAgD;AAClF,EAAA,MAAM,IAAA,GAAO,WAAW,MAAM,CAAA;AAC9B,EAAA,MAAM,KAAK,aAAA,CAAc,KAAA,EAAO,IAAI,CAAA,IAAK,yBAAyB,KAAA,GAAQ,KAAA;AAE1E,EAAA,OAAO;AAAA,IACH,IAAA;AAAA,IACA,OAAA,EAAS,cAAA;AAAA,MACL,SAAA,CAAU,MAAM,SAAA,EAAW;AAAA,QACvB,cAAA,EAAgB,yBAAA;AAAA,QAChB,YAAA,EAAc;AAAA,OACjB,CAAA;AAAA,MACD,EAAA;AAAA,MACA;AAAA,KACJ;AAAA,IACA,EAAA;AAAA,IACA,IAAA,EAAM,cAAA,CAAe,IAAA,EAAM,KAAA,EAAO,iBAAiB,CAAA;AAAA,IACnD,KAAA,EAAO,MAAA,CAAO,IAAA,EAAM,WAAW;AAAA,GACnC;AACJ;AAEO,SAAS,mBAAA,CACZ,QACA,UAAA,EACkB;AAClB,EAAA,OAAO,MAAA,CAAO,MAAA;AAAA,IAAO,CAAC,UAClB,qBAAA,CAAsB,KAAK,MAAM,cAAA,GAC3B,UAAA,CAAW,aACX,UAAA,CAAW;AAAA,GACrB;AACJ","file":"chunk-CQDOEP6T.js","sourcesContent":["import { computed, type ComputedRef } from 'vue'\n\nimport type { NestedCategory, Product } from '@zenky/storefront-api'\n\nexport interface CategoryWithProducts {\n id: string\n shortId: string\n slug: string | null\n name: string | null\n products: Product[]\n}\n\nexport function useProductsByCategory(\n products: ComputedRef<Product[]>,\n categories: ComputedRef<NestedCategory[]>\n): {\n grouped: ComputedRef<CategoryWithProducts[]>\n} {\n const grouped = computed<CategoryWithProducts[]>(() => {\n if (!categories.value.length || !products.value.length) {\n return []\n }\n\n const productsByCategory = new Map<string, Product[]>()\n\n for (const product of products.value) {\n for (const category of product.categories) {\n const existing = productsByCategory.get(category.id) ?? []\n existing.push(product)\n productsByCategory.set(category.id, existing)\n }\n }\n\n return flattenCategories(categories.value)\n .filter((category) => productsByCategory.has(category.id))\n .map((category) => ({\n id: category.id,\n shortId: category.short_id,\n slug: category.slug,\n name: category.name,\n products: productsByCategory.get(category.id) ?? [],\n }))\n })\n\n return { grouped }\n}\n\nfunction flattenCategories(categories: NestedCategory[]): NestedCategory[] {\n const result: NestedCategory[] = []\n\n for (const category of categories) {\n result.push(category)\n\n if (category.children?.length) {\n result.push(...flattenCategories(category.children))\n }\n }\n\n return result\n}\n","import { computed, ref, watch, type ComputedRef, type Ref } from 'vue'\n\nimport type { ProductModifiersRequest, ProductVariant } from '@zenky/storefront-api'\n\nfunction getInitialModifiersModel(variant: ProductVariant | null): ProductModifiersRequest[] {\n if (!variant?.default_modifiers?.modifiers.length) {\n return []\n }\n\n return variant.default_modifiers.modifiers.map((modifier) => ({\n modifier_id: modifier.modifier_id,\n modifiers_group_id: modifier.modifiers_group_id,\n quantity: modifier.quantity,\n }))\n}\n\nexport function useProductVariantModifiers(variant: ComputedRef<ProductVariant | null>): {\n modifiersModel: Ref<ProductModifiersRequest[]>\n selectedModifiersHash: Ref<string | null>\n hasAnyModifier: ComputedRef<boolean>\n} {\n const modifiersModel: Ref<ProductModifiersRequest[]> = ref([\n ...getInitialModifiersModel(variant.value),\n ])\n const selectedModifiersHash: Ref<string | null> = ref(null)\n const hasAnyModifier = computed<boolean>(() => modifiersModel.value.length > 0)\n\n watch(variant, () => {\n const newDefaults = getInitialModifiersModel(variant.value)\n\n // Keep standalone modifiers (no group) — they belong to the product, not the variant.\n // Group modifiers reset to the new variant's defaults.\n const userStandalone = modifiersModel.value.filter((m) => !m.modifiers_group_id)\n const defaultStandaloneIds = new Set(\n newDefaults.filter((d) => !d.modifiers_group_id).map((d) => d.modifier_id)\n )\n const preservedStandalone = userStandalone.filter(\n (m) => !defaultStandaloneIds.has(m.modifier_id)\n )\n\n modifiersModel.value = [...preservedStandalone, ...newDefaults]\n })\n\n return { modifiersModel, selectedModifiersHash, hasAnyModifier }\n}\n","import { computed, ref, watch, type ComputedRef, type Ref } from 'vue'\n\nimport type {\n Product,\n ProductVariant,\n ProductVariantOption,\n ProductVariantOptionValue,\n} from '@zenky/storefront-api'\n\nexport interface ProductVariantOptionListItem {\n id: string\n name: string | null\n values: ProductVariantOptionValue[]\n}\n\nfunction getDefaultOptionsModel(product: Product): Record<string, string> {\n const model: Record<string, string> = {}\n\n if (!product.variants?.length) {\n return model\n }\n\n const firstVariantOptions = product.variants.find(\n (variant: ProductVariant) => variant.options?.length\n )?.options\n\n if (!firstVariantOptions) {\n return model\n }\n\n firstVariantOptions.forEach((option: ProductVariantOption) => {\n model[option.id] = option.value.id\n })\n\n return model\n}\n\nfunction getProductVariantOptionsList(product: Product): ProductVariantOptionListItem[] {\n const list: ProductVariantOptionListItem[] = []\n\n if (!product.variants?.length) {\n return list\n }\n\n product.variants.forEach((variant: ProductVariant) => {\n if (!variant.options?.length) {\n return\n }\n\n variant.options.forEach((option: ProductVariantOption) => {\n let index = list.findIndex(\n (item: ProductVariantOptionListItem) => item.id === option.id\n )\n\n if (index === -1) {\n index = list.push({\n id: option.id,\n name: option.name,\n values: [],\n })\n\n index--\n }\n\n const valueIndex = list[index]!.values.findIndex(\n (value: ProductVariantOptionValue) => value.id === option.value.id\n )\n\n if (valueIndex === -1) {\n list[index]!.values.push(option.value)\n }\n })\n })\n\n return list\n}\n\nfunction computeDisabledValues(\n variants: ProductVariant[],\n optionsList: ProductVariantOptionListItem[],\n optionsModel: Record<string, string>\n): Record<string, Set<string>> {\n if (!variants.length) return {}\n\n const result: Record<string, Set<string>> = {}\n\n for (const option of optionsList) {\n const disabled = new Set<string>()\n\n for (const value of option.values) {\n const hasMatch = variants.some((variant) => {\n if (!variant.options?.length) return false\n\n const variantMap: Record<string, string> = {}\n for (const opt of variant.options) {\n variantMap[opt.id] = opt.value.id\n }\n\n // Variant must have this specific value for this option\n if (variantMap[option.id] !== value.id) return false\n\n // Variant must match all OTHER currently-selected values\n for (const [otherId, selectedId] of Object.entries(optionsModel)) {\n if (otherId === option.id) continue\n if (variantMap[otherId] !== selectedId) return false\n }\n\n return true\n })\n\n if (!hasMatch) {\n disabled.add(value.id)\n }\n }\n\n result[option.id] = disabled\n }\n\n return result\n}\n\nexport function useProductVariant(product: ComputedRef<Product>): {\n optionsModel: Ref<Record<string, string>>\n optionsList: Ref<ProductVariantOptionListItem[]>\n selectedVariant: ComputedRef<ProductVariant | null>\n disabledValues: ComputedRef<Record<string, Set<string>>>\n} {\n const optionsModel = ref({ ...getDefaultOptionsModel(product.value) })\n const optionsList = ref([...getProductVariantOptionsList(product.value)])\n\n const selectedVariant = computed<ProductVariant | null>(() => {\n if (!product.value.variants?.length) {\n return null\n } else if (product.value.variants.length === 1 || !Object.keys(optionsModel.value).length) {\n return product.value.variants[0] ?? null\n }\n\n return (\n product.value.variants.find((variant: ProductVariant) => {\n if (!variant.options?.length) {\n return false\n }\n\n return variant.options.every(\n (option: ProductVariantOption) =>\n optionsModel.value[option.id] === option.value.id\n )\n }) ?? null\n )\n })\n\n const disabledValues = computed<Record<string, Set<string>>>(() =>\n computeDisabledValues(product.value.variants ?? [], optionsList.value, optionsModel.value)\n )\n\n watch(product, () => {\n optionsModel.value = { ...getDefaultOptionsModel(product.value) }\n optionsList.value = [...getProductVariantOptionsList(product.value)]\n })\n\n return { optionsModel, optionsList, selectedVariant, disabledValues }\n}\n","import { computed, ref, watch, type ComputedRef, type Ref } from 'vue'\n\nimport type { Product, ProductModifiersRequest, ProductVariant } from '@zenky/storefront-api'\n\nimport { useRuntime } from '../ports/runtime'\nimport { useStoreProfileStore } from '../stores/store-profile'\nimport { createDebounce } from '../utils/debounce'\nimport { resolveVariantPrice } from './useProductPricing'\n\ninterface PriceRecalculationOptions {\n product: ComputedRef<Product>\n selectedVariant: ComputedRef<ProductVariant | null>\n modifiersModel: Ref<ProductModifiersRequest[]>\n requiredModifiersGroupIsMissing: ComputedRef<boolean>\n selectedModifiersHash: Ref<string | null>\n}\n\nexport function usePriceRecalculation({\n product,\n selectedVariant,\n modifiersModel,\n requiredModifiersGroupIsMissing,\n selectedModifiersHash,\n}: PriceRecalculationOptions): {\n price: ComputedRef<number>\n originalPrice: ComputedRef<number | null>\n priceWasModified: ComputedRef<boolean>\n priceIsRecalculating: Ref<boolean>\n} {\n // Get the SDK from the runtime (DI port), not from the Nuxt-specific useStorefrontApi().\n const sdk = useRuntime().sdk\n const profileStore = useStoreProfileStore()\n\n // -------------------------------------------------------------------------\n // Computed: stock-aware variant pricing\n // -------------------------------------------------------------------------\n\n const currentStockId = computed(() => profileStore.stock?.id ?? null)\n\n const resolvedVariant = computed(() => {\n if (!selectedVariant.value) return null\n\n return resolveVariantPrice(selectedVariant.value, currentStockId.value)\n })\n\n // -------------------------------------------------------------------------\n // Computed: modifier price helpers\n // -------------------------------------------------------------------------\n\n const modifierPriceMap = computed<Map<string, number>>(() => {\n const map = new Map<string, number>()\n\n for (const item of product.value.modifiers ?? []) {\n if (item.modifier.price) {\n map.set(item.modifier.id, item.modifier.price)\n }\n }\n\n for (const group of product.value.modifiers_groups ?? []) {\n for (const item of group.group.modifiers ?? []) {\n if (item.modifier.price) {\n map.set(item.modifier.id, item.modifier.price)\n }\n }\n }\n\n return map\n })\n\n // Sum of selected modifier prices (includes defaults — they're already in modifiersModel)\n const selectedModifierTotal = computed<number>(() =>\n modifiersModel.value.reduce(\n (sum, req) => sum + (modifierPriceMap.value.get(req.modifier_id) ?? 0) * req.quantity,\n 0\n )\n )\n\n // -------------------------------------------------------------------------\n // Computed: optimistic price (instant, without hitting the API)\n // -------------------------------------------------------------------------\n\n // variant.price is the variant's base price (stock-specific or fallback);\n // it does NOT include modifiers. selectedModifierTotal adds all selected\n // modifiers (default + required + custom).\n const optimisticPrice = computed<number>(() => {\n if (!resolvedVariant.value) return 0\n\n return resolvedVariant.value.price + selectedModifierTotal.value\n })\n\n const optimisticOriginalPrice = computed<number | null>(() => {\n if (!resolvedVariant.value) return null\n\n const r = resolvedVariant.value\n\n if (r.originalPrice && r.originalPrice > r.price) return r.originalPrice\n if (r.discount && r.discount.difference > 0) return r.price + r.discount.difference\n\n return null\n })\n\n // -------------------------------------------------------------------------\n // API-confirmed price (overrides the optimistic price once the response arrives)\n // -------------------------------------------------------------------------\n\n const apiPrice = ref<number | null>(null)\n const apiOriginalPrice = ref<number | null>(null)\n const priceIsRecalculating = ref(false)\n let requestId = 0\n\n // -------------------------------------------------------------------------\n // Final displayed price: API > optimistic\n // -------------------------------------------------------------------------\n\n const price = computed<number>(() => apiPrice.value ?? optimisticPrice.value)\n const originalPrice = computed<number | null>(\n () => apiOriginalPrice.value ?? optimisticOriginalPrice.value\n )\n const priceWasModified = computed<boolean>(() => apiPrice.value !== null)\n\n // -------------------------------------------------------------------------\n // API recalculation (confirms / corrects the optimistic price)\n // -------------------------------------------------------------------------\n\n async function recalculatePrice(): Promise<void> {\n if (requiredModifiersGroupIsMissing.value) return\n if (!modifiersModel.value.length || !selectedVariant.value) return\n\n const currentRequestId = ++requestId\n priceIsRecalculating.value = true\n\n try {\n const response = await sdk.products.getProductVariantPrice(\n profileStore.store!.id,\n product.value.id,\n selectedVariant.value.id,\n {\n modifiers: modifiersModel.value,\n // exactOptionalPropertyTypes: only include stock_id when it's set\n ...(currentStockId.value ? { stock_id: currentStockId.value } : {}),\n }\n )\n\n if (currentRequestId !== requestId) return\n\n apiPrice.value = response.price\n apiOriginalPrice.value = response.original_price\n selectedModifiersHash.value = response.modifiers_hash\n } catch (e) {\n console.error('[usePriceRecalculation] price recalculation failed', e)\n } finally {\n if (currentRequestId === requestId) {\n priceIsRecalculating.value = false\n }\n }\n }\n\n const debouncedRecalculate = createDebounce(() => recalculatePrice(), 300)\n\n // -------------------------------------------------------------------------\n // Watcher: reset the API price + recalculate when the variant/modifiers change\n // -------------------------------------------------------------------------\n\n watch(selectedVariant, () => {\n apiPrice.value = null\n apiOriginalPrice.value = null\n requestId++\n selectedModifiersHash.value = selectedVariant.value?.default_modifiers?.hash ?? null\n })\n\n watch(\n modifiersModel,\n () => {\n apiPrice.value = null\n apiOriginalPrice.value = null\n requestId++\n\n if (modifiersModel.value.length && selectedVariant.value) {\n debouncedRecalculate()\n } else {\n selectedModifiersHash.value = selectedVariant.value?.default_modifiers?.hash ?? null\n }\n },\n { deep: true }\n )\n\n return { price, originalPrice, priceWasModified, priceIsRecalculating }\n}\n","import { computed, watch, type ComputedRef, type Ref } from 'vue'\n\nimport type { Product, ProductModifiersRequest, ProductVariant } from '@zenky/storefront-api'\n\nimport { usePriceRecalculation } from './usePriceRecalculation'\nimport { useProductVariant, type ProductVariantOptionListItem } from './useProductVariant'\nimport { useProductVariantModifiers } from './useProductVariantModifiers'\n\n// The SDK's min_quantity field is optional (number | null); normalize it to a positive quantity.\nfunction resolveQuantity(minQuantity: number | null): number {\n return minQuantity && minQuantity > 0 ? minQuantity : 1\n}\n\nexport function useProductVariantSelector(product: ComputedRef<Product>): {\n optionsModel: Ref<Record<string, string>>\n optionsList: Ref<ProductVariantOptionListItem[]>\n disabledValues: ComputedRef<Record<string, Set<string>>>\n modifiersModel: Ref<ProductModifiersRequest[]>\n selectedVariant: ComputedRef<ProductVariant | null>\n price: ComputedRef<number>\n originalPrice: ComputedRef<number | null>\n priceWasModified: ComputedRef<boolean>\n priceIsRecalculating: Ref<boolean>\n selectedModifiersHash: Ref<string | null>\n requiredModifiersGroupIsMissing: ComputedRef<boolean>\n} {\n const { optionsModel, optionsList, selectedVariant, disabledValues } =\n useProductVariant(product)\n const { modifiersModel, selectedModifiersHash } = useProductVariantModifiers(selectedVariant)\n\n // Required modifiers must always be present in the model.\n // 1) modEntry.is_required — an individually required modifier\n // 2) groupEntry.is_required — a required group: if it has no is_required modifiers,\n // auto-select the cheapest one (mirrors minRequiredModifiersCost in useProductPricing)\n const requiredModifierEntries = computed<ProductModifiersRequest[]>(() => {\n const result: ProductModifiersRequest[] = []\n\n for (const groupEntry of product.value.modifiers_groups ?? []) {\n const group = groupEntry.group\n const hasIndividualRequired = group.modifiers.some((m) => m.is_required)\n\n // 1. Individually required modifiers\n for (const modEntry of group.modifiers) {\n if (modEntry.is_required) {\n result.push({\n modifier_id: modEntry.modifier.id,\n modifiers_group_id: group.id,\n quantity: resolveQuantity(modEntry.min_quantity),\n })\n }\n }\n\n // 2. A required group with no is_required modifiers →\n // the user must pick at least one; take the cheapest\n if (groupEntry.is_required && !hasIndividualRequired) {\n const sorted = [...group.modifiers].sort(\n (a, b) => (a.modifier.price ?? 0) - (b.modifier.price ?? 0)\n )\n const cheapest = sorted[0]\n\n if (cheapest) {\n result.push({\n modifier_id: cheapest.modifier.id,\n modifiers_group_id: group.id,\n quantity: resolveQuantity(cheapest.min_quantity),\n })\n }\n }\n }\n\n return result\n })\n\n // Adds required modifiers to the model (for both UI and API).\n // Single mutation — avoids extra reactive recalculations.\n function seedRequiredModifiers(): void {\n const missing = requiredModifierEntries.value.filter(\n (req) => !modifiersModel.value.some((m) => m.modifier_id === req.modifier_id)\n )\n\n if (missing.length) {\n modifiersModel.value = [...modifiersModel.value, ...missing]\n }\n }\n\n // Synchronous initialization — runs before any watchers are registered in\n // usePriceRecalculation, so the first render already sees the correct price.\n seedRequiredModifiers()\n\n // On variant change: the useProductVariantModifiers watcher resets the model to defaults,\n // then we add the required ones back. Both watchers use flush: 'pre' — they run in\n // registration order, before the render.\n watch(selectedVariant, seedRequiredModifiers)\n\n const requiredModifiersGroupIsMissing = computed<boolean>(() => {\n const requiredGroups = (product.value.modifiers_groups ?? [])\n .filter((group) => group.is_required)\n .map((group) => group.group.id)\n\n if (!requiredGroups.length) return false\n\n return requiredGroups.some(\n (groupId) =>\n !modifiersModel.value.find(\n (m) => m.modifiers_group_id === groupId && m.quantity > 0\n )\n )\n })\n\n const { price, originalPrice, priceWasModified, priceIsRecalculating } = usePriceRecalculation({\n product,\n selectedVariant,\n modifiersModel,\n requiredModifiersGroupIsMissing,\n selectedModifiersHash,\n })\n\n return {\n optionsModel,\n optionsList,\n disabledValues,\n modifiersModel,\n selectedVariant,\n price,\n originalPrice,\n priceWasModified,\n priceIsRecalculating,\n selectedModifiersHash,\n requiredModifiersGroupIsMissing,\n }\n}\n","// Requests for recommended products. The SDK has no typed related.products.list\n// method, so this goes through the public sdk.client.request instead.\nimport type { Product } from '@zenky/storefront-api'\n\nimport { useRuntime } from '../ports/runtime'\nimport { createRuntimeState } from '../ports/runtimeState'\nimport { useAuthStore } from '../stores/auth'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nexport interface OrderCredentials {\n id: string\n token: string\n}\n\ninterface UseRelatedProductsApi {\n fetchForProduct: (\n productId: string,\n orderCredentials: OrderCredentials | null,\n signal?: AbortSignal\n ) => Promise<Product[]>\n fetchForOrder: (orderId: string, orderToken: string, signal?: AbortSignal) => Promise<Product[]>\n}\n\n/**\n * A single variant and no modifiers — such a product can be added to the cart\n * directly with one click from a recommendation, without opening the product card.\n */\nexport function canAddDirectly(product: Product): boolean {\n const variantsCount = product.variants?.length ?? 0\n const hasModifiers = (product.modifiers?.length ?? 0) > 0\n const hasModifierGroups = (product.modifiers_groups?.length ?? 0) > 0\n return variantsCount === 1 && !hasModifiers && !hasModifierGroups\n}\n\n// Without `variants.prices` prices come back as 0 (prices live on variants). Without\n// modifiers/groups, canAddDirectly breaks — it treats the product as \"direct add\"\n// even though it has modifiers.\nconst RELATED_PRODUCT_INCLUDES = 'variants.prices,modifiers,modifiers_groups'\n\ninterface RelatedProductsState {\n productInFlight: Map<string, Promise<Product[]>>\n}\n\nconst getRelatedProductsState = createRuntimeState<RelatedProductsState>(() => ({\n productInFlight: new Map<string, Promise<Product[]>>(),\n}))\n\nexport function useRelatedProducts(): UseRelatedProductsApi {\n const runtime = useRuntime()\n const { sdk } = runtime\n const { productInFlight } = getRelatedProductsState(runtime)\n const profileStore = useStoreProfileStore()\n const authStore = useAuthStore()\n\n function getStoreId(): string {\n const id = profileStore.store?.id\n if (!id) throw new Error('Store is not initialized')\n return id\n }\n\n async function fetchForProduct(\n productId: string,\n orderCredentials: OrderCredentials | null,\n signal?: AbortSignal\n ): Promise<Product[]> {\n if (signal?.aborted) return []\n\n const key = orderCredentials ? `${productId}:${orderCredentials.id}` : productId\n\n let promise = productInFlight.get(key)\n if (!promise) {\n promise = (async (): Promise<Product[]> => {\n try {\n const storeId = getStoreId()\n const query: Record<string, string> = { with: RELATED_PRODUCT_INCLUDES }\n if (orderCredentials) {\n query.order_id = orderCredentials.id\n query.order_token = orderCredentials.token\n }\n const url = sdk.client.getStoreUrl(\n storeId,\n `/products/${productId}/related/products`,\n query\n )\n const response = await sdk.client.request(\n 'GET',\n url,\n undefined,\n authStore.token\n )\n return (response?.data as Product[] | undefined) ?? []\n } catch (e: unknown) {\n // Per spec: on error or empty response, show nothing to the customer —\n // the block just doesn't appear. The log is for developers.\n console.warn('[recommendations:product] fetch failed', e)\n return []\n }\n })().finally(() => productInFlight.delete(key))\n productInFlight.set(key, promise)\n }\n\n const result = await promise\n return signal?.aborted ? [] : result\n }\n\n async function fetchForOrder(\n orderId: string,\n orderToken: string,\n signal?: AbortSignal\n ): Promise<Product[]> {\n if (signal?.aborted) return []\n\n try {\n const storeId = getStoreId()\n const url = sdk.client.getStoreUrl(storeId, `/orders/${orderId}/related/products`, {\n token: orderToken,\n with: RELATED_PRODUCT_INCLUDES,\n })\n const response = await sdk.client.request('GET', url, undefined, authStore.token)\n if (signal?.aborted) return []\n return (response?.data as Product[] | undefined) ?? []\n } catch (e: unknown) {\n console.warn('[recommendations:order] fetch failed', e)\n return []\n }\n }\n\n return { fetchForProduct, fetchForOrder }\n}\n","import type { Product } from '@zenky/storefront-api'\n\nimport type { StaticCatalogItem } from '../catalog/catalogEntity'\n\nexport interface CatalogProductMatch {\n product: Product\n catalogItem: StaticCatalogItem\n}\n\nexport function findProductInCatalog(\n catalog: StaticCatalogItem[],\n shortId: string\n): CatalogProductMatch | null {\n for (const item of catalog) {\n if (!item.products.length) continue\n\n const found = item.products.find((p) => p.short_id === shortId)\n if (found) return { product: found, catalogItem: item }\n }\n\n return null\n}\n","import { useRuntime } from '../ports/runtime'\nimport { useCatalogStore } from '../stores/catalog'\nimport { useStoreProfileStore } from '../stores/store-profile'\nimport { findProductInCatalog, type CatalogProductMatch } from './findProductInCatalog'\n\nimport type { Product } from '@zenky/storefront-api'\n\n// images — cover and OG image; variants.options — without it the variant selector\n// collapses to the first variant; variants.prices — the variant's own price, not 0;\n// custom_fields — extra product attributes.\nconst PRODUCT_DETAIL_INCLUDES =\n 'images,variants.prices,variants.options,categories,modifiers,modifiers.cover,modifiers_groups,modifiers_groups.cover,custom_fields'\n\nexport interface UseProductDetailApi {\n /** Synchronous search against the already-loaded static catalog. */\n findInCatalog: (shortId: string) => CatalogProductMatch | null\n /** API fallback for when the product isn't in the catalog. */\n fetchProduct: (shortId: string) => Promise<Product | null>\n}\n\nexport function useProductDetail(): UseProductDetailApi {\n const { sdk } = useRuntime()\n const catalogStore = useCatalogStore()\n const profileStore = useStoreProfileStore()\n\n function findInCatalog(shortId: string): CatalogProductMatch | null {\n return findProductInCatalog(catalogStore.catalog, shortId)\n }\n\n async function fetchProduct(shortId: string): Promise<Product | null> {\n const storeId = profileStore.store?.id\n if (!storeId) return null\n\n try {\n return await sdk.products.getProduct(storeId, shortId, {\n with: PRODUCT_DETAIL_INCLUDES,\n })\n } catch (e) {\n console.error('[product-detail] getProduct failed', e)\n return null\n }\n }\n\n return { findInCatalog, fetchProduct }\n}\n","import { useRuntime } from '../ports/runtime'\nimport { useCartStore } from '../stores/cart'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nimport type { PaginatedResponse, Product } from '@zenky/storefront-api'\n\n// images — cover image; variants.prices — price per stock (see resolveVariantPrice);\n// modifiers/modifiers_groups — the card shows \"from X ₽\" when these are present.\nconst PRODUCT_LIST_INCLUDES =\n 'images,variants.prices,variants.options,modifiers,modifiers.cover,modifiers_groups,modifiers_groups.cover'\n\nexport interface ProductListParams {\n categoryId?: string\n collectionId?: string\n orderBy?: string\n page?: number\n count?: number\n}\n\nexport interface UseProductListApi {\n fetchProducts: (params: ProductListParams) => Promise<PaginatedResponse<Product>>\n}\n\nfunction emptyPage(page: number, count: number): PaginatedResponse<Product> {\n return {\n items: [],\n pagination: {\n total: 0,\n count: 0,\n per_page: count,\n current_page: page,\n total_pages: 0,\n links: {},\n has_previous_page: false,\n has_next_page: false,\n elements: [],\n },\n }\n}\n\nexport function useProductList(): UseProductListApi {\n const { sdk } = useRuntime()\n const profileStore = useStoreProfileStore()\n const cartStore = useCartStore()\n\n async function fetchProducts(params: ProductListParams): Promise<PaginatedResponse<Product>> {\n const storeId = profileStore.store?.id\n const stockId = cartStore.order?.stock?.id\n const cityId = stockId ? undefined : profileStore.city?.id\n\n if (!storeId || (!stockId && !cityId)) {\n return emptyPage(params.page ?? 1, params.count ?? 0)\n }\n\n return sdk.products.getProducts(storeId, {\n category_id: params.categoryId,\n collection_id: params.collectionId,\n with: PRODUCT_LIST_INCLUDES,\n order_by: params.orderBy,\n page: params.page,\n count: params.count,\n stock_id: stockId,\n city_id: cityId,\n })\n }\n\n return { fetchProducts }\n}\n","/**\n * Internal color math for derived badge palettes. Not part of the public API: only the\n * helpers built on top of it (see `products/badges.ts`) are exported from the package.\n */\n\nexport type Rgb = [number, number, number]\n\nexport interface HueRotationOptions {\n lightnessBoost?: number\n maxLightness?: number\n}\n\nexport const WHITE = '#ffffff'\nexport const BLACK = '#000000'\n\nconst CONTRAST_STEPS = 14\nconst CONTRAST_STEP_WEIGHT = 0.1\n\nexport function parseHex(hex: string): Rgb {\n const digits = hex.slice(1)\n const full =\n digits.length <= 4\n ? digits\n .split('')\n .map((char) => char + char)\n .join('')\n : digits\n\n return [0, 2, 4].map((offset) => parseInt(full.slice(offset, offset + 2), 16)) as Rgb\n}\n\nexport function toHex([r, g, b]: Rgb): string {\n return `#${[r, g, b]\n .map((channel) =>\n Math.round(Math.max(0, Math.min(255, channel)))\n .toString(16)\n .padStart(2, '0')\n )\n .join('')}`\n}\n\nexport function luminance(hex: string): number {\n const [r, g, b] = parseHex(hex).map((channel) => {\n const value = channel / 255\n\n return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4\n }) as Rgb\n\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function contrastRatio(a: string, b: string): number {\n const first = luminance(a)\n const second = luminance(b)\n\n return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05)\n}\n\nexport function chroma(hex: string): number {\n const channels = parseHex(hex).map((channel) => channel / 255)\n\n return Math.max(...channels) - Math.min(...channels)\n}\n\n/** Linear RGB mix: `weightOfTo` 0 returns `from`, 1 returns `to`. */\nexport function mixColors(from: string, to: string, weightOfTo: number): string {\n const a = parseHex(from)\n const b = parseHex(to)\n\n return toHex(a.map((channel, index) => channel + (b[index]! - channel) * weightOfTo) as Rgb)\n}\n\nexport function toRgba(hex: string, alpha: number): string {\n const [r, g, b] = parseHex(hex)\n\n return `rgba(${r}, ${g}, ${b}, ${alpha})`\n}\n\n/** Rotates the hue in HSL space; `lightnessBoost` is added to lightness and capped by `maxLightness`. */\nexport function rotateHue(\n hex: string,\n degrees: number,\n { lightnessBoost = 0, maxLightness = 1 }: HueRotationOptions = {}\n): string {\n const [r, g, b] = parseHex(hex).map((channel) => channel / 255) as Rgb\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n const delta = max - min\n const lightness = (max + min) / 2\n let hue = 0\n let saturation = 0\n\n if (delta) {\n saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min)\n\n if (max === r) hue = (g - b) / delta + (g < b ? 6 : 0)\n else if (max === g) hue = (b - r) / delta + 2\n else hue = (r - g) / delta + 4\n\n hue *= 60\n }\n\n const rotatedHue = (((hue + degrees) % 360) + 360) % 360\n const rotatedLightness = Math.min(lightness + lightnessBoost, maxLightness)\n const spread = ((1 - Math.abs(2 * rotatedLightness - 1)) * saturation) / 2\n const channel = (offset: number): number => {\n const position = (offset + rotatedHue / 30) % 12\n const value =\n rotatedLightness - spread * Math.max(-1, Math.min(position - 3, 9 - position, 1))\n\n return value * 255\n }\n\n return toHex([channel(0), channel(8), channel(4)])\n}\n\n/** Moves `color` toward black or white (whichever contrasts with `against`) until `minimum` is met. */\nexport function ensureContrast(color: string, against: string, minimum: number): string {\n const target = luminance(against) > 0.5 ? BLACK : WHITE\n let result = color\n\n for (let step = 0; step < CONTRAST_STEPS && contrastRatio(result, against) < minimum; step++) {\n result = mixColors(result, target, CONTRAST_STEP_WEIGHT)\n }\n\n return result\n}\n","import type { ProductBadge, ProductBadgeColors } from '@zenky/storefront-api'\n\nimport {\n BLACK,\n WHITE,\n chroma,\n contrastRatio,\n ensureContrast,\n luminance,\n rotateHue,\n toRgba,\n} from '../utils/color'\n\n/** A merchant badge validated and normalized for rendering. */\nexport interface ProductBadgeView {\n id: string\n label: string | null\n emoji: string | null\n imageUrl: string | null\n colors: ProductBadgeColors | null\n}\n\n/** `image-square`: an image without a label, drawn as a square with no background. */\nexport type ProductBadgeLayout = 'text' | 'image-square'\n\n/** Colors derived from a badge's own text/background pair, for styles other than solid. */\nexport interface ProductBadgeAccent {\n base: string\n shifted: string\n on: string\n text: string\n glass: string\n}\n\nexport interface ProductBadgeVisibility {\n showText: boolean\n showImages: boolean\n}\n\nconst ON_ACCENT_CONTRAST_MIN = 3\nconst TEXT_CONTRAST_MIN = 4.5\nconst NEUTRAL_CHROMA_GAP = 0.08\nconst HUE_SHIFT = 38\nconst HUE_SHIFT_LIGHTNESS_BOOST = 0.06\nconst HUE_SHIFT_MAX_LIGHTNESS = 0.7\nconst GLASS_ALPHA = 0.35\n\nconst HEX_COLOR = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i\nconst HTTP_URL = /^https?:\\/\\//i\n\nfunction cleanText(value: unknown): string | null {\n if (typeof value !== 'string') return null\n\n const text = value.trim()\n\n return text || null\n}\n\nfunction dropAlpha(hex: string): string {\n if (hex.length === 5) return hex.slice(0, 4)\n if (hex.length === 9) return hex.slice(0, 7)\n\n return hex\n}\n\nfunction toColors(badge: ProductBadge): ProductBadgeColors | null {\n const background = cleanText(badge.colors?.background)\n const text = cleanText(badge.colors?.text)\n\n if (!background || !text || !HEX_COLOR.test(background) || !HEX_COLOR.test(text)) {\n return null\n }\n\n return { background: dropAlpha(background), text: dropAlpha(text) }\n}\n\nfunction toView(badge: ProductBadge): ProductBadgeView | null {\n const label = cleanText(badge.label)\n const iconValue = cleanText(badge.icon?.value)\n const emoji = badge.icon?.type === 'emoji' ? iconValue : null\n const imageUrl =\n badge.icon?.type === 'image' && iconValue && HTTP_URL.test(iconValue) ? iconValue : null\n\n if (!label && !emoji && !imageUrl) return null\n\n return { id: badge.id, label, emoji, imageUrl, colors: toColors(badge) }\n}\n\n/**\n * Validates the backend `Product.badges` list: drops badges with nothing to show, repeated\n * ids and unusable icons, accepts only hex colors (alpha is ignored) and http(s) image urls.\n * `colors` is `null` when either color is missing or invalid, so the consumer can fall back\n * to its own theme.\n */\nexport function toProductBadgeViews(badges: ProductBadge[] | null | undefined): ProductBadgeView[] {\n if (!Array.isArray(badges)) return []\n\n const result: ProductBadgeView[] = []\n const seen = new Set<string>()\n\n for (const badge of badges) {\n if (!badge || typeof badge.id !== 'string' || !badge.id || seen.has(badge.id)) continue\n\n const view = toView(badge)\n if (!view) continue\n\n seen.add(badge.id)\n result.push(view)\n }\n\n return result\n}\n\nexport function getProductBadgeLayout(badge: ProductBadgeView): ProductBadgeLayout {\n return !badge.label && badge.imageUrl ? 'image-square' : 'text'\n}\n\nfunction pickAccent(colors: ProductBadgeColors): string {\n const textChroma = chroma(colors.text)\n const backgroundChroma = chroma(colors.background)\n\n if (Math.abs(textChroma - backgroundChroma) > NEUTRAL_CHROMA_GAP) {\n return textChroma > backgroundChroma ? colors.text : colors.background\n }\n\n return luminance(colors.text) <= luminance(colors.background) ? colors.text : colors.background\n}\n\n/**\n * Derives a palette from the badge's own colors: the more chromatic of text/background\n * becomes the accent (darker one when both are neutral), `on` is white or black, whichever\n * stays readable on it, `shifted` is the hue-rotated gradient end and `glass` is a\n * translucent fill. Pure JS math, no CSS color functions, so it works for any hex input.\n */\nexport function getProductBadgeAccent(colors: ProductBadgeColors): ProductBadgeAccent {\n const base = pickAccent(colors)\n const on = contrastRatio(WHITE, base) >= ON_ACCENT_CONTRAST_MIN ? WHITE : BLACK\n\n return {\n base,\n shifted: ensureContrast(\n rotateHue(base, HUE_SHIFT, {\n lightnessBoost: HUE_SHIFT_LIGHTNESS_BOOST,\n maxLightness: HUE_SHIFT_MAX_LIGHTNESS,\n }),\n on,\n ON_ACCENT_CONTRAST_MIN\n ),\n on,\n text: ensureContrast(base, WHITE, TEXT_CONTRAST_MIN),\n glass: toRgba(base, GLASS_ALPHA),\n }\n}\n\nexport function filterProductBadges(\n badges: ProductBadgeView[],\n visibility: ProductBadgeVisibility\n): ProductBadgeView[] {\n return badges.filter((badge) =>\n getProductBadgeLayout(badge) === 'image-square'\n ? visibility.showImages\n : visibility.showText\n )\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCartCredentials, usePromotionsChecker } from './chunk-QFKA2R6D.js';
|
|
2
2
|
import { logCartError, getCartErrorHttpCode, getCartErrorCode, getCartErrorMessage } from './chunk-TE42OCFK.js';
|
|
3
|
-
import {
|
|
3
|
+
import { usePromotionsStore } from './chunk-544USTPB.js';
|
|
4
4
|
import { toRequestedMethod } from './chunk-TIQ7AJLY.js';
|
|
5
5
|
import { getRemoteCatalog } from './chunk-FS2UNPTY.js';
|
|
6
6
|
import { minorToMajor, majorToMinor } from './chunk-2Y6QTHXI.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { createRuntimeState } from './chunk-5QCUH3FF.js';
|
|
8
|
+
import { useCatalogStore } from './chunk-4JCJHAL3.js';
|
|
9
9
|
import { useRuntime, useCartStore, useAuthStore, useOrderSettingsStore } from './chunk-TXR76IDL.js';
|
|
10
10
|
import { useStoreProfileStore } from './chunk-IOYYCA75.js';
|
|
11
11
|
import { PaymentMethod, OrderAuthenticationMethod, DeliveryMethod, OrderCartCheckerResultAction, RecaptchaAction } from '@zenky/storefront-api';
|
|
@@ -1983,5 +1983,5 @@ function useVisibleCartVariants() {
|
|
|
1983
1983
|
}
|
|
1984
1984
|
|
|
1985
1985
|
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey };
|
|
1986
|
-
//# sourceMappingURL=chunk-
|
|
1987
|
-
//# sourceMappingURL=chunk-
|
|
1986
|
+
//# sourceMappingURL=chunk-IEHN2WNU.js.map
|
|
1987
|
+
//# sourceMappingURL=chunk-IEHN2WNU.js.map
|