{"version":3,"file":"modal-upsell-section.min.js","mappings":"YACA,IAAAA,EAAA,CCAAA,EAAA,SAAAC,GACAC,OAAAC,eAAAF,EAAAG,OAAAC,YAAA,CAAsDC,MAAA,WACtDJ,OAAAC,eAAAF,EAAA,cAAgDK,OAAA,GAChD,oBCoCA,SAASC,EAAwBC,GAC/BC,GACF,CAUA,SAASA,IAKPC,oBAAoB,0BAA2BH,GAE/C,MAAMI,EAAcC,SAASC,cAAc,gBACvCF,IACFA,EAAYG,QAAQC,KAAO,QAE/B,CAEAC,iBAAiB,wBAvDjB,SAA+BR,GAC7B,MAAMG,EAAcC,SAASC,cAAc,gBAC3C,GAAIF,EAAa,CACf,MAAMM,EAAaL,SAASC,cAAc,eAExCF,EAAYG,QAAQI,QADlBD,EAC4B,QAIA,OAGhCN,EAAYG,QAAQC,KAAO,OAK3BC,iBAAiB,0BAA2BT,EAC9C,CACF,GAqCAS,iBAAiB,yBAtBjB,SAAgCR,GAC9BC,GACF","sources":["webpack://lange/webpack/bootstrap","webpack://lange/webpack/runtime/make namespace object","webpack://lange/./sections/modal-upsell/index.ts"],"sourcesContent":["// The require scope\nlet __webpack_require__ = {};\n\n","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","type UpsellOpenRequestedEvent = Event;\ntype UpsellCloseRequestedEvent = Event;\n\ndeclare global {\n  interface WindowEventMap {\n    'upsell-close-requested': UpsellCloseRequestedEvent;\n    'upsell-open-requested': UpsellOpenRequestedEvent;\n  }\n}\n\nfunction onUpsellOpenRequested(_event: UpsellOpenRequestedEvent) {\n  const upsellModal = document.querySelector('upsell-modal');\n  if (upsellModal) {\n    const cartDrawer = document.querySelector('cart-drawer');\n    if (cartDrawer) {\n      upsellModal.dataset.animate = 'false';\n    } else {\n      // only animate the upsell modal when the cart drawer is not available setting this again on\n      // close() is not needed\n      upsellModal.dataset.animate = 'true';\n    }\n\n    upsellModal.dataset.show = 'true';\n\n    // Only listen for dismissal once the upsell is actually shown. Registering when there is no\n    // upsell modal would leave a stray global listener that reacts to dismiss gestures meant for\n    // other modals.\n    addEventListener('modal-dismiss-requested', onModalDismissRequested);\n  }\n}\n\n/**\n * Closes the upsell when the user performs a light-dismiss gesture (a click on the backdrop or an\n * escape key press) while it is the open modal. The modal manager broadcasts this request to every\n * open modal; this listener is only attached while the upsell is open.\n *\n * This path closes the upsell and nothing else, so the shopper is left with no modal open. It is a\n * known difference from the upsell's own close control and the continue shopping button, which both\n * dispatch a cart open request on the way out and so return the shopper to the cart drawer.\n */\nfunction onModalDismissRequested(_event: WindowEventMap['modal-dismiss-requested']) {\n  closeUpsell();\n}\n\nfunction onUpsellCloseRequested(_event: UpsellCloseRequestedEvent) {\n  closeUpsell();\n}\n\n/**\n * Closes the upsell modal and removes the dismiss listener. Shared close routine that both the\n * upsell-close-requested event and the dismiss handler delegate to.\n */\nfunction closeUpsell() {\n  // Remove the dismiss listener here, in the shared routine, so it is cleaned up no matter which\n  // path closed the upsell. Closing via upsell-close-requested also needs the listener gone, so\n  // doing it only in the dismiss handler would leave it attached on that path. Removing a listener\n  // that was never registered (for example when no upsell modal was present to open) is harmless.\n  removeEventListener('modal-dismiss-requested', onModalDismissRequested);\n\n  const upsellModal = document.querySelector('upsell-modal');\n  if (upsellModal) {\n    upsellModal.dataset.show = 'false';\n  }\n}\n\naddEventListener('upsell-open-requested', onUpsellOpenRequested);\naddEventListener('upsell-close-requested', onUpsellCloseRequested);\n"],"names":["__webpack_require__","exports","Object","defineProperty","Symbol","toStringTag","value","onModalDismissRequested","_event","closeUpsell","removeEventListener","upsellModal","document","querySelector","dataset","show","addEventListener","cartDrawer","animate"],"sourceRoot":""}