@commercelayer/react-components 4.9.0-beta.3 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/lib/cjs/components/MetadataInput.d.ts +0 -1
  2. package/lib/cjs/components/addresses/Address.d.ts +0 -1
  3. package/lib/cjs/components/addresses/Address.js +1 -1
  4. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +0 -1
  5. package/lib/cjs/components/addresses/AddressInput.d.ts +0 -1
  6. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +0 -1
  7. package/lib/cjs/components/addresses/AddressStateSelector.js +1 -1
  8. package/lib/cjs/components/addresses/AddressesEmpty.d.ts +0 -1
  9. package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +0 -1
  10. package/lib/cjs/components/auth/CommerceLayer.d.ts +0 -1
  11. package/lib/cjs/components/auth/CommerceLayer.js +1 -1
  12. package/lib/cjs/components/customers/CustomerContainer.d.ts +0 -1
  13. package/lib/cjs/components/customers/CustomerField.d.ts +0 -1
  14. package/lib/cjs/components/customers/CustomerInput.d.ts +0 -1
  15. package/lib/cjs/components/customers/CustomerInput.js +1 -1
  16. package/lib/cjs/components/customers/CustomerPaymentSource.d.ts +0 -1
  17. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.d.ts +0 -1
  18. package/lib/cjs/components/customers/MyAccountLink.d.ts +0 -1
  19. package/lib/cjs/components/customers/MyAccountLink.js +1 -1
  20. package/lib/cjs/components/customers/MyIdentityLink.d.ts +0 -1
  21. package/lib/cjs/components/customers/SaveCustomerButton.js +1 -1
  22. package/lib/cjs/components/errors/Errors.d.ts +0 -1
  23. package/lib/cjs/components/gift_cards/GiftCard.d.ts +0 -1
  24. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -1
  25. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +0 -1
  26. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +0 -1
  27. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +0 -1
  28. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +0 -1
  29. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +0 -1
  30. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.js +1 -1
  31. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +0 -1
  32. package/lib/cjs/components/line_items/LineItem.d.ts +0 -1
  33. package/lib/cjs/components/line_items/LineItemAmount.d.ts +0 -1
  34. package/lib/cjs/components/line_items/LineItemCode.d.ts +0 -1
  35. package/lib/cjs/components/line_items/LineItemField.d.ts +0 -1
  36. package/lib/cjs/components/line_items/LineItemImage.d.ts +0 -1
  37. package/lib/cjs/components/line_items/LineItemName.d.ts +0 -1
  38. package/lib/cjs/components/line_items/LineItemsContainer.d.ts +0 -1
  39. package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
  40. package/lib/cjs/components/line_items/LineItemsCount.d.ts +0 -1
  41. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +0 -1
  42. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +0 -1
  43. package/lib/cjs/components/orders/CheckoutLink.d.ts +0 -1
  44. package/lib/cjs/components/orders/DiscountAmount.d.ts +0 -1
  45. package/lib/cjs/components/orders/GiftCardAmount.d.ts +0 -1
  46. package/lib/cjs/components/orders/HostedCart.js +1 -1
  47. package/lib/cjs/components/orders/OrderContainer.d.ts +0 -1
  48. package/lib/cjs/components/orders/OrderList.d.ts +0 -1
  49. package/lib/cjs/components/orders/OrderListEmpty.d.ts +0 -1
  50. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +0 -1
  51. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +0 -1
  52. package/lib/cjs/components/orders/OrderListRow.d.ts +0 -1
  53. package/lib/cjs/components/orders/OrderNumber.d.ts +0 -1
  54. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +0 -1
  55. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -1
  56. package/lib/cjs/components/orders/ShippingAmount.d.ts +0 -1
  57. package/lib/cjs/components/orders/SubTotalAmount.d.ts +0 -1
  58. package/lib/cjs/components/orders/TaxesAmount.d.ts +0 -1
  59. package/lib/cjs/components/orders/TotalAmount.d.ts +0 -1
  60. package/lib/cjs/components/parcels/ParcelField.d.ts +0 -1
  61. package/lib/cjs/components/parcels/ParcelLineItem.d.ts +0 -1
  62. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +0 -1
  63. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +0 -1
  64. package/lib/cjs/components/parcels/Parcels.d.ts +0 -1
  65. package/lib/cjs/components/parcels/ParcelsCount.d.ts +0 -1
  66. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +0 -1
  67. package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -1
  68. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +0 -1
  69. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +0 -1
  70. package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +0 -1
  71. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +0 -1
  72. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +0 -1
  73. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +0 -1
  74. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +0 -1
  75. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +0 -1
  76. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +0 -1
  77. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +0 -1
  78. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +0 -1
  79. package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -1
  80. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +0 -1
  81. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +0 -1
  82. package/lib/cjs/components/payment_source/ExternalPayment.d.ts +0 -1
  83. package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +0 -1
  84. package/lib/cjs/components/payment_source/PaymentSource.d.ts +0 -1
  85. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +0 -1
  86. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +0 -1
  87. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +0 -1
  88. package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +0 -1
  89. package/lib/cjs/components/payment_source/StripeExpressPayment.js +1 -1
  90. package/lib/cjs/components/payment_source/StripePayment.d.ts +0 -1
  91. package/lib/cjs/components/payment_source/StripePayment.js +1 -1
  92. package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +0 -1
  93. package/lib/cjs/components/prices/Price.d.ts +0 -1
  94. package/lib/cjs/components/prices/Price.js +1 -1
  95. package/lib/cjs/components/prices/PricesContainer.d.ts +0 -1
  96. package/lib/cjs/components/shipments/ShipmentField.d.ts +0 -1
  97. package/lib/cjs/components/shipments/ShipmentsCount.d.ts +0 -1
  98. package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -1
  99. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +0 -1
  100. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +0 -1
  101. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -1
  102. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +0 -1
  103. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +0 -1
  104. package/lib/cjs/components/skus/SkuField.d.ts +0 -1
  105. package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +0 -1
  106. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +0 -1
  107. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +0 -1
  108. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +0 -1
  109. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +0 -1
  110. package/lib/cjs/components/utils/PriceTemplate.d.ts +2 -3
  111. package/lib/cjs/components/utils/getAllErrors.d.ts +0 -1
  112. package/lib/cjs/components/utils/getAllErrors.js +1 -1
  113. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  114. package/lib/cjs/reducers/GiftCardReducer.js +1 -1
  115. package/lib/cjs/reducers/OrderReducer.js +1 -1
  116. package/lib/cjs/typings/globals.d.ts +0 -1
  117. package/lib/cjs/utils/filterChildren.d.ts +0 -1
  118. package/lib/cjs/utils/getCustomerIdByToken.js +1 -1
  119. package/lib/cjs/utils/getDomain.js +1 -1
  120. package/lib/cjs/utils/getLoaderComponent.d.ts +0 -1
  121. package/lib/cjs/utils/getPrices.d.ts +0 -1
  122. package/lib/cjs/utils/getPrices.js +1 -1
  123. package/lib/cjs/utils/isGuestToken.js +1 -1
  124. package/lib/cjs/utils/jwt.d.ts +1 -1
  125. package/lib/cjs/utils/jwt.js +1 -1
  126. package/lib/esm/components/MetadataInput.d.ts +0 -1
  127. package/lib/esm/components/addresses/Address.d.ts +0 -1
  128. package/lib/esm/components/addresses/Address.js +1 -1
  129. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +0 -1
  130. package/lib/esm/components/addresses/AddressInput.d.ts +0 -1
  131. package/lib/esm/components/addresses/AddressStateSelector.d.ts +0 -1
  132. package/lib/esm/components/addresses/AddressStateSelector.js +1 -1
  133. package/lib/esm/components/addresses/AddressesEmpty.d.ts +0 -1
  134. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +0 -1
  135. package/lib/esm/components/auth/CommerceLayer.d.ts +0 -1
  136. package/lib/esm/components/auth/CommerceLayer.js +1 -1
  137. package/lib/esm/components/customers/CustomerContainer.d.ts +0 -1
  138. package/lib/esm/components/customers/CustomerField.d.ts +0 -1
  139. package/lib/esm/components/customers/CustomerInput.d.ts +0 -1
  140. package/lib/esm/components/customers/CustomerInput.js +1 -1
  141. package/lib/esm/components/customers/CustomerPaymentSource.d.ts +0 -1
  142. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +0 -1
  143. package/lib/esm/components/customers/MyAccountLink.d.ts +0 -1
  144. package/lib/esm/components/customers/MyAccountLink.js +1 -1
  145. package/lib/esm/components/customers/MyIdentityLink.d.ts +0 -1
  146. package/lib/esm/components/customers/SaveCustomerButton.js +1 -1
  147. package/lib/esm/components/errors/Errors.d.ts +0 -1
  148. package/lib/esm/components/gift_cards/GiftCard.d.ts +0 -1
  149. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -1
  150. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +0 -1
  151. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +0 -1
  152. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +0 -1
  153. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +0 -1
  154. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +0 -1
  155. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.js +1 -1
  156. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +0 -1
  157. package/lib/esm/components/line_items/LineItem.d.ts +0 -1
  158. package/lib/esm/components/line_items/LineItemAmount.d.ts +0 -1
  159. package/lib/esm/components/line_items/LineItemCode.d.ts +0 -1
  160. package/lib/esm/components/line_items/LineItemField.d.ts +0 -1
  161. package/lib/esm/components/line_items/LineItemImage.d.ts +0 -1
  162. package/lib/esm/components/line_items/LineItemName.d.ts +0 -1
  163. package/lib/esm/components/line_items/LineItemsContainer.d.ts +0 -1
  164. package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
  165. package/lib/esm/components/line_items/LineItemsCount.d.ts +0 -1
  166. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +0 -1
  167. package/lib/esm/components/orders/AdjustmentAmount.d.ts +0 -1
  168. package/lib/esm/components/orders/CheckoutLink.d.ts +0 -1
  169. package/lib/esm/components/orders/DiscountAmount.d.ts +0 -1
  170. package/lib/esm/components/orders/GiftCardAmount.d.ts +0 -1
  171. package/lib/esm/components/orders/HostedCart.js +1 -1
  172. package/lib/esm/components/orders/OrderContainer.d.ts +0 -1
  173. package/lib/esm/components/orders/OrderList.d.ts +0 -1
  174. package/lib/esm/components/orders/OrderListEmpty.d.ts +0 -1
  175. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +0 -1
  176. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +0 -1
  177. package/lib/esm/components/orders/OrderListRow.d.ts +0 -1
  178. package/lib/esm/components/orders/OrderNumber.d.ts +0 -1
  179. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +0 -1
  180. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -1
  181. package/lib/esm/components/orders/ShippingAmount.d.ts +0 -1
  182. package/lib/esm/components/orders/SubTotalAmount.d.ts +0 -1
  183. package/lib/esm/components/orders/TaxesAmount.d.ts +0 -1
  184. package/lib/esm/components/orders/TotalAmount.d.ts +0 -1
  185. package/lib/esm/components/parcels/ParcelField.d.ts +0 -1
  186. package/lib/esm/components/parcels/ParcelLineItem.d.ts +0 -1
  187. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +0 -1
  188. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +0 -1
  189. package/lib/esm/components/parcels/Parcels.d.ts +0 -1
  190. package/lib/esm/components/parcels/ParcelsCount.d.ts +0 -1
  191. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +0 -1
  192. package/lib/esm/components/payment_gateways/AdyenGateway.js +1 -1
  193. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +0 -1
  194. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +0 -1
  195. package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +0 -1
  196. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +0 -1
  197. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +0 -1
  198. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +0 -1
  199. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +0 -1
  200. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +0 -1
  201. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +0 -1
  202. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +0 -1
  203. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +0 -1
  204. package/lib/esm/components/payment_methods/PaymentMethodRadioButton.js +1 -1
  205. package/lib/esm/components/payment_source/BraintreePayment.d.ts +0 -1
  206. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +0 -1
  207. package/lib/esm/components/payment_source/ExternalPayment.d.ts +0 -1
  208. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +0 -1
  209. package/lib/esm/components/payment_source/PaymentSource.d.ts +0 -1
  210. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +0 -1
  211. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +0 -1
  212. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +0 -1
  213. package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +0 -1
  214. package/lib/esm/components/payment_source/StripeExpressPayment.js +1 -1
  215. package/lib/esm/components/payment_source/StripePayment.d.ts +0 -1
  216. package/lib/esm/components/payment_source/StripePayment.js +1 -1
  217. package/lib/esm/components/payment_source/WireTransferPayment.d.ts +0 -1
  218. package/lib/esm/components/prices/Price.d.ts +0 -1
  219. package/lib/esm/components/prices/Price.js +1 -1
  220. package/lib/esm/components/prices/PricesContainer.d.ts +0 -1
  221. package/lib/esm/components/shipments/ShipmentField.d.ts +0 -1
  222. package/lib/esm/components/shipments/ShipmentsCount.d.ts +0 -1
  223. package/lib/esm/components/shipping_methods/ShippingMethod.js +1 -1
  224. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +0 -1
  225. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +0 -1
  226. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -1
  227. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +0 -1
  228. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +0 -1
  229. package/lib/esm/components/skus/SkuField.d.ts +0 -1
  230. package/lib/esm/components/stock_transfers/StockTransfer.d.ts +0 -1
  231. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +0 -1
  232. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +0 -1
  233. package/lib/esm/components/utils/BaseOrderPrice.d.ts +0 -1
  234. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +0 -1
  235. package/lib/esm/components/utils/PriceTemplate.d.ts +2 -3
  236. package/lib/esm/components/utils/getAllErrors.d.ts +0 -1
  237. package/lib/esm/components/utils/getAllErrors.js +1 -1
  238. package/lib/esm/reducers/CustomerReducer.js +1 -1
  239. package/lib/esm/reducers/GiftCardReducer.js +1 -1
  240. package/lib/esm/reducers/OrderReducer.js +1 -1
  241. package/lib/esm/typings/globals.d.ts +0 -1
  242. package/lib/esm/utils/filterChildren.d.ts +0 -1
  243. package/lib/esm/utils/getCustomerIdByToken.js +1 -1
  244. package/lib/esm/utils/getDomain.js +1 -1
  245. package/lib/esm/utils/getLoaderComponent.d.ts +0 -1
  246. package/lib/esm/utils/getPrices.d.ts +0 -1
  247. package/lib/esm/utils/getPrices.js +1 -1
  248. package/lib/esm/utils/isGuestToken.js +1 -1
  249. package/lib/esm/utils/jwt.d.ts +1 -1
  250. package/lib/esm/utils/jwt.js +1 -1
  251. package/package.json +30 -30
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function KlarnaGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type LoaderType } from '../../typings/index';
3
2
  import { type PaymentSourceProps } from '../payment_source/PaymentSource';
