{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popup-exit-intent",
  "type": "registry:component",
  "title": "Exit Intent Popup",
  "description": "Opens when the pointer leaves through the top of the window and reminds the visitor of their bag. The coupon stub tears off when pulled down or tapped, revealing a code that can be copied and a discounted total.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "exit-intent",
    "popup",
    "coupon",
    "ecommerce",
    "retention",
    "drag"
  ],
  "docs": "https://hyperblur.dev/effects/popup-exit-intent",
  "files": [
    {
      "path": "registry/hyperblur/popup-exit-intent.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/popup-exit-intent.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PopupExitIntentItem {\n  name: string;\n  variant: string;\n  price: number;\n  tint: string;\n}\n\nexport interface PopupExitIntentProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  title?: string;\n  description?: string;\n  code?: string;\n  discount?: string;\n  items?: PopupExitIntentItem[];\n  currency?: string;\n  locale?: string;\n  threshold?: number;\n  delay?: number;\n  once?: boolean;\n  storageKey?: string;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  onReveal?: (code: string) => void;\n  onCheckout?: () => void;\n  showTrigger?: boolean;\n  triggerLabel?: string;\n  embedded?: boolean;\n  accent?: string;\n}\n\nconst defaultItems: PopupExitIntentItem[] = [\n  { name: \"Merino Crew Sweater\", variant: \"Oat · M\", price: 89, tint: \"#d9b98c\" },\n  { name: \"Canvas Field Tote\", variant: \"Olive\", price: 43, tint: \"#7d8a5a\" },\n];\n\nconst focusable = 'a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction useModal(active: boolean, panelRef: React.RefObject<HTMLElement | null>, onClose: () => void) {\n  const closeRef = React.useRef(onClose);\n  React.useEffect(() => {\n    closeRef.current = onClose;\n  });\n  React.useEffect(() => {\n    if (!active) return;\n    const panel = panelRef.current;\n    if (!panel) return;\n    const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n    const html = document.documentElement;\n    const prevOverflow = html.style.overflow;\n    html.style.overflow = \"hidden\";\n    (panel.querySelector<HTMLElement>(\"[data-autofocus]\") ?? panel).focus({ preventScroll: true });\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        closeRef.current();\n        return;\n      }\n      if (e.key !== \"Tab\") return;\n      const nodes = Array.from(panel.querySelectorAll<HTMLElement>(focusable)).filter((n) => n.getClientRects().length > 0);\n      if (!nodes.length) {\n        e.preventDefault();\n        return;\n      }\n      const first = nodes[0];\n      const last = nodes[nodes.length - 1];\n      const cur = document.activeElement;\n      if (e.shiftKey && (cur === first || cur === panel || !panel.contains(cur))) {\n        e.preventDefault();\n        last.focus();\n      } else if (!e.shiftKey && (cur === last || !panel.contains(cur))) {\n        e.preventDefault();\n        first.focus();\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      html.style.overflow = prevOverflow;\n      opener?.focus({ preventScroll: true });\n    };\n  }, [active, panelRef]);\n}\n\nfunction usePresence(open: boolean, ms: number) {\n  const [mounted, setMounted] = React.useState(open);\n  if (open && !mounted) setMounted(true);\n  React.useEffect(() => {\n    if (open || !mounted) return;\n    const t = window.setTimeout(() => setMounted(false), ms);\n    return () => window.clearTimeout(t);\n  }, [open, mounted, ms]);\n  return mounted;\n}\n\nconst css = `\n.hb-xf5 { --hb-xf5-accent: #e8573f; box-sizing: border-box; font-family: inherit; color: #ededed; }\n.hb-xf5 *, .hb-xf5 *::before, .hb-xf5 *::after { box-sizing: border-box; }\n.hb-xf5-embedded { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }\n.hb-xf5-trigger { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: #ededed; background: #161616; border: 1px solid #2a2a2a; cursor: pointer; transition: border-color .2s, transform .15s cubic-bezier(.3,.7,.4,1); }\n.hb-xf5-trigger:hover { border-color: #3a3a3a; }\n.hb-xf5-trigger:active { transform: scale(.97); }\n.hb-xf5-trigger:focus-visible { outline: 2px solid var(--hb-xf5-accent); outline-offset: 2px; }\n.hb-xf5-trigger svg { width: 14px; height: 14px; }\n.hb-xf5-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; min-height: 100dvh; }\n.hb-xf5-embedded .hb-xf5-overlay { position: relative; inset: auto; min-height: 0; padding: 0; width: 100%; }\n.hb-xf5-scrim { position: absolute; inset: 0; background: rgba(5,5,5,.72); backdrop-filter: blur(4px) saturate(.8); animation: hb-xf5-fade .3s ease both; }\n.hb-xf5-embedded .hb-xf5-scrim { display: none; }\n.hb-xf5-overlay[data-state=\"closed\"] .hb-xf5-scrim { animation: hb-xf5-fade .2s ease reverse both; }\n.hb-xf5-panel { position: relative; width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow: auto; border-radius: 22px; padding: 20px; background: linear-gradient(180deg, #181818, #101010 50%); border: 1px solid #2a2a2a; box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 40px 80px -30px rgba(0,0,0,.9); outline: none; animation: hb-xf5-in .5s cubic-bezier(.16,1,.3,1) both; }\n.hb-xf5-overlay[data-state=\"closed\"] .hb-xf5-panel { animation: hb-xf5-out .2s cubic-bezier(.4,0,1,1) both; }\n.hb-xf5-close { all: unset; position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #8f8f8f; cursor: pointer; transition: background .2s, color .2s; }\n.hb-xf5-close:hover { background: #1f1f1f; color: #ededed; }\n.hb-xf5-close:focus-visible { outline: 2px solid var(--hb-xf5-accent); }\n.hb-xf5-close svg { width: 14px; height: 14px; }\n.hb-xf5-title { margin: 0; padding-right: 30px; font-family: var(--font-grotesk), var(--font-sans), sans-serif; font-size: 21px; font-weight: 600; letter-spacing: -.02em; }\n.hb-xf5-desc { margin: 4px 0 14px; font-size: 12.5px; color: #a1a1a1; }\n.hb-xf5-items { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }\n.hb-xf5-item { display: flex; align-items: center; gap: 10px; }\n.hb-xf5-thumb { position: relative; width: 40px; height: 40px; border-radius: 10px; flex: none; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--hb-xf5-tint) 80%, #fff), var(--hb-xf5-tint) 60%, color-mix(in srgb, var(--hb-xf5-tint) 60%, #000)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }\n.hb-xf5-thumb::after { content: \"\"; position: absolute; left: 10px; right: 10px; top: 12px; bottom: 9px; border-radius: 6px 6px 4px 4px; border: 2px solid rgba(0,0,0,.25); border-top-width: 5px; }\n.hb-xf5-iname { margin: 0; font-size: 12.5px; font-weight: 500; }\n.hb-xf5-ivar { margin: 1px 0 0; font-size: 11px; color: #8f8f8f; }\n.hb-xf5-price { margin-left: auto; font-size: 12.5px; font-variant-numeric: tabular-nums; color: #d4d4d4; }\n.hb-xf5-ticket { position: relative; display: flex; height: 76px; margin-bottom: 14px; filter: drop-shadow(0 10px 20px rgba(0,0,0,.45)); }\n.hb-xf5-main { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 16px; border-radius: 14px 0 0 14px; background: linear-gradient(120deg, color-mix(in srgb, var(--hb-xf5-accent) 90%, #fff 0%), color-mix(in srgb, var(--hb-xf5-accent) 70%, #000)); color: #fff; overflow: hidden; mask: radial-gradient(circle 8px at 100% 0, transparent 98%, #000) top right / 100% 51% no-repeat, radial-gradient(circle 8px at 100% 100%, transparent 98%, #000) bottom right / 100% 51% no-repeat; }\n.hb-xf5-main::before { content: \"\"; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, rgba(255,255,255,.06) 0 6px, transparent 6px 12px); }\n.hb-xf5-off { position: relative; font-family: var(--font-grotesk), var(--font-sans), sans-serif; font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }\n.hb-xf5-offsub { position: relative; margin-top: 4px; font-size: 11px; opacity: .85; }\n.hb-xf5-under { position: absolute; right: 0; top: 0; bottom: 0; width: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-radius: 0 14px 14px 0; background: #0d0d0d; border: 1px dashed #333; border-left: 0; }\n.hb-xf5-code { font-family: var(--font-mono), ui-monospace, monospace; font-size: 15px; font-weight: 600; letter-spacing: .14em; color: #fff; }\n.hb-xf5-copy { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 11px; color: #a1a1a1; background: #1a1a1a; border: 1px solid #2c2c2c; cursor: pointer; transition: color .2s, border-color .2s; }\n.hb-xf5-copy:hover { color: #ededed; border-color: #3c3c3c; }\n.hb-xf5-copy:focus-visible { outline: 2px solid var(--hb-xf5-accent); outline-offset: 2px; }\n.hb-xf5-copy[data-done=\"true\"] { color: #3ddc84; border-color: #1f4d33; }\n.hb-xf5-copy svg { width: 11px; height: 11px; }\n.hb-xf5-stub { all: unset; box-sizing: border-box; position: relative; width: 132px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 0 14px 14px 0; background: linear-gradient(120deg, color-mix(in srgb, var(--hb-xf5-accent) 70%, #000), color-mix(in srgb, var(--hb-xf5-accent) 55%, #000)); color: #fff; cursor: grab; touch-action: none; transform-origin: 0 100%; transform: translateY(var(--hb-xf5-pull, 0px)) rotate(calc(var(--hb-xf5-pull, 0px) * .12deg)); mask: radial-gradient(circle 8px at 0 0, transparent 98%, #000) top left / 100% 51% no-repeat, radial-gradient(circle 8px at 0 100%, transparent 98%, #000) bottom left / 100% 51% no-repeat; transition: transform .45s cubic-bezier(.3,1.5,.5,1); }\n.hb-xf5-stub[data-dragging=\"true\"] { transition: none; cursor: grabbing; }\n.hb-xf5-stub::before { content: \"\"; position: absolute; left: 0; top: 10px; bottom: 10px; border-left: 2px dotted rgba(255,255,255,.45); }\n.hb-xf5-stub:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }\n.hb-xf5-stub b { font-size: 12px; font-weight: 600; }\n.hb-xf5-stub small { font-size: 10.5px; opacity: .75; }\n.hb-xf5-stub svg { width: 16px; height: 16px; animation: hb-xf5-nudge 1.8s cubic-bezier(.4,0,.2,1) infinite; }\n.hb-xf5-stub[data-torn=\"true\"] { pointer-events: none; animation: hb-xf5-fall .7s cubic-bezier(.5,0,.75,0) both; }\n.hb-xf5-sum { display: flex; justify-content: space-between; margin: 0 0 12px; font-size: 12.5px; color: #a1a1a1; font-variant-numeric: tabular-nums; }\n.hb-xf5-sum b { font-weight: 600; color: #ededed; }\n.hb-xf5-sum s { color: #6f6f6f; margin-right: 6px; }\n.hb-xf5-cta { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 42px; border-radius: 12px; font-size: 13.5px; font-weight: 600; color: #0a0a0a; background: linear-gradient(#fafafa, #dedede); box-shadow: inset 0 -1px 0 rgba(0,0,0,.2), 0 10px 24px -12px rgba(255,255,255,.4); cursor: pointer; transition: transform .15s cubic-bezier(.3,.7,.4,1), background .2s; }\n.hb-xf5-cta:hover { background: #fff; }\n.hb-xf5-cta:active { transform: scale(.98); }\n.hb-xf5-cta:focus-visible { outline: 2px solid var(--hb-xf5-accent); outline-offset: 2px; }\n.hb-xf5-cta svg { width: 14px; height: 14px; transition: transform .25s cubic-bezier(.3,.7,.4,1); }\n.hb-xf5-cta:hover svg { transform: translateX(3px); }\n.hb-xf5-skip { all: unset; display: block; margin: 10px auto 0; font-size: 12px; color: #7a7a7a; cursor: pointer; }\n.hb-xf5-skip:hover { color: #ededed; }\n.hb-xf5-skip:focus-visible { outline: 2px solid var(--hb-xf5-accent); outline-offset: 2px; border-radius: 3px; }\n@keyframes hb-xf5-fade { from { opacity: 0; } }\n@keyframes hb-xf5-in { 0% { opacity: 0; transform: translateY(-40px) scale(.96); } 100% { opacity: 1; transform: none; } }\n@keyframes hb-xf5-out { to { opacity: 0; transform: translateY(12px) scale(.98); } }\n@keyframes hb-xf5-fall { 0% { transform: translateY(var(--hb-xf5-pull, 0px)) rotate(4deg); opacity: 1; } 100% { transform: translate(30px, 180px) rotate(38deg); opacity: 0; } }\n@keyframes hb-xf5-nudge { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(4px); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xf5 *, .hb-xf5 *::before { animation: none !important; transition: none !important; }\n  .hb-xf5-stub[data-torn=\"true\"] { opacity: 0; }\n}\n`;\n\nexport function PopupExitIntent({\n  title = \"Leaving already?\",\n  description = \"Your bag is saved for 48 hours. Tear off the stub for a little push.\",\n  code = \"STAY15\",\n  discount = \"15% off\",\n  items = defaultItems,\n  currency = \"USD\",\n  locale = \"en-US\",\n  threshold = 12,\n  delay = 4000,\n  once = true,\n  storageKey = \"hb-exit-intent\",\n  open,\n  defaultOpen,\n  onOpenChange,\n  onReveal,\n  onCheckout,\n  showTrigger = true,\n  triggerLabel = \"Preview exit offer\",\n  embedded = false,\n  accent = \"#e8573f\",\n  className = \"\",\n  style,\n  ...rest\n}: PopupExitIntentProps) {\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const [inner, setInner] = React.useState(defaultOpen ?? embedded);\n  const isOpen = open ?? inner;\n  const mounted = usePresence(isOpen, 220);\n  const panelRef = React.useRef<HTMLDivElement>(null);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const touched = React.useRef(false);\n  const [torn, setTorn] = React.useState(false);\n  const [gone, setGone] = React.useState(false);\n  const [pull, setPull] = React.useState(0);\n  const [dragging, setDragging] = React.useState(false);\n  const [copied, setCopied] = React.useState(false);\n  const drag = React.useRef<{ y: number; id: number } | null>(null);\n  const timers = React.useRef<number[]>([]);\n\n  const money = React.useMemo(() => new Intl.NumberFormat(locale, { style: \"currency\", currency }), [locale, currency]);\n\n  const setOpen = React.useCallback(\n    (value: boolean) => {\n      touched.current = true;\n      if (open === undefined) setInner(value);\n      onOpenChange?.(value);\n    },\n    [open, onOpenChange],\n  );\n  const close = React.useCallback(() => setOpen(false), [setOpen]);\n  useModal(isOpen && !embedded, panelRef, close);\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach((t) => window.clearTimeout(t));\n  }, []);\n\n  React.useEffect(() => {\n    if (!embedded || !touched.current) return;\n    if (isOpen) panelRef.current?.focus({ preventScroll: true });\n    else triggerRef.current?.focus({ preventScroll: true });\n  }, [embedded, isOpen]);\n\n  React.useEffect(() => {\n    if (embedded || isOpen) return;\n    let armed = false;\n    const arm = window.setTimeout(() => {\n      armed = true;\n    }, delay);\n    const onOut = (e: MouseEvent) => {\n      if (!armed || e.relatedTarget || e.clientY > threshold) return;\n      if (once) {\n        try {\n          if (window.sessionStorage.getItem(storageKey)) return;\n          window.sessionStorage.setItem(storageKey, \"1\");\n        } catch {}\n      }\n      setOpen(true);\n    };\n    document.addEventListener(\"mouseout\", onOut);\n    return () => {\n      window.clearTimeout(arm);\n      document.removeEventListener(\"mouseout\", onOut);\n    };\n  }, [embedded, isOpen, delay, threshold, once, storageKey, setOpen]);\n\n  const tear = () => {\n    if (torn) return;\n    setTorn(true);\n    setDragging(false);\n    onReveal?.(code);\n    timers.current.push(window.setTimeout(() => setGone(true), 700));\n    timers.current.push(window.setTimeout(() => panelRef.current?.querySelector<HTMLElement>(\".hb-xf5-copy\")?.focus({ preventScroll: true }), 720));\n  };\n\n  const copy = () => {\n    navigator.clipboard?.writeText(code).catch(() => {});\n    setCopied(true);\n    timers.current.push(window.setTimeout(() => setCopied(false), 1800));\n  };\n\n  const subtotal = items.reduce((s, i) => s + i.price, 0);\n  const pct = Number.parseFloat(discount) || 0;\n  const after = discount.includes(\"%\") ? subtotal * (1 - pct / 100) : subtotal - pct;\n\n  return (\n    <div\n      className={`hb-xf5 ${embedded ? \"hb-xf5-embedded\" : \"\"} ${className}`}\n      style={{ \"--hb-xf5-accent\": accent, ...style } as React.CSSProperties}\n      onKeyDown={(e) => {\n        if (embedded && e.key === \"Escape\" && isOpen) {\n          e.stopPropagation();\n          close();\n        }\n      }}\n      {...rest}\n    >\n      <style href=\"hb-popup-exit-intent\" precedence=\"default\">{css}</style>\n      {showTrigger && (!embedded || !mounted) && (\n        <button ref={triggerRef} type=\"button\" className=\"hb-xf5-trigger\" aria-haspopup=\"dialog\" onClick={() => setOpen(true)}>\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M15 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-4M10 16l4-4-4-4M14 12H4\" /></svg>\n          {triggerLabel}\n        </button>\n      )}\n      {mounted && (\n        <div className=\"hb-xf5-overlay\" data-state={isOpen ? \"open\" : \"closed\"}>\n          <div className=\"hb-xf5-scrim\" onClick={close} aria-hidden=\"true\" />\n          <div ref={panelRef} className=\"hb-xf5-panel\" role=\"dialog\" aria-modal={embedded ? undefined : true} aria-labelledby={`${uid}-t`} aria-describedby={`${uid}-d`} tabIndex={-1}>\n            <button type=\"button\" className=\"hb-xf5-close\" aria-label=\"Close\" onClick={close}>\n              <svg viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"m3 3 8 8M11 3l-8 8\" /></svg>\n            </button>\n            <h2 className=\"hb-xf5-title\" id={`${uid}-t`}>{title}</h2>\n            <p className=\"hb-xf5-desc\" id={`${uid}-d`}>{description}</p>\n            <ul className=\"hb-xf5-items\">\n              {items.map((it) => (\n                <li key={it.name} className=\"hb-xf5-item\">\n                  <span className=\"hb-xf5-thumb\" style={{ \"--hb-xf5-tint\": it.tint } as React.CSSProperties} aria-hidden=\"true\" />\n                  <div style={{ minWidth: 0 }}>\n                    <p className=\"hb-xf5-iname\">{it.name}</p>\n                    <p className=\"hb-xf5-ivar\">{it.variant}</p>\n                  </div>\n                  <span className=\"hb-xf5-price\">{money.format(it.price)}</span>\n                </li>\n              ))}\n            </ul>\n            <div className=\"hb-xf5-ticket\">\n              <div className=\"hb-xf5-main\">\n                <span className=\"hb-xf5-off\">{discount}</span>\n                <span className=\"hb-xf5-offsub\">Your whole bag, today only</span>\n              </div>\n              {torn && (\n                <div className=\"hb-xf5-under\" aria-live=\"polite\">\n                  <span className=\"hb-xf5-code\">{code}</span>\n                  <button type=\"button\" className=\"hb-xf5-copy\" data-done={copied} onClick={copy}>\n                    {copied ? (\n                      <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"m2.5 6.2 2.3 2.3 4.7-5\" /></svg>\n                    ) : (\n                      <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.4\" aria-hidden=\"true\"><rect x=\"4\" y=\"4\" width=\"6.5\" height=\"6.5\" rx=\"1.5\" /><path d=\"M8 4V2.5A1 1 0 0 0 7 1.5H2.5a1 1 0 0 0-1 1V7a1 1 0 0 0 1 1H4\" /></svg>\n                    )}\n                    {copied ? \"Copied\" : \"Copy code\"}\n                  </button>\n                </div>\n              )}\n              {!gone && (\n                <button\n                  type=\"button\"\n                  className=\"hb-xf5-stub\"\n                  data-autofocus\n                  data-torn={torn}\n                  data-dragging={dragging}\n                  aria-label={`Tear off to reveal your ${discount} code`}\n                  style={{ \"--hb-xf5-pull\": `${pull}px` } as React.CSSProperties}\n                  onClick={() => {\n                    if (pull < 4) tear();\n                  }}\n                  onPointerDown={(e) => {\n                    if (torn) return;\n                    drag.current = { y: e.clientY, id: e.pointerId };\n                    e.currentTarget.setPointerCapture(e.pointerId);\n                    setDragging(true);\n                  }}\n                  onPointerMove={(e) => {\n                    if (!drag.current || drag.current.id !== e.pointerId) return;\n                    const dy = Math.max(0, Math.min(60, e.clientY - drag.current.y));\n                    setPull(Math.round(dy));\n                    if (dy > 42) {\n                      drag.current = null;\n                      tear();\n                    }\n                  }}\n                  onPointerUp={() => {\n                    drag.current = null;\n                    setDragging(false);\n                    if (!torn) window.setTimeout(() => setPull(0), 0);\n                  }}\n                  onPointerCancel={() => {\n                    drag.current = null;\n                    setDragging(false);\n                    setPull(0);\n                  }}\n                >\n                  <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M8 3v9M4.5 8.5 8 12l3.5-3.5\" /></svg>\n                  <b>Tear here</b>\n                  <small>pull down or tap</small>\n                </button>\n              )}\n            </div>\n            <p className=\"hb-xf5-sum\">\n              <span>Bag total</span>\n              <span>\n                {torn && <s>{money.format(subtotal)}</s>}\n                <b>{money.format(torn ? after : subtotal)}</b>\n              </span>\n            </p>\n            <button\n              type=\"button\"\n              className=\"hb-xf5-cta\"\n              onClick={() => {\n                onCheckout?.();\n                close();\n              }}\n            >\n              Return to checkout\n              <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M3 8h10M9 4l4 4-4 4\" /></svg>\n            </button>\n            <button type=\"button\" className=\"hb-xf5-skip\" onClick={close}>No thanks, I will pay full price</button>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}