{
  "version": 3,
  "sources": ["/cdn/shop/t/104/assets/bottom-sheet.js?x=1792313282"],
  "sourcesContent": ["/**\n * Drag-to-dismiss for the standard bottom sheet (snippets/bottom-sheet.liquid).\n *\n * The sheet follows the finger from its top strip (grip + title row). Let go\n * past CLOSE_DISTANCE, or flick down, and it closes; otherwise it settles back.\n * Closing is handed to <dialog-component> so the scroll lock and focus are\n * restored exactly as they are for the close button, Esc and the backdrop.\n *\n * One set of document listeners serves every sheet on the page, including ones\n * rendered after load. Pointer events, so mouse, pen and touch share one path.\n *\n * ponytail: the drag zone is the top strip only. Pulling down on the content\n * (when it is scrolled to the top) needs non-passive touch handlers to win the\n * gesture from native scrolling \u2014 add that if shoppers are seen trying it.\n */\n\n/** Drag distance that closes the sheet, in px. Same as the older hand-rolled sheets. */\nconst CLOSE_DISTANCE = 80;\n\n/** A shorter drag still closes when it is this fast, in px per ms. */\nconst FLICK_SPEED = 0.5;\nconst FLICK_MIN_DISTANCE = 24;\n\n/** Matches the settle transition in the snippet's stylesheet, plus a frame. */\nconst SETTLE_MS = 220;\n\n/** @type {{ sheet: HTMLDialogElement, pointerId: number, startY: number, startTime: number, offset: number } | null} */\nlet drag = null;\n\ndocument.addEventListener('pointerdown', (event) => {\n  if (!(event.target instanceof Element)) return;\n\n  const zone = event.target.closest('[data-bottom-sheet-drag]');\n  // The close button sits inside the zone; a press on it is a tap, not a drag.\n  if (!zone || event.target.closest('button')) return;\n  if (event.pointerType === 'mouse' && event.button !== 0) return;\n  // From 750px up the sheet is a centred popup with no grip (see the snippet's stylesheet).\n  if (window.matchMedia('(min-width: 750px)').matches) return;\n\n  const sheet = zone.closest('dialog');\n  if (!sheet) return;\n\n  drag = { sheet, pointerId: event.pointerId, startY: event.clientY, startTime: event.timeStamp, offset: 0 };\n  sheet.classList.remove('bottom-sheet--settling');\n  zone.setPointerCapture(event.pointerId);\n});\n\ndocument.addEventListener('pointermove', (event) => {\n  if (!drag || event.pointerId !== drag.pointerId) return;\n\n  // Downward only: the sheet is already as high as it goes.\n  drag.offset = Math.max(0, event.clientY - drag.startY);\n  drag.sheet.style.transform = `translateY(${drag.offset}px)`;\n});\n\n/** @param {PointerEvent} event */\nfunction endDrag(event) {\n  if (!drag || event.pointerId !== drag.pointerId) return;\n\n  const { sheet, offset, startTime } = drag;\n  drag = null;\n\n  // Closed some other way mid-drag (Esc, a tap on the backdrop): there is nothing\n  // left to close or settle, and a leftover offset would displace the next open.\n  if (!sheet.open) {\n    sheet.style.transform = '';\n    return;\n  }\n\n  const speed = offset / Math.max(1, event.timeStamp - startTime);\n  const shouldClose =\n    event.type === 'pointerup' && (offset > CLOSE_DISTANCE || (offset > FLICK_MIN_DISTANCE && speed > FLICK_SPEED));\n  const component = /** @type {(HTMLElement & { closeDialog?: () => void }) | null} */ (sheet.closest('dialog-component'));\n\n  if (shouldClose && typeof component?.closeDialog === 'function') {\n    // The slide-out starts from where the finger left the sheet, not from the top.\n    sheet.style.setProperty('--bottom-sheet-from', `${offset}px`);\n    component.addEventListener(\n      'dialog:close',\n      () => {\n        sheet.style.transform = '';\n        sheet.style.removeProperty('--bottom-sheet-from');\n      },\n      { once: true }\n    );\n    component.closeDialog();\n    return;\n  }\n\n  sheet.classList.add('bottom-sheet--settling');\n  sheet.style.transform = '';\n  setTimeout(() => sheet.classList.remove('bottom-sheet--settling'), SETTLE_MS);\n}\n\ndocument.addEventListener('pointerup', endDrag);\ndocument.addEventListener('pointercancel', endDrag);\n"],
  "mappings": "AAiBA,MAAM,eAAiB,GAGjB,YAAc,GACd,mBAAqB,GAGrB,UAAY,IAGlB,IAAI,KAAO,KAEX,SAAS,iBAAiB,cAAgB,OAAU,CAClD,GAAI,EAAE,MAAM,kBAAkB,SAAU,OAExC,MAAM,KAAO,MAAM,OAAO,QAAQ,0BAA0B,EAK5D,GAHI,CAAC,MAAQ,MAAM,OAAO,QAAQ,QAAQ,GACtC,MAAM,cAAgB,SAAW,MAAM,SAAW,GAElD,OAAO,WAAW,oBAAoB,EAAE,Q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