4
3
  export type GatewayBaseType = Props & {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = Partial<GatewayBaseType>;
4
3
  export declare function PaypalGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function StripeGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function WireTransferGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { LoaderType } from '../../typings/index';
3
2
  import type { Order, PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
4
3
  import type { PaymentResource } from '../../reducers/PaymentMethodReducer';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ChildrenFunction } from '../../typings/index';
3
2
  interface ChildrenProps extends Omit<Props, 'children'> {
4
3
  labelName: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type BaseAmountComponent } from '../../typings/index';
3
2
  interface Props extends BaseAmountComponent {
4
3
  type?: 'amount';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaymentMethodRadioButton=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function PaymentMethodRadioButton(props){const{onChange}=props,p=tslib_1.__rest(props,["onChange"]),{payment,paymentSelected,setPaymentSelected,clickableContainer}=(0,useCustomContext_1.default)({context:PaymentMethodChildrenContext_1.default,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodRadioButton",key:"payment"}),{order}=(0,react_1.useContext)(OrderContext_1.default),{setPaymentMethod,setLoading}=(0,react_1.useContext)(PaymentMethodContext_1.default),orderId=order?.id||"",paymentResource=payment?.payment_source_type,paymentMethodId=payment?.id,name=`payment-${orderId}`,checked=paymentSelected===payment?.id,handleOnChange=e=>tslib_1.__awaiter(this,void 0,void 0,function*(){if(e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer){const{order:order2}=yield setPaymentMethod({paymentResource,paymentMethodId});onChange&&onChange({payment,order:order2})}setLoading({loading:!1})}),id=payment?.payment_source_type,parentProps=Object.assign({handleOnChange,checked,id,name},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):(0,jsx_runtime_1.jsx)("input",Object.assign({title:name,type:"radio",id,onChange:e=>{handleOnChange(e)},checked},p))}exports.PaymentMethodRadioButton=PaymentMethodRadioButton,exports.default=PaymentMethodRadioButton;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaymentMethodRadioButton=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function PaymentMethodRadioButton(props){var _a;const{onChange}=props,p=tslib_1.__rest(props,["onChange"]),{payment,paymentSelected,setPaymentSelected,clickableContainer}=(0,useCustomContext_1.default)({context:PaymentMethodChildrenContext_1.default,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodRadioButton",key:"payment"}),{order}=(0,react_1.useContext)(OrderContext_1.default),{setPaymentMethod,setLoading}=(0,react_1.useContext)(PaymentMethodContext_1.default),orderId=order?.id||"",paymentResource=payment?.payment_source_type,paymentMethodId=(_a=payment?.id)!==null&&_a!==void 0?_a:"",name=`payment-${orderId}`,checked=paymentSelected===payment?.id,handleOnChange=e=>tslib_1.__awaiter(this,void 0,void 0,function*(){if(e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer){const{order:order2}=yield setPaymentMethod({paymentResource,paymentMethodId});onChange&&onChange({payment,order:order2})}setLoading({loading:!1})}),id=payment?.payment_source_type,parentProps=Object.assign({handleOnChange,checked,id,name},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):(0,jsx_runtime_1.jsx)("input",Object.assign({title:name,type:"radio",id,onChange:e=>{handleOnChange(e)},checked},p))}exports.PaymentMethodRadioButton=PaymentMethodRadioButton,exports.default=PaymentMethodRadioButton;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PaymentSourceProps } from './PaymentSource';
3
2
  import { type HostedFieldFieldOptions } from 'braintree-web';
4
3
  type BraintreeHostedFields<Type> = {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
3
2
  import { type PaymentSourceProps } from './PaymentSource';
4
3
  import { type FramesStyle } from 'frames-react';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ChildrenFunction } from '../../typings/index';
3
2
  import type { StripeElementLocale } from '@stripe/stripe-js';
4
3
  import { type PaymentSourceProps } from './PaymentSource';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
3
2
  import { type PaymentSourceProps } from './PaymentSource';
4
3
  type KlarnaPaymentProps = PaymentMethodConfig['klarnaPayment'] & JSX.IntrinsicElements['div'] & Partial<PaymentSourceProps['templateCustomerSaveToWallet']> & {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type LoaderType } from '../../typings/index';
3
2
  import { type CustomerCardsTemplateChildren } from '../utils/PaymentCardsTemplate';
4
3
  export interface CustomerCardsProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type IconBrand } from '../../context/PaymentSourceContext';
3
2
  import { type ChildrenFunction } from '../../typings/index';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type IconBrand } from '../../context/PaymentSourceContext';
3
2
  import { type ChildrenFunction } from '../../typings/index';
4
3
  interface CustomComponent extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ChildrenFunction } from '../../typings/index';
3
2
  export type PaymentSourceDetailType = 'last4' | 'exp_year' | 'exp_month';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  clientSecret: string;
