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AAArT,UAAAC,OAAAqT,EAAA,IAAAzU,MAAAwU,GAAAE,EAAA,EAAAA,EAAAF,EAAAE,IAAAD,EAAAC,GAAAvT,UAAAuT,GACwB,OADxBJ,EAAAK,GAAA,KAAAP,EAAA,GAAA7P,OAAAkQ,KAAAhT,EAAAA,EAAAA,GAAA6S,EAAA,QACsB,CAAC,GAACA,CAAA,QAAAM,EAAAA,GAAAA,GAAAR,EAAAC,IAAAQ,EAAAA,GAAAA,GAAAT,EAAA,EAAA1T,IAAA,SAAAC,MAMhD,WACE,IAAQkJ,EAA8BiL,KAAKC,MAAnClL,MAER,OAAIA,GACFhG,GAASgG,GAEF,MAGgCiL,KAAKE,MAAtC1B,QAGV,IAAC,EAAA5S,IAAA,2BAAAC,MAhBD,SAAgCkJ,GAC9B,MAAO,CAAEA,MAAAA,EACX,IAAC,CALuB,CAASoL,EAAAA,W,ykBCHnC,IAAMzI,IAAWmC,EAAAA,EAAAA,IAAevL,EAAAA,IAKnB8R,GAAS5S,eAAO6S,EAA4BC,GACvD,IAAAC,EAAmCF,EAA3BG,UAAWC,OAAM,IAAAF,EAAG,GAAEA,EACxBG,GAAkBC,EAAAA,EAAAA,GAAsCF,EAAQ,CACpE,kBACA,aACA,eACA,cACA,WAEF/I,GAAS,uBAAwBgJ,GACjC,IAAQlM,EAAoCkM,EAApClM,WAAY0K,EAAwBwB,EAAxBxB,YAAwBwB,EAAXjM,OAEjC,IAAKyK,EACH,MAAM,IAAI0B,MAAM,0BAclBC,EAAAA,EAAAA,GAAWP,GAAaF,QACtBxB,EAAAA,GAAAA,KAACU,GAAa,CAAAd,UACZI,EAAAA,GAAAA,KAACkC,EAAAA,EAAsB,CACrBtM,WAAYA,EACZuM,aAAa,GAAEvC,UAEfI,EAAAA,GAAAA,KAACI,GAAG3R,GAAA,GAAKqT,QAIjB,C","sources":["webpack://oribasketprovider/../../src/index.ts","webpack://oribasketprovider/../../../src/types/RequestUrl.ts","webpack://oribasketprovider/../../../src/utils/convertToCamelCase.ts","webpack://oribasketprovider/../../../src/types/HttpHeader.ts","webpack://oribasketprovider/../../../src/types/ContentType.ts","webpack://oribasketprovider/../../../src/utils/getHttpRequestSettings.ts","webpack://oribasketprovider/../../../src/utils/addBasketOffer.ts","webpack://oribasketprovider/../../../src/utils/addToBasket.ts","webpack://oribasketprovider/../../../src/handlers/replaceSubscriptionHandler.ts","webpack://oribasketprovider/../../../src/constants/requestOptions.ts","webpack://oribasketprovider/../../../src/constants/shoppingContextActions.ts","webpack://oribasketprovider/../../../src/handlers/acceptNotificationHandler.ts","webpack://oribasketprovider/../../../src/handlers/addBackorderDemandHandler.ts","webpack://oribasketprovider/../../../src/handlers/addBasketOfferHandler.ts","webpack://oribasketprovider/../../../src/handlers/addCatalogueOfferHandler.ts","webpack://oribasketprovider/../../../src/handlers/addCustomerOrderHandler.ts","webpack://oribasketprovider/../../../src/handlers/addFreeShippingOfferHandler.ts","webpack://oribasketprovider/../../../src/handlers/addToBasketHandler.ts","webpack://oribasketprovider/../../../src/utils/getBuyingUrlAndMethod.ts","webpack://oribasketprovider/../../../src/handlers/addVoucherHandler.ts","webpack://oribasketprovider/../../../src/handlers/cancelBackorderDemandHandler.ts","webpack://oribasketprovider/../../../src/handlers/cancelSubscriptionHandler.ts","webpack://oribasketprovider/../../../src/handlers/clearBasketHandler.ts","webpack://oribasketprovider/../../../src/handlers/delaySubscriptionHandler.ts","webpack://oribasketprovider/../../../src/handlers/checkLoyaltyDialogResultAndAddToBasketHandler.ts","webpack://oribasketprovider/../../../src/handlers/removeBasketItemHandler.ts","webpack://oribasketprovider/../../../src/handlers/removeCustomerOrderHandler.ts","webpack://oribasketprovider/../../../src/handlers/removeVoucherHandler.ts","webpack://oribasketprovider/../../../src/handlers/replaceShoppingBagItemHandler.ts","webpack://oribasketprovider/../../../src/api/replaceSubscription.ts","webpack://oribasketprovider/../../../src/handlers/requestShoppingContextHandler.ts","webpack://oribasketprovider/../../../src/handlers/resetShippingSelectionHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateBasketItemHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateCustomerOrderItemHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateDeliveryHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateDeliveryChannelHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateDonationHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateOfferItemHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateOfferItemsHandler.ts","webpack://oribasketprovider/../../../src/handlers/updatePaymentProviderHandler.ts","webpack://oribasketprovider/../../../src/utils/storage.ts","webpack://oribasketprovider/../../../src/utils/cookies.ts","webpack://oribasketprovider/../../../src/utils/hashes.ts","webpack://oribasketprovider/../../../src/utils/dispatchBasketUpdatedEvent.ts","webpack://oribasketprovider/../../../src/utils/logReceivedEvent.ts","webpack://oribasketprovider/../../../src/utils/clearCachePages.ts","webpack://oribasketprovider/../../../src/hooks/useBasketProviderData.ts","webpack://oribasketprovider/../../../src/components/BasketProvider.ts","webpack://oribasketprovider/../../../src/containers/ApiProvider.tsx","webpack://oribasketprovider/../../../src/containers/BasketProviderController.tsx","webpack://oribasketprovider/./src/App.tsx","webpack://oribasketprovider/./src/containers/ErrorBoundary.ts","webpack://oribasketprovider/./src/appRender.tsx"],"sourcesContent":["import type { Data } from './Data';\n\nexport { Results as LastAddedItemMethod } from '@ori-events/loyalty-dialog-result';\n\nexport type {\n BasketOffer,\n BasketOfferBenefit,\n BasketOfferConcept,\n BasketOfferConceptBenefit,\n BasketOfferItem,\n BasketOfferProduct,\n BasketOfferPurchase,\n} from './BasketOffer';\nexport { BasketOfferTypes } from './BasketOffer';\n\nexport type { GodModeOutput, GodModeOutputItem } from './GodModeOutput';\n\nexport type { LastAddedItem } from './LastAddedItem';\n\nexport type { Referral } from './Referral';\n\nexport type {\n ShoppingBag,\n ShoppingBagBalance,\n ShoppingBagDiscount,\n ShoppingBagSubscriptions,\n ShoppingBagSubscriptionsPackages,\n ShoppingBagVipLoyalty,\n} from './ShoppingBag';\n\nexport type {\n DiscountMessage,\n OriginalProduct,\n Replacement,\n ReplacementItem,\n ShoppingBagItem,\n ShoppingBagItemProductFlag,\n} from './ShoppingBagItem';\n\nexport type { ShoppingBagOffer } from './ShoppingBagOffer';\n\nexport type { ShoppingMessage, ProgressBarItems } from './ShoppingMessage';\n\nexport type { ShoppingNotification } from './ShoppingNotification';\nexport { ShoppingNotificationType } from './ShoppingNotification';\n\nexport type {\n EndConsumerOrderItem,\n PendingEndConsumerOrder,\n ShippingOffer,\n SliderModel,\n UnitDataCollection,\n UnitDataCollectionBeautyConsultant,\n UnitDataCollectionCommon,\n UnitDataCollectionDelivery,\n UnitDataCollectionDonationUnit,\n UnitDataCollectionEndConsumerPendingOrder,\n UnitDataCollectionOffer,\n UnitDataCollectionPreOrderTargetUnit,\n UnitDataCollectionSectionUnit,\n UnitDataCollectionSpecialOffer,\n UnitDataCollectionVouchers,\n UnitDataCollectionWellnessSelling,\n UnitDataOffer,\n UnitDataOfferItem,\n} from './UnitDataCollection';\n\nexport const Test = 'TEST';\nexport const Name = 'basket-updated';\ntype EventName = typeof Name;\n\nexport const BasketUpdatedEvent: EventName = Name;\nexport type { Data };\n\nexport interface Event extends CustomEvent {\n type: EventName;\n}\n\nexport default Event;\n\ndeclare global {\n interface WindowEventMap {\n [Name]: Event;\n }\n}\n","export enum RequestUrl {\n AcceptNotification = '/system/ajax/Message/AcceptFailMessage',\n AddBackorderDemand = '/system/ajax/ShoppingBag/AddBackorderDemand',\n AddBasketOffer = '/system/ajax/Offer/ApplyBasketOffer',\n AddCatalogueOffer = '/system/ajax/Offer/ApplyCatalogueOffer',\n AddCustomerOrder = '/system/ajax/EndConsumerOrder/ApproveOrders',\n AddFreeShippingOffer = '/system/ajax/Delivery/AddFreeShippingItem',\n AddToBasketCheckLoyalty = '/system/ajax/ShoppingBag/AddToShoppingBagItemAndCheckLoyalty',\n AddToBasketForMoney = '/system/ajax/ShoppingBag/AddOrUpdateShoppingBagItem',\n AddToBasketForPoints = '/system/ajax/Offer/AddOfferItem',\n AddToBasketForPointsRewardShop = '/system/ajax/Offer/RedeemLoyaltyPoints',\n AddVoucher = '/system/ajax/ShoppingBag/AddVoucher',\n CancelBackorderDemand = '/system/ajax/ShoppingBag/CancelBackorderDemand',\n CancelSubscription = '/system/ajax/ShoppingBag/CancelSubscription',\n ClearBasket = '/system/ajax/ShoppingBag/RemoveAllShoppingBagItems',\n DelaySubscription = '/system/ajax/ShoppingBag/DelaySubscription',\n GetShoppingContext = '/system/ajax/ShoppingBag/GetShoppingContext',\n PurchaseBasketOffer = '/system/ajax/Offer/PurchaseBasketOffer',\n RemoveBasketItem = '/system/ajax/ShoppingBag/RemoveShoppingBagItem',\n RemoveCustomerOrder = '/system/ajax/EndConsumerOrder/UnapproveOrder',\n RemoveVoucher = '/system/ajax/ShoppingBag/RemoveVoucher',\n ReplaceShoppingBagItem = '/system/ajax/ShoppingBag/ReplaceShoppingBagItem',\n ResetFreeShippingSelection = '/system/ajax/Delivery/ResetFreeShippingSelection',\n UpdateBasketItem = '/system/ajax/ShoppingBag/UpdateShoppingBagItem',\n UpdateCustomerOrderItem = '/system/ajax/EndConsumerOrder/UpdateEndConsumerOrderItem',\n UpdateDeliveryAddress = '/system/ajax/DeliverySelection/UpdateDeliveryAddress',\n UpdateDeliveryChannel = '/system/ajax/DeliverySelection/UpdateDeliveryChannel',\n UpdateDonation = '/system/ajax/Donation/UpdateDonation',\n UpdateOfferItem = '/system/ajax/Offer/UpdateOfferItem',\n UpdateOfferItems = '/system/ajax/Offer/UpdateOfferItems',\n UpdatePaymentProvider = '/system/ajax/Payment/UpdatePaymentProvider',\n}\n","import camelCase from 'lodash.camelcase';\n\ntype CamelCaseObjectDeepType = (object?: unknown) => T;\n\nexport const convertToCamelCase: CamelCaseObjectDeepType = (object?: unknown) => {\n if (Array.isArray(object)) {\n return object.map(convertToCamelCase) as unknown as T;\n }\n\n if (typeof object === 'object' && object !== null && object.constructor === Object) {\n return Object.fromEntries(\n Object.entries(object).map(([key, value]) => [camelCase(key), convertToCamelCase(value)]),\n ) as unknown as T;\n }\n\n return object as T;\n};\n","// TODO: Move to checkout-utils\nexport enum HttpHeader {\n ContentType = 'Content-Type',\n Placement = 'x-placement',\n}\n","// TODO: Move to checkout-utils\nexport enum ContentType {\n Json = 'application/json',\n}\n","import type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { ContentType, HttpHeader } from '../types';\n\nexport const getHttpRequestSettings: (data?: T, method?: HttpMethod) => RequestInit = (\n data,\n method = HttpMethod.Get,\n) => {\n const headers: HeadersInit = {\n [HttpHeader.ContentType]: ContentType.Json,\n };\n let body: BodyInit | undefined;\n if (data) {\n const { placement, ...finalData } = data;\n if (placement) {\n headers[HttpHeader.Placement] = placement;\n }\n const bodyValue = JSON.stringify(finalData);\n body = bodyValue === '{}' ? undefined : bodyValue;\n }\n\n return {\n credentials: 'same-origin',\n headers,\n method,\n ...(method === HttpMethod.Post && Boolean(body) && { body }),\n };\n};\n","import type { BasketOfferItem } from '@ori-events/add-basket-offer';\nimport * as AddBasketOfferFailed from '@ori-events/add-basket-offer-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport type { RequestUrl } from '../types';\nimport { convertToCamelCase } from './convertToCamelCase';\nimport { getHttpRequestSettings } from './getHttpRequestSettings';\n\ntype AddBasketOfferApplyParams = PositionData & {\n offerId: number;\n};\n\ntype AddBasketOfferPurchaseParams = PositionData & {\n choiceId: number;\n items: BasketOfferItem[];\n};\n\nexport async function addBasketOffer(\n url: RequestUrl.AddBasketOffer | RequestUrl.PurchaseBasketOffer,\n params: AddBasketOfferApplyParams | AddBasketOfferPurchaseParams,\n) {\n const response = await fetch(url, getHttpRequestSettings(params, HttpMethod.Post));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (AddBasketOfferFailed.isAddBasketOfferErrorResponse(data)) {\n const event = new CustomEvent(AddBasketOfferFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(event);\n\n return false;\n }\n\n return data;\n}\n","import type * as AddToBasket from '@ori-events/add-to-basket';\nimport * as AddToBasketFailed from '@ori-events/add-to-basket-failed';\nimport * as ShowLoyaltyDialog from '@ori-events/show-loyalty-dialog';\nimport type { PositionData } from '@ori/analytics-data';\nimport { getWarningLogger, HttpMethod } from '@ori/checkout-utils';\n\nimport { APP_NAME } from '../constants';\nimport { convertToCamelCase } from './convertToCamelCase';\nimport { getHttpRequestSettings } from './getHttpRequestSettings';\n\nexport type AddToBasketParams = AddToBasket.Data &\n PositionData & {\n choiceId?: number | null;\n catalogueItemId?: string;\n };\n\nconst logWarning = getWarningLogger(APP_NAME);\nexport const MISSING_PLACEMENT_MESSAGE = `Missing 'placement' property in add-to-basket action data will impact reporting, please contact your SE.`;\n\nexport async function addToBasket(url: string, params: AddToBasketParams, buyingMethod: AddToBasket.Method) {\n const { itemCode, placement, quantity } = params;\n if (!placement) {\n logWarning(MISSING_PLACEMENT_MESSAGE);\n }\n const response = await fetch(url, getHttpRequestSettings(params, HttpMethod.Post));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (AddToBasketFailed.isAddToBasketErrorResponse(data)) {\n const event = new CustomEvent(AddToBasketFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(event);\n\n return false;\n }\n\n if (AddToBasketFailed.isAddToBasketLoyaltyResponse(data)) {\n const event = new CustomEvent(ShowLoyaltyDialog.Name, {\n detail: {\n ...data,\n itemCode,\n placement,\n quantity,\n },\n });\n window.dispatchEvent(event);\n\n return false;\n }\n\n return {\n ...data,\n lastAddedItem: {\n itemCode,\n method: buyingMethod,\n quantity,\n },\n };\n}\n","import type * as ReplaceSubscription from '@ori-events/replace-subscription';\nimport * as ReplaceSubscriptionFailed from '@ori-events/replace-subscription-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { getErrorLogger, HttpMethod } from '@ori/checkout-utils';\nimport { type GlobalCustomersSubscriptionItemDto } from '@ori/global-api-client-react';\n\nimport { replaceSubscription } from '../api';\nimport { APP_NAME } from '../constants';\nimport { RequestUrl } from '../types';\nimport type { HandlerSettings } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & ReplaceSubscription.Data;\ntype Response = ReplaceSubscriptionFailed.ReplaceSubscriptionResponse;\n\nconst logError = getErrorLogger(APP_NAME);\n\nexport async function replaceSubscriptionHandler(\n { detail: { droppingId, itemCode, subscriptionId } }: CustomEvent,\n { client, customerId, tenant }: HandlerSettings,\n) {\n // STEP 1 - Update through API\n const subscriptionItemId = 0;\n const item = {\n droppingId,\n isReplacementAllowed: true,\n itemCode,\n quantity: 1,\n subscriptionItemId,\n // TODO: This was optional / not used before, that's why the cast for now.\n // The ReplaceSubscription event data contains currently only the props destructured above.\n // To change it (if requested), we need cross-team collaboration with Presentation.\n // discountedPrice: 0,\n // discountPercent: 0,\n // totalBp: 0,\n // price: 0,\n // isDropped: false,\n };\n const globalCustomersSubscriptionItemDto = item as GlobalCustomersSubscriptionItemDto;\n\n try {\n await replaceSubscription({\n client,\n customerId,\n globalCustomersSubscriptionItemDto,\n subscriptionId,\n subscriptionItemId,\n tenant,\n });\n } catch (error: unknown) {\n const message = String(error);\n logError(`Error while replacing subscription in replaceSubscription event: ${message}`);\n\n return false;\n }\n\n // STEP 2 - Update shopping context via Online endpoint\n const response = await fetch(RequestUrl.GetShoppingContext, getHttpRequestSettings(undefined, HttpMethod.Post));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (ReplaceSubscriptionFailed.isReplaceSubscriptionErrorResponse(data)) {\n const errorEvent = new CustomEvent(ReplaceSubscriptionFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","// TODO: common header names & values to checkout-utils\nexport const putRequestOptions = {\n // eslint-disable-next-line @typescript-eslint/naming-convention -- predefined HTTP header name\n headers: { 'Content-Type': 'application/json' },\n method: 'PUT',\n};\n","import * as AcceptNotification from '@ori-events/accept-notification';\nimport * as AcceptNotificationFailed from '@ori-events/accept-notification-failed';\nimport * as AddBackorderDemand from '@ori-events/add-backorder-demand';\nimport * as AddBackorderDemandFailed from '@ori-events/add-backorder-demand-failed';\nimport * as AddBasketOffer from '@ori-events/add-basket-offer';\nimport * as AddBasketOfferFailed from '@ori-events/add-basket-offer-failed';\nimport * as AddCatalogueOffer from '@ori-events/add-catalogue-offer';\nimport * as AddCatalogueOfferFailed from '@ori-events/add-catalogue-offer-failed';\nimport * as AddCustomerOrder from '@ori-events/add-customer-order';\nimport * as AddCustomerOrderFailed from '@ori-events/add-customer-order-failed';\nimport * as AddFreeShippingOffer from '@ori-events/add-free-shipping-offer';\nimport * as AddFreeShippingOfferFailed from '@ori-events/add-free-shipping-offer-failed';\nimport * as AddToBasket from '@ori-events/add-to-basket';\nimport * as AddToBasketFailed from '@ori-events/add-to-basket-failed';\nimport * as AddVoucher from '@ori-events/add-voucher';\nimport * as AddVoucherFailed from '@ori-events/add-voucher-failed';\nimport * as CancelBackorderDemand from '@ori-events/cancel-backorder-demand';\nimport * as CancelSubscription from '@ori-events/cancel-subscription';\nimport * as CancelSubscriptionFailed from '@ori-events/cancel-subscription-failed';\nimport * as ClearBasket from '@ori-events/clear-basket';\nimport * as DelaySubscription from '@ori-events/delay-subscription';\nimport * as DelaySubscriptionFailed from '@ori-events/delay-subscription-failed';\nimport * as LoyaltyDialogResult from '@ori-events/loyalty-dialog-result';\nimport * as RemoveBasketItem from '@ori-events/remove-basket-item';\nimport * as RemoveBasketItemFailed from '@ori-events/remove-basket-item-failed';\nimport * as RemoveCustomerOrder from '@ori-events/remove-customer-order';\nimport * as RemoveCustomerOrderFailed from '@ori-events/remove-customer-order-failed';\nimport * as RemoveVoucher from '@ori-events/remove-voucher';\nimport * as RemoveVoucherFailed from '@ori-events/remove-voucher-failed';\nimport * as ReplaceShoppingBagItem from '@ori-events/replace-shopping-bag-item';\nimport * as ReplaceShoppingBagItemFailed from '@ori-events/replace-shopping-bag-item-failed';\nimport * as ReplaceSubscription from '@ori-events/replace-subscription';\nimport * as ReplaceSubscriptionFailed from '@ori-events/replace-subscription-failed';\nimport * as RequestShoppingContext from '@ori-events/request-shopping-context';\nimport * as ResetShippingSelection from '@ori-events/reset-shipping-selection';\nimport * as ShoppingContextLoaded from '@ori-events/shopping-context-loaded';\nimport * as UpdateBasketItem from '@ori-events/update-basket-item';\nimport * as UpdateBasketItemFailed from '@ori-events/update-basket-item-failed';\nimport * as UpdateCustomerOrderItem from '@ori-events/update-customer-order-item';\nimport * as UpdateCustomerOrderItemFailed from '@ori-events/update-customer-order-item-failed';\nimport * as UpdateDelivery from '@ori-events/update-delivery';\nimport * as UpdateDeliveryChannel from '@ori-events/update-delivery-channel';\nimport * as UpdateDeliveryChannelFailed from '@ori-events/update-delivery-channel-failed';\nimport * as UpdateDeliveryFailed from '@ori-events/update-delivery-failed';\nimport * as UpdateDonation from '@ori-events/update-donation';\nimport * as UpdateDonationFailed from '@ori-events/update-donation-failed';\nimport * as UpdateOfferItem from '@ori-events/update-offer-item';\nimport * as UpdateOfferItems from '@ori-events/update-offer-items';\nimport * as UpdatePaymentProvider from '@ori-events/update-payment-provider';\nimport * as UpdatePaymentProviderFailed from '@ori-events/update-payment-provider-failed';\n\nimport {\n acceptNotificationHandler,\n addBackorderDemandHandler,\n addBasketOfferHandler,\n addCatalogueOfferHandler,\n addCustomerOrderHandler,\n addFreeShippingOfferHandler,\n addToBasketHandler,\n addVoucherHandler,\n cancelBackorderDemandHandler,\n cancelSubscriptionHandler,\n checkLoyaltyDialogResultAndAddToBasketHandler,\n clearBasketHandler,\n delaySubscriptionHandler,\n removeBasketItemHandler,\n removeCustomerOrderHandler,\n removeVoucherHandler,\n replaceShoppingBagItemHandler,\n replaceSubscriptionHandler,\n requestShoppingContextHandler,\n resetShippingSelectionHandler,\n updateBasketItemHandler,\n updateCustomerOrderItemHandler,\n updateDeliveryHandler,\n updateDeliveryChannelHandler,\n updateDonationHandler,\n updateOfferItemHandler,\n updateOfferItemsHandler,\n updatePaymentProviderHandler,\n} from '../handlers';\nimport type { ShoppingContextActionInfo, TriggerActionEventName } from '../types';\n\n/**\n * Configuration of shopping context actions. Mapping of triggering events to response\n * success & failed events and event handlers for the responses.\n */\nexport const shoppingContextActions = new Map([\n [AcceptNotification.Name, { failedEvent: AcceptNotificationFailed.Name, handler: acceptNotificationHandler }],\n [AddBackorderDemand.Name, { failedEvent: AddBackorderDemandFailed.Name, handler: addBackorderDemandHandler }],\n [AddBasketOffer.Name, { failedEvent: AddBasketOfferFailed.Name, handler: addBasketOfferHandler }],\n [AddCatalogueOffer.Name, { failedEvent: AddCatalogueOfferFailed.Name, handler: addCatalogueOfferHandler }],\n [AddCustomerOrder.Name, { failedEvent: AddCustomerOrderFailed.Name, handler: addCustomerOrderHandler }],\n [AddFreeShippingOffer.Name, { failedEvent: AddFreeShippingOfferFailed.Name, handler: addFreeShippingOfferHandler }],\n [AddToBasket.Name, { failedEvent: AddToBasketFailed.Name, handler: addToBasketHandler }],\n [AddVoucher.Name, { failedEvent: AddVoucherFailed.Name, handler: addVoucherHandler }],\n // TODO: no failed event available so far for CancelBackorderDemand\n [CancelBackorderDemand.Name, { handler: cancelBackorderDemandHandler }],\n [CancelSubscription.Name, { failedEvent: CancelSubscriptionFailed.Name, handler: cancelSubscriptionHandler }],\n // TODO: no failed event available so far for ClearBasket\n [ClearBasket.Name, { handler: clearBasketHandler }],\n [DelaySubscription.Name, { failedEvent: DelaySubscriptionFailed.Name, handler: delaySubscriptionHandler }],\n // TODO: solve better the possible cases for LoyaltyDialogResult - maybe add-to-basket-failed,\n // and don't set up the loading state when just closed dialog (so exception to check for this case)\n [LoyaltyDialogResult.Name, { handler: checkLoyaltyDialogResultAndAddToBasketHandler }],\n [RemoveBasketItem.Name, { failedEvent: RemoveBasketItemFailed.Name, handler: removeBasketItemHandler }],\n [RemoveCustomerOrder.Name, { failedEvent: RemoveCustomerOrderFailed.Name, handler: removeCustomerOrderHandler }],\n [RemoveVoucher.Name, { failedEvent: RemoveVoucherFailed.Name, handler: removeVoucherHandler }],\n [\n ReplaceShoppingBagItem.Name,\n { failedEvent: ReplaceShoppingBagItemFailed.Name, handler: replaceShoppingBagItemHandler },\n ],\n [ReplaceSubscription.Name, { failedEvent: ReplaceSubscriptionFailed.Name, handler: replaceSubscriptionHandler }],\n [RequestShoppingContext.Name, { successEvent: ShoppingContextLoaded.Name, handler: requestShoppingContextHandler }],\n // TODO: no failed event available so far for ResetShippingSelection\n [ResetShippingSelection.Name, { handler: resetShippingSelectionHandler }],\n [UpdateBasketItem.Name, { failedEvent: UpdateBasketItemFailed.Name, handler: updateBasketItemHandler }],\n [\n UpdateCustomerOrderItem.Name,\n { failedEvent: UpdateCustomerOrderItemFailed.Name, handler: updateCustomerOrderItemHandler },\n ],\n [UpdateDelivery.Name, { failedEvent: UpdateDeliveryFailed.Name, handler: updateDeliveryHandler }],\n [\n UpdateDeliveryChannel.Name,\n { failedEvent: UpdateDeliveryChannelFailed.Name, handler: updateDeliveryChannelHandler },\n ],\n [UpdateDonation.Name, { failedEvent: UpdateDonationFailed.Name, handler: updateDonationHandler }],\n // TODO: no failed event available so far for UpdateOfferItem\n [UpdateOfferItem.Name, { handler: updateOfferItemHandler }],\n // TODO: no failed event available so far for UpdateOfferItems\n [UpdateOfferItems.Name, { handler: updateOfferItemsHandler }],\n [\n UpdatePaymentProvider.Name,\n { failedEvent: UpdatePaymentProviderFailed.Name, handler: updatePaymentProviderHandler },\n ],\n]);\n","import type * as AcceptNotification from '@ori-events/accept-notification';\nimport type { Data as ErrorData, AcceptNotificationResponse } from '@ori-events/accept-notification-failed';\nimport { isAcceptNotificationErrorResponse, Name as ErrorEventName } from '@ori-events/accept-notification-failed';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase } from '../utils';\n\nexport async function acceptNotificationHandler({ detail: { reasonId } }: CustomEvent) {\n const response = await fetch(`${RequestUrl.AcceptNotification}?reasonId=${reasonId}`);\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isAcceptNotificationErrorResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as AddBackorderDemand from '@ori-events/add-backorder-demand';\nimport type { AddBackorderDemandResponse, Data as ErrorData } from '@ori-events/add-backorder-demand-failed';\nimport { isAddBackorderDemandErrorResponse, Name as ErrorEventName } from '@ori-events/add-backorder-demand-failed';\nimport type * as BasketUpdated from '@ori-events/basket-updated';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddBackorderDemand.Data & PositionData;\n\nexport async function addBackorderDemandHandler({ detail: { lineNumber, placement, quantity } }: CustomEvent) {\n if (typeof quantity === 'number' && quantity > 0) {\n const responseWithQuantity = await fetch(\n `${RequestUrl.UpdateBasketItem}?lineNumber=${lineNumber}&quantity=${quantity}`,\n getHttpRequestSettings({ placement }),\n );\n const dataWithQuantity = convertToCamelCase(\n (await responseWithQuantity.json()) as object,\n );\n\n if (isAddBackorderDemandErrorResponse(dataWithQuantity)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: dataWithQuantity,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n }\n\n const response = await fetch(`${RequestUrl.AddBackorderDemand}?lineNumber=${lineNumber}`, getHttpRequestSettings());\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isAddBackorderDemandErrorResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as AddBasketOffer from '@ori-events/add-basket-offer';\nimport { isAddBasketOfferPurchaseEvent } from '@ori-events/add-basket-offer';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { addBasketOffer } from '../utils';\n\ntype Data = AddBasketOffer.Data & PositionData;\ntype PurchaseData = AddBasketOffer.AddBasketOfferPurchaseData & PositionData;\n\nexport async function addBasketOfferHandler(event: CustomEvent) {\n if (isAddBasketOfferPurchaseEvent(event)) {\n const {\n detail: { items, offerId: choiceId, placement },\n } = event as CustomEvent;\n\n return addBasketOffer(RequestUrl.PurchaseBasketOffer, {\n choiceId,\n items,\n placement,\n });\n }\n\n const {\n detail: { offerId, placement },\n } = event as CustomEvent;\n\n return addBasketOffer(RequestUrl.AddBasketOffer, {\n offerId,\n placement,\n });\n}\n","import type * as AddCatalogueOffer from '@ori-events/add-catalogue-offer';\nimport * as AddCatalogueOfferFailed from '@ori-events/add-catalogue-offer-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddCatalogueOffer.Data & PositionData;\n\nexport const dispatchAddCatalogueOfferFailedEvent = (detail: AddCatalogueOfferFailed.Data) => {\n const event = new CustomEvent(AddCatalogueOfferFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function addCatalogueOfferHandler({ detail: { offerId, placement } }: CustomEvent) {\n const request = await fetch(\n RequestUrl.AddCatalogueOffer,\n getHttpRequestSettings({ offerId, placement }, HttpMethod.Post),\n );\n\n const response = convertToCamelCase(\n (await request.json()) as object,\n );\n if (AddCatalogueOfferFailed.isAddCatalogueOfferErrorResponse(response)) {\n dispatchAddCatalogueOfferFailedEvent(response);\n\n return false;\n }\n\n return response;\n}\n","import type * as AddCustomerOrder from '@ori-events/add-customer-order';\nimport * as AddCustomerOrderFailed from '@ori-events/add-customer-order-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddCustomerOrder.Data & PositionData;\n\nexport async function addCustomerOrderHandler({ detail: { orderIds, placement } }: CustomEvent) {\n const url = new URL(RequestUrl.AddCustomerOrder, window.location.href);\n orderIds.forEach((id) => url.searchParams.append('orderIds', String(id)));\n\n const response = await fetch(url.toString(), getHttpRequestSettings({ placement }));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (AddCustomerOrderFailed.isAddCustomerOrderErrorResponse(data)) {\n const errorEvent = new CustomEvent(AddCustomerOrderFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return {\n ...data,\n lastAddedCustomerOrderIds: orderIds,\n };\n}\n","import type * as AddFreeShippingOffer from '@ori-events/add-free-shipping-offer';\nimport * as AddFreeShippingOfferFailed from '@ori-events/add-free-shipping-offer-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddFreeShippingOffer.Data & PositionData;\n\nexport const dispatchAddFreeShippingOfferFailedEvent = (detail: AddFreeShippingOfferFailed.Data) => {\n const event = new CustomEvent(AddFreeShippingOfferFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function addFreeShippingOfferHandler({ detail: { itemCode, placement } }: CustomEvent) {\n const request = await fetch(\n RequestUrl.AddFreeShippingOffer,\n getHttpRequestSettings({ itemCode, placement }, HttpMethod.Post),\n );\n\n const response = convertToCamelCase(\n (await request.json()) as object,\n );\n if (AddFreeShippingOfferFailed.isAddFreeShippingOfferErrorResponse(response)) {\n dispatchAddFreeShippingOfferFailedEvent(response);\n\n return false;\n }\n\n return response;\n}\n","import type * as AddToBasket from '@ori-events/add-to-basket';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { addToBasket, getBuyingUrlAndMethod } from '../utils';\n\ntype Data = AddToBasket.Data & PositionData;\n\nexport async function addToBasketHandler({\n detail: { itemCode, quantity, originalItemCode, replacementType, method: addToBasketMethod, placement },\n}: CustomEvent) {\n const { url, method } = getBuyingUrlAndMethod(addToBasketMethod);\n\n return addToBasket(\n url,\n {\n itemCode,\n quantity,\n originalItemCode,\n replacementType,\n placement,\n },\n method,\n );\n}\n","import * as AddToBasket from '@ori-events/add-to-basket';\n\nimport { RequestUrl } from '../types';\n\ninterface BuyingUrlAndMethod {\n url: string;\n method: AddToBasket.Method;\n}\n\nexport function getBuyingUrlAndMethod(method?: AddToBasket.Method): BuyingUrlAndMethod {\n switch (method) {\n case AddToBasket.Method.BUY_FOR_MONEY:\n return {\n url: RequestUrl.AddToBasketForMoney,\n method: AddToBasket.Method.BUY_FOR_MONEY,\n };\n case AddToBasket.Method.BUY_FOR_POINTS:\n return {\n url: RequestUrl.AddToBasketForPointsRewardShop,\n method: AddToBasket.Method.BUY_FOR_POINTS,\n };\n default:\n return {\n url: RequestUrl.AddToBasketCheckLoyalty,\n method: AddToBasket.Method.BUY_FOR_MONEY,\n };\n }\n}\n","import type * as AddVoucher from '@ori-events/add-voucher';\nimport * as AddVoucherFailed from '@ori-events/add-voucher-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddVoucher.Data & PositionData;\n\nconst dispatchAddVoucherFailed = (detail: AddVoucherFailed.Data) => {\n const event = new CustomEvent(AddVoucherFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function addVoucherHandler({ detail: { placement, voucherCode } }: CustomEvent) {\n const fetchUrl = `${RequestUrl.AddVoucher}?voucherCode=${voucherCode}`;\n const response = await fetch(fetchUrl, getHttpRequestSettings({ placement }));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (AddVoucherFailed.isAddVoucherErrorResponse(data)) {\n dispatchAddVoucherFailed(data);\n\n return false;\n }\n\n return data;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as CancelBackorderDemand from '@ori-events/cancel-backorder-demand';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = CancelBackorderDemand.Data & PositionData;\n\nexport async function cancelBackorderDemandHandler({ detail: { lineNumber, placement } }: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.CancelBackorderDemand}?lineNumber=${lineNumber}`,\n getHttpRequestSettings({ placement }),\n );\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as CancelSubscription from '@ori-events/cancel-subscription';\nimport * as CancelSubscriptionFailed from '@ori-events/cancel-subscription-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = CancelSubscription.Data & PositionData;\n\nexport const dispatchCancelSubscriptionFailedEvent = (detail: CancelSubscriptionFailed.Data) => {\n const event = new CustomEvent(CancelSubscriptionFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function cancelSubscriptionHandler({\n detail: { consumerId, packageId, placement, subscriptionId },\n}: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.CancelSubscription}?consumerId=${consumerId}&subscriptionId=${subscriptionId}&packageId=${packageId}`,\n getHttpRequestSettings({ placement }),\n );\n\n const data = convertToCamelCase(\n (await response.json()) as object,\n );\n\n if (CancelSubscriptionFailed.isCancelSubscriptionErrorResponse(data)) {\n dispatchCancelSubscriptionFailedEvent(data);\n\n return false;\n }\n\n return data;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\nexport async function clearBasketHandler() {\n const response = await fetch(RequestUrl.ClearBasket, getHttpRequestSettings());\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as DelaySubscription from '@ori-events/delay-subscription';\nimport * as DelaySubscriptionFailed from '@ori-events/delay-subscription-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = DelaySubscription.Data & PositionData;\n\nexport const dispatchDelaySubscriptionFailedEvent = (detail: DelaySubscriptionFailed.Data) => {\n const event = new CustomEvent(DelaySubscriptionFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function delaySubscriptionHandler({\n detail: { cycle, placement, step, subscriptionId },\n}: CustomEvent) {\n const response = await fetch(\n RequestUrl.DelaySubscription,\n getHttpRequestSettings({ cycle, placement, step, subscriptionId }, HttpMethod.Post),\n );\n const data = convertToCamelCase((await response.json()) as object);\n\n if (DelaySubscriptionFailed.isDelaySubscriptionErrorResponse(data)) {\n dispatchDelaySubscriptionFailedEvent(data);\n\n return false;\n }\n\n return data;\n}\n","import * as AddToBasket from '@ori-events/add-to-basket';\nimport * as LoyaltyDialogResult from '@ori-events/loyalty-dialog-result';\n\nimport { RequestUrl } from '../types';\nimport { addToBasket } from '../utils';\n\nexport async function checkLoyaltyDialogResultAndAddToBasketHandler({ detail }: CustomEvent) {\n const { result } = detail;\n\n if (LoyaltyDialogResult.isLoyaltyCloseResult(result)) {\n return false;\n }\n\n if (LoyaltyDialogResult.isLoyaltyBuyForPointsResult(result)) {\n const { catalogueItemId, choiceId, itemCode, quantity, placement } = detail;\n\n return addToBasket(\n RequestUrl.AddToBasketForPoints,\n {\n itemCode,\n quantity,\n choiceId,\n catalogueItemId,\n placement,\n },\n AddToBasket.Method.BUY_FOR_POINTS,\n );\n }\n\n if (LoyaltyDialogResult.isLoyaltyBuyForMoneyResult(result)) {\n const { itemCode, quantity, originalItemCode, replacementType, placement } = detail;\n\n return addToBasket(\n RequestUrl.AddToBasketForMoney,\n {\n itemCode,\n quantity,\n originalItemCode,\n replacementType,\n placement,\n },\n AddToBasket.Method.BUY_FOR_MONEY,\n );\n }\n\n return false;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as RemoveBasketItem from '@ori-events/remove-basket-item';\nimport * as RemoveBasketItemFailed from '@ori-events/remove-basket-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & RemoveBasketItem.Data;\n\nexport async function removeBasketItemHandler({ detail: { lineNumber, placement } }: CustomEvent) {\n const response = await fetch(\n RequestUrl.RemoveBasketItem,\n getHttpRequestSettings({ lineNumber, placement }, HttpMethod.Post),\n );\n\n const data = convertToCamelCase((await response.json()) as object);\n\n if (RemoveBasketItemFailed.isRemoveBasketItemErrorResponse(data)) {\n const errorEvent = new CustomEvent(RemoveBasketItemFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as RemoveCustomerOrder from '@ori-events/remove-customer-order';\nimport * as RemoveCustomerOrderFailed from '@ori-events/remove-customer-order-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & RemoveCustomerOrder.Data;\n\nexport async function removeCustomerOrderHandler({ detail: { endConsumerOrderId, placement } }: CustomEvent) {\n const fetchUrl = `${RequestUrl.RemoveCustomerOrder}?endConsumerOrderId=${endConsumerOrderId}`;\n\n const response = await fetch(fetchUrl, getHttpRequestSettings({ placement }));\n const data = convertToCamelCase(\n (await response.json()) as object,\n );\n\n if (RemoveCustomerOrderFailed.isRemoveCustomerOrderErrorResponse(data)) {\n const errorEvent = new CustomEvent(RemoveCustomerOrderFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as RemoveVoucher from '@ori-events/remove-voucher';\nimport * as RemoveVoucherFailed from '@ori-events/remove-voucher-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & RemoveVoucher.Data;\n\nconst dispatchRemoveVoucherFailed = (detail: RemoveVoucherFailed.Data) => {\n const event = new CustomEvent(RemoveVoucherFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function removeVoucherHandler({ detail: { placement, voucherCode } }: CustomEvent) {\n const fetchUrl = `${RequestUrl.RemoveVoucher}?voucherCode=${voucherCode}`;\n const response = await fetch(fetchUrl, getHttpRequestSettings({ placement }));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (RemoveVoucherFailed.isRemoveVoucherErrorResponse(data)) {\n dispatchRemoveVoucherFailed(data);\n\n return false;\n }\n\n return data;\n}\n","import type * as ReplaceShoppingBagItem from '@ori-events/replace-shopping-bag-item';\nimport * as ReplaceShoppingBagItemFailed from '@ori-events/replace-shopping-bag-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & ReplaceShoppingBagItem.Data;\n\nexport async function replaceShoppingBagItemHandler({\n detail: { itemCode, lineNumber, placement },\n}: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.ReplaceShoppingBagItem}?lineNumber=${lineNumber}&itemCode=${itemCode}`,\n getHttpRequestSettings({ placement }),\n );\n const data = convertToCamelCase(\n (await response.json()) as object,\n );\n\n if (ReplaceShoppingBagItemFailed.isReplaceShoppingBagItemErrorResponse(data)) {\n const errorEvent = new CustomEvent(ReplaceShoppingBagItemFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import {\n type GlobalCustomersSubscriptionItemDto,\n updateCustomerSubscriptionSubscriptionItem,\n type UpdateCustomerSubscriptionSubscriptionItemHeaders,\n} from '@ori/global-api-client-react';\n\nimport type { HandlerSettings } from '../types';\n\nexport type ReplaceSubscriptionParams = HandlerSettings & {\n globalCustomersSubscriptionItemDto: GlobalCustomersSubscriptionItemDto;\n subscriptionId: number;\n subscriptionItemId: number;\n tenant: string;\n};\n\nexport async function replaceSubscription({\n client,\n customerId,\n globalCustomersSubscriptionItemDto,\n subscriptionId,\n subscriptionItemId,\n tenant,\n}: ReplaceSubscriptionParams) {\n // TODO: Is this needed when there is the tenant prop of ApiProvider applied on some upper level?\n const headers: UpdateCustomerSubscriptionSubscriptionItemHeaders = {\n 'x-tenant-context': tenant,\n };\n\n return updateCustomerSubscriptionSubscriptionItem(\n client,\n customerId,\n subscriptionId,\n subscriptionItemId,\n globalCustomersSubscriptionItemDto,\n headers,\n );\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport * as ShoppingContextLoaded from '@ori-events/shopping-context-loaded';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\nexport async function requestShoppingContextHandler() {\n const response = await fetch(RequestUrl.GetShoppingContext, getHttpRequestSettings(undefined, HttpMethod.Post));\n const data = convertToCamelCase((await response.json()) as object);\n const event = new CustomEvent(ShoppingContextLoaded.Name, {\n detail: data,\n });\n window.dispatchEvent(event);\n\n return data;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\nexport async function resetShippingSelectionHandler() {\n const response = await fetch(RequestUrl.ResetFreeShippingSelection, getHttpRequestSettings());\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as UpdateBasketItem from '@ori-events/update-basket-item';\nimport type { Data as ErrorData, UpdateBasketItemResponse } from '@ori-events/update-basket-item-failed';\nimport { isUpdateBasketItemErrorResponse, Name as ErrorEventName } from '@ori-events/update-basket-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateBasketItem.Data;\n\nexport async function updateBasketItemHandler({ detail: { lineNumber, placement, quantity } }: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.UpdateBasketItem}?lineNumber=${lineNumber}&quantity=${quantity}`,\n getHttpRequestSettings({ placement }),\n );\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdateBasketItemErrorResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as UpdateCustomerOrderItem from '@ori-events/update-customer-order-item';\nimport * as UpdateCustomerOrderItemFailed from '@ori-events/update-customer-order-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateCustomerOrderItem.Data;\n\nexport async function updateCustomerOrderItemHandler({\n detail: { endConsumerOrderId, itemCode, placement, requestedQuantity },\n}: CustomEvent) {\n const fetchUrl =\n `${RequestUrl.UpdateCustomerOrderItem}` +\n `?endConsumerOrderId=${endConsumerOrderId}` +\n `&itemCode=${itemCode}` +\n `&requestedQuantity=${requestedQuantity}`;\n\n const response = await fetch(fetchUrl, getHttpRequestSettings({ placement }));\n const data = convertToCamelCase(\n (await response.json()) as object,\n );\n\n if (UpdateCustomerOrderItemFailed.isUpdateCustomerOrderItemErrorResponse(data)) {\n const errorEvent = new CustomEvent(UpdateCustomerOrderItemFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as UpdateDelivery from '@ori-events/update-delivery';\nimport type { Data as ErrorData, UpdateDeliveryResponse } from '@ori-events/update-delivery-failed';\nimport { isUpdateDeliveryErrorResponse, Name as ErrorEventName } from '@ori-events/update-delivery-failed';\n\nimport { putRequestOptions } from '../constants/requestOptions';\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase } from '../utils';\n\ntype Data = UpdateDelivery.Data;\n\nexport async function updateDeliveryHandler({\n detail: { deliveryAddressId, deliveryChannelId, registrationId },\n}: CustomEvent) {\n // if needed, start with delivery channel ID update\n if (typeof deliveryChannelId !== 'undefined') {\n const channelRequestOptions = {\n ...putRequestOptions,\n body: JSON.stringify({ deliveryChannelId }),\n };\n const channelResponse = await fetch(RequestUrl.UpdateDeliveryChannel, channelRequestOptions);\n const channelResponseData = convertToCamelCase((await channelResponse.json()) as object);\n\n if (isUpdateDeliveryErrorResponse(channelResponseData)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: channelResponseData,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n }\n\n // delivery address ID update\n const addressParams: {\n addressId: number;\n registrationId?: string;\n } = {\n addressId: deliveryAddressId,\n };\n if (registrationId) {\n addressParams.registrationId = registrationId;\n }\n const addressRequestOptions = {\n ...putRequestOptions,\n body: JSON.stringify(addressParams),\n };\n const addressResponse = await fetch(RequestUrl.UpdateDeliveryAddress, addressRequestOptions);\n const addressResponseData = convertToCamelCase((await addressResponse.json()) as object);\n\n if (isUpdateDeliveryErrorResponse(addressResponseData)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: addressResponseData,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return addressResponseData;\n}\n","import type * as UpdateDeliveryChannel from '@ori-events/update-delivery-channel';\nimport type { Data as ErrorData, UpdateDeliveryChannelResponse } from '@ori-events/update-delivery-channel-failed';\nimport {\n isUpdateDeliveryChannelErrorResponse,\n Name as ErrorEventName,\n} from '@ori-events/update-delivery-channel-failed';\n\nimport { putRequestOptions } from '../constants/requestOptions';\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase } from '../utils';\n\ntype Data = UpdateDeliveryChannel.Data;\n\nexport async function updateDeliveryChannelHandler({ detail: { deliveryChannelId } }: CustomEvent) {\n const requestOptions = {\n ...putRequestOptions,\n body: JSON.stringify({ deliveryChannelId }),\n };\n const response = await fetch(RequestUrl.UpdateDeliveryChannel, requestOptions);\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdateDeliveryChannelErrorResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as UpdateDonation from '@ori-events/update-donation';\nimport type { Data as ErrorData, UpdateDonationResponse } from '@ori-events/update-donation-failed';\nimport { isUpdateDonationFailedResponse, Name as ErrorEventName } from '@ori-events/update-donation-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateDonation.Data;\n\nexport async function updateDonationHandler({ detail: { choiceId, checked } }: CustomEvent) {\n const response = await fetch(\n RequestUrl.UpdateDonation,\n getHttpRequestSettings({ choiceId, checked }, HttpMethod.Post),\n );\n\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdateDonationFailedResponse(data)) {\n const event = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(event);\n\n return false;\n }\n\n return data;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as UpdateOfferItem from '@ori-events/update-offer-item';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateOfferItem.Data;\n\nexport async function updateOfferItemHandler({\n detail: { choiceId, itemCode, placement, quantity },\n}: CustomEvent) {\n const response = await fetch(\n RequestUrl.UpdateOfferItem,\n getHttpRequestSettings({ choiceId, itemCode, placement, quantity }, HttpMethod.Post),\n );\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as UpdateOfferItems from '@ori-events/update-offer-items';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateOfferItems.Data;\n\nexport async function updateOfferItemsHandler({ detail: { choiceId, items, placement } }: CustomEvent) {\n const response = await fetch(\n RequestUrl.UpdateOfferItems,\n getHttpRequestSettings({ choiceId, items, placement }, HttpMethod.Post),\n );\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as UpdatePaymentProvider from '@ori-events/update-payment-provider';\nimport type { Data as ErrorData, UpdatePaymentProviderResponse } from '@ori-events/update-payment-provider-failed';\nimport {\n isUpdatePaymentProviderFailedResponse,\n Name as ErrorEventName,\n} from '@ori-events/update-payment-provider-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdatePaymentProvider.Data;\n\nexport async function updatePaymentProviderHandler({ detail: { paymentProviderId, placement } }: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.UpdatePaymentProvider}?paymentProviderId=${paymentProviderId}`,\n getHttpRequestSettings({ placement }),\n );\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdatePaymentProviderFailedResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import { getLoggers } from '@ori/checkout-utils';\n\nimport { APP_NAME, DATA_CACHE_TIMEOUT, SCHEDULED_CLEANUP_KEY, USER_COOKIE_NAME } from '../constants';\nimport type { StoredValue } from '../types';\nimport { getCookie } from './cookies';\nimport { adler32 } from './hashes';\n\nconst { logDebug, logWarning, logError } = getLoggers(APP_NAME);\n\nexport const isValidTimestamp = (timestamp: number) => Date.now() - timestamp <= DATA_CACHE_TIMEOUT;\n\n// Both sessionStorage or localStorage could be used here.\n// The sessionStorage doesn't support triggering syncing events on other browser tabs.\n// The sessionStorage should clean up stored data after the browser tab gets closed.\n// But the browser's restore-session-on-reopen functionality may clash with this.\n// Both storage types have no connection with server-side session,\n// so, if working with server session data, manual cleanups / refreshing\n// has to be solved anyway.\nexport const getStorage = () => typeof window === 'object' && window.localStorage;\nexport const isStorageAvailable = () => Boolean(getStorage());\nif (!isStorageAvailable()) {\n logWarning('Storage is not available.');\n}\n\n// In Online session, there should always be some value set.\n// The 'unknown' value is just a fallback for testing.\nexport const getUserCheck = () => adler32((getCookie(USER_COOKIE_NAME) ?? '').trim() || 'unknown');\n\n// TODO: don't we have some util for this already in some NPM?\nconst parseValue = (serializedData: string) => {\n let parsedValue: StoredValue | undefined;\n try {\n parsedValue = JSON.parse(serializedData) as StoredValue;\n } catch (error) {\n logError(`Error parsing serialized data:`, error);\n }\n\n return parsedValue;\n};\n\nexport const getStorageItem = (key: string): T | undefined => {\n const storage = getStorage();\n if (typeof storage !== 'object') {\n return undefined;\n }\n\n const data = storage.getItem(key);\n if (!data) {\n logDebug(`Item with key '${key}' wasn't found in storage.`);\n\n return undefined;\n }\n\n const parsedValue = parseValue(data);\n if (!parsedValue) {\n logError(`Error getting stored item with key '${key}'.`);\n\n return undefined;\n }\n\n const { savedTimestamp, value, userCheck } = parsedValue;\n if (!isValidTimestamp(savedTimestamp)) {\n storage.removeItem(key);\n logDebug(`Stored item with key '${key}' has expired and was deleted.`);\n\n return undefined;\n }\n\n if (userCheck !== getUserCheck()) {\n storage.removeItem(key);\n logDebug(`Item with key '${key}' was stored for different user and was deleted.`);\n\n return undefined;\n }\n\n logDebug(`Item with key ${key} was found in storage.\\n\\t`, parsedValue);\n\n return value;\n};\n\nexport const setStorageItem = (key: string, value: T) => {\n const storage = getStorage();\n if (typeof storage !== 'object') {\n return false;\n }\n\n const data: StoredValue = {\n savedTimestamp: Date.now(),\n value,\n userCheck: getUserCheck(),\n };\n\n try {\n storage.setItem(key, JSON.stringify(data));\n logDebug(`Stored item with key '${key}', value:\\n\\t`, data);\n } catch (error) {\n logError(`Error storing item with ${key}:`, error);\n\n return false;\n }\n\n return true;\n};\n\nexport const removeStorageItem = (key: string) => {\n const storage = getStorage();\n if (typeof storage !== 'object') {\n return false;\n }\n\n try {\n storage.removeItem(key);\n logDebug(`Stored item with key '${key}' was removed.`);\n } catch (error) {\n logError(`Error removing item with key '${key}':`, error);\n\n return false;\n }\n\n return true;\n};\n\nexport const isScheduledCacheCleanup = (): boolean => {\n const storage = getStorage();\n if (typeof storage !== 'object') {\n return false;\n }\n\n const isScheduled = Boolean(storage.getItem(SCHEDULED_CLEANUP_KEY));\n if (isScheduled) {\n logDebug('Cache cleanup was scheduled with last page reload.');\n }\n\n return isScheduled;\n};\n\nexport const removeScheduledCacheCleanup = () => removeStorageItem(SCHEDULED_CLEANUP_KEY);\n\nexport const listenToStoredItemChanges = (key: string, callback?: (value: T | undefined) => unknown) => {\n const storage = getStorage();\n if (typeof storage !== 'object') {\n return undefined;\n }\n\n const eventName = 'storage';\n const eventListener = ((event: StorageEvent) => {\n if (event.storageArea !== storage || event.key !== key) {\n return undefined;\n }\n\n logDebug(`Storage change event from another browser tab was received for item with key '${key}'.`);\n if (event.newValue === null) {\n logDebug(`Stored item with '${key}' was removed in another browser window.`);\n removeStorageItem(key);\n\n return callback?.(undefined);\n }\n\n const parsedValue = parseValue(event.newValue);\n if (!parsedValue) {\n return undefined;\n }\n\n try {\n storage.setItem(key, event.newValue);\n logDebug(`Stored item with key '${key}', value:\\n\\t`, parsedValue);\n } catch (error) {\n logError(`Error storing item with key '${key}':`, error);\n }\n\n return callback?.(parsedValue.value);\n }) as EventListener;\n\n return { eventName, eventListener };\n};\n","export const getCookie = (cookieName: string) => {\n const match = document.cookie.match(new RegExp(`${cookieName}=([^;]+)`));\n\n return match ? match[1] : undefined;\n};\n","export const adler32 = (data: string) => {\n const MOD_ADLER = 65521;\n const BITS_MOVED = 16;\n const { length } = data;\n\n let a = 1;\n let b = 0;\n\n for (let i = 0; i < length; i++) {\n // eslint-disable-next-line unicorn/prefer-code-point -- x\n a += data.charCodeAt(i);\n b += a;\n }\n\n a %= MOD_ADLER;\n b %= MOD_ADLER;\n\n // eslint-disable-next-line no-bitwise -- x\n return (b << BITS_MOVED) | a;\n};\n","import * as BasketUpdated from '@ori-events/basket-updated';\n\nimport type { UpdateEventType } from '../types';\n\nexport const dispatchBasketUpdatedEvent = (\n detail: BasketUpdated.Data,\n eventType: UpdateEventType = BasketUpdated.Name,\n) => {\n const event = new CustomEvent(eventType, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport default dispatchBasketUpdatedEvent;\n","import { getDebugLogger } from '@ori/checkout-utils';\n\nimport { APP_NAME } from '../constants';\n\nconst logDebug = getDebugLogger(APP_NAME);\n\nexport const logReceivedEvent = (event: T) => logDebug(`Received ${event.type} event:\\n\\t`, event);\n","import { getDebugLogger } from '@ori/checkout-utils';\n\nimport { APP_NAME } from '../constants';\n\nconst logDebug = getDebugLogger(APP_NAME);\n\nconst pagePathPatterns = ['/shopping/basket'];\n\nexport const isPageMarkedForCacheCleanup = () => {\n const isCleanupPage = pagePathPatterns.some((item) => window.location.pathname.includes(item));\n if (isCleanupPage) {\n logDebug('Cache cleanup is always requested for current page.');\n }\n\n return isCleanupPage;\n};\n","import { useSpaConfig } from '@ori-appshell/config';\nimport * as BasketUpdated from '@ori-events/basket-updated';\nimport * as PlaceOrderRequested from '@ori-events/place-order-requested';\nimport * as RequestClearShoppingCache from '@ori-events/request-clear-shopping-cache';\nimport * as RequestShoppingContext from '@ori-events/request-shopping-context';\nimport * as ShoppingContextLoaded from '@ori-events/shopping-context-loaded';\nimport { useToken } from '@ori/auth';\nimport { getDebugLogger } from '@ori/checkout-utils';\nimport { useApiClient } from '@ori/global-api-client-react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { APP_NAME, CONTEXT_KEY } from '../constants';\nimport { shoppingContextActions } from '../constants/shoppingContextActions';\nimport type { HandlerSettings, ContextUpdateEventHandler, SuccessEventName } from '../types';\nimport {\n dispatchBasketUpdatedEvent,\n getStorageItem,\n isPageMarkedForCacheCleanup,\n isScheduledCacheCleanup,\n isStorageAvailable,\n listenToStoredItemChanges,\n logReceivedEvent,\n removeStorageItem,\n removeScheduledCacheCleanup,\n setStorageItem,\n} from '../utils';\n\nconst logDebug = getDebugLogger(APP_NAME);\n\nlet isReadyPromiseResolve: (value: PromiseLike | boolean) => void;\n\n/**\n * Promise indicating that shopping bag provider handlers are connected\n * and other components can start communicating with the provider via events.\n */\nexport const isReady = new Promise((resolve) => {\n isReadyPromiseResolve = resolve;\n});\n\ntype EventListenerInfo = {\n eventName: string;\n eventListener: EventListener;\n};\n\nconst getCachedContext = () => getStorageItem(CONTEXT_KEY);\nconst setCachedContext = (value: BasketUpdated.Data) => setStorageItem(CONTEXT_KEY, value);\nconst clearCachedContext = () => removeStorageItem(CONTEXT_KEY);\n\nexport const useBasketProviderData = () => {\n const client = useApiClient();\n const { tenant } = useSpaConfig();\n const { customerId } = useToken();\n\n // Indication that startup shopping context data initialization was done.\n const isInitialShoppingContextApplied = useRef(false);\n\n // Requesting shopping context data usually on application startup has now\n // specific logic involving also this state flag. When true, subsequent coming\n // request-shopping-context events will not trigger additional server requests\n // & it waits for the 1st request to return.\n const isRequestingShoppingContext = useRef(false);\n\n // Current shopping context / shopping session data. This is also being synchronized\n // with the cache on startup & after each update action.\n const [shoppingContext, setShoppingContext] = useState();\n\n /**\n * Sets current shopping context data state while optionally setting also the cache\n * and/or triggering a requested success response event.\n */\n const updateContext = useCallback(\n (data: BasketUpdated.Data, eventTypeToBeTriggered?: SuccessEventName, shouldStoreData = true) => {\n setShoppingContext(data);\n if (shouldStoreData && isStorageAvailable()) {\n setCachedContext(data);\n logDebug('Stored context was updated with new data:\\n\\t', data);\n } else {\n logDebug('Context was updated with new data:\\n\\t', data);\n }\n if (eventTypeToBeTriggered) {\n logDebug(`Triggering ${eventTypeToBeTriggered} event ...`);\n dispatchBasketUpdatedEvent(data, eventTypeToBeTriggered);\n }\n },\n [],\n );\n\n /** Tries to read last cache and, if found, sets it back into current shopping context state. */\n const getStoredContext = useCallback(() => {\n const data = getCachedContext();\n if (!data) {\n return;\n }\n updateContext(data, undefined, false);\n logDebug('Restored context data from storage.');\n }, [updateContext]);\n\n /** Clears current shopping context data and stored cache. */\n const clearContext = useCallback(() => {\n logDebug('Clearing stored shopping context data ...');\n clearCachedContext();\n setShoppingContext(undefined);\n }, []);\n\n /** Clears shopping context data based on received event. */\n const clearContextOnEvent = useCallback(\n (event: Event) => {\n logReceivedEvent(event);\n clearContext();\n },\n [clearContext],\n );\n\n /** Generic event listener for most update actions. */\n const createEventListener = useCallback(\n (handler: ContextUpdateEventHandler, currentSettings: HandlerSettings) => {\n const result = (async (event: T) => {\n logReceivedEvent(event);\n const data = await handler(event, currentSettings);\n if (data === false) {\n logDebug('Shopping context update failed.');\n } else {\n updateContext(data, BasketUpdated.Name);\n }\n }) as EventListener;\n\n return result;\n },\n [updateContext],\n );\n\n /**\n * Specific event listener for request-shopping-context action.\n * Getting the shopping context data from storage and/or the isRequestingShoppingContext\n * state is involved in this case. If in cache, the data is returned w/o creating\n * another request to server. If the loading already started before, it waits for\n * the original request to return the data.\n */\n const createRequestShoppingContextEventListener = useCallback(\n (handler: ContextUpdateEventHandler, currentSettings: HandlerSettings) => {\n const result = (async (event: T) => {\n logReceivedEvent(event);\n\n if (shoppingContext) {\n const triggerResponse = () => {\n logDebug(`Context data was loaded before. Triggering ${ShoppingContextLoaded.Name} event ...`);\n dispatchBasketUpdatedEvent(shoppingContext, ShoppingContextLoaded.Name);\n };\n\n // postpone a bit to have same events order as when really fetching the data\n setTimeout(() => triggerResponse());\n\n return;\n }\n\n if (isRequestingShoppingContext.current) {\n logDebug('Shopping context was already requested. Waiting for response ...');\n\n return;\n }\n\n logDebug('Loading shopping context ...');\n isRequestingShoppingContext.current = true;\n const data = await handler(event, currentSettings);\n isRequestingShoppingContext.current = false;\n if (data === false) {\n logDebug('Shopping context load failed.');\n } else {\n logDebug('Shopping context was loaded.');\n updateContext(data, ShoppingContextLoaded.Name);\n }\n }) as EventListener;\n\n return result;\n },\n [isRequestingShoppingContext, shoppingContext, updateContext],\n );\n\n /** Creates event listeners for the actions defined in shoppingContextActions list. */\n const getEventListeners = useCallback(\n (currentSettings: HandlerSettings) => {\n const result: EventListenerInfo[] = [];\n for (const [triggerActionEventName, { handler }] of shoppingContextActions.entries()) {\n const eventListenerFactory =\n triggerActionEventName === RequestShoppingContext.Name\n ? createRequestShoppingContextEventListener\n : createEventListener;\n result.push({\n eventName: triggerActionEventName,\n eventListener: eventListenerFactory(handler, currentSettings),\n });\n }\n\n return result;\n },\n [createEventListener, createRequestShoppingContextEventListener],\n );\n\n // setup initial state of shopping context data\n useEffect(() => {\n if (isStorageAvailable() && !isInitialShoppingContextApplied.current) {\n isInitialShoppingContextApplied.current = true;\n if (isPageMarkedForCacheCleanup() || isScheduledCacheCleanup()) {\n removeScheduledCacheCleanup();\n clearContext();\n } else {\n getStoredContext();\n }\n }\n }, [clearContext, getStoredContext]);\n\n // init event listeners\n useEffect(() => {\n const eventListeners = getEventListeners({ client, customerId, tenant });\n eventListeners.push(\n // This is now called when the user requests creating a new order.\n // That means that the cache should be cleared. But we don't know yet\n // if the create order action succeeds. Getting exact order creation\n // result / success might be problematic, as there are page redirects\n // involved, and after page reload, it is too late for clearing caches.\n // So current solution calls the PlaceOrderRequested event before\n // calling the request on server, so that there is enough time to\n // do this cache cleanup here before the redirects happen.\n // ATM, the redirect is being done in legacy module & this logic might\n // change after rewriting to React.\n {\n eventName: PlaceOrderRequested.Name,\n eventListener: clearContextOnEvent,\n },\n\n // This is now called for other cases when clearing context data is needed.\n {\n eventName: RequestClearShoppingCache.Name,\n eventListener: clearContextOnEvent,\n },\n );\n\n // If there was a change in stored data from another browser tab,\n // if the context value was set, update the context with triggering\n // basket-updated event. Other components need to be informed about\n // the new state & this will not happen on page load, but later.\n // So the basket-updated event should be fine for this.\n if (isStorageAvailable()) {\n const monitoredStorageChanges = listenToStoredItemChanges(CONTEXT_KEY, (value) => {\n if (value) {\n updateContext(value, BasketUpdated.Name, false);\n }\n });\n if (monitoredStorageChanges) {\n const { eventName, eventListener } = monitoredStorageChanges;\n eventListeners.push({ eventName, eventListener });\n }\n }\n\n eventListeners.forEach(({ eventName, eventListener }) => {\n window.addEventListener(eventName, eventListener);\n });\n logDebug('Event listeners are connected.');\n\n // TODO: We publish the promise to window scope & resolve it immediately.\n // Is it worth using promise at all when polling is still needed in consuming components?\n // Maybe the exported isReady promise on module level is still worth it?\n window.isBasketProviderReady = isReady;\n isReadyPromiseResolve(true);\n\n return () => {\n eventListeners.forEach(({ eventName, eventListener }) => {\n window.removeEventListener(eventName, eventListener);\n });\n eventListeners.length = 0;\n logDebug('Old event listeners were disconnected.');\n };\n }, [clearContextOnEvent, client, customerId, getEventListeners, tenant, updateContext]);\n\n const contextValue = useMemo(\n () => ({\n isRequestingShoppingContext,\n isReady,\n shoppingContext,\n }),\n [isRequestingShoppingContext, shoppingContext],\n );\n\n return contextValue;\n};\n","import type { FC } from 'react';\n\nimport { useBasketProviderData } from '../hooks';\n\nexport const BasketProvider: FC = () => {\n useBasketProviderData();\n\n return null;\n};\n","import { useSpaConfig } from '@ori-appshell/config';\nimport { useToken } from '@ori/auth';\nimport { useServiceUrls } from '@ori/configuration-manager';\nimport { ApiClientProvider } from '@ori/global-api-client-react';\nimport type { ReactElement } from 'react';\n\ninterface ApiProviderProps {\n children: ReactElement;\n}\n\nexport const ApiProvider = ({ children }: ApiProviderProps) => {\n const { globalApiUrl } = useServiceUrls(['globalApi']);\n const { tenant } = useSpaConfig();\n const { token } = useToken();\n\n return (\n \n {children}\n \n );\n};\n","import type { FC } from 'react';\n\nimport { BasketProvider } from '../components';\nimport { ApiProvider } from './ApiProvider';\n\nexport const BasketProviderController: FC = () => (\n \n \n \n);\n","import { SpaConfigProvider } from '@ori-appshell/config';\nimport { BasketProviderController } from '@ori/basket-provider-lib';\nimport { ServiceUrlsProvider } from '@ori/configuration-manager';\n\nimport type { ClientAppConfig } from './types';\n\nexport const App = ({ currentLanguage, globalApiUrl, identityUrl, tenant }: ClientAppConfig) => (\n \n \n \n \n \n);\n","import { APP_NAME } from '@ori/basket-provider-lib';\nimport { getErrorLogger } from '@ori/checkout-utils';\nimport { type ReactNode, Component } from 'react';\n\ninterface ErrorBoundaryProps {\n children: JSX.Element;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nconst logError = getErrorLogger(APP_NAME);\n\nexport class ErrorBoundary extends Component {\n override readonly state: ErrorBoundaryState = {};\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { error };\n }\n\n override render(): ReactNode {\n const { error }: ErrorBoundaryState = this.state;\n\n if (error) {\n logError(error);\n\n return null;\n }\n\n const { children }: ErrorBoundaryProps = this.props;\n\n return children;\n }\n}\n","/* istanbul ignore file */\nimport { UniversalTokenProvider, doDevelopmentLogin } from '@ori/auth';\nimport { APP_NAME } from '@ori/basket-provider-lib';\nimport { getDebugLogger } from '@ori/checkout-utils';\nimport { parseClientAppConfig } from '@ori/client-app-config';\nimport { createRoot } from 'react-dom/client';\n\nimport { App } from './App';\nimport { ErrorBoundary } from './containers';\nimport type { ClientAppConfig } from './types';\n\nconst logDebug = getDebugLogger(APP_NAME);\n\n/**\n * React app renderer that is used when app is used as a standalone app\n */\nexport const render = async (configElement: HTMLElement, rootElement: HTMLElement) => {\n const { innerText: config = '' } = configElement;\n const clientAppConfig = parseClientAppConfig(config, [\n 'currentLanguage',\n 'customerId',\n 'globalApiUrl',\n 'identityUrl',\n 'tenant',\n ]);\n logDebug('parsed configuration', clientAppConfig);\n const { customerId, identityUrl, tenant } = clientAppConfig;\n\n if (!identityUrl) {\n throw new Error('Missing Identity URL!');\n }\n\n // Get token for local development\n if (process.env.NODE_ENV !== 'production') {\n // when using Requestly we do not want to load token\n if (process.env.REACT_APP_USE_REQUESTLY === '1') {\n // eslint-disable-next-line no-console -- wanted behavior\n console.log('USING REQUESTLY');\n } else {\n await doDevelopmentLogin({ identityUrl, tenant });\n }\n }\n\n createRoot(rootElement).render(\n \n \n \n \n ,\n );\n};\n"],"names":["Name","isErrorResponse","response","_typeof","isSuccess","isAddBackorderDemandErrorResponse","isAddBasketOfferErrorResponse","Method","isAddToBasketErrorResponse","isAddToBasketLoyaltyResponse","Boolean","loyaltyPoints","LoyaltyDialogResults","Results","BUY_FOR_MONEY","BUY_FOR_POINTS","isUpdateDeliveryErrorResponse","RequestUrl","convertToCamelCase","object","Array","isArray","map","constructor","Object","fromEntries","entries","_ref","_ref2","_slicedToArray","key","value","camelCase","HttpHeader","ContentType","getHttpRequestSettings","data","body","method","arguments","length","undefined","HttpMethod","Get","headers","_defineProperty","Json","placement","finalData","_objectWithoutProperties","_excluded","Placement","bodyValue","JSON","stringify","_objectSpread","credentials","Post","async","addBasketOffer","url","params","fetch","json","AddBasketOfferFailed","event","CustomEvent","detail","window","dispatchEvent","logWarning","getWarningLogger","APP_NAME","MISSING_PLACEMENT_MESSAGE","addToBasket","buyingMethod","itemCode","quantity","AddToBasketFailed","ShowLoyaltyDialog","lastAddedItem","logError","getErrorLogger","putRequestOptions","shoppingContextActions","Map","AcceptNotification","failedEvent","AcceptNotificationFailed","handler","reasonId","concat","isAcceptNotificationErrorResponse","errorEvent","ErrorEventName","AddBackorderDemand","AddBackorderDemandFailed","_ref$detail","lineNumber","responseWithQuantity","UpdateBasketItem","dataWithQuantity","AddBasketOffer","items","isAddBasketOfferPurchaseEvent","_event$detail","choiceId","offerId","PurchaseBasketOffer","_event$detail2","AddCatalogueOffer","AddCatalogueOfferFailed","request","AddCustomerOrder","AddCustomerOrderFailed","orderIds","URL","location","href","forEach","id","searchParams","append","String","toString","lastAddedCustomerOrderIds","AddFreeShippingOffer","AddFreeShippingOfferFailed","AddToBasket","originalItemCode","replacementType","addToBasketMethod","_getBuyingUrlAndMetho","AddToBasketForMoney","AddToBasketForPointsRewardShop","AddToBasketCheckLoyalty","getBuyingUrlAndMethod","AddVoucher","AddVoucherFailed","voucherCode","fetchUrl","CancelBackorderDemand","CancelSubscription","CancelSubscriptionFailed","consumerId","packageId","subscriptionId","ClearBasket","DelaySubscription","DelaySubscriptionFailed","cycle","step","LoyaltyDialogResult","result","CLOSE","catalogueItemId","AddToBasketForPoints","RemoveBasketItem","RemoveBasketItemFailed","RemoveCustomerOrder","RemoveCustomerOrderFailed","endConsumerOrderId","RemoveVoucher","RemoveVoucherFailed","ReplaceShoppingBagItem","ReplaceShoppingBagItemFailed","ReplaceSubscription","ReplaceSubscriptionFailed","droppingId","client","customerId","tenant","globalCustomersSubscriptionItemDto","isReplacementAllowed","subscriptionItemId","updateCustomerSubscriptionSubscriptionItem","replaceSubscription","error","message","GetShoppingContext","RequestShoppingContext","successEvent","ShoppingContextLoaded","ResetShippingSelection","ResetFreeShippingSelection","UpdateBasketItemFailed","isUpdateBasketItemErrorResponse","UpdateCustomerOrderItem","UpdateCustomerOrderItemFailed","requestedQuantity","UpdateDelivery","UpdateDeliveryFailed","deliveryAddressId","deliveryChannelId","registrationId","channelRequestOptions","channelResponse","UpdateDeliveryChannel","channelResponseData","addressParams","addressId","addressRequestOptions","addressResponse","UpdateDeliveryAddress","addressResponseData","UpdateDeliveryChannelFailed","requestOptions","isUpdateDeliveryChannelErrorResponse","UpdateDonation","UpdateDonationFailed","checked","isUpdateDonationFailedResponse","UpdateOfferItem","UpdateOfferItems","UpdatePaymentProvider","UpdatePaymentProviderFailed","paymentProviderId","isUpdatePaymentProviderFailedResponse","_getLoggers","getLoggers","logDebug","getStorage","localStorage","isStorageAvailable","getUserCheck","_getCookie","cookieName","match","a","b","i","charCodeAt","adler32","USER_COOKIE_NAME","document","cookie","RegExp","trim","parseValue","serializedData","parsedValue","parse","getStorageItem","storage","getItem","timestamp","savedTimestamp","userCheck","Date","now","DATA_CACHE_TIMEOUT","removeItem","removeStorageItem","dispatchBasketUpdatedEvent","BasketUpdated","getDebugLogger","logReceivedEvent","type","pagePathPatterns","isReadyPromiseResolve","isReady","Promise","resolve","setCachedContext","setItem","setStorageItem","CONTEXT_KEY","useBasketProviderData","useApiClient","useSpaConfig","useToken","isInitialShoppingContextApplied","useRef","isRequestingShoppingContext","_useState","useState","_useState2","shoppingContext","setShoppingContext","updateContext","useCallback","eventTypeToBeTriggered","shouldStoreData","getStoredContext","clearContext","clearContextOnEvent","createEventListener","currentSettings","createRequestShoppingContextEventListener","setTimeout","current","getEventListeners","_step","_iterator","_createForOfIteratorHelper","s","n","done","_step$value","triggerActionEventName","eventListenerFactory","push","eventName","eventListener","err","e","f","useEffect","isCleanupPage","some","item","pathname","includes","isScheduled","SCHEDULED_CLEANUP_KEY","isScheduledCacheCleanup","eventListeners","PlaceOrderRequested","RequestClearShoppingCache","monitoredStorageChanges","callback","storageArea","newValue","listenToStoredItemChanges","addEventListener","isBasketProviderReady","removeEventListener","useMemo","BasketProvider","ApiProvider","children","globalApiUrl","useServiceUrls","token","_jsx","ApiClientProvider","baseUrl","BasketProviderController","App","currentLanguage","identityUrl","ServiceUrlsProvider","serviceUrls","SpaConfigProvider","ErrorBoundary","_Component","_this","_classCallCheck","_len","args","_key","_callSuper","_inherits","_createClass","this","state","props","Component","render","configElement","rootElement","_configElement$innerT","innerText","config","clientAppConfig","parseClientAppConfig","Error","createRoot","UniversalTokenProvider","initialToken"],"sourceRoot":""}