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AvBA,EAAAA,EAAQa,uBAARb,IAAAA,OAAAA,EAAAA,EAAyBe,gBAGtB,CACL,IAAMC,E,sUAAa,IAAKvB,EAAiBO,GACzCC,EAAWe,EAAYZ,GACvBD,EAAS,CAAEhB,KAAM,SACnB,MALEgB,EAAS,CAAEhB,KAAM,cAAeY,UAAAA,EAAWD,YAAAA,EAAaE,OAAAA,IAQ1DM,SAASC,KAAKC,UAAUC,OAAO,mBAC/BH,SAASC,KAAKG,gBAAgB,cAChC,EAQF,C,osBC/DaO,cAAa,W,OAAbA,C,EA0BAC,MAAK,W,OAALA,C,IA1BN,IAAMD,EAAgB,SAACE,GAC5B,IAAMC,EAAIC,OAAOC,IAiBjB,OAhB4B,IAAIC,OAE9BH,EAAAA,KAEEA,EAAAA,KAEAA,EAAAA,KAGAA,EAAAA,KAEAA,EAAAA,KAEAA,EAAAA,MAGuBI,KAAKL,EAClC,EAOaD,EAAQ,Y,IACnBO,EAAAA,EAAAA,aAAAA,EAAAA,EACAC,iB,YAAAA,IAAmB,EAAAT,EAAAA,GACUQ,E,2ICvB/B,C,qBANkB,O,uDAMlB,EAAe,Y,IAAGE,EAAAA,EAAAA,S,OAChB,sB,WACE,SAACtG,OAAAA,CAAKjB,UAAU,O,SACb,GAAmBuH,OAAhBA,EAAS,SAA+B,OAAxBA,EAAW,EAAI,IAAM,GAAG,OACvC,uB","sources":["webpack://webstaurantstore/./ProductDetails/Pricing/AddToCart/AccessoryPopover.tsx","webpack://webstaurantstore/./common/AddToCart/Constants.ts","webpack://webstaurantstore/./common/AddToCartModal/AccessoriesModal.tsx","webpack://webstaurantstore/./common/AddToCartModal/index.ts","webpack://webstaurantstore/./common/AddToCartModal/useAddToCartModals.ts","webpack://webstaurantstore/./common/Email/EmailValidator.ts","webpack://webstaurantstore/./productListing/ProductBox/SuccessMessage.tsx"],"sourcesContent":["import {\n Icon,\n Popover,\n PopoverBody,\n PopoverContent,\n PopoverClose,\n PopoverTrigger,\n} from \"@clarkinc/zest-design-system/ui\";\nimport React, {\n FocusEventHandler,\n MouseEventHandler,\n MutableRefObject,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\ninterface Props {\n accessoryName: string;\n extendedInfo: string;\n placement?: \"left\" | \"right\" | \"bottom\" | \"top\";\n portalContainer?: HTMLElement;\n}\n\nconst AccessoryPopover = ({\n accessoryName,\n extendedInfo,\n placement,\n portalContainer,\n}: Props) => {\n const [open, setOpen] = useState(false);\n const [wasAutoFocusedOnClose, setWasAutoFocusedOnClose] = useState(false);\n const mouseOverRef: MutableRefObject = useRef(\n null\n );\n const contentRef = useRef(null);\n const triggerRef = useRef(null);\n\n const handleMouseEnter: MouseEventHandler<\n HTMLButtonElement | HTMLDivElement\n > = useCallback((e): void => {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n mouseOverRef.current = e.target as HTMLElement;\n setOpen(true);\n }, []);\n\n const handleMouseTriggerLeave = useCallback((): void => {\n if (contentRef.current?.contains(mouseOverRef.current)) {\n return;\n }\n setOpen(false);\n }, [contentRef]);\n\n const handleMouseContentLeave = useCallback((): void => {\n if (triggerRef.current?.contains(mouseOverRef.current)) {\n return;\n }\n setOpen(false);\n }, [triggerRef]);\n\n const handleFocus: FocusEventHandler = useCallback(() => {\n if (wasAutoFocusedOnClose) {\n setWasAutoFocusedOnClose(false);\n setOpen(false);\n return;\n }\n setOpen(true);\n }, [wasAutoFocusedOnClose]);\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n setOpen(false);\n setWasAutoFocusedOnClose(true);\n setTimeout(() => {\n triggerRef.current?.focus();\n }, 0);\n };\n\n return (\n \n \n \n \n {\n handleCloseAutoFocus(e);\n }}\n ref={contentRef}\n placement={placement}\n portalContainer={portalContainer}\n >\n \n \n {/* eslint-disable-next-line react/no-danger */}\n \n \n \n \n );\n};\nexport default AccessoryPopover;\n","export const AddToCartErrorNames = {\n cartItemCountLimit: \"cartItemCountLimit\",\n};\n\nexport const AddToCartErrorMessages = {\n cartItemCountLimitMessage:\n \"You have reached the maximum amount of items for a single order. Please place your order, so you can continue to purchase items on a second separate order.\",\n};\n","import React, { useCallback, useState } from \"react\";\nimport formatAsCurrency from \"@wss/utilities/formatAsCurrency\";\nimport Modal, { Header, Footer, Body } from \"~/common/ModalReact\";\nimport Button from \"~/common/Buttons\";\nimport { AddToCartModal } from \".\";\nimport { Accessory } from \"../Store/models/ProductListing\";\nimport AccessoryPopover from \"~/ProductDetails/Pricing/AddToCart/AccessoryPopover\";\n\ninterface Props extends AddToCartModal<\"accessories\"> {\n accessories: Readonly;\n itemNumber: string;\n previouslyPurchased?: boolean;\n}\n\nexport default ({\n isOpen,\n accessories,\n itemNumber,\n closeModal,\n submitModal,\n previouslyPurchased = false,\n}: Props) => {\n interface Values {\n [index: string]: string;\n }\n\n const [values, setValues] = useState({});\n\n const [errors, setErrors] = useState([]);\n\n const [portalContainer, setPortalContainer] = useState(\n null\n );\n\n const setModalRef = useCallback((node: HTMLDivElement | null) => {\n if (node) {\n setPortalContainer(node); // Store in state to trigger re-render for Modal content\n }\n }, []);\n\n const valid = () => {\n const newErrors: string[] = [];\n\n accessories.forEach((accessory) => {\n if (!accessory.isRequired || values[accessory.name]) return;\n\n newErrors.push(accessory.name);\n });\n\n setErrors(newErrors);\n\n return !newErrors.length;\n };\n\n const handleAddToCart = async (event: React.SyntheticEvent) => {\n event.preventDefault();\n\n if (valid()) {\n submitModal({ accessories: Object.values(values) });\n setValues({});\n }\n };\n\n const validateSingle = (accessoryName: string) => {\n setErrors([...errors].filter((error) => error !== accessoryName));\n };\n\n return (\n \n
\n