4
3
  }
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StripeExpressPayment=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),expressPaymentHelper_1=require("../../utils/expressPaymentHelper"),isEmpty_1=require("../../utils/isEmpty"),react_stripe_js_1=require("@stripe/react-stripe-js"),react_1=require("react");function StripeExpressPayment({clientSecret}){const stripe=(0,react_stripe_js_1.useStripe)(),[paymentRequest,setPaymentRequest]=(0,react_1.useState)(null),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),{paymentMethods,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default);return(0,react_1.useEffect)(()=>{var _a,_b,_c,_d,_e;if(stripe==null||order==null)return;const pr=stripe.paymentRequest({country:(_a=order?.country_code)!==null&&_a!==void 0?_a:"US",currency:(_c=(_b=order?.currency_code)===null||_b===void 0?void 0:_b.toLowerCase())!==null&&_c!==void 0?_c:"",total:{label:`#${(_d=order?.number)!==null&&_d!==void 0?_d:""}`,amount:(_e=order?.total_amount_with_taxes_cents)!==null&&_e!==void 0?_e:0},requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:!0,requestShipping:!0});pr.canMakePayment().then(result=>{result&&setPaymentRequest(pr)}).catch(err=>{console.error("Can make payment:",err)})},[(0,isEmpty_1.isEmpty)(stripe),(0,isEmpty_1.isEmpty)(order)]),paymentRequest!=null&&stripe!=null?(paymentRequest.on("shippingaddresschange",ev=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_e,_f,_g;if(order!=null&&accessToken!=null&&endpoint!=null){const requiresBillingInfo=(_a=order?.requires_billing_info)!==null&&_a!==void 0?_a:!1,orderWithShipments=yield(0,expressPaymentHelper_1.setExpressFakeAddress)({orderId:order.id,config:{accessToken,endpoint},address:{first_name:"Fake name",last_name:"Fake lastname",country_code:(_b=ev.shippingAddress.country)!==null&&_b!==void 0?_b:"",line_1:"Fake street 123",city:(_c=ev.shippingAddress.city)!==null&&_c!==void 0?_c:"Fake city",zip_code:(_d=ev.shippingAddress.postalCode)!==null&&_d!==void 0?_d:"12345",state_code:(_e=ev.shippingAddress.region)!==null&&_e!==void 0?_e:"Fake state",phone:"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0}}),shippingOptions=(0,expressPaymentHelper_1.getExpressShippingMethods)(orderWithShipments);shippingOptions!=null&&!(0,isEmpty_1.isEmpty)(shippingOptions)?ev.updateWith({status:"success",shippingOptions,total:{label:`#${(_f=orderWithShipments?.number)!==null&&_f!==void 0?_f:""}`,amount:(_g=orderWithShipments?.total_amount_with_taxes_cents)!==null&&_g!==void 0?_g:0}}):ev.updateWith({status:"invalid_shipping_address"})}else ev.updateWith({status:"fail"})})),paymentRequest.on("shippingoptionchange",ev=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _h,_j;if(order!=null&&accessToken!=null&&endpoint!=null){const updatedOrder=yield(0,expressPaymentHelper_1.setExpressShippingMethod)({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev.shippingOption.id,params:{include:["shipments.available_shipping_methods"]}});ev.updateWith({status:"success",total:{label:`#${(_h=updatedOrder?.number)!==null&&_h!==void 0?_h:""}`,amount:(_j=updatedOrder?.total_amount_with_taxes_cents)!==null&&_j!==void 0?_j:0}})}else ev.updateWith({status:"fail"})})),paymentRequest.on("paymentmethod",ev=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _k,_l,_m,_o,_p,_q,_r,_s,_t,_u,_v,_w,_x,_y,_z,_0;if(order?.id==null)throw new Error("Order is null");if(paymentMethods==null)throw new Error("Payment methods are null");const[paymentMethod]=(0,expressPaymentHelper_1.getAvailableExpressPayments)(paymentMethods);if(paymentMethod==null)throw new Error("Payment method is null");if(paymentSource==null)throw new Error("Payment source is null");const requiresBillingInfo=(_k=order?.requires_billing_info)!==null&&_k!==void 0?_k:!1,paymentResource=paymentMethod?.payment_source_type;if(accessToken!=null&&endpoint!=null){const[firstName,lastName]=(_m=(_l=ev.payerName)===null||_l===void 0?void 0:_l.split(" "))!==null&&_m!==void 0?_m:[],[line]=(_p=(_o=ev.shippingAddress)===null||_o===void 0?void 0:_o.addressLine)!==null&&_p!==void 0?_p:"",email=(_q=ev.payerEmail)!==null&&_q!==void 0?_q:"";yield(0,expressPaymentHelper_1.setExpressFakeAddress)({orderId:order.id,config:{accessToken,endpoint},address:{first_name:firstName??"Fake name",last_name:lastName??"Fake lastname",country_code:(_s=(_r=ev?.shippingAddress)===null||_r===void 0?void 0:_r.country)!==null&&_s!==void 0?_s:"",line_1:line??"Fake street 123",city:(_u=(_t=ev?.shippingAddress)===null||_t===void 0?void 0:_t.city)!==null&&_u!==void 0?_u:"Fake city",zip_code:(_w=(_v=ev?.shippingAddress)===null||_v===void 0?void 0:_v.postalCode)!==null&&_w!==void 0?_w:"12345",state_code:(_y=(_x=ev?.shippingAddress)===null||_x===void 0?void 0:_x.region)!==null&&_y!==void 0?_y:"Fake state",phone:(_z=ev?.payerPhone)!==null&&_z!==void 0?_z:"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0},email}),yield(0,expressPaymentHelper_1.setExpressShippingMethod)({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:(_0=ev?.shippingOption)===null||_0===void 0?void 0:_0.id,params:{include:["shipments.available_shipping_methods"]}});const placeOrderParams={config:{accessToken,endpoint},orderId:order?.id,paymentResource,paymentSourceId:paymentSource?.id};yield(0,expressPaymentHelper_1.setExpressPlaceOrder)(placeOrderParams);const{paymentIntent,error:confirmError}=yield stripe.confirmCardPayment(clientSecret,{payment_method:ev.paymentMethod.id},{handleActions:!1});if(confirmError)ev.complete("fail"),console.error("Confirm card payment:",confirmError);else if(ev.complete("success"),paymentIntent.status==="requires_action"){const{error}=yield stripe.confirmCardPayment(clientSecret);if(error)console.error("Confirm card payment:",error);else{const placeOrderParams2={config:{accessToken,endpoint},orderId:order?.id,placeTheOrder:!0};try{const order2=yield(0,expressPaymentHelper_1.setExpressPlaceOrder)(placeOrderParams2);ev.complete("success"),(0,expressPaymentHelper_1.expressRedirectUrl)({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}else{const placeOrderParams2={config:{accessToken,endpoint},orderId:order?.id,placeTheOrder:!0};try{const order2=yield(0,expressPaymentHelper_1.setExpressPlaceOrder)(placeOrderParams2);ev.complete("success"),(0,expressPaymentHelper_1.expressRedirectUrl)({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}})),(0,jsx_runtime_1.jsx)(react_stripe_js_1.PaymentRequestButtonElement,{className:"",options:{paymentRequest}})):null}exports.StripeExpressPayment=StripeExpressPayment;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StripeExpressPayment=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),expressPaymentHelper_1=require("../../utils/expressPaymentHelper"),isEmpty_1=require("../../utils/isEmpty"),react_stripe_js_1=require("@stripe/react-stripe-js"),react_1=require("react");function StripeExpressPayment({clientSecret}){const stripe=(0,react_stripe_js_1.useStripe)(),[paymentRequest,setPaymentRequest]=(0,react_1.useState)(null),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),{paymentMethods,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default);return(0,react_1.useEffect)(()=>{var _a,_b,_c,_d,_e;if(stripe==null||order==null)return;const pr=stripe.paymentRequest({country:(_a=order?.country_code)!==null&&_a!==void 0?_a:"US",currency:(_c=(_b=order?.currency_code)===null||_b===void 0?void 0:_b.toLowerCase())!==null&&_c!==void 0?_c:"",total:{label:`#${(_d=order?.number)!==null&&_d!==void 0?_d:""}`,amount:(_e=order?.total_amount_with_taxes_cents)!==null&&_e!==void 0?_e:0},requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:!0,requestShipping:!0});pr.canMakePayment().then(result=>{result&&setPaymentRequest(pr)}).catch(err=>{console.error("Can make payment:",err)})},[(0,isEmpty_1.isEmpty)(stripe),(0,isEmpty_1.isEmpty)(order)]),paymentRequest!=null&&stripe!=null?(paymentRequest.on("shippingaddresschange",ev=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_e,_f,_g;if(order!=null&&accessToken!=null&&endpoint!=null){const requiresBillingInfo=(_a=order?.requires_billing_info)!==null&&_a!==void 0?_a:!1,orderWithShipments=yield(0,expressPaymentHelper_1.setExpressFakeAddress)({orderId:order.id,config:{accessToken,endpoint},address:{first_name:"Fake name",last_name:"Fake lastname",country_code:(_b=ev.shippingAddress.country)!==null&&_b!==void 0?_b:"",line_1:"Fake street 123",city:(_c=ev.shippingAddress.city)!==null&&_c!==void 0?_c:"Fake city",zip_code:(_d=ev.shippingAddress.postalCode)!==null&&_d!==void 0?_d:"12345",state_code:(_e=ev.shippingAddress.region)!==null&&_e!==void 0?_e:"Fake state",phone:"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0}}),shippingOptions=(0,expressPaymentHelper_1.getExpressShippingMethods)(orderWithShipments);shippingOptions!=null&&!(0,isEmpty_1.isEmpty)(shippingOptions)?ev.updateWith({status:"success",shippingOptions,total:{label:`#${(_f=orderWithShipments?.number)!==null&&_f!==void 0?_f:""}`,amount:(_g=orderWithShipments?.total_amount_with_taxes_cents)!==null&&_g!==void 0?_g:0}}):ev.updateWith({status:"invalid_shipping_address"})}else ev.updateWith({status:"fail"})})),paymentRequest.on("shippingoptionchange",ev=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _h,_j;if(order!=null&&accessToken!=null&&endpoint!=null){const updatedOrder=yield(0,expressPaymentHelper_1.setExpressShippingMethod)({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev.shippingOption.id,params:{include:["shipments.available_shipping_methods"]}});ev.updateWith({status:"success",total:{label:`#${(_h=updatedOrder?.number)!==null&&_h!==void 0?_h:""}`,amount:(_j=updatedOrder?.total_amount_with_taxes_cents)!==null&&_j!==void 0?_j:0}})}else ev.updateWith({status:"fail"})})),paymentRequest.on("paymentmethod",ev=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _k,_l,_m,_o,_p,_q,_r,_s,_t,_u,_v,_w,_x,_y,_z,_0;if(order?.id==null)throw new Error("Order is null");if(paymentMethods==null)throw new Error("Payment methods are null");const[paymentMethod]=(0,expressPaymentHelper_1.getAvailableExpressPayments)(paymentMethods);if(paymentMethod==null)throw new Error("Payment method is null");if(paymentSource==null)throw new Error("Payment source is null");const requiresBillingInfo=(_k=order?.requires_billing_info)!==null&&_k!==void 0?_k:!1,paymentResource=paymentMethod?.payment_source_type;if(accessToken!=null&&endpoint!=null){const[firstName,lastName]=(_m=(_l=ev.payerName)===null||_l===void 0?void 0:_l.split(" "))!==null&&_m!==void 0?_m:[],[line]=(_p=(_o=ev.shippingAddress)===null||_o===void 0?void 0:_o.addressLine)!==null&&_p!==void 0?_p:"",email=(_q=ev.payerEmail)!==null&&_q!==void 0?_q:"";yield(0,expressPaymentHelper_1.setExpressFakeAddress)({orderId:order.id,config:{accessToken,endpoint},address:{first_name:firstName??"Fake name",last_name:lastName??"Fake lastname",country_code:(_s=(_r=ev?.shippingAddress)===null||_r===void 0?void 0:_r.country)!==null&&_s!==void 0?_s:"",line_1:line??"Fake street 123",city:(_u=(_t=ev?.shippingAddress)===null||_t===void 0?void 0:_t.city)!==null&&_u!==void 0?_u:"Fake city",zip_code:(_w=(_v=ev?.shippingAddress)===null||_v===void 0?void 0:_v.postalCode)!==null&&_w!==void 0?_w:"12345",state_code:(_y=(_x=ev?.shippingAddress)===null||_x===void 0?void 0:_x.region)!==null&&_y!==void 0?_y:"Fake state",phone:(_z=ev?.payerPhone)!==null&&_z!==void 0?_z:"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0},email}),yield(0,expressPaymentHelper_1.setExpressShippingMethod)({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:(_0=ev?.shippingOption)===null||_0===void 0?void 0:_0.id,params:{include:["shipments.available_shipping_methods"]}});const placeOrderParams={config:{accessToken,endpoint},orderId:order?.id,paymentResource,paymentSourceId:paymentSource?.id};yield(0,expressPaymentHelper_1.setExpressPlaceOrder)(placeOrderParams);const{paymentIntent,error:confirmError}=yield stripe.confirmCardPayment(clientSecret,{payment_method:ev.paymentMethod.id},{handleActions:!1});if(confirmError)ev.complete("fail"),console.error("Confirm card payment:",confirmError);else if(ev.complete("success"),paymentIntent.status==="requires_action"){const{error}=yield stripe.confirmCardPayment(clientSecret);if(error)console.error("Confirm card payment:",error);else{const placeOrderParams2={config:{accessToken,endpoint},orderId:order?.id,placeTheOrder:!0};try{const order2=yield(0,expressPaymentHelper_1.setExpressPlaceOrder)(placeOrderParams2);ev.complete("success"),(0,expressPaymentHelper_1.expressRedirectUrl)({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}else{const placeOrderParams2={config:{accessToken,endpoint},orderId:order?.id,placeTheOrder:!0};try{const order2=yield(0,expressPaymentHelper_1.setExpressPlaceOrder)(placeOrderParams2);ev.complete("success"),(0,expressPaymentHelper_1.expressRedirectUrl)({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}})),(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:(0,jsx_runtime_1.jsx)(react_stripe_js_1.PaymentRequestButtonElement,{className:"",options:{paymentRequest}})})):null}exports.StripeExpressPayment=StripeExpressPayment;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type StripeElementLocale, type StripeElementsOptions, type StripePaymentElementOptions } from '@stripe/stripe-js';
3
2
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
4
3
  import { type PaymentSourceProps } from './PaymentSource';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StripePayment=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),react_stripe_js_1=require("@stripe/react-stripe-js"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),localStorage_1=require("../../utils/localStorage"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),StripeExpressPayment_1=require("./StripeExpressPayment"),defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet}){const ref=(0,react_1.useRef)(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=(0,react_1.useContext)(PaymentMethodContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),stripe=(0,react_stripe_js_1.useStripe)(),elements=(0,react_stripe_js_1.useElements)();(0,react_1.useEffect)(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield onSubmit({event:ref.current,stripe,elements})}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=({event,stripe:stripe2,elements:elements2})=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_e,_f;if(!stripe2)return!1;const savePaymentSourceToCustomerWallet=(_b=(_a=event?.elements)===null||_a===void 0?void 0:_a.save_payment_source_to_customer_wallet)===null||_b===void 0?void 0:_b.checked;if(savePaymentSourceToCustomerWallet&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=(_c=order?.customer_email)!==null&&_c!==void 0?_c:"",billingDetails={name:(_d=billingInfo?.full_name)!==null&&_d!==void 0?_d:"",email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:(_e=billingInfo?.line_2)!==null&&_e!==void 0?_e:"",postal_code:(_f=billingInfo?.zip_code)!==null&&_f!==void 0?_f:"",state:billingInfo?.state_code}},{error}=yield stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:window.location.href,payment_method_data:{billing_details:billingDetails}},redirect:"if_required"});return error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1):!0}return!1});return(0,jsx_runtime_1.jsxs)("form",{ref,children:[(0,jsx_runtime_1.jsx)(react_stripe_js_1.PaymentElement,{id:"payment-element",options:Object.assign(Object.assign({},defaultOptions),options)}),templateCustomerSaveToWallet&&(0,jsx_runtime_1.jsx)(Parent_1.default,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}function StripePayment(_a){var{publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1}=_a,p=tslib_1.__rest(_a,["publishableKey","show","options","clientSecret","locale","expressPayments"]);const[isLoaded,setIsLoaded]=(0,react_1.useState)(!1),[stripe,setStripe]=(0,react_1.useState)(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance}=p,divProps=tslib_1.__rest(p,["containerClassName","templateCustomerSaveToWallet","fonts","appearance"]);(0,react_1.useEffect)(()=>(show&&publishableKey&&Promise.resolve().then(()=>tslib_1.__importStar(require("@stripe/stripe-js"))).then(({loadStripe})=>{(()=>tslib_1.__awaiter(this,void 0,void 0,function*(){const res=yield loadStripe(publishableKey,{locale});res!=null&&(setStripe(res),setIsLoaded(!0))}))()}),()=>{setIsLoaded(!1)}),[show,publishableKey]);const elementsOptions={clientSecret,appearance:Object.assign(Object.assign({},defaultAppearance),appearance),fonts};return isLoaded&&stripe!=null&&clientSecret!=null?(0,jsx_runtime_1.jsx)("div",Object.assign({className:containerClassName},divProps,{children:(0,jsx_runtime_1.jsx)(react_stripe_js_1.Elements,{stripe,options:elementsOptions,children:expressPayments?(0,jsx_runtime_1.jsx)(StripeExpressPayment_1.StripeExpressPayment,{clientSecret}):(0,jsx_runtime_1.jsx)(StripePaymentForm,{options,templateCustomerSaveToWallet})})})):null}exports.StripePayment=StripePayment,exports.default=StripePayment;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StripePayment=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),react_stripe_js_1=require("@stripe/react-stripe-js"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),localStorage_1=require("../../utils/localStorage"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),StripeExpressPayment_1=require("./StripeExpressPayment"),defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet}){const ref=(0,react_1.useRef)(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=(0,react_1.useContext)(PaymentMethodContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),stripe=(0,react_stripe_js_1.useStripe)(),elements=(0,react_stripe_js_1.useElements)();(0,react_1.useEffect)(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield onSubmit({event:ref.current,stripe,elements})}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=({event,stripe:stripe2,elements:elements2})=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_e,_f,_g;if(!stripe2)return!1;const savePaymentSourceToCustomerWallet=(_b=(_a=event?.elements)===null||_a===void 0?void 0:_a.save_payment_source_to_customer_wallet)===null||_b===void 0?void 0:_b.checked;if(savePaymentSourceToCustomerWallet&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=(_c=order?.customer_email)!==null&&_c!==void 0?_c:"",billingDetails={name:(_d=billingInfo?.full_name)!==null&&_d!==void 0?_d:"",email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:(_e=billingInfo?.line_2)!==null&&_e!==void 0?_e:"",postal_code:(_f=billingInfo?.zip_code)!==null&&_f!==void 0?_f:"",state:billingInfo?.state_code}},{error}=yield stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:window.location.href,payment_method_data:{billing_details:billingDetails}},redirect:"if_required"});return error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:(_g=error.message)!==null&&_g!==void 0?_g:""}]),!1):!0}return!1});return(0,jsx_runtime_1.jsxs)("form",{ref,children:[(0,jsx_runtime_1.jsx)(react_stripe_js_1.PaymentElement,{id:"payment-element",options:Object.assign(Object.assign({},defaultOptions),options)}),templateCustomerSaveToWallet&&(0,jsx_runtime_1.jsx)(Parent_1.default,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}function StripePayment(_a){var{publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1}=_a,p=tslib_1.__rest(_a,["publishableKey","show","options","clientSecret","locale","expressPayments"]);const[isLoaded,setIsLoaded]=(0,react_1.useState)(!1),[stripe,setStripe]=(0,react_1.useState)(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance}=p,divProps=tslib_1.__rest(p,["containerClassName","templateCustomerSaveToWallet","fonts","appearance"]);(0,react_1.useEffect)(()=>(show&&publishableKey&&Promise.resolve().then(()=>tslib_1.__importStar(require("@stripe/stripe-js"))).then(({loadStripe})=>{(()=>tslib_1.__awaiter(this,void 0,void 0,function*(){const res=yield loadStripe(publishableKey,{locale});res!=null&&(setStripe(res),setIsLoaded(!0))}))()}),()=>{setIsLoaded(!1)}),[show,publishableKey]);const elementsOptions={clientSecret,appearance:Object.assign(Object.assign({},defaultAppearance),appearance),fonts};return isLoaded&&stripe!=null&&clientSecret!=null?(0,jsx_runtime_1.jsx)("div",Object.assign({className:containerClassName},divProps,{children:(0,jsx_runtime_1.jsx)(react_stripe_js_1.Elements,{stripe,options:elementsOptions,children:expressPayments?(0,jsx_runtime_1.jsx)(StripeExpressPayment_1.StripeExpressPayment,{clientSecret}):(0,jsx_runtime_1.jsx)(StripePaymentForm,{options,templateCustomerSaveToWallet})})})):null}exports.StripePayment=StripePayment,exports.default=StripePayment;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface WireTransferConfig {
3
2
  infoMessage?: {
4
3
  text?: string | JSX.Element[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type Price as PriceType } from '@commercelayer/sdk';
3
2
  import { type ChildrenFunction, type LoaderType } from '../../typings/index';
4
3
  interface PriceChildrenProps extends Omit<PriceProps, 'children'> {
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Price=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),PricesContext_1=tslib_1.__importDefault(require("../../context/PricesContext")),react_1=require("react"),getPrices_1=require("../../utils/getPrices"),SkuChildrenContext_1=tslib_1.__importDefault(require("../../context/SkuChildrenContext"));function Price(props){const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=(0,react_1.useContext)(PricesContext_1.default),{sku}=(0,react_1.useContext)(SkuChildrenContext_1.default),[skuPrices,setSkuPrices]=(0,react_1.useState)([]),sCode=pricesSkuCode||skuCode||sku?.code;(0,react_1.useEffect)(()=>(prices!=null&&`${sCode}`in prices?setSkuPrices(prices[sCode]):sCode&&!skuCodes.includes(sCode)&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes({skuCodes})),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps=Object.assign({loading,loader,prices:skuPrices},props),pricesComponent=prices==null||skuPrices==null?null:(0,getPrices_1.getPricesComponent)(skuPrices,props);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:loading||pricesComponent==null?loader:pricesComponent})}exports.Price=Price,exports.default=Price;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Price=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),PricesContext_1=tslib_1.__importDefault(require("../../context/PricesContext")),react_1=require("react"),getPrices_1=require("../../utils/getPrices"),SkuChildrenContext_1=tslib_1.__importDefault(require("../../context/SkuChildrenContext"));function Price(props){const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=(0,react_1.useContext)(PricesContext_1.default),{sku}=(0,react_1.useContext)(SkuChildrenContext_1.default),[skuPrices,setSkuPrices]=(0,react_1.useState)([]),sCode=pricesSkuCode||skuCode||sku?.code||"";(0,react_1.useEffect)(()=>(prices!=null&&`${sCode}`in prices?setSkuPrices(prices[sCode]):sCode&&!skuCodes.includes(sCode)&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes({skuCodes})),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps=Object.assign({loading,loader,prices:skuPrices},props),pricesComponent=prices==null||skuPrices==null?null:(0,getPrices_1.getPricesComponent)(skuPrices,props);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:loading||pricesComponent==null?loader:pricesComponent})}exports.Price=Price,exports.default=Price;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type LoaderType } from '../../typings/index';
3
2
  interface Props {
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type Shipment } from '@commercelayer/sdk';
3
2
  type ShipmentFieldChildrenProps = Omit<Props, 'children'> & {
4
3
  shipment: Shipment;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ChildrenFunction } from '../../typings/index';
3
2
  import type { Shipment } from '@commercelayer/sdk';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShippingMethod=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),ShipmentChildrenContext_1=tslib_1.__importDefault(require("../../context/ShipmentChildrenContext")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty"));function ShippingMethod(props){const{children,readonly,emptyText="There are not any shipping method available"}=props,{shippingMethods,currentShippingMethodId,deliveryLeadTimes,shipment}=(0,react_1.useContext)(ShipmentChildrenContext_1.default),[items,setItems]=(0,react_1.useState)([]);(0,react_1.useEffect)(()=>{const methods=shippingMethods?.filter(s=>readonly?s.id===currentShippingMethodId:!0).map((shippingMethod,k)=>{const[deliveryLeadTimeForShipment]=deliveryLeadTimes?.filter(delivery=>{var _a;const deliveryShippingMethodId=(_a=delivery.shipping_method)===null||_a===void 0?void 0:_a.id;return shippingMethod.id===deliveryShippingMethodId}),shippingProps={shipmentId:shipment?.id,shippingMethod,currentShippingMethodId,deliveryLeadTimeForShipment};return(0,jsx_runtime_1.jsx)(ShippingMethodChildrenContext_1.default.Provider,{value:shippingProps,children},k)});return methods&&setItems(methods),()=>{setItems([])}},[currentShippingMethodId,deliveryLeadTimes,shippingMethods]);const components=!(0,isEmpty_1.default)(items)&&items||emptyText;return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:components})}exports.ShippingMethod=ShippingMethod,exports.default=ShippingMethod;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShippingMethod=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),ShipmentChildrenContext_1=tslib_1.__importDefault(require("../../context/ShipmentChildrenContext")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty"));function ShippingMethod(props){const{children,readonly,emptyText="There are not any shipping method available"}=props,{shippingMethods,currentShippingMethodId,deliveryLeadTimes,shipment}=(0,react_1.useContext)(ShipmentChildrenContext_1.default),[items,setItems]=(0,react_1.useState)([]);(0,react_1.useEffect)(()=>{const methods=shippingMethods?.filter(s=>readonly?s.id===currentShippingMethodId:!0).map((shippingMethod,k)=>{var _a;const[deliveryLeadTimeForShipment]=(_a=deliveryLeadTimes?.filter(delivery=>{var _a2;const deliveryShippingMethodId=(_a2=delivery.shipping_method)===null||_a2===void 0?void 0:_a2.id;return shippingMethod.id===deliveryShippingMethodId}))!==null&&_a!==void 0?_a:[],shippingProps={shipmentId:shipment?.id,shippingMethod,currentShippingMethodId,deliveryLeadTimeForShipment};return(0,jsx_runtime_1.jsx)(ShippingMethodChildrenContext_1.default.Provider,{value:shippingProps,children},k)});return methods&&setItems(methods),()=>{setItems([])}},[currentShippingMethodId,deliveryLeadTimes,shippingMethods]);const components=!(0,isEmpty_1.default)(items)&&items||emptyText;return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:components})}exports.ShippingMethod=ShippingMethod,exports.default=ShippingMethod;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ShippingMethod } from '@commercelayer/sdk';
