@pisell/pisellos 2.3.116 → 2.3.118

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.
@@ -21,15 +21,31 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
21
21
  import dayjs from 'dayjs';
22
22
  import Decimal from 'decimal.js';
23
23
  var DEFAULT_LOCALES = ['en', 'zh_CN'];
24
+ var SERVICE_TYPE_LABEL_KEYS = {
25
+ takeaway: 'takeAway',
26
+ pick_up: 'pickUp',
27
+ table_service: 'tableService',
28
+ delivery: 'delivery',
29
+ room_service: 'roomService',
30
+ dine_in: 'dineIn',
31
+ delivery_by_uber: 'deliveryByUber',
32
+ delivery_by_panda: 'deliveryByPanda',
33
+ delivery_by_merchant: 'deliveryByMerchant'
34
+ };
24
35
  var LABELS = {
25
36
  en: {
26
37
  contactName: 'Contact name',
27
38
  contactMobile: 'Contact Mobile',
28
39
  email: 'email',
29
- dineIn: 'Dine-in',
30
- takeAway: 'Take away',
40
+ dineIn: 'Dine in',
41
+ takeAway: 'Takeaway',
31
42
  delivery: 'Delivery',
32
- pickUp: 'Pick-up',
43
+ pickUp: 'Pickup',
44
+ tableService: 'Table Service',
45
+ roomService: 'Room Service',
46
+ deliveryByUber: 'Uber Eats Delivery',
47
+ deliveryByPanda: 'HungryPanda Delivery',
48
+ deliveryByMerchant: 'Merchant Delivery',
33
49
  shopService: 'Dine-in',
34
50
  pickUpTime: 'Pick-up time',
35
51
  asap: 'ASAP',
@@ -45,6 +61,7 @@ var LABELS = {
45
61
  remainingAmount: 'Remaining amount',
46
62
  redeemPoints: 'Redeem points',
47
63
  remainingPoints: 'Points balance',
64
+ entitlementRemaining: 'Remaining',
48
65
  table: 'Table',
49
66
  bookingId: 'Booking ID',
50
67
  bookingDateTime: 'Date & time',
@@ -68,7 +85,12 @@ var LABELS = {
68
85
  dineIn: '堂食',
69
86
  takeAway: '外带',
70
87
  delivery: '配送',
71
- pickUp: '自提',
88
+ pickUp: '自取',
89
+ tableService: '送餐到桌',
90
+ roomService: '客房服务',
91
+ deliveryByUber: 'Uber 配送',
92
+ deliveryByPanda: '熊猫外卖配送',
93
+ deliveryByMerchant: '商家配送',
72
94
  shopService: '堂食',
73
95
  pickUpTime: '取餐时间',
74
96
  asap: '尽快',
@@ -84,6 +106,7 @@ var LABELS = {
84
106
  remainingAmount: '剩余金额',
85
107
  redeemPoints: '本次使用积分',
86
108
  remainingPoints: '积分余额',
109
+ entitlementRemaining: '剩余次数',
87
110
  table: '桌台',
88
111
  bookingId: '预约编号',
89
112
  bookingDateTime: '日期和时间',
@@ -108,6 +131,11 @@ var LABELS = {
108
131
  takeAway: '外帶',
109
132
  delivery: '配送',
110
133
  pickUp: '自取',
134
+ tableService: '送餐到桌',
135
+ roomService: '客房服務',
136
+ deliveryByUber: 'Uber 配送',
137
+ deliveryByPanda: '熊貓外賣配送',
138
+ deliveryByMerchant: '商家配送',
111
139
  shopService: '堂食',
112
140
  pickUpTime: '取餐時間',
113
141
  asap: '盡快',
@@ -123,6 +151,7 @@ var LABELS = {
123
151
  remainingAmount: '剩餘金額',
124
152
  redeemPoints: '本次使用積分',
125
153
  remainingPoints: '積分餘額',
154
+ entitlementRemaining: '剩餘次數',
126
155
  table: '桌台',
127
156
  bookingId: '預約編號',
128
157
  bookingDateTime: '日期和時間',
@@ -147,6 +176,11 @@ var LABELS = {
147
176
  takeAway: 'テイクアウト',
148
177
  delivery: '配達',
149
178
  pickUp: '受け取り',
179
+ tableService: 'テーブルサービス',
180
+ roomService: 'ルームサービス',
181
+ deliveryByUber: 'Uber Eats 配達',
182
+ deliveryByPanda: 'HungryPanda 配達',
183
+ deliveryByMerchant: '店舗による配達',
150
184
  shopService: '店内飲食',
151
185
  pickUpTime: '受取時間',
152
186
  asap: 'できるだけ早く',
@@ -160,6 +194,7 @@ var LABELS = {
160
194
  remainingAmount: '残高',
161
195
  redeemPoints: '利用ポイント',
162
196
  remainingPoints: 'ポイント残高',
197
+ entitlementRemaining: '残り回数',
163
198
  table: 'テーブル',
164
199
  bookingId: '予約ID',
165
200
  bookingDateTime: '日時',
@@ -185,6 +220,11 @@ var LABELS = {
185
220
  takeAway: 'Para levar',
186
221
  delivery: 'Entrega',
187
222
  pickUp: 'Recolha',
223
+ tableService: 'Serviço à mesa',
224
+ roomService: 'Serviço de quarto',
225
+ deliveryByUber: 'Entrega pela Uber Eats',
226
+ deliveryByPanda: 'Entrega pela HungryPanda',
227
+ deliveryByMerchant: 'Entrega pelo comerciante',
188
228
  shopService: 'Consumo no local',
189
229
  pickUpTime: 'Hora de recolha',
190
230
  asap: 'Assim que possível',
@@ -198,6 +238,7 @@ var LABELS = {
198
238
  remainingAmount: 'Saldo restante',
199
239
  redeemPoints: 'Pontos utilizados',
200
240
  remainingPoints: 'Saldo de pontos',
241
+ entitlementRemaining: 'Utilizações restantes',
201
242
  table: 'Mesa',
202
243
  bookingId: 'ID da reserva',
203
244
  bookingDateTime: 'Data e hora',
@@ -513,7 +554,8 @@ function normalizeProductDiscounts(params) {
513
554
  var title = resolveDiscountTitleWithPercent(discount, locale);
514
555
  var amount = (_ref15 = (_discount$amount2 = discount.amount) !== null && _discount$amount2 !== void 0 ? _discount$amount2 : discount.value) !== null && _ref15 !== void 0 ? _ref15 : discount.discount_amount;
515
556
  var isMarkup = isManualMarkup(discount);
516
- var totalAmount = new Decimal(toMoneyNumber(amount)).mul(quantity);
557
+ var isAggregatedBundleDiscount = Boolean(getReceiptDiscountBundleMapId(discount));
558
+ var totalAmount = new Decimal(toMoneyNumber(amount)).mul(isAggregatedBundleDiscount ? 1 : quantity);
517
559
  var formattedAmount = isMarkup ? formatMoney(totalAmount.abs(), currencySymbol) : formatNegativeMoney(totalAmount, currencySymbol);
518
560
  return {
519
561
  item: title,
@@ -613,6 +655,9 @@ function buildProductQuantityPriceText(params) {
613
655
  function resolveDiscountTitleWithPercent(discount, locale) {
614
656
  var _discount$discount2, _discount$discount$di, _discount$discount3;
615
657
  var title = resolveDiscountTitle(discount, locale);
658
+ if (getProductWalletDiscountType(discount) === 'entitlement_pass') {
659
+ return title;
660
+ }
616
661
  var percentRaw = (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.percent;
617
662
  var cardType = (_discount$discount$di = (_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.discount_card_type) !== null && _discount$discount$di !== void 0 ? _discount$discount$di : 'percent';
618
663
  var percent = percentRaw !== undefined && percentRaw !== null ? Math.trunc(Number(percentRaw)) : NaN;
@@ -1198,9 +1243,8 @@ function normalizeCustomerDisplayValue(value) {
1198
1243
  }
1199
1244
  function buildDelivery(order, locale) {
1200
1245
  var _order$metadata2, _order$metadata3, _order$metadata4, _order$metadata5, _order$metadata6, _order$metadata7, _order$metadata8, _order$metadata9, _order$metadata10, _order$metadata11, _order$metadata12;
1201
- var deliveryType = stringify(order.delivery_type).trim();
1202
- var serviceType = deliveryType || stringify(firstPresentValue((_order$metadata2 = order.metadata) === null || _order$metadata2 === void 0 ? void 0 : _order$metadata2.service_type, order.service_type)).trim();
1203
- var serviceTypeLabelKey = resolveServiceTypeLabelKey(serviceType, order);
1246
+ var serviceType = stringify((_order$metadata2 = order.metadata) === null || _order$metadata2 === void 0 || (_order$metadata2 = _order$metadata2.shop_service_data) === null || _order$metadata2 === void 0 ? void 0 : _order$metadata2.service_type).trim();
1247
+ var serviceTypeLabelKey = resolveServiceTypeLabelKey(serviceType);
1204
1248
  if (!serviceTypeLabelKey) return [];
1205
1249
  var items = [{
1206
1250
  item: '',
@@ -1505,43 +1549,323 @@ function buildWallets(params) {
1505
1549
  virtualCurrencyUnit: virtualCurrencySnapshot ? getVirtualCurrencySnapshotUnit(virtualCurrencySnapshot, params.locale) : undefined
1506
1550
  });
1507
1551
  });
1508
- var displayedWalletPassIds = collectDisplayedWalletPassIds(displayedWalletPayments);
1509
- return [].concat(_toConsumableArray(paymentWallets), _toConsumableArray(buildVoucherAssets(params)), _toConsumableArray(buildPointCardSnapshotAssets({
1552
+ var displayedWalletAssetIdentities = collectDisplayedWalletAssetIdentities(displayedWalletPayments);
1553
+ var voucherWallets = buildVoucherAssets(_objectSpread(_objectSpread({}, params), {}, {
1554
+ displayedWalletAssetIdentities: displayedWalletAssetIdentities
1555
+ }));
1556
+ var productDiscountWallets = buildProductDiscountAssets(_objectSpread(_objectSpread({}, params), {}, {
1557
+ displayedWalletAssetIdentities: displayedWalletAssetIdentities
1558
+ }));
1559
+ return [].concat(_toConsumableArray(paymentWallets), voucherWallets, productDiscountWallets, _toConsumableArray(buildPointCardSnapshotAssets({
1510
1560
  order: params.order,
1511
1561
  locale: params.locale,
1512
- displayedWalletPassIds: displayedWalletPassIds
1562
+ displayedWalletAssetIdentities: displayedWalletAssetIdentities
1513
1563
  })), _toConsumableArray(buildVirtualCurrencySnapshotAssets({
1514
1564
  snapshots: virtualCurrencySnapshots.items,
1515
1565
  order: params.order,
1516
1566
  locale: params.locale,
1517
- displayedWalletPassIds: displayedWalletPassIds
1567
+ displayedWalletAssetIdentities: displayedWalletAssetIdentities
1518
1568
  })));
1519
1569
  }
1520
- function collectDisplayedWalletPassIds(payments) {
1521
- var ids = new Set();
1570
+ function collectDisplayedWalletAssetIdentities(payments) {
1571
+ var identities = [];
1522
1572
  payments.forEach(function (payment) {
1523
1573
  var fundRecord = getFundRecord(payment);
1524
- [payment.voucher_id, fundRecord === null || fundRecord === void 0 ? void 0 : fundRecord.voucher_id].forEach(function (value) {
1525
- var id = normalizeWalletPassId(value);
1526
- if (id) ids.add(id);
1574
+ var ids = Array.from(new Set([fundRecord === null || fundRecord === void 0 ? void 0 : fundRecord.voucher_id, payment.voucher_id].map(function (value) {
1575
+ return normalizeWalletPassId(value);
1576
+ }).filter(function (value) {
1577
+ return !!value;
1578
+ })));
1579
+ var codes = normalizeWalletAssetCodes(fundRecord === null || fundRecord === void 0 ? void 0 : fundRecord.code, fundRecord === null || fundRecord === void 0 ? void 0 : fundRecord.encoded);
1580
+ if (!ids.length) {
1581
+ registerWalletAssetIdentity(identities, {
1582
+ id: null,
1583
+ codes: codes
1584
+ });
1585
+ return;
1586
+ }
1587
+ ids.forEach(function (id) {
1588
+ registerWalletAssetIdentity(identities, {
1589
+ id: id,
1590
+ codes: codes
1591
+ });
1527
1592
  });
1528
1593
  });
1529
- return ids;
1594
+ return identities;
1595
+ }
1596
+ var PRODUCT_WALLET_DISCOUNT_TYPES = new Set(['good_pass', 'discount_card', 'product_discount_card', 'entitlement_pass']);
1597
+ function buildProductDiscountAssets(params) {
1598
+ var fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
1599
+ return collectProductWalletDiscountAssets(params.order).flatMap(function (asset) {
1600
+ var _getProductWalletDisc;
1601
+ if (!claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
1602
+ id: asset.id,
1603
+ codes: asset.codes
1604
+ })) return [];
1605
+ var name = getProductWalletDiscountName(asset, params.locale);
1606
+ var assetTime = (_getProductWalletDisc = getProductWalletDiscountTime(asset)) !== null && _getProductWalletDisc !== void 0 ? _getProductWalletDisc : fallbackAssetTime;
1607
+ var timeRow = isPresentId(assetTime) ? {
1608
+ item: formatDateTime(assetTime, params.locale),
1609
+ value: ''
1610
+ } : null;
1611
+ if (asset.type === 'entitlement_pass') {
1612
+ var remaining = getProductEntitlementBalance(asset);
1613
+ return [[{
1614
+ item: name,
1615
+ value: ''
1616
+ }].concat(_toConsumableArray(remaining ? [{
1617
+ item: label(params.locale, 'entitlementRemaining'),
1618
+ value: formatEntitlementUses(remaining, params.locale)
1619
+ }] : []), _toConsumableArray(timeRow ? [timeRow] : []))];
1620
+ }
1621
+ var percent = getProductWalletDiscountPercent(asset);
1622
+ if (percent) {
1623
+ return [[{
1624
+ item: appendPercentToVoucherName(name, percent),
1625
+ value: formatVoucherDiscount(percent, params.locale)
1626
+ }].concat(_toConsumableArray(timeRow ? [timeRow] : []))];
1627
+ }
1628
+ var balance = getProductWalletMoneyBalance(asset);
1629
+ return [[{
1630
+ item: name,
1631
+ value: ''
1632
+ }].concat(_toConsumableArray(balance ? [{
1633
+ item: label(params.locale, 'balance'),
1634
+ value: formatMoney(balance, params.currencySymbol)
1635
+ }] : []), _toConsumableArray(timeRow ? [timeRow] : []))];
1636
+ });
1637
+ }
1638
+ function collectProductWalletDiscountAssets(order) {
1639
+ var assets = [];
1640
+ var assetsById = new Map();
1641
+ normalizeArray(order.products).forEach(function (rawProduct) {
1642
+ if (!rawProduct || _typeof(rawProduct) !== 'object') return;
1643
+ visitProductWalletDiscounts(restoreReceiptDiscountHierarchy(rawProduct), assets, assetsById);
1644
+ });
1645
+ return assets;
1646
+ }
1647
+ function visitProductWalletDiscounts(product, assets, assetsById) {
1648
+ normalizeArray(product.discount_list).forEach(function (record) {
1649
+ if (!record || _typeof(record) !== 'object' || Array.isArray(record)) return;
1650
+ var type = getProductWalletDiscountType(record);
1651
+ if (!type) return;
1652
+ var id = getProductWalletDiscountAssetId(record);
1653
+ if (!id) return;
1654
+ var codes = getProductWalletDiscountCodes(record);
1655
+ var existing = assetsById.get(id);
1656
+ if (existing) {
1657
+ existing.records.push(record);
1658
+ existing.codes = Array.from(new Set([].concat(_toConsumableArray(existing.codes), codes)));
1659
+ return;
1660
+ }
1661
+ var asset = {
1662
+ id: id,
1663
+ type: type,
1664
+ codes: codes,
1665
+ records: [record]
1666
+ };
1667
+ assetsById.set(id, asset);
1668
+ assets.push(asset);
1669
+ });
1670
+ for (var _i6 = 0, _arr2 = ['combinations', 'product_bundle', 'bundle']; _i6 < _arr2.length; _i6++) {
1671
+ var childKey = _arr2[_i6];
1672
+ normalizeArray(product[childKey]).forEach(function (child) {
1673
+ if (!child || _typeof(child) !== 'object' || Array.isArray(child)) return;
1674
+ visitProductWalletDiscounts(child, assets, assetsById);
1675
+ });
1676
+ }
1677
+ }
1678
+ function getProductWalletDiscountType(record) {
1679
+ for (var _i7 = 0, _arr3 = [record.tag, record.type, (_record$discount = record.discount) === null || _record$discount === void 0 ? void 0 : _record$discount.tag, (_record$discount2 = record.discount) === null || _record$discount2 === void 0 ? void 0 : _record$discount2.type]; _i7 < _arr3.length; _i7++) {
1680
+ var _record$discount, _record$discount2;
1681
+ var value = _arr3[_i7];
1682
+ var type = stringify(value).trim().toLowerCase();
1683
+ if (PRODUCT_WALLET_DISCOUNT_TYPES.has(type)) return type;
1684
+ }
1685
+ return null;
1686
+ }
1687
+ function getProductWalletDiscountAssetId(record) {
1688
+ for (var _i8 = 0, _arr4 = [(_record$discount3 = record.discount) === null || _record$discount3 === void 0 ? void 0 : _record$discount3.resource_id, record.resource_id, record.id, record.discount_id]; _i8 < _arr4.length; _i8++) {
1689
+ var _record$discount3;
1690
+ var value = _arr4[_i8];
1691
+ var id = normalizeWalletPassId(value);
1692
+ if (id && id !== '0') return id;
1693
+ }
1694
+ return null;
1695
+ }
1696
+ function getProductWalletDiscountCodes(record) {
1697
+ var _record$discount4, _record$discount5;
1698
+ return normalizeWalletAssetCodes(record.code, record.encoded, (_record$discount4 = record.discount) === null || _record$discount4 === void 0 ? void 0 : _record$discount4.code, (_record$discount5 = record.discount) === null || _record$discount5 === void 0 ? void 0 : _record$discount5.encoded);
1699
+ }
1700
+ function getProductWalletDiscountName(asset, locale) {
1701
+ var _iterator4 = _createForOfIteratorHelper(asset.records),
1702
+ _step4;
1703
+ try {
1704
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1705
+ var record = _step4.value;
1706
+ for (var _i9 = 0, _arr5 = [(_record$discount6 = record.discount) === null || _record$discount6 === void 0 ? void 0 : _record$discount6.title, (_record$discount7 = record.discount) === null || _record$discount7 === void 0 ? void 0 : _record$discount7.name, (_record$discount8 = record.discount) === null || _record$discount8 === void 0 ? void 0 : _record$discount8.message, record.product_name, record.format_title, record.title, record.name, record.message]; _i9 < _arr5.length; _i9++) {
1707
+ var _record$discount6, _record$discount7, _record$discount8;
1708
+ var value = _arr5[_i9];
1709
+ var name = getLocalizedValue(value, locale).trim();
1710
+ if (name) return name;
1711
+ }
1712
+ }
1713
+ } catch (err) {
1714
+ _iterator4.e(err);
1715
+ } finally {
1716
+ _iterator4.f();
1717
+ }
1718
+ return asset.codes[0] || label(locale, 'giftCard');
1719
+ }
1720
+ function getProductWalletDiscountTime(asset) {
1721
+ for (var _i10 = 0, _arr6 = ['updated_at', 'created_at', 'collection_time']; _i10 < _arr6.length; _i10++) {
1722
+ var field = _arr6[_i10];
1723
+ var _iterator5 = _createForOfIteratorHelper(asset.records),
1724
+ _step5;
1725
+ try {
1726
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1727
+ var _record$discount9;
1728
+ var record = _step5.value;
1729
+ var value = firstPresentValue(record[field], (_record$discount9 = record.discount) === null || _record$discount9 === void 0 ? void 0 : _record$discount9[field]);
1730
+ if (isPresentId(value)) return value;
1731
+ }
1732
+ } catch (err) {
1733
+ _iterator5.e(err);
1734
+ } finally {
1735
+ _iterator5.f();
1736
+ }
1737
+ }
1738
+ return undefined;
1739
+ }
1740
+ function getProductEntitlementBalance(asset) {
1741
+ var _iterator6 = _createForOfIteratorHelper(asset.records),
1742
+ _step6;
1743
+ try {
1744
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1745
+ var record = _step6.value;
1746
+ var balance = getProductDiscountEntitlementBalance(record);
1747
+ if (balance) return balance;
1748
+ }
1749
+ } catch (err) {
1750
+ _iterator6.e(err);
1751
+ } finally {
1752
+ _iterator6.f();
1753
+ }
1754
+ return null;
1755
+ }
1756
+ function getProductDiscountEntitlementBalance(record) {
1757
+ var _record$metadata, _record$discount10, _record$discount11;
1758
+ return getEntitlementBalance((_record$metadata = record.metadata) === null || _record$metadata === void 0 ? void 0 : _record$metadata.balance, record.balance, (_record$discount10 = record.discount) === null || _record$discount10 === void 0 || (_record$discount10 = _record$discount10.metadata) === null || _record$discount10 === void 0 ? void 0 : _record$discount10.balance, (_record$discount11 = record.discount) === null || _record$discount11 === void 0 ? void 0 : _record$discount11.balance);
1759
+ }
1760
+ function getEntitlementBalance() {
1761
+ for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1762
+ values[_key3] = arguments[_key3];
1763
+ }
1764
+ for (var _i11 = 0, _values2 = values; _i11 < _values2.length; _i11++) {
1765
+ var value = _values2[_i11];
1766
+ if (!isNumericAmount(value)) continue;
1767
+ var balance = new Decimal(value);
1768
+ if (balance.isFinite() && balance.isInteger() && balance.gte(0)) {
1769
+ return balance;
1770
+ }
1771
+ }
1772
+ return null;
1773
+ }
1774
+ function formatEntitlementUses(value, locale) {
1775
+ var count = value.toFixed(0);
1776
+ switch (normalizeLocaleKey(locale)) {
1777
+ case 'zh_CN':
1778
+ case 'zh_HK':
1779
+ return "".concat(count, "\u6B21");
1780
+ case 'ja':
1781
+ return "".concat(count, "\u56DE");
1782
+ case 'pt':
1783
+ return "".concat(count, " ").concat(value.eq(1) ? 'utilização' : 'utilizações');
1784
+ default:
1785
+ return "".concat(count, " ").concat(value.eq(1) ? 'use' : 'uses');
1786
+ }
1787
+ }
1788
+ function getProductWalletDiscountPercent(asset) {
1789
+ if (asset.type !== 'discount_card' && asset.type !== 'product_discount_card') return null;
1790
+ var _iterator7 = _createForOfIteratorHelper(asset.records),
1791
+ _step7;
1792
+ try {
1793
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1794
+ var _record$metadata2, _record$discount12, _record$discount13, _record$discount14;
1795
+ var record = _step7.value;
1796
+ var discountType = stringify(firstPresentValue(record.discount_card_type, (_record$metadata2 = record.metadata) === null || _record$metadata2 === void 0 ? void 0 : _record$metadata2.discount_card_type, (_record$discount12 = record.discount) === null || _record$discount12 === void 0 ? void 0 : _record$discount12.discount_card_type, (_record$discount13 = record.discount) === null || _record$discount13 === void 0 || (_record$discount13 = _record$discount13.metadata) === null || _record$discount13 === void 0 ? void 0 : _record$discount13.discount_card_type)).trim().toLowerCase();
1797
+ if (discountType && discountType !== 'percent' && discountType !== 'percentage') continue;
1798
+ var candidates = [record.percent, (_record$discount14 = record.discount) === null || _record$discount14 === void 0 ? void 0 : _record$discount14.percent];
1799
+ if (discountType === 'percent' || discountType === 'percentage') {
1800
+ var _record$discount15;
1801
+ candidates.push(record.par_value, (_record$discount15 = record.discount) === null || _record$discount15 === void 0 ? void 0 : _record$discount15.par_value);
1802
+ }
1803
+ for (var _i12 = 0, _candidates = candidates; _i12 < _candidates.length; _i12++) {
1804
+ var value = _candidates[_i12];
1805
+ if (!isNumericAmount(value)) continue;
1806
+ var percent = new Decimal(value);
1807
+ if (percent.isFinite() && percent.gt(0) && percent.lte(100)) {
1808
+ return percent;
1809
+ }
1810
+ }
1811
+ }
1812
+ } catch (err) {
1813
+ _iterator7.e(err);
1814
+ } finally {
1815
+ _iterator7.f();
1816
+ }
1817
+ return null;
1818
+ }
1819
+ function getProductWalletMoneyBalance(asset) {
1820
+ var _iterator8 = _createForOfIteratorHelper(asset.records),
1821
+ _step8;
1822
+ try {
1823
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1824
+ var record = _step8.value;
1825
+ for (var _i13 = 0, _arr7 = [(_record$metadata3 = record.metadata) === null || _record$metadata3 === void 0 ? void 0 : _record$metadata3.balance, record.balance, (_record$discount16 = record.discount) === null || _record$discount16 === void 0 || (_record$discount16 = _record$discount16.metadata) === null || _record$discount16 === void 0 ? void 0 : _record$discount16.balance, (_record$discount17 = record.discount) === null || _record$discount17 === void 0 ? void 0 : _record$discount17.balance]; _i13 < _arr7.length; _i13++) {
1826
+ var _record$metadata3, _record$discount16, _record$discount17;
1827
+ var value = _arr7[_i13];
1828
+ if (!isNumericAmount(value)) continue;
1829
+ return Decimal.max(new Decimal(value), 0);
1830
+ }
1831
+ }
1832
+ } catch (err) {
1833
+ _iterator8.e(err);
1834
+ } finally {
1835
+ _iterator8.f();
1836
+ }
1837
+ var _iterator9 = _createForOfIteratorHelper(asset.records),
1838
+ _step9;
1839
+ try {
1840
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1841
+ var _record$discount18, _record$discount19;
1842
+ var _record = _step9.value;
1843
+ var parValue = firstPresentValue(_record.par_value, (_record$discount18 = _record.discount) === null || _record$discount18 === void 0 ? void 0 : _record$discount18.par_value);
1844
+ var usedParValue = firstPresentValue(_record.used_par_value, (_record$discount19 = _record.discount) === null || _record$discount19 === void 0 ? void 0 : _record$discount19.used_par_value);
1845
+ if (!isNumericAmount(parValue) || !isNumericAmount(usedParValue)) continue;
1846
+ return Decimal.max(new Decimal(parValue).minus(new Decimal(usedParValue)), 0);
1847
+ }
1848
+ } catch (err) {
1849
+ _iterator9.e(err);
1850
+ } finally {
1851
+ _iterator9.f();
1852
+ }
1853
+ return null;
1530
1854
  }
1531
1855
  function buildPointCardSnapshotAssets(params) {
1532
1856
  var _params$order$order_m;
1533
1857
  var snapshots = (_params$order$order_m = params.order.order_meta_list) === null || _params$order$order_m === void 0 ? void 0 : _params$order$order_m.point_cards_snapshot;
1534
1858
  if (!Array.isArray(snapshots)) return [];
1535
1859
  var snapshotTime = firstPresentValue(params.order.updated_at, params.order.created_at);
1536
- var seenSnapshotIds = new Set();
1537
1860
  return snapshots.flatMap(function (snapshot) {
1538
1861
  if (!snapshot || _typeof(snapshot) !== 'object' || Array.isArray(snapshot)) return [];
1539
1862
  var pointCard = snapshot;
1540
1863
  if (stringify(pointCard.tag).trim().toLowerCase() !== 'point_card') return [];
1541
- var id = normalizeWalletPassId(pointCard.id);
1542
- if (!id || seenSnapshotIds.has(id)) return [];
1543
- seenSnapshotIds.add(id);
1544
- if (params.displayedWalletPassIds.has(id)) return [];
1864
+ var assetId = normalizeWalletPassId(pointCard.id);
1865
+ if (!assetId || !claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
1866
+ id: assetId,
1867
+ codes: []
1868
+ })) return [];
1545
1869
  var rows = [{
1546
1870
  item: stringify(pointCard.product_name).trim() || label(params.locale, 'pointCard'),
1547
1871
  value: ''
@@ -1587,8 +1911,8 @@ function collectVirtualCurrencySnapshots(order) {
1587
1911
  }
1588
1912
  function findVirtualCurrencySnapshotForPayment(payment, snapshotsById) {
1589
1913
  var fundRecord = getFundRecord(payment);
1590
- for (var _i6 = 0, _arr2 = [fundRecord === null || fundRecord === void 0 ? void 0 : fundRecord.voucher_id, payment.voucher_id]; _i6 < _arr2.length; _i6++) {
1591
- var value = _arr2[_i6];
1914
+ for (var _i14 = 0, _arr8 = [fundRecord === null || fundRecord === void 0 ? void 0 : fundRecord.voucher_id, payment.voucher_id]; _i14 < _arr8.length; _i14++) {
1915
+ var value = _arr8[_i14];
1592
1916
  var id = normalizeWalletPassId(value);
1593
1917
  if (!id) continue;
1594
1918
  var snapshot = snapshotsById.get(id);
@@ -1599,8 +1923,11 @@ function findVirtualCurrencySnapshotForPayment(payment, snapshotsById) {
1599
1923
  function buildVirtualCurrencySnapshotAssets(params) {
1600
1924
  var snapshotTime = firstPresentValue(params.order.updated_at, params.order.created_at);
1601
1925
  return params.snapshots.flatMap(function (virtualCurrency) {
1602
- var id = normalizeWalletPassId(virtualCurrency.id);
1603
- if (!id || params.displayedWalletPassIds.has(id)) return [];
1926
+ var assetId = normalizeWalletPassId(virtualCurrency.id);
1927
+ if (!assetId || !claimWalletAssetIdentity(params.displayedWalletAssetIdentities, {
1928
+ id: assetId,
1929
+ codes: []
1930
+ })) return [];
1604
1931
  var rows = [{
1605
1932
  item: stringify(virtualCurrency.product_name).trim(),
1606
1933
  value: ''
@@ -1635,8 +1962,8 @@ function getNonEmptyLocalizedValue(value, locale) {
1635
1962
  if (_typeof(value) !== 'object' || Array.isArray(value)) return stringify(value).trim();
1636
1963
  var dashedLocale = locale.replace('_', '-');
1637
1964
  var underscoredLocale = locale.replace('-', '_');
1638
- for (var _i7 = 0, _arr3 = [value[locale], value[dashedLocale], value[underscoredLocale], value.original, value.auto, value.default, value.en]; _i7 < _arr3.length; _i7++) {
1639
- var candidate = _arr3[_i7];
1965
+ for (var _i15 = 0, _arr9 = [value[locale], value[dashedLocale], value[underscoredLocale], value.original, value.auto, value.default, value.en]; _i15 < _arr9.length; _i15++) {
1966
+ var candidate = _arr9[_i15];
1640
1967
  var text = stringify(candidate).trim();
1641
1968
  if (text) return text;
1642
1969
  }
@@ -1652,6 +1979,66 @@ function normalizeWalletPassId(value) {
1652
1979
  if (typeof value !== 'string') return null;
1653
1980
  return value.trim() || null;
1654
1981
  }
1982
+ function firstNormalizedWalletAssetId() {
1983
+ for (var _len4 = arguments.length, values = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1984
+ values[_key4] = arguments[_key4];
1985
+ }
1986
+ for (var _i16 = 0, _values3 = values; _i16 < _values3.length; _i16++) {
1987
+ var value = _values3[_i16];
1988
+ var id = normalizeWalletPassId(value);
1989
+ if (id) return id;
1990
+ }
1991
+ return null;
1992
+ }
1993
+ function normalizeWalletAssetCodes() {
1994
+ for (var _len5 = arguments.length, values = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1995
+ values[_key5] = arguments[_key5];
1996
+ }
1997
+ return Array.from(new Set(values.map(function (value) {
1998
+ return normalizeWalletPassId(value);
1999
+ }).filter(function (value) {
2000
+ return !!value;
2001
+ })));
2002
+ }
2003
+ function registerWalletAssetIdentity(identities, candidate) {
2004
+ if (!candidate.id && !candidate.codes.length) return;
2005
+ var existing = identities.find(function (identity) {
2006
+ return isSameWalletAssetIdentity(identity, candidate);
2007
+ });
2008
+ if (existing) {
2009
+ mergeWalletAssetIdentity(existing, candidate);
2010
+ return;
2011
+ }
2012
+ identities.push({
2013
+ id: candidate.id,
2014
+ codes: _toConsumableArray(candidate.codes)
2015
+ });
2016
+ }
2017
+ function claimWalletAssetIdentity(identities, candidate) {
2018
+ if (!candidate.id && !candidate.codes.length) return true;
2019
+ var existing = identities.find(function (identity) {
2020
+ return isSameWalletAssetIdentity(identity, candidate);
2021
+ });
2022
+ if (existing) {
2023
+ mergeWalletAssetIdentity(existing, candidate);
2024
+ return false;
2025
+ }
2026
+ identities.push({
2027
+ id: candidate.id,
2028
+ codes: _toConsumableArray(candidate.codes)
2029
+ });
2030
+ return true;
2031
+ }
2032
+ function isSameWalletAssetIdentity(left, right) {
2033
+ if (left.id && right.id) return left.id === right.id;
2034
+ return left.codes.some(function (code) {
2035
+ return right.codes.includes(code);
2036
+ });
2037
+ }
2038
+ function mergeWalletAssetIdentity(target, source) {
2039
+ if (!target.id && source.id) target.id = source.id;
2040
+ target.codes = Array.from(new Set([].concat(_toConsumableArray(target.codes), _toConsumableArray(source.codes))));
2041
+ }
1655
2042
  function getPointCardSnapshotRemainingPoints(snapshot) {
1656
2043
  if (!isNumericAmount(snapshot.par_value) || !isNumericAmount(snapshot.used_par_value)) {
1657
2044
  return null;
@@ -1659,19 +2046,27 @@ function getPointCardSnapshotRemainingPoints(snapshot) {
1659
2046
  return Decimal.max(new Decimal(snapshot.par_value).minus(new Decimal(snapshot.used_par_value)), 0);
1660
2047
  }
1661
2048
  function buildVoucherAssets(params) {
1662
- var seenVoucherKeys = new Set();
1663
2049
  var fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
1664
- return normalizeArray(params.order.vouchers).flatMap(function (voucher, index) {
2050
+ return normalizeArray(params.order.vouchers).flatMap(function (voucher) {
1665
2051
  if (!voucher || _typeof(voucher) !== 'object' || Array.isArray(voucher)) return [];
1666
- var voucherKey = getVoucherAssetKey(voucher, index);
1667
- if (seenVoucherKeys.has(voucherKey)) return [];
1668
- seenVoucherKeys.add(voucherKey);
2052
+ if (!claimWalletAssetIdentity(params.displayedWalletAssetIdentities, getVoucherAssetIdentity(voucher))) return [];
1669
2053
  var name = getVoucherAssetName(voucher, params.locale);
1670
2054
  var assetTime = firstPresentValue(voucher.updated_at, voucher.created_at, voucher.collection_time, fallbackAssetTime);
1671
2055
  var timeRow = isPresentId(assetTime) ? {
1672
2056
  item: formatDateTime(assetTime, params.locale),
1673
2057
  value: ''
1674
2058
  } : null;
2059
+ if (isEntitlementVoucher(voucher)) {
2060
+ var _voucher$metadata;
2061
+ var remaining = getEntitlementBalance((_voucher$metadata = voucher.metadata) === null || _voucher$metadata === void 0 ? void 0 : _voucher$metadata.balance, voucher.balance);
2062
+ return [[{
2063
+ item: name,
2064
+ value: ''
2065
+ }].concat(_toConsumableArray(remaining ? [{
2066
+ item: label(params.locale, 'entitlementRemaining'),
2067
+ value: formatEntitlementUses(remaining, params.locale)
2068
+ }] : []), _toConsumableArray(timeRow ? [timeRow] : []))];
2069
+ }
1675
2070
  if (isTicketVoucher(voucher)) {
1676
2071
  var validity = getVoucherValidity(voucher, params.locale);
1677
2072
  return [[{
@@ -1700,19 +2095,24 @@ function buildVoucherAssets(params) {
1700
2095
  });
1701
2096
  }
1702
2097
  var TICKET_VOUCHER_TAGS = new Set(['ticket', 'product_package_ticket', 'appointment_ticket', 'session_ticket']);
2098
+ function isEntitlementVoucher(voucher) {
2099
+ return [voucher.tag, voucher.type].some(function (value) {
2100
+ return stringify(value).trim().toLowerCase() === 'entitlement_pass';
2101
+ });
2102
+ }
1703
2103
  function isTicketVoucher(voucher) {
1704
2104
  return TICKET_VOUCHER_TAGS.has(stringify(voucher.tag).trim().toLowerCase());
1705
2105
  }
1706
2106
  function getVoucherValidity(voucher, locale) {
1707
- var _voucher$metadata, _voucher$metadata2, _voucher$metadata3, _voucher$metadata4, _voucher$metadata5, _voucher$metadata6, _voucher$metadata7, _voucher$metadata8, _voucher$metadata9, _voucher$metadata10, _voucher$start_time, _voucher$metadata11, _voucher$end_time, _voucher$metadata12;
1708
- var availableTime = firstPresentValue(voucher.available_time, voucher.avaliable_time, (_voucher$metadata = voucher.metadata) === null || _voucher$metadata === void 0 ? void 0 : _voucher$metadata.available_time, (_voucher$metadata2 = voucher.metadata) === null || _voucher$metadata2 === void 0 ? void 0 : _voucher$metadata2.avaliable_time);
2107
+ var _voucher$metadata2, _voucher$metadata3, _voucher$metadata4, _voucher$metadata5, _voucher$metadata6, _voucher$metadata7, _voucher$metadata8, _voucher$metadata9, _voucher$metadata10, _voucher$metadata11, _voucher$start_time, _voucher$metadata12, _voucher$end_time, _voucher$metadata13;
2108
+ var availableTime = firstPresentValue(voucher.available_time, voucher.avaliable_time, (_voucher$metadata2 = voucher.metadata) === null || _voucher$metadata2 === void 0 ? void 0 : _voucher$metadata2.available_time, (_voucher$metadata3 = voucher.metadata) === null || _voucher$metadata3 === void 0 ? void 0 : _voucher$metadata3.avaliable_time);
1709
2109
  var availableTimeText = formatVoucherAvailableTime(availableTime, locale);
1710
2110
  if (availableTimeText) return availableTimeText;
1711
- var startDate = firstPresentValue(voucher.valid_from, voucher.start_at, voucher.start_date_time, voucher.start_date, (_voucher$metadata3 = voucher.metadata) === null || _voucher$metadata3 === void 0 ? void 0 : _voucher$metadata3.valid_from, (_voucher$metadata4 = voucher.metadata) === null || _voucher$metadata4 === void 0 ? void 0 : _voucher$metadata4.start_at, (_voucher$metadata5 = voucher.metadata) === null || _voucher$metadata5 === void 0 ? void 0 : _voucher$metadata5.start_date);
1712
- var endDate = firstPresentValue(voucher.valid_to, voucher.end_at, voucher.end_date_time, voucher.expire_date, voucher.end_date, voucher.expire_time, (_voucher$metadata6 = voucher.metadata) === null || _voucher$metadata6 === void 0 ? void 0 : _voucher$metadata6.valid_to, (_voucher$metadata7 = voucher.metadata) === null || _voucher$metadata7 === void 0 ? void 0 : _voucher$metadata7.end_at, (_voucher$metadata8 = voucher.metadata) === null || _voucher$metadata8 === void 0 ? void 0 : _voucher$metadata8.expire_date, (_voucher$metadata9 = voucher.metadata) === null || _voucher$metadata9 === void 0 ? void 0 : _voucher$metadata9.end_date, (_voucher$metadata10 = voucher.metadata) === null || _voucher$metadata10 === void 0 ? void 0 : _voucher$metadata10.expire_time);
2111
+ var startDate = firstPresentValue(voucher.valid_from, voucher.start_at, voucher.start_date_time, voucher.start_date, (_voucher$metadata4 = voucher.metadata) === null || _voucher$metadata4 === void 0 ? void 0 : _voucher$metadata4.valid_from, (_voucher$metadata5 = voucher.metadata) === null || _voucher$metadata5 === void 0 ? void 0 : _voucher$metadata5.start_at, (_voucher$metadata6 = voucher.metadata) === null || _voucher$metadata6 === void 0 ? void 0 : _voucher$metadata6.start_date);
2112
+ var endDate = firstPresentValue(voucher.valid_to, voucher.end_at, voucher.end_date_time, voucher.expire_date, voucher.end_date, voucher.expire_time, (_voucher$metadata7 = voucher.metadata) === null || _voucher$metadata7 === void 0 ? void 0 : _voucher$metadata7.valid_to, (_voucher$metadata8 = voucher.metadata) === null || _voucher$metadata8 === void 0 ? void 0 : _voucher$metadata8.end_at, (_voucher$metadata9 = voucher.metadata) === null || _voucher$metadata9 === void 0 ? void 0 : _voucher$metadata9.expire_date, (_voucher$metadata10 = voucher.metadata) === null || _voucher$metadata10 === void 0 ? void 0 : _voucher$metadata10.end_date, (_voucher$metadata11 = voucher.metadata) === null || _voucher$metadata11 === void 0 ? void 0 : _voucher$metadata11.expire_time);
1713
2113
  return formatVoucherValidityRange(startDate, endDate, locale, {
1714
- startTime: (_voucher$start_time = voucher.start_time) !== null && _voucher$start_time !== void 0 ? _voucher$start_time : (_voucher$metadata11 = voucher.metadata) === null || _voucher$metadata11 === void 0 ? void 0 : _voucher$metadata11.start_time,
1715
- endTime: (_voucher$end_time = voucher.end_time) !== null && _voucher$end_time !== void 0 ? _voucher$end_time : (_voucher$metadata12 = voucher.metadata) === null || _voucher$metadata12 === void 0 ? void 0 : _voucher$metadata12.end_time
2114
+ startTime: (_voucher$start_time = voucher.start_time) !== null && _voucher$start_time !== void 0 ? _voucher$start_time : (_voucher$metadata12 = voucher.metadata) === null || _voucher$metadata12 === void 0 ? void 0 : _voucher$metadata12.start_time,
2115
+ endTime: (_voucher$end_time = voucher.end_time) !== null && _voucher$end_time !== void 0 ? _voucher$end_time : (_voucher$metadata13 = voucher.metadata) === null || _voucher$metadata13 === void 0 ? void 0 : _voucher$metadata13.end_time
1716
2116
  });
1717
2117
  }
1718
2118
  function formatVoucherAvailableTime(value, locale) {
@@ -1778,16 +2178,18 @@ function formatVoucherValidityDate(value, locale) {
1778
2178
  text: time ? "".concat(time, " ").concat(date) : date
1779
2179
  };
1780
2180
  }
1781
- function getVoucherAssetKey(voucher, index) {
1782
- var identity = firstPresentValue(voucher.voucher_id, voucher.id, voucher.code, voucher.encoded);
1783
- return identity === undefined ? "voucher-index:".concat(index) : "voucher:".concat(String(identity));
2181
+ function getVoucherAssetIdentity(voucher) {
2182
+ return {
2183
+ id: firstNormalizedWalletAssetId(voucher.voucher_id, voucher.id),
2184
+ codes: normalizeWalletAssetCodes(voucher.code, voucher.encoded)
2185
+ };
1784
2186
  }
1785
2187
  function getVoucherAssetName(voucher, locale) {
1786
2188
  return getLocalizedValue(voucher.product_name || voucher.name || voucher.title, locale) || stringify(voucher.encoded || voucher.code || label(locale, 'giftCard'));
1787
2189
  }
1788
2190
  function getVoucherDiscountPercent(voucher) {
1789
- var _voucher$metadata13;
1790
- var discountType = stringify(((_voucher$metadata13 = voucher.metadata) === null || _voucher$metadata13 === void 0 ? void 0 : _voucher$metadata13.discount_card_type) || voucher.discount_card_type).toLowerCase();
2191
+ var _voucher$metadata14;
2192
+ var discountType = stringify(((_voucher$metadata14 = voucher.metadata) === null || _voucher$metadata14 === void 0 ? void 0 : _voucher$metadata14.discount_card_type) || voucher.discount_card_type).toLowerCase();
1791
2193
  if (discountType !== 'percent' && discountType !== 'percentage') return null;
1792
2194
  var percent = new Decimal(toMoneyNumber(voucher.par_value));
1793
2195
  if (!percent.isFinite() || percent.lte(0) || percent.gt(100)) return null;
@@ -1807,6 +2209,12 @@ function formatVoucherDiscount(percent, locale) {
1807
2209
  return normalizedLocale === 'en' ? "Discount ".concat(trimDecimal(percent), "% OFF") : "".concat(trimDecimal(percent), "% OFF");
1808
2210
  }
1809
2211
  function getVoucherBalance(voucher) {
2212
+ for (var _i17 = 0, _arr10 = [(_voucher$metadata15 = voucher.metadata) === null || _voucher$metadata15 === void 0 ? void 0 : _voucher$metadata15.balance, voucher.balance]; _i17 < _arr10.length; _i17++) {
2213
+ var _voucher$metadata15;
2214
+ var value = _arr10[_i17];
2215
+ if (!isNumericAmount(value)) continue;
2216
+ return Decimal.max(new Decimal(value), 0);
2217
+ }
1810
2218
  var parValue = new Decimal(toMoneyNumber(voucher.par_value));
1811
2219
  var usedParValue = new Decimal(toMoneyNumber(voucher.used_par_value));
1812
2220
  return Decimal.max(parValue.minus(usedParValue), 0);
@@ -2018,26 +2426,8 @@ function getLocalizedValue(value, locale) {
2018
2426
  var underscoredLocale = locale.replace('-', '_');
2019
2427
  return stringify((_ref60 = (_ref61 = (_ref62 = (_ref63 = (_ref64 = (_ref65 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref65 !== void 0 ? _ref65 : value[underscoredLocale]) !== null && _ref64 !== void 0 ? _ref64 : value.original) !== null && _ref63 !== void 0 ? _ref63 : value.auto) !== null && _ref62 !== void 0 ? _ref62 : value.default) !== null && _ref61 !== void 0 ? _ref61 : value.en) !== null && _ref60 !== void 0 ? _ref60 : '');
2020
2428
  }
2021
- function resolveServiceTypeLabelKey(serviceType, order) {
2022
- var normalized = serviceType.trim().toLowerCase().replace(/[\s-]+/g, '_');
2023
- if (['', 'nil', 'none', 'unknown'].includes(normalized)) return null;
2024
- if (['pickup', 'pick_up', 'self_pickup'].includes(normalized)) return 'pickUp';
2025
- if (['delivery', 'shipping', 'local_delivery'].includes(normalized)) return 'delivery';
2026
- if (['takeaway', 'take_away'].includes(normalized)) return 'takeAway';
2027
- if (['dine_in', 'dinein'].includes(normalized)) return 'dineIn';
2028
- if (['shop_service', 'shop_server'].includes(normalized)) {
2029
- return resolveShopServiceLabelKey(order);
2030
- }
2031
- return null;
2032
- }
2033
- function resolveShopServiceLabelKey(order) {
2034
- var _order$metadata15, _order$shop_service_t;
2035
- var rawShopServiceType = firstPresentValue((_order$metadata15 = order.metadata) === null || _order$metadata15 === void 0 || (_order$metadata15 = _order$metadata15.shop_service_type) === null || _order$metadata15 === void 0 ? void 0 : _order$metadata15.server_type, (_order$shop_service_t = order.shop_service_type) === null || _order$shop_service_t === void 0 ? void 0 : _order$shop_service_t.server_type, typeof order.shop_service_type === 'string' ? order.shop_service_type : undefined);
2036
- if (!isPresentId(rawShopServiceType)) return 'dineIn';
2037
- var normalized = stringify(rawShopServiceType).trim().toLowerCase().replace(/[\s-]+/g, '_');
2038
- if (['takeaway', 'take_away'].includes(normalized)) return 'takeAway';
2039
- if (['dine_in', 'dinein'].includes(normalized)) return 'dineIn';
2040
- return null;
2429
+ function resolveServiceTypeLabelKey(serviceType) {
2430
+ return SERVICE_TYPE_LABEL_KEYS[serviceType] || null;
2041
2431
  }
2042
2432
  function normalizeBooleanFlag(value) {
2043
2433
  if (value === true || value === 1 || stringify(value).trim() === '1') return 1;