{
  "version": 3,
  "sources": ["/cdn/shop/t/40/assets/cart-drawer.js?bt_rev=20260729_mobile_swipe_close"],
  "sourcesContent": ["/* global SideDrawer */\n\nclass CartDrawer extends SideDrawer {\n  connectedCallback() {\n    this.bindEvents();\n    this.bindSwipeClose();\n  }\n\n  bindEvents() {\n    this.openDrawerViaEventHandler = this.handleDrawerOpenViaEvent.bind(this);\n    this.closeDrawerViaEventHandler = this.close.bind(this, null);\n    document.addEventListener('dispatch:cart-drawer:open', this.openDrawerViaEventHandler);\n    document.addEventListener('dispatch:cart-drawer:close', this.closeDrawerViaEventHandler);\n    document.addEventListener('dispatch:cart-drawer:refresh', this.cartRefreshHandler);\n    this.addEventListener('on:cart-drawer:before-open', () => {\n      document.documentElement.classList.add('cart-drawer-open');\n      theme.manuallyLoadImages(this);\n      this.querySelectorAll('cc-cart-cross-sell').forEach((el) => el.init());\n    });\n    this.addEventListener('on:cart-drawer:before-close', () => {\n      document.documentElement.classList.remove('cart-drawer-open');\n    });\n    this.addEventListener('on:cart:after-merge', () => {\n      theme.manuallyLoadImages(this);\n      this.querySelectorAll('cc-cart-cross-sell').forEach((el) => el.init());\n    });\n  }\n\n  bindSwipeClose() {\n    if (this.swipeStartHandler) return;\n\n    this.swipeStartHandler = this.handleSwipeStart.bind(this);\n    this.swipeMoveHandler = this.handleSwipeMove.bind(this);\n    this.swipeEndHandler = this.handleSwipeEnd.bind(this);\n    this.swipeCancelHandler = this.handleSwipeCancel.bind(this);\n    this.touchSwipeStartHandler = this.handleTouchSwipeStart.bind(this);\n    this.touchSwipeMoveHandler = this.handleTouchSwipeMove.bind(this);\n    this.touchSwipeEndHandler = this.handleTouchSwipeEnd.bind(this);\n    this.touchSwipeCancelHandler = this.handleTouchSwipeCancel.bind(this);\n\n    this.addEventListener('pointerdown', this.swipeStartHandler);\n    this.addEventListener('pointermove', this.swipeMoveHandler, { passive: false });\n    this.addEventListener('pointerup', this.swipeEndHandler);\n    this.addEventListener('pointercancel', this.swipeCancelHandler);\n    this.addEventListener('touchstart', this.touchSwipeStartHandler, { passive: true });\n    this.addEventListener('touchmove', this.touchSwipeMoveHandler, { passive: false });\n    this.addEventListener('touchend', this.touchSwipeEndHandler);\n    this.addEventListener('touchcancel', this.touchSwipeCancelHandler);\n  }\n\n  isSwipeStartAllowed(target) {\n    return target.closest('.cart-drawer__header, .cart-drawer__content, .cart-drawer__footer, .cart-drawer__empty-content')\n      && !target.closest('button, input, select, textarea, iframe, [contenteditable=\"true\"], a:not(.cart-item__image-link), carousel-slider, .slider, .buttoned-input, .cart-drawer-popup');\n  }\n\n  handleSwipeStart(evt) {\n    if (!this.hasAttribute('open')\n      || evt.isPrimary === false\n      || evt.pointerType === 'mouse'\n      || evt.pointerType === 'touch'\n      || this.swipeSettling\n      || (this.swipePointerId !== null && this.swipePointerId !== undefined)\n      || !this.isSwipeStartAllowed(evt.target)) {\n      return;\n    }\n\n    this.swipePointerId = evt.pointerId;\n    this.swipeStartX = evt.clientX;\n    this.swipeStartY = evt.clientY;\n    this.swipeStartTime = performance.now();\n    this.swipeDistance = 0;\n    this.swipeDragging = false;\n  }\n\n  handleSwipeMove(evt) {\n    if (evt.pointerId !== this.swipePointerId || this.swipeSettling) return;\n\n    const deltaX = evt.clientX - this.swipeStartX;\n    const deltaY = evt.clientY - this.swipeStartY;\n    const absX = Math.abs(deltaX);\n    const absY = Math.abs(deltaY);\n\n    if (!this.swipeDragging) {\n      if (Math.max(absX, absY) < 10) return;\n      if (absY >= absX || deltaX <= 0) {\n        this.resetSwipeTracking();\n        return;\n      }\n\n      this.swipeDragging = true;\n      this.classList.add('cart-drawer--swiping');\n      if (evt.pointerType !== 'touch-fallback') {\n        this.setPointerCapture?.(evt.pointerId);\n      }\n    }\n\n    if (evt.cancelable) evt.preventDefault();\n    this.swipeDistance = Math.min(this.offsetWidth, Math.max(0, deltaX));\n    this.style.setProperty('--cart-drawer-swipe-x', `${this.swipeDistance}px`);\n  }\n\n  handleSwipeEnd(evt) {\n    if (evt.pointerId !== this.swipePointerId) return;\n    if (!this.swipeDragging) {\n      this.resetSwipeTracking();\n      return;\n    }\n\n    const elapsed = Math.max(1, performance.now() - this.swipeStartTime);\n    const velocity = this.swipeDistance / elapsed;\n    const distanceThreshold = Math.min(120, this.offsetWidth * 0.3);\n    const shouldClose = this.swipeDistance >= distanceThreshold\n      || (this.swipeDistance >= 32 && velocity >= 0.55);\n\n    this.settleSwipe(shouldClose);\n  }\n\n  handleSwipeCancel(evt) {\n    if (evt.pointerId !== this.swipePointerId) return;\n    if (this.swipeDragging) {\n      this.settleSwipe(false);\n    } else {\n      this.resetSwipeTracking();\n    }\n  }\n\n  handleTouchSwipeStart(evt) {\n    if (evt.touches.length !== 1) return;\n\n    const touch = evt.touches[0];\n    this.handleSwipeStart({\n      isPrimary: true,\n      pointerType: 'touch-fallback',\n      pointerId: `touch-${touch.identifier}`,\n      clientX: touch.clientX,\n      clientY: touch.clientY,\n      target: evt.target\n    });\n  }\n\n  handleTouchSwipeMove(evt) {\n    const touch = Array.from(evt.touches).find((item) => `touch-${item.identifier}` === this.swipePointerId);\n    if (!touch) return;\n\n    this.handleSwipeMove({\n      pointerType: 'touch-fallback',\n      pointerId: this.swipePointerId,\n      clientX: touch.clientX,\n      clientY: touch.clientY,\n      cancelable: evt.cancelable,\n      preventDefault: () => evt.preventDefault()\n    });\n  }\n\n  handleTouchSwipeEnd(evt) {\n    const touch = Array.from(evt.changedTouches).find((item) => `touch-${item.identifier}` === this.swipePointerId);\n    if (!touch) return;\n    this.handleSwipeEnd({ pointerId: this.swipePointerId });\n  }\n\n  handleTouchSwipeCancel() {\n    if (typeof this.swipePointerId !== 'string' || !this.swipePointerId.startsWith('touch-')) return;\n    this.handleSwipeCancel({ pointerId: this.swipePointerId });\n  }\n\n  settleSwipe(shouldClose) {\n    this.swipeSettling = true;\n    this.classList.add('cart-drawer--swipe-settling');\n    this.style.setProperty(\n      '--cart-drawer-swipe-x',\n      shouldClose ? `${this.offsetWidth}px` : '0px'\n    );\n\n    const settleDuration = window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 180;\n    this.swipeSettleTimer = window.setTimeout(() => {\n      this.swipeSettleTimer = null;\n      if (shouldClose && this.hasAttribute('open')) {\n        this.close();\n      } else {\n        this.resetSwipeClose();\n      }\n    }, settleDuration + 20);\n  }\n\n  resetSwipeTracking() {\n    this.swipePointerId = null;\n    this.swipeStartX = null;\n    this.swipeStartY = null;\n    this.swipeStartTime = null;\n    this.swipeDistance = 0;\n    this.swipeDragging = false;\n  }\n\n  resetSwipeClose() {\n    if (this.swipeSettleTimer) {\n      window.clearTimeout(this.swipeSettleTimer);\n      this.swipeSettleTimer = null;\n    }\n    if (Number.isInteger(this.swipePointerId) && this.hasPointerCapture?.(this.swipePointerId)) {\n      this.releasePointerCapture(this.swipePointerId);\n    }\n\n    this.classList.remove('cart-drawer--swiping', 'cart-drawer--swipe-settling');\n    this.style.removeProperty('--cart-drawer-swipe-x');\n    this.swipeSettling = false;\n    this.resetSwipeTracking();\n  }\n\n  open(opener, elementToFocus, callback) {\n    this.resetSwipeClose();\n    super.open(opener, elementToFocus, callback);\n  }\n\n  close(callback) {\n    this.resetSwipeClose();\n    super.close(callback);\n  }\n\n  disconnectedCallback() {\n    document.documentElement.classList.remove('cart-drawer-open');\n    document.removeEventListener('dispatch:cart-drawer:refresh', this.cartRefreshHandler);\n    document.removeEventListener('dispatch:cart-drawer:open', this.openDrawerViaEventHandler);\n    document.removeEventListener('dispatch:cart-drawer:close', this.closeDrawerViaEventHandler);\n    this.removeEventListener('pointerdown', this.swipeStartHandler);\n    this.removeEventListener('pointermove', this.swipeMoveHandler);\n    this.removeEventListener('pointerup', this.swipeEndHandler);\n    this.removeEventListener('pointercancel', this.swipeCancelHandler);\n    this.removeEventListener('touchstart', this.touchSwipeStartHandler);\n    this.removeEventListener('touchmove', this.touchSwipeMoveHandler);\n    this.removeEventListener('touchend', this.touchSwipeEndHandler);\n    this.removeEventListener('touchcancel', this.touchSwipeCancelHandler);\n    this.resetSwipeClose();\n  }\n\n  /**\n   * Handle when the drawer is opened via an event\n   * @param {object} evt - Event object.\n   */\n  handleDrawerOpenViaEvent(evt) {\n    this.open(evt.detail ? evt.detail.opener : null);\n  }\n\n  /**\n   * Trigger refresh of contents\n   */\n  cartRefreshHandler() {\n    this.querySelector('cart-form').refresh();\n  }\n\n  /**\n   * Update section's cart-form element with new contents\n   * @param {string} html - Whole-section HTML.\n   */\n  updateFromCartChange(html) {\n    this.querySelector('cart-form').refreshFromHtml(html);\n  }\n}\n\nwindow.customElements.define('cart-drawer', CartDrawer);\n"],
  "mappings": "AAEA,MAAM,mBAAmB,UAAW,CAClC,mBAAoB,CAClB,KAAK,WAAW,EAChB,KAAK,eAAe,CACtB,CAEA,YAAa,CACX,KAAK,0BAA4B,KAAK,yBAAyB,KAAK,IAAI,EACxE,KAAK,2BAA6B,KAAK,MAAM,KAAK,KAAM,IAAI,EAC5D,SAAS,iBAAiB,4BAA6B,KAAK,yBAAyB,EACrF,SAAS,iBAAiB,6BAA8B,KAAK,0BAA0B,EACvF,SAAS,iBAAiB,+BAAgC,KAAK,kBAAkB,EACjF,KAAK,iBAAiB,6BAA8B,IAAM,CACxD,SAAS,gBAAgB,UAAU,IAAI,kBAAkB,EACzD,MAAM,mBAAmB,IAAI,EAC7B,KAAK,iBAAiB,oBAAoB,EAAE,QAAS,IAAO,GAAG,KAAK,CAAC,CACvE,CAAC,EACD,KAAK,iBAAiB,8BAA+B,IAAM,CACzD,SAAS,gBAAgB,UAAU,OAAO,kBAAkB,CAC9D,CAAC,EACD,KAAK,iBAAiB,sBAAuB,IAAM,CACjD,MAAM,mBAAmB,IAAI,EAC7B,KAAK,iBAAiB,oBAAoB,EAAE,QAAS,IAAO,GAAG,KAAK,CAAC,CACvE,CAAC,CACH,CAEA,gBAAiB,CACX,KAAK,oBAET,KAAK,kBAAoB,KAAK,iBAAiB,KAAK,IAAI,EACxD,KAAK,iBAAmB,KAAK,gBAAgB,KAAK,IAAI,EACtD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