3
2
  type ChildrenProps = Omit<Props, 'children'> & {
4
3
  label: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type BaseAmountComponent } from '../../typings/index';
3
2
  type Props = BaseAmountComponent & {
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Order, ShippingMethod } from '@commercelayer/sdk';
3
2
  interface ShippingMethodRadioButtonType extends Omit<Props, 'children'> {
4
3
  shippingMethod: ShippingMethod;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type TimeFormat, type ChildrenFunction } from '../../typings/index';
3
2
  import { type DeliveryLeadTime } from '../../reducers/AvailabilityReducer';
4
3
  interface AvailabilityTemplateChildrenProps extends Omit<Props, 'children'>, DeliveryLeadTime {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export type DeliveryLeadTimeField = 'min_hours' | 'max_hours' | 'min_days' | 'max_days';
3
2
  export type DeliveryLeadTimeComponentChildren = Omit<Props, 'children'>;
4
3
  type Props = Partial<JSX.IntrinsicElements['span']> & {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ConditionalElement } from '../../typings/index';
3
2
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
4
3
  type SkuFieldChildrenProps = TGenericChildrenProps<TResources['Sku']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { DefaultChildrenType } from '../../typings/globals';
3
2
  interface Props {
4
3
  children: DefaultChildrenType;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ConditionalElement } from '../../typings/index';
3
2
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
4
3
  type StockTransferFieldChildrenProps = TGenericChildrenProps<TResources['StockTransfer']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Address } from '@commercelayer/sdk';
3
2
  import AddressChildrenContext from '../../context/AddressChildrenContext';
4
3
  import { type ChildrenFunction } from '../../typings/index';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PropsType } from '../../utils/PropsType';
3
2
  import { type baseOrderPricePropTypes } from '../../typings/index';
4
3
  export type BaseOrderPriceProps = PropsType<typeof baseOrderPricePropTypes, unknown> & Omit<JSX.IntrinsicElements['span'], 'children'>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PaymentResource } from '../../reducers/PaymentMethodReducer';
3
2
  import PaymentSourceContext, { type IconBrand } from '../../context/PaymentSourceContext';
4
3
  import { type ChildrenFunction } from '../../typings/index';
@@ -1,8 +1,7 @@
1
- /// <reference types="react" />
2
1
  import { type PriceProps } from '../prices/Price';
3
2
  export type PTemplateProps = {
4
- formattedAmount?: string;
5
- formattedCompare?: string;
3
+ formattedAmount?: string | null;
4
+ formattedCompare?: string | null;
6
5
  } & Omit<PriceProps, 'children'>;
7
6
  export declare function PriceTemplate(props: PTemplateProps): JSX.Element;
8
7
  export default PriceTemplate;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type LineItem } from '@commercelayer/sdk';
3
2
  import { type BaseError } from '../../typings/errors';