\n {`Product Accessories for ${itemNumber.toUpperCase()}`}\n

\n
\n\n \n
\n \n

\n This item has further options/accessories available.\n

\n {accessories.map((accessory) => (\n
\n \n {accessory.extendedInfo && (\n \n \n \n )}\n {\n setValues({\n ...values,\n [accessory.name]: e.target.value,\n });\n\n validateSingle(accessory.name);\n }}\n name=\"accessories\"\n className=\"form__control\"\n title={accessory.name}\n >\n \n {accessory.options.map((option) => (\n \n {option.available\n ? `${\n option.description\n } - ${formatAsCurrency.formatIfUndefined(\n Number(option.price)\n )}`\n : `${option.description} [OUT OF STOCK]`}\n \n ))}\n \n \n \n
\n
\n ))}\n {errors[0] && (\n

\n \n {`Please select a ${errors[0]} for this product.`}\n \n

\n )}\n \n \n \n
\n \n Cancel\n \n \n Add To Cart\n \n
\n \n );\n};\n","type AddToCartModalWithUserInput = {\n name: ModalName;\n result: ResultType;\n};\n\ntype AddToCartModalWithoutUserInput = {\n name: ModalName;\n};\n\n/*\n * Add To Cart Modal Types.\n * Add To Cart Modals with user input will map there result type to\n * their submit modal callbacks.\n */\ntype Accessories = AddToCartModalWithUserInput<\"accessories\", string[]>;\ntype VirtualGrouping = AddToCartModalWithUserInput<\n \"virtualGrouping\",\n VirtualGroupingInput\n>;\ntype Outlet = AddToCartModalWithoutUserInput<\"outlet\">;\ntype Warning = AddToCartModalWithoutUserInput<\"warning\">;\ntype CommercialUse = AddToCartModalWithUserInput<\"commercialUse\", boolean>;\ntype Warranty = AddToCartModalWithUserInput<\"warranty\", WarrantyOption>;\n\nexport type VirtualGroupingInput = {\n groupMemberItemNumber: string;\n hasAccessories: boolean;\n};\n\nexport type WarrantyOption = {\n warrantyId: number;\n skipCommercialModal?: boolean;\n noThanksSelected?: boolean;\n};\n\n/*\n * Add all of the Modals from above to one of these unions.\n */\ntype AddToCartModalsWithUserInput =\n | Accessories\n | VirtualGrouping\n | Warranty\n | CommercialUse;\ntype AddToCartModalsWithoutUserInput = Warning | Outlet;\n\ntype AddToCartModals =\n | AddToCartModalsWithUserInput\n | AddToCartModalsWithoutUserInput;\n\nexport type AddToCartModalNames = AddToCartModals[\"name\"];\ntype AddToCartModalWithUserInputName = AddToCartModalsWithUserInput[\"name\"];\n\ntype UnboxProductModalUserInput<\n ModalName extends AddToCartModalWithUserInputName,\n BoxedProductResult extends AddToCartModalsWithUserInput\n> = BoxedProductResult extends AddToCartModalWithUserInput<\n ModalName,\n infer ModalResult\n>\n ? ModalResult\n : never;\n\n/*\n * Takes the name of the modal and determines its result type\n */\ntype AddToCartModalUserInput<\n ModalName extends AddToCartModalWithUserInputName\n> = UnboxProductModalUserInput;\n\nexport type AddToCartModal = {\n isOpen: boolean;\n closeModal: () => void;\n submitModal: ModalName extends AddToCartModalWithUserInputName\n ? (result: { [K in ModalName]: AddToCartModalUserInput }) => void\n : () => void;\n};\n\n/*\n * Maps the modal name to a key with the correct type\n * EX:\n * ProductModalWithResult<\"isTrue\", boolean> -> isTrue?: boolean | undefined;\n * ProductModalWithResult<\"testArray\", string[]> -> testArray?: string[] | undefined;\n */\nexport type AddToCartModalUserInputs = {\n [Key in AddToCartModalWithUserInputName]?: AddToCartModalUserInput;\n};\n\nexport type State = {\n modalsToOpen: AddToCartModalNames[];\n modalResults: AddToCartModalUserInputs;\n activeModal: AddToCartModalNames | \"\";\n};\n\nexport type Action =\n | {\n type: \"openModal\";\n firstModal: AddToCartModalNames;\n otherModals: AddToCartModalNames[];\n }\n | {\n type: \"submitModal\";\n result?: AddToCartModalUserInputs;\n nextModal: AddToCartModalNames;\n otherModals: AddToCartModalNames[];\n }\n | {\n type: \"reset\";\n };\n\nexport const initialState: State = {\n modalsToOpen: [],\n modalResults: {},\n activeModal: \"\",\n};\n\nexport const reducer = (state: State, action: Action): State => {\n switch (action.type) {\n case \"openModal\":\n return {\n modalResults: {},\n activeModal: action.firstModal,\n modalsToOpen: action.otherModals,\n };\n case \"submitModal\":\n return {\n activeModal: action.nextModal,\n modalsToOpen: action.otherModals,\n modalResults: {\n ...state.modalResults,\n ...action.result,\n },\n };\n case \"reset\":\n return initialState;\n default:\n return state;\n }\n};\n","import { useCallback, useReducer } from \"react\";\nimport {\n AddToCartModalNames,\n AddToCartModalUserInputs,\n initialState,\n reducer,\n} from \".\";\n\ninterface Props {\n onComplete: (\n results: AddToCartModalUserInputs,\n openModals: (modals: AddToCartModalNames[]) => void\n ) => void;\n}\n\nconst useAddToCartModals = ({ onComplete }: Props) => {\n const [state, dispatch] = useReducer(reducer, initialState);\n const { modalsToOpen, modalResults, activeModal } = state;\n\n const openModals = (modals: AddToCartModalNames[]) => {\n if (modals[0]) {\n const [firstModal, ...otherModals] = modals;\n dispatch({ type: \"openModal\", firstModal, otherModals });\n }\n };\n\n const closeModal = useCallback(() => {\n // Workaround for react-modal issue: https://github.com/reactjs/react-modal/issues/888\n document.body.classList.remove(\"overflow-hidden\");\n document.body.removeAttribute(\"aria-hidden\");\n\n dispatch({ type: \"reset\" });\n }, []);\n\n const submitModal = (result?: AddToCartModalUserInputs) => {\n const [nextModal, ...otherModals] = modalsToOpen;\n\n if (\n nextModal &&\n (nextModal !== \"commercialUse\" ||\n !result?.warranty?.skipCommercialModal) &&\n (nextModal !== \"accessories\" ||\n !result?.virtualGrouping?.groupMemberItemNumber ||\n result?.virtualGrouping?.hasAccessories)\n ) {\n dispatch({ type: \"submitModal\", nextModal, otherModals, result });\n } else {\n const allResults = { ...modalResults, ...result };\n onComplete(allResults, openModals);\n dispatch({ type: \"reset\" });\n }\n\n // Workaround for react-modal issue: https://github.com/reactjs/react-modal/issues/888\n document.body.classList.remove(\"overflow-hidden\");\n document.body.removeAttribute(\"aria-hidden\");\n };\n\n return {\n openModals,\n activeModal,\n closeModal,\n submitModal,\n };\n};\n\nexport default useAddToCartModals;\n","export const validateEmail = (emailaddress: string) => {\n const r = String.raw;\n const emailAddressPattern = new RegExp(\n // beginning of string\n r`^` +\n // username portion: one or more characters that are not whitespace or @\n r`[^@\\s]+` +\n // an @ symbol\n r`@` +\n // domain components: one or more groups of one or more characters\n // other than @, \\, ., or whitespace, each followed by a . separator\n r`(?:[^@\\s\\\\.]+\\.)+` +\n // TLD: one additional domain component but without a . after it\n r`[^@\\s\\\\.]+` +\n // end of string\n r`$`\n );\n\n return emailAddressPattern.test(emailaddress);\n};\n\ninterface Params {\n emailAddress: string;\n validationsToRun?: typeof validateEmail;\n}\n\nexport const valid = ({\n emailAddress,\n validationsToRun = validateEmail,\n}: Params) => validationsToRun(emailAddress);\n","import React from \"react\";\n\ninterface Props {\n quantity: number;\n}\n\nexport default ({ quantity }: Props) => (\n <>\n \n {`${quantity} item${quantity > 1 ? \"s\" : \"\"} `}\n \n added to your cart\n \n);\n"],"names":["accessoryName","extendedInfo","placement","portalContainer","useState","open","setOpen","wasAutoFocusedOnClose","setWasAutoFocusedOnClose","mouseOverRef","useRef","contentRef","triggerRef","handleMouseEnter","useCallback","e","current","target","handleMouseTriggerLeave","contains","handleMouseContentLeave","handleFocus","Popover","onOpenChange","PopoverTrigger","aria-label","className","onMouseEnter","onMouseLeave","onFocus","ref","Icon","theme","data-testid","name","size","PopoverContent","onCloseAutoFocus","preventDefault","setTimeout","focus","PopoverClose","PopoverBody","span","dangerouslySetInnerHTML","__html","AddToCartErrorNames","AddToCartErrorMessages","cartItemCountLimit","cartItemCountLimitMessage","values","isOpen","accessories","itemNumber","closeModal","submitModal","previouslyPurchased","setValues","errors","setErrors","setPortalContainer","setModalRef","node","handleAddToCart","event","newErrors","forEach","accessory","isRequired","push","length","Object","Modal","onRequestClose","Header","h4","toUpperCase","Body","div","id","p","map","includes","AccessoryPopover","undefined","select","value","onChange","filter","error","title","option","disabled","options","available","formatAsCurrency","description","formatIfUndefined","Number","price","label","i","Footer","Button","color","type","onClick","gtm-id","initialState","reducer","modalsToOpen","modalResults","activeModal","state","action","firstModal","otherModals","nextModal","result","onComplete","useReducer","dispatch","openModals","modals","document","body","classList","remove","removeAttribute","warranty","skipCommercialModal","virtualGrouping","groupMemberItemNumber","hasAccessories","allResults","validateEmail","valid","emailaddress","r","String","raw","RegExp","test","emailAddress","validationsToRun","quantity"],"sourceRoot":""}