4
3
  import { type TResourceError } from '../errors/Errors';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),customMessages_1=tslib_1.__importDefault(require("../../utils/customMessages")),getAllErrors=params=>{const{allErrors,messages,field,props,lineItem,resource,returnHtml=!0}=params;return allErrors.map((v,k)=>{var _a;const objMsg=(0,customMessages_1.default)(messages,v);let text=v?.title&&v?.detail!=null&&!(!((_a=v.detail)===null||_a===void 0)&&_a.includes(v.title))?`${v.title} - ${v.detail}`.trim():`${v?.detail||v.message}`.trim();objMsg?.message&&(text=objMsg?.message.trim());const isEmpty=text.length===0;if(field){if(v.resource==="line_items"&&lineItem&&v.id===lineItem.id)return isEmpty?void 0:returnHtml?(0,jsx_runtime_1.jsx)("span",Object.assign({},props,{children:text}),k):text;if(field===v.field&&resource===v.resource)return isEmpty?void 0:returnHtml?(0,jsx_runtime_1.jsx)("span",Object.assign({},props,{children:text}),k):text}if(resource===v.resource&&!field)return isEmpty?void 0:returnHtml?(0,jsx_runtime_1.jsx)("span",Object.assign({},props,{children:text}),k):text}).filter(v=>v!==void 0)};exports.default=getAllErrors;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),customMessages_1=tslib_1.__importDefault(require("../../utils/customMessages")),getAllErrors=params=>{const{allErrors,messages,field,props,lineItem,resource,returnHtml=!0}=params;return allErrors.map((v,k)=>{var _a,_b;const objMsg=(0,customMessages_1.default)(messages,v);let text=v?.title&&v?.detail!=null&&!(!((_a=v.detail)===null||_a===void 0)&&_a.includes(v.title))?`${v.title} - ${v.detail}`.trim():`${v?.detail||v.message}`.trim();objMsg?.message&&(text=objMsg?.message.trim());const isEmpty=text.length===0;if(field){if(v.resource==="line_items"&&lineItem&&v.id===lineItem.id)return isEmpty?void 0:returnHtml?(0,jsx_runtime_1.jsx)("span",Object.assign({},props,{children:text}),k):text;if((field===v.field||!((_b=v.detail)===null||_b===void 0)&&_b.includes(field))&&resource===v.resource)return isEmpty?void 0:returnHtml?(0,jsx_runtime_1.jsx)("span",Object.assign({},props,{children:text}),k):text}if(resource===v.resource&&!field)return isEmpty?void 0:returnHtml?(0,jsx_runtime_1.jsx)("span",Object.assign({},props,{children:text}),k):text}).filter(v=>v!==void 0)};exports.default=getAllErrors;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.customerInitialState=exports.setResourceTrigger=exports.getCustomerInfo=exports.getCustomerPayments=exports.createCustomerAddress=exports.getCustomerSubscriptions=exports.getCustomerOrders=exports.getCustomerPaymentSources=exports.deleteCustomerAddress=exports.getCustomerAddresses=exports.setCustomerEmail=exports.setCustomerErrors=exports.saveCustomerUser=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),jwt_1=tslib_1.__importDefault(require("../utils/jwt")),getCustomerIdByToken_1=require("../utils/getCustomerIdByToken"),triggerAttributeHelper_1=require("../utils/triggerAttributeHelper");function saveCustomerUser({customerEmail,order,updateOrder}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(order){const attributes={customer_email:customerEmail,id:order.id};yield updateOrder({id:order.id,attributes})}})}exports.saveCustomerUser=saveCustomerUser;function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}exports.setCustomerErrors=setCustomerErrors;function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}exports.setCustomerEmail=setCustomerEmail;function getCustomerAddresses({config,dispatch,isOrderAvailable}){return tslib_1.__awaiter(this,void 0,void 0,function*(){try{const addresses=[];(yield(0,getSdk_1.default)(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&(customerAddress.id!==customerAddress.address.reference&&!isOrderAvailable&&(customerAddress.address.reference=customerAddress.id),addresses.push(customerAddress.address))}),addresses.sort((a,b)=>a.full_name&&b.full_name?a.full_name.localeCompare(b.full_name):0),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=(0,getErrors_1.default)({error,resource:"addresses"});dispatch({type:"setErrors",payload:{errors}})}})}exports.getCustomerAddresses=getCustomerAddresses;function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config&&addresses&&dispatch&&config)try{yield(0,getSdk_1.default)(config).customer_addresses.delete(customerAddressId);const newAddresses=addresses.filter(({reference})=>reference!==customerAddressId);dispatch({type:"setAddresses",payload:{addresses:newAddresses}})}catch{throw new Error("Couldn't delete address")}})}exports.deleteCustomerAddress=deleteCustomerAddress;function getCustomerPaymentSources(params){if(params){const{order,dispatch}=params;order?.available_customer_payment_sources&&dispatch&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})}}exports.getCustomerPaymentSources=getCustomerPaymentSources;function getCustomerOrders({config,dispatch,pageSize=10,pageNumber=1}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config.accessToken){const{owner}=(0,jwt_1.default)(config.accessToken);if(owner?.id){const orders=yield(0,getSdk_1.default)(config).customers.orders(owner.id,{filters:{status_not_in:"draft,pending"},pageSize,pageNumber});dispatch({type:"setOrders",payload:{orders}})}}})}exports.getCustomerOrders=getCustomerOrders;function getCustomerSubscriptions({number,config,dispatch,pageSize=10,pageNumber=1}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config.accessToken){const{owner}=(0,jwt_1.default)(config.accessToken);if(owner?.id){const sdk=(0,getSdk_1.default)(config);if(number!=null){const subscriptions=yield sdk.customers.orders(owner.id,{filters:{order_subscription_number_eq:number},pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}else{const subscriptions=yield sdk.customers.order_subscriptions(owner.id,{pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}}}})}exports.getCustomerSubscriptions=getCustomerSubscriptions;function createCustomerAddress({address,config,dispatch,state}){var _a,_b,_c;return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config&&address){const sdk=(0,getSdk_1.default)(config),{id}=address;try{if(id){const upAddress=yield sdk.addresses.update(address),updatedAddresses=(_a=state?.addresses)===null||_a===void 0?void 0:_a.map(a=>a.id===upAddress.id?upAddress:a);dispatch&&dispatch({type:"setAddresses",payload:{addresses:updatedAddresses}})}else{const newAddress=yield sdk.addresses.create(address);if(!((_b=state?.customers)===null||_b===void 0)&&_b.id&&newAddress?.id){const newCustomerAddress=yield sdk.customer_addresses.create({customer:sdk.customers.relationship((_c=state?.customers)===null||_c===void 0?void 0:_c.id),address:sdk.addresses.relationship(newAddress.id)});yield sdk.addresses.update({id:newAddress.id,reference:newCustomerAddress.id}),dispatch&&state?.addresses&&(newAddress.reference=newCustomerAddress.id,dispatch({type:"setAddresses",payload:{addresses:[...state.addresses,newAddress]}}))}}}catch{throw new Error("Couldn't create customer address")}}})}exports.createCustomerAddress=createCustomerAddress;function getCustomerPayments({config,dispatch,pageSize=10,pageNumber=1}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config?.accessToken!=null&&dispatch!=null){const sdk=(0,getSdk_1.default)(config),{owner}=(0,jwt_1.default)(config.accessToken);if(owner?.id){const payments=yield sdk.customer_payment_sources.list({include:["payment_source"],pageNumber,pageSize});dispatch({type:"setPayments",payload:{payments}})}}})}exports.getCustomerPayments=getCustomerPayments;function getCustomerInfo({config,dispatch}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config.accessToken&&dispatch!=null){const sdk=(0,getSdk_1.default)(config),customerId=(0,getCustomerIdByToken_1.getCustomerIdByToken)(config.accessToken);if(customerId){const customers=yield sdk.customers.retrieve(customerId),customerEmail=customers.email;dispatch({type:"setCustomers",payload:{customers,customerEmail}})}}})}exports.getCustomerInfo=getCustomerInfo;function setResourceTrigger({config,dispatch,resource,attribute,id,pageSize=10,pageNumber=1,reloadList=!1}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config.accessToken){const{owner}=(0,jwt_1.default)(config.accessToken);if(owner?.id){const params={config,resource,attribute,id};if((yield(0,triggerAttributeHelper_1.triggerAttributeHelper)(params))!=null&&dispatch!=null&&reloadList){switch(resource){case"orders":yield getCustomerOrders({config,dispatch,pageSize,pageNumber});break;case"order_subscriptions":yield getCustomerSubscriptions({config,dispatch,pageSize,pageNumber});break;default:return!1}return!0}}}return!1})}exports.setResourceTrigger=setResourceTrigger,exports.customerInitialState={errors:[],addresses:null,payments:null};const type=["setErrors","setCustomerEmail","setAddresses","setPayments","setOrders","setSubscriptions","setCustomers"],customerReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=customerReducer;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.customerInitialState=exports.setResourceTrigger=exports.getCustomerInfo=exports.getCustomerPayments=exports.createCustomerAddress=exports.getCustomerSubscriptions=exports.getCustomerOrders=exports.getCustomerPaymentSources=exports.deleteCustomerAddress=exports.getCustomerAddresses=exports.setCustomerEmail=exports.setCustomerErrors=exports.saveCustomerUser=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),jwt_1=require("../utils/jwt"),getCustomerIdByToken_1=require("../utils/getCustomerIdByToken"),triggerAttributeHelper_1=require("../utils/triggerAttributeHelper");function saveCustomerUser({customerEmail,order,updateOrder}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(order){const attributes={customer_email:customerEmail,id:order.id};yield updateOrder({id:order.id,attributes})}})}exports.saveCustomerUser=saveCustomerUser;function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}exports.setCustomerErrors=setCustomerErrors;function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}exports.setCustomerEmail=setCustomerEmail;function getCustomerAddresses({config,dispatch,isOrderAvailable}){return tslib_1.__awaiter(this,void 0,void 0,function*(){try{const addresses=[];(yield(0,getSdk_1.default)(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&(customerAddress.id!==customerAddress.address.reference&&!isOrderAvailable&&(customerAddress.address.reference=customerAddress.id),addresses.push(customerAddress.address))}),addresses.sort((a,b)=>a.full_name&&b.full_name?a.full_name.localeCompare(b.full_name):0),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=(0,getErrors_1.default)({error,resource:"addresses"});dispatch({type:"setErrors",payload:{errors}})}})}exports.getCustomerAddresses=getCustomerAddresses;function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config&&addresses&&dispatch&&config)try{yield(0,getSdk_1.default)(config).customer_addresses.delete(customerAddressId);const newAddresses=addresses.filter(({reference})=>reference!==customerAddressId);dispatch({type:"setAddresses",payload:{addresses:newAddresses}})}catch{throw new Error("Couldn't delete address")}})}exports.deleteCustomerAddress=deleteCustomerAddress;function getCustomerPaymentSources(params){if(params){const{order,dispatch}=params;order?.available_customer_payment_sources&&dispatch&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})}}exports.getCustomerPaymentSources=getCustomerPaymentSources;function getCustomerOrders({config,dispatch,pageSize=10,pageNumber=1}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config.accessToken){const{owner}=(0,jwt_1.jwt)(config.accessToken);if(owner?.id){const orders=yield(0,getSdk_1.default)(config).customers.orders(owner.id,{filters:{status_not_in:"draft,pending"},pageSize,pageNumber});dispatch({type:"setOrders",payload:{orders}})}}})}exports.getCustomerOrders=getCustomerOrders;function getCustomerSubscriptions({number,config,dispatch,pageSize=10,pageNumber=1}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config.accessToken){const{owner}=(0,jwt_1.jwt)(config.accessToken);if(owner?.id){const sdk=(0,getSdk_1.default)(config);if(number!=null){const subscriptions=yield sdk.customers.orders(owner.id,{filters:{order_subscription_number_eq:number},pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}else{const subscriptions=yield sdk.customers.order_subscriptions(owner.id,{pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}}}})}exports.getCustomerSubscriptions=getCustomerSubscriptions;function createCustomerAddress({address,config,dispatch,state}){var _a,_b,_c;return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config&&address){const sdk=(0,getSdk_1.default)(config),{id}=address;try{if(id){const upAddress=yield sdk.addresses.update(address),updatedAddresses=(_a=state?.addresses)===null||_a===void 0?void 0:_a.map(a=>a.id===upAddress.id?upAddress:a);dispatch&&dispatch({type:"setAddresses",payload:{addresses:updatedAddresses}})}else{const newAddress=yield sdk.addresses.create(address);if(!((_b=state?.customers)===null||_b===void 0)&&_b.id&&newAddress?.id){const newCustomerAddress=yield sdk.customer_addresses.create({customer:sdk.customers.relationship((_c=state?.customers)===null||_c===void 0?void 0:_c.id),address:sdk.addresses.relationship(newAddress.id)});yield sdk.addresses.update({id:newAddress.id,reference:newCustomerAddress.id}),dispatch&&state?.addresses&&(newAddress.reference=newCustomerAddress.id,dispatch({type:"setAddresses",payload:{addresses:[...state.addresses,newAddress]}}))}}}catch{throw new Error("Couldn't create customer address")}}})}exports.createCustomerAddress=createCustomerAddress;function getCustomerPayments({config,dispatch,pageSize=10,pageNumber=1}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config?.accessToken!=null&&dispatch!=null){const sdk=(0,getSdk_1.default)(config),{owner}=(0,jwt_1.jwt)(config.accessToken);if(owner?.id){const payments=yield sdk.customer_payment_sources.list({include:["payment_source"],pageNumber,pageSize});dispatch({type:"setPayments",payload:{payments}})}}})}exports.getCustomerPayments=getCustomerPayments;function getCustomerInfo({config,dispatch}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config.accessToken&&dispatch!=null){const sdk=(0,getSdk_1.default)(config),customerId=(0,getCustomerIdByToken_1.getCustomerIdByToken)(config.accessToken);if(customerId){const customers=yield sdk.customers.retrieve(customerId),customerEmail=customers.email;dispatch({type:"setCustomers",payload:{customers,customerEmail}})}}})}exports.getCustomerInfo=getCustomerInfo;function setResourceTrigger({config,dispatch,resource,attribute,id,pageSize=10,pageNumber=1,reloadList=!1}){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(config.accessToken){const{owner}=(0,jwt_1.jwt)(config.accessToken);if(owner?.id){const params={config,resource,attribute,id};if((yield(0,triggerAttributeHelper_1.triggerAttributeHelper)(params))!=null&&dispatch!=null&&reloadList){switch(resource){case"orders":yield getCustomerOrders({config,dispatch,pageSize,pageNumber});break;case"order_subscriptions":yield getCustomerSubscriptions({config,dispatch,pageSize,pageNumber});break;default:return!1}return!0}}}return!1})}exports.setResourceTrigger=setResourceTrigger,exports.customerInitialState={errors:[],addresses:null,payments:null};const type=["setErrors","setCustomerEmail","setAddresses","setPayments","setOrders","setSubscriptions","setCustomers"],customerReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=customerReducer;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addGiftCardError=exports.addGiftCard=exports.addGiftCardLoading=exports.addGiftCardRecipient=exports.giftCardInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:!1,rechargeable:!0,loading:!1,expiresAt:null,errors:[]};function addGiftCardRecipient(values,config,dispatch){return tslib_1.__awaiter(this,void 0,void 0,function*(){try{const recipient=yield(0,getSdk_1.default)(config).gift_card_recipients.create(values);dispatch({type:"setGiftCardRecipient",payload:{giftCardRecipient:recipient}})}catch(error){console.error(error)}})}exports.addGiftCardRecipient=addGiftCardRecipient;const addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})};exports.addGiftCardLoading=addGiftCardLoading;function addGiftCard(values,{config,dispatch,getOrder,createOrder,order}){var _a;return tslib_1.__awaiter(this,void 0,void 0,function*(){try{const sdk=(0,getSdk_1.default)(config);(0,exports.addGiftCardLoading)(!0,dispatch);const{firstName,lastName,email}=values,val=tslib_1.__rest(values,["firstName","lastName","email"]),giftCardValue=Object.assign({recipient_email:email},val),giftCard=yield sdk.gift_cards.create(giftCardValue,{include:["gift_card_recipient"]}),recipientValues={id:(_a=giftCard.gift_card_recipient)===null||_a===void 0?void 0:_a.id};if(firstName&&(recipientValues.first_name=firstName),lastName&&(recipientValues.last_name=lastName),(0,isEmpty_1.default)(recipientValues)||(yield sdk.gift_card_recipients.update(recipientValues)),createOrder&&getOrder){const id=order?order.id:yield createOrder({});if(id){const order2=sdk.orders.relationship(id),item=sdk.gift_cards.relationship(giftCard.id);yield sdk.line_items.create({quantity:1,order:order2,item}),yield getOrder(id)}}dispatch({type:"setGiftCardRecipient",payload:Object.assign({},giftCardValue)}),(0,exports.addGiftCardLoading)(!1,dispatch)}catch(error){const errors=(0,getErrors_1.default)({error,resource:"gift_cards"});dispatch({type:"setGiftCardErrors",payload:{errors}}),(0,exports.addGiftCardLoading)(!1,dispatch)}})}exports.addGiftCard=addGiftCard;const addGiftCardError=(errors,dispatch)=>{dispatch({type:"setGiftCardErrors",payload:{errors}})};exports.addGiftCardError=addGiftCardError;const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"],giftCardReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=giftCardReducer;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addGiftCardError=exports.addGiftCard=exports.addGiftCardLoading=exports.addGiftCardRecipient=exports.giftCardInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:!1,rechargeable:!0,loading:!1,expiresAt:null,errors:[]};function addGiftCardRecipient(values,config,dispatch){return tslib_1.__awaiter(this,void 0,void 0,function*(){try{const recipient=yield(0,getSdk_1.default)(config).gift_card_recipients.create(values);dispatch({type:"setGiftCardRecipient",payload:{giftCardRecipient:recipient}})}catch(error){console.error(error)}})}exports.addGiftCardRecipient=addGiftCardRecipient;const addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})};exports.addGiftCardLoading=addGiftCardLoading;function addGiftCard(values,{config,dispatch,getOrder,createOrder,order}){var _a,_b;return tslib_1.__awaiter(this,void 0,void 0,function*(){try{const sdk=(0,getSdk_1.default)(config);(0,exports.addGiftCardLoading)(!0,dispatch);const{firstName,lastName,email}=values,val=tslib_1.__rest(values,["firstName","lastName","email"]),giftCardValue=Object.assign({recipient_email:email},val),giftCard=yield sdk.gift_cards.create(giftCardValue,{include:["gift_card_recipient"]}),recipientValues={id:(_b=(_a=giftCard.gift_card_recipient)===null||_a===void 0?void 0:_a.id)!==null&&_b!==void 0?_b:""};if(firstName&&(recipientValues.first_name=firstName),lastName&&(recipientValues.last_name=lastName),(0,isEmpty_1.default)(recipientValues)||(yield sdk.gift_card_recipients.update(recipientValues)),createOrder&&getOrder){const id=order?order.id:yield createOrder({});if(id){const order2=sdk.orders.relationship(id),item=sdk.gift_cards.relationship(giftCard.id);yield sdk.line_items.create({quantity:1,order:order2,item}),yield getOrder(id)}}dispatch({type:"setGiftCardRecipient",payload:Object.assign({},giftCardValue)}),(0,exports.addGiftCardLoading)(!1,dispatch)}catch(error){const errors=(0,getErrors_1.default)({error,resource:"gift_cards"});dispatch({type:"setGiftCardErrors",payload:{errors}}),(0,exports.addGiftCardLoading)(!1,dispatch)}})}exports.addGiftCard=addGiftCard;const addGiftCardError=(errors,dispatch)=>{dispatch({type:"setGiftCardErrors",payload:{errors}})};exports.addGiftCardError=addGiftCardError;const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"],giftCardReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=giftCardReducer;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.orderInitialState=exports.removeGiftCardOrCouponCode=exports.setGiftCardOrCouponCode=exports.saveAddressToCustomerAddressBook=exports.setOrderErrors=exports.unsetOrderState=exports.addToCart=exports.addResourceToInclude=exports.setOrder=exports.updateOrder=exports.getApiOrder=exports.createOrder=void 0;const tslib_1=require("tslib"),localStorage_1=require("../utils/localStorage"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),organization_1=tslib_1.__importDefault(require("../utils/organization")),actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];function createOrder(params){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=(0,getSdk_1.default)(config);try{const o=yield sdk?.orders.create(Object.assign({metadata},orderAttributes));return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});console.error("Create order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""})}exports.createOrder=createOrder;const getApiOrder=params=>tslib_1.__awaiter(void 0,void 0,void 0,function*(){const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=(0,getSdk_1.default)(config);try{const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=yield sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch});return}});exports.getApiOrder=getApiOrder;function updateOrder({id,attributes,dispatch,config,include,state}){return tslib_1.__awaiter(this,void 0,void 0,function*(){const sdk=(0,getSdk_1.default)(config);try{const resource=Object.assign(Object.assign({},attributes),{id});yield sdk.orders.update(resource,{include});const order=yield(0,exports.getApiOrder)({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}})}exports.updateOrder=updateOrder;const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};exports.setOrder=setOrder;function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded=Object.assign(Object.assign({},payload.includeLoaded),{[resource]:!0});payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded=Object.assign(Object.assign(Object.assign({},resourceIncludedLoaded),newResourceLoaded),payload.includeLoaded&&payload.includeLoaded);payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:Object.assign(Object.assign({},payload),{withoutIncludes:!1})})}exports.addResourceToInclude=addResourceToInclude;function addToCart(params){var _a,_b,_c,_d;return tslib_1.__awaiter(this,void 0,void 0,function*(){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption}=params;try{if(config){const sdk=(0,getSdk_1.default)(config),id=yield createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(!((_a=state?.order)===null||_a===void 0)&&_a.line_items)yield Promise.all((_b=state?.order)===null||_b===void 0?void 0:_b.line_items.map(lineItem2=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield sdk.line_items.delete(lineItem2.id)})));else{const{line_items:lineItems}=yield sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&(yield Promise.all(lineItems.map(lineItem2=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield sdk.line_items.delete(lineItem2.id)}))))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:!0,bundle_code:bundleCode,metadata,frequency};externalPrice===!0&&(attrs._external_price=externalPrice);const newLineItem=yield sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};yield sdk.line_item_options.create(lineItemOptionsAttributes),yield(0,exports.getApiOrder)(Object.assign({id},params))}else yield(0,exports.getApiOrder)(Object.assign(Object.assign({id},params),{state}));if(!(0,isEmpty_1.default)(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=(0,organization_1.default)((_c=config.endpoint)!==null&&_c!==void 0?_c:""),params2=`${id}?accessToken=${(_d=config.accessToken)!==null&&_d!==void 0?_d:""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=(0,getErrors_1.default)({error,resource:"orders"});return console.error("Add to cart",errors2),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}})}exports.addToCart=addToCart;const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};exports.unsetOrderState=unsetOrderState;function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}exports.setOrderErrors=setOrderErrors;const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;(0,localStorage_1.setCustomerOrderParam)(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};exports.saveAddressToCustomerAddressBook=saveAddressToCustomerAddressBook;function setGiftCardOrCouponCode({code,codeType,dispatch,config,order,include,state}){return tslib_1.__awaiter(this,void 0,void 0,function*(){try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,order:currentOrder,error}=yield updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success,order:currentOrder}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders",field:codeType});return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}})}exports.setGiftCardOrCouponCode=setGiftCardOrCouponCode;function removeGiftCardOrCouponCode({codeType,dispatch,config,order,include,state}){return tslib_1.__awaiter(this,void 0,void 0,function*(){try{if(config&&order&&dispatch){const attributes={[codeType]:""},orderUpdated=yield updateOrder({id:order.id,attributes,config,include,dispatch,state});return dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0,order:orderUpdated?.order}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders",field:codeType});return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}})}exports.removeGiftCardOrCouponCode=removeGiftCardOrCouponCode,exports.orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,actionType);exports.default=orderReducer;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.orderInitialState=exports.removeGiftCardOrCouponCode=exports.setGiftCardOrCouponCode=exports.saveAddressToCustomerAddressBook=exports.setOrderErrors=exports.unsetOrderState=exports.addToCart=exports.addResourceToInclude=exports.setOrder=exports.updateOrder=exports.getApiOrder=exports.createOrder=void 0;const tslib_1=require("tslib"),localStorage_1=require("../utils/localStorage"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),organization_1=tslib_1.__importDefault(require("../utils/organization")),actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];function createOrder(params){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return"";const o=yield sdk?.orders.create(Object.assign({metadata},orderAttributes));return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});console.error("Create order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""})}exports.createOrder=createOrder;const getApiOrder=params=>tslib_1.__awaiter(void 0,void 0,void 0,function*(){const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return;const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=yield sdk.orders.retrieve(id??"",options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch});return}});exports.getApiOrder=getApiOrder;function updateOrder({id,attributes,dispatch,config,include,state}){return tslib_1.__awaiter(this,void 0,void 0,function*(){const sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return{success:!1};const resource=Object.assign(Object.assign({},attributes),{id});yield sdk.orders.update(resource,{include});const order=yield(0,exports.getApiOrder)({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}})}exports.updateOrder=updateOrder;const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};exports.setOrder=setOrder;function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded=Object.assign(Object.assign({},payload.includeLoaded),{[resource]:!0});payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded=Object.assign(Object.assign(Object.assign({},resourceIncludedLoaded),newResourceLoaded),payload.includeLoaded&&payload.includeLoaded);payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:Object.assign(Object.assign({},payload),{withoutIncludes:!1})})}exports.addResourceToInclude=addResourceToInclude;function addToCart(params){var _a,_b,_c,_d;return tslib_1.__awaiter(this,void 0,void 0,function*(){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption}=params;try{if(config){const sdk=(0,getSdk_1.default)(config),id=yield createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(!((_a=state?.order)===null||_a===void 0)&&_a.line_items)yield Promise.all((_b=state?.order)===null||_b===void 0?void 0:_b.line_items.map(lineItem2=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield sdk.line_items.delete(lineItem2.id)})));else{const{line_items:lineItems}=yield sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&(yield Promise.all(lineItems.map(lineItem2=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield sdk.line_items.delete(lineItem2.id)}))))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:!0,bundle_code:bundleCode,metadata,frequency};externalPrice===!0&&(attrs._external_price=externalPrice);const newLineItem=yield sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};yield sdk.line_item_options.create(lineItemOptionsAttributes),yield(0,exports.getApiOrder)(Object.assign({id},params))}else yield(0,exports.getApiOrder)(Object.assign(Object.assign({id},params),{state}));if(!(0,isEmpty_1.default)(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=(0,organization_1.default)((_c=config.endpoint)!==null&&_c!==void 0?_c:""),params2=`${id}?accessToken=${(_d=config.accessToken)!==null&&_d!==void 0?_d:""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=(0,getErrors_1.default)({error,resource:"orders"});return console.error("Add to cart",errors2),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}})}exports.addToCart=addToCart;const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};exports.unsetOrderState=unsetOrderState;function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}exports.setOrderErrors=setOrderErrors;const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;(0,localStorage_1.setCustomerOrderParam)(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};exports.saveAddressToCustomerAddressBook=saveAddressToCustomerAddressBook;function setGiftCardOrCouponCode({code,codeType,dispatch,config,order,include,state}){return tslib_1.__awaiter(this,void 0,void 0,function*(){try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,order:currentOrder,error}=yield updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success,order:currentOrder}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders",field:codeType});return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}})}exports.setGiftCardOrCouponCode=setGiftCardOrCouponCode;function removeGiftCardOrCouponCode({codeType,dispatch,config,order,include,state}){return tslib_1.__awaiter(this,void 0,void 0,function*(){try{if(config&&order&&dispatch){const attributes={[codeType]:""},orderUpdated=yield updateOrder({id:order.id,attributes,config,include,dispatch,state});return dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0,order:orderUpdated?.order}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders",field:codeType});return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}})}exports.removeGiftCardOrCouponCode=removeGiftCardOrCouponCode,exports.orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,actionType);exports.default=orderReducer;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export type DefaultChildrenType = JSX.Element[] | JSX.Element | null;
3
2
  type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
4
3
  export type TRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type DefaultChildrenType } from '../typings/globals';
3
2
  interface Props<T> {
4
3
  children: DefaultChildrenType;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCustomerIdByToken=void 0;const tslib_1=require("tslib"),jwt_1=tslib_1.__importDefault(require("./jwt"));function getCustomerIdByToken(accessToken){var _a,_b;return(_b=(_a=(0,jwt_1.default)(accessToken))===null||_a===void 0?void 0:_a.owner)===null||_b===void 0?void 0:_b.id}exports.getCustomerIdByToken=getCustomerIdByToken;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCustomerIdByToken=void 0;const jwt_1=require("./jwt");function getCustomerIdByToken(accessToken){var _a,_b;return(_b=(_a=(0,jwt_1.jwt)(accessToken))===null||_a===void 0?void 0:_a.owner)===null||_b===void 0?void 0:_b.id}exports.getCustomerIdByToken=getCustomerIdByToken;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDomain=void 0;function getDomain(endpoint){const url=new URL(endpoint),[slug]=url.hostname.split(".");return{domain:url.hostname.replace(`${slug??""}.`,""),slug}}exports.getDomain=getDomain;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDomain=void 0;function getDomain(endpoint){const url=new URL(endpoint),[slug]=url.hostname.split(".");return{domain:url.hostname.replace(`${slug??""}.`,""),slug:slug??""}}exports.getDomain=getDomain;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { type LoaderType } from '../typings/index';
3
2
  export default function getLoaderComponent(loader: LoaderType): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type Price } from '@commercelayer/sdk';
3
2
  import { type PTemplateProps } from '../components/utils/PriceTemplate';
4
3
  export declare function getPriceByCode(skuPrices: Price[], code?: string): Price | undefined;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPricesComponent=exports.getPriceByCode=void 0;const tslib_1=require("tslib"),react_1=require("react"),jsx_runtime_1=require("react/jsx-runtime"),lodash_1=require("lodash"),PriceTemplate_1=tslib_1.__importDefault(require("../components/utils/PriceTemplate"));function getPriceByCode(skuPrices,code=""){return code?(0,lodash_1.first)(skuPrices.filter(p=>p.currency_code===code)):(0,lodash_1.first)(skuPrices)}exports.getPriceByCode=getPriceByCode;function getPricesComponent(skuPrices,props){return(0,lodash_1.isEmpty)(skuPrices)?(0,jsx_runtime_1.jsx)(PriceTemplate_1.default,Object.assign({},props)):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare>"u"&&p?.compare_at_amount_cents>p?.amount_cents||props.showCompare;return(0,react_1.createElement)(PriceTemplate_1.default,Object.assign({},props,{key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount,skuCode:p.sku_code}))})}exports.getPricesComponent=getPricesComponent;function getPrices(prices){const obj={};return(0,lodash_1.isArray)(prices)&&prices.forEach(p=>{const sku=p.sku_code;(0,lodash_1.has)(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}exports.default=getPrices;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPricesComponent=exports.getPriceByCode=void 0;const tslib_1=require("tslib"),react_1=require("react"),jsx_runtime_1=require("react/jsx-runtime"),lodash_1=require("lodash"),PriceTemplate_1=tslib_1.__importDefault(require("../components/utils/PriceTemplate"));function getPriceByCode(skuPrices,code=""){return code?(0,lodash_1.first)(skuPrices.filter(p=>p.currency_code===code)):(0,lodash_1.first)(skuPrices)}exports.getPriceByCode=getPriceByCode;function getPricesComponent(skuPrices,props){return(0,lodash_1.isEmpty)(skuPrices)?(0,jsx_runtime_1.jsx)(PriceTemplate_1.default,Object.assign({},props)):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare>"u"&&p?.compare_at_amount_cents!=null&&p?.compare_at_amount_cents>p?.amount_cents||props.showCompare;return(0,react_1.createElement)(PriceTemplate_1.default,Object.assign({},props,{key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount,skuCode:p.sku_code}))})}exports.getPricesComponent=getPricesComponent;function getPrices(prices){const obj={};return(0,lodash_1.isArray)(prices)&&prices.forEach(p=>{var _a;const sku=(_a=p?.sku_code)!==null&&_a!==void 0?_a:"";(0,lodash_1.has)(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}exports.default=getPrices;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isGuestToken=void 0;const tslib_1=require("tslib"),jwt_1=tslib_1.__importDefault(require("./jwt"));function isGuestToken(accessToken){return(0,jwt_1.default)(accessToken).owner==null}exports.isGuestToken=isGuestToken;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isGuestToken=void 0;const jwt_1=require("./jwt");function isGuestToken(accessToken){return(0,jwt_1.jwt)(accessToken).owner==null}exports.isGuestToken=isGuestToken;
@@ -23,5 +23,5 @@ interface JWT {
23
23
  rand: number;
24
24
  test: boolean;
25
25
  }
26
- export default function jwt(accessToken: string): JWT;
26
+ export declare function jwt(accessToken: string): JWT;
27
27
  export {};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jwt_decode_1=tslib_1.__importDefault(require("jwt-decode"));function jwt(accessToken){return(0,jwt_decode_1.default)(accessToken)}exports.default=jwt;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.jwt=void 0;const jwt_decode_1=require("jwt-decode");function jwt(accessToken){return(0,jwt_decode_1.jwtDecode)(accessToken)}exports.jwt=jwt;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type BaseInputComponentProps } from '../typings/index';
3
2
  type Props = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
4
3
  export declare function MetadataInput(props: Props): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type Address as AddressType } from '@commercelayer/sdk';
3
2
  import { type AddressCardsTemplateChildren } from '../utils/AddressCardsTemplate';
4
3
  import type { DefaultChildrenType } from '../../typings/globals';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import AddressChildrenContext from"../../context/AddressChildrenContext";import CustomerContext from"../../context/CustomerContext";import BillingAddressContext from"../../context/BillingAddressContext";import ShippingAddressContext from"../../context/ShippingAddressContext";import isEmpty from"lodash/isEmpty";import AddressContext from"../../context/AddressContext";import OrderContext from"../../context/OrderContext";import AddressCardsTemplate from"../utils/AddressCardsTemplate";export function Address(props){const{children,className,selectedClassName="",disabledClassName="",onSelect,addresses=[],deselect=!1,...p}=props,{addresses:addressesContext}=useContext(CustomerContext),{setBillingAddress,billingCustomerAddressId}=useContext(BillingAddressContext),{setShippingAddress,shippingCustomerAddressId}=useContext(ShippingAddressContext),{shipToDifferentAddress,billingAddressId,shippingAddressId}=useContext(AddressContext),{order}=useContext(OrderContext),[selected,setSelected]=useState(null),items=isEmpty(addresses)?addressesContext&&addressesContext||[]:addresses;useEffect(()=>{items&&!deselect&&items.forEach((address,k)=>{billingCustomerAddressId&&address.reference===billingCustomerAddressId&&selected===null&&setSelected(k),!billingAddressId&&k===selected&&setBillingAddress&&setBillingAddress(address.id,{customerAddressId:address.reference}),shippingCustomerAddressId&&address.reference===shippingCustomerAddressId&&selected===null&&setSelected(k),!shippingAddressId&&k===selected&&setShippingAddress&&setShippingAddress(address.id,{customerAddressId:address.reference})}),deselect&&(async()=>(setBillingAddress&&await setBillingAddress(""),setShippingAddress&&await setShippingAddress("")))()},[deselect,billingCustomerAddressId,shippingCustomerAddressId,addressesContext,shipToDifferentAddress]);const handleSelect=async(k,addressId,customerAddressId,disabled,address)=>{!disabled&&setSelected(k),setBillingAddress&&await setBillingAddress(addressId,{customerAddressId}),!disabled&&setShippingAddress&&await setShippingAddress(addressId,{customerAddressId}),onSelect&&onSelect(address)},countryLock=order?.shipping_country_code_lock,components=typeof children=="function"?[]:items.filter(address=>!(setShippingAddress&&countryLock&&countryLock!==address.country_code)).map((address,k)=>{const addressProps={address},disabled=setShippingAddress&&countryLock&&countryLock!==address.country_code||!1,addressSelectedClass=selected===k?`${className||""} ${deselect?"":selectedClassName}`:className,customerAddressId=address?.reference||"",finalClassName=disabled?`${className||""} ${disabledClassName}`:addressSelectedClass;return _jsx(AddressChildrenContext.Provider,{value:addressProps,children:_jsx("div",{className:finalClassName,onClick:()=>{handleSelect(k,address.id,customerAddressId,disabled,address)},"data-disabled":disabled,...p,children})},k)}),parentProps={customerAddresses:items,selected,handleSelect,countryLock,...props};return typeof children=="function"?_jsx(AddressCardsTemplate,{...parentProps,children}):_jsx(_Fragment,{children:components})}export default Address;
2
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import AddressChildrenContext from"../../context/AddressChildrenContext";import CustomerContext from"../../context/CustomerContext";import BillingAddressContext from"../../context/BillingAddressContext";import ShippingAddressContext from"../../context/ShippingAddressContext";import isEmpty from"lodash/isEmpty";import AddressContext from"../../context/AddressContext";import OrderContext from"../../context/OrderContext";import AddressCardsTemplate from"../utils/AddressCardsTemplate";export function Address(props){const{children,className,selectedClassName="",disabledClassName="",onSelect,addresses=[],deselect=!1,...p}=props,{addresses:addressesContext}=useContext(CustomerContext),{setBillingAddress,billingCustomerAddressId}=useContext(BillingAddressContext),{setShippingAddress,shippingCustomerAddressId}=useContext(ShippingAddressContext),{shipToDifferentAddress,billingAddressId,shippingAddressId}=useContext(AddressContext),{order}=useContext(OrderContext),[selected,setSelected]=useState(null),items=isEmpty(addresses)?addressesContext&&addressesContext||[]:addresses;useEffect(()=>{items&&!deselect&&items.forEach((address,k)=>{billingCustomerAddressId&&address.reference===billingCustomerAddressId&&selected===null&&setSelected(k),!billingAddressId&&k===selected&&setBillingAddress&&address.reference!=null&&setBillingAddress(address.id,{customerAddressId:address.reference}),shippingCustomerAddressId&&address.reference===shippingCustomerAddressId&&selected===null&&setSelected(k),!shippingAddressId&&k===selected&&setShippingAddress&&address.reference!=null&&setShippingAddress(address.id,{customerAddressId:address.reference})}),deselect&&(async()=>(setBillingAddress&&await setBillingAddress(""),setShippingAddress&&await setShippingAddress("")))()},[deselect,billingCustomerAddressId,shippingCustomerAddressId,addressesContext,shipToDifferentAddress]);const handleSelect=async(k,addressId,customerAddressId,disabled,address)=>{!disabled&&setSelected(k),setBillingAddress&&await setBillingAddress(addressId,{customerAddressId}),!disabled&&setShippingAddress&&await setShippingAddress(addressId,{customerAddressId}),onSelect&&onSelect(address)},countryLock=order?.shipping_country_code_lock,components=typeof children=="function"?[]:items.filter(address=>!(setShippingAddress&&countryLock&&countryLock!==address.country_code)).map((address,k)=>{const addressProps={address},disabled=setShippingAddress&&countryLock&&countryLock!==address.country_code||!1,addressSelectedClass=selected===k?`${className||""} ${deselect?"":selectedClassName}`:className,customerAddressId=address?.reference||"",finalClassName=disabled?`${className||""} ${disabledClassName}`:addressSelectedClass;return _jsx(AddressChildrenContext.Provider,{value:addressProps,children:_jsx("div",{className:finalClassName,onClick:()=>{handleSelect(k,address.id,customerAddressId,disabled,address)},"data-disabled":disabled,...p,children})},k)}),parentProps={customerAddresses:items,selected,handleSelect,countryLock,...props};return typeof children=="function"?_jsx(AddressCardsTemplate,{...parentProps,children}):_jsx(_Fragment,{children:components})}export default Address;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type BaseSelectComponentProps } from '../../typings/index';
3
2
  import { type AddressValuesKeys } from '../../context/BillingAddressFormContext';
4
3
  import { type Country } from '../../utils/countryStateCity';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type BaseInputComponentProps, type AddressInputName } from '../../typings/index';
3
2
  import { type AddressValuesKeys } from '../../context/BillingAddressFormContext';
4
3
  type Props = {