{
  "version": 3,
  "sources": ["/cdn/shop/t/113/assets/ada-upcart-keyboard.js?theme_ada=20260930-3"],
  "sourcesContent": ["(() => {\n  const observedRoots = new WeakSet();\n\n  // After the cart opens, UpCart moves focus to the first product link on its own (several times while it\n  // re-renders). Keep focus on the close button until the user interacts, instead of racing it with timers.\n  const OPEN_FOCUS_GUARD_MS = 2000;\n\n  // Adding to cart from a theme dialog (e.g. the product card \"Quick add\" drawer) opens UpCart on top of it, but\n  // the dialog's focus trap keeps pulling focus back into the dialog. Close such dialogs without letting them\n  // return focus, and make the dialog's own toggle the place focus goes back to when the cart closes.\n  const closeThemeDialogsUnderCart = () => {\n    document.querySelectorAll('[role=\"dialog\"][open]').forEach((dialog) => {\n      if (typeof dialog.hide !== \"function\" || !dialog._focusTrap) return;\n\n      const toggle = dialog.controls?.find((control) => control.getClientRects().length > 0);\n      if (toggle) {\n        document.dispatchEvent(\n          new CustomEvent(\"theme:upcart-return-target\", { detail: { target: toggle } })\n        );\n      }\n\n      // Deactivating the trap hides the dialog (its onDeactivate calls hide()).\n      dialog._focusTrap.deactivate({ returnFocus: false });\n      dialog.hide();\n    });\n  };\n\n  // The open cart is marked aria-modal, but that alone doesn't stop a screen reader's browse mode from reading the\n  // page behind it. While it is open, make the other top-level parts of the page inert, and undo exactly that.\n  const setPageBehindCartInert = (isOpen) => {\n    const host = document.querySelector(\"#upCart\");\n    if (isOpen && host) {\n      const cartRoot = Array.from(document.body.children).find((child) => child.contains(host));\n      Array.from(document.body.children).forEach((child) => {\n        if (child === cartRoot || child.inert || /^(SCRIPT|STYLE|LINK|NOSCRIPT|TEMPLATE)$/.test(child.tagName)) return;\n        child.inert = true;\n        child.dataset.themeCartInert = \"true\";\n      });\n    } else {\n      document.querySelectorAll(\"[data-theme-cart-inert]\").forEach((element) => {\n        element.inert = false;\n        delete element.dataset.themeCartInert;\n      });\n    }\n  };\n\n  const installUpcartKeyboardSupport = () => {\n    const root = document.querySelector(\"#upCart\")?.shadowRoot;\n    if (!root) return;\n\n    if (!root.querySelector(\"#theme-upcart-keyboard-focus\")) {\n      const style = document.createElement(\"style\");\n      style.id = \"theme-upcart-keyboard-focus\";\n      style.textContent = `\n      #UpcartPopup input[aria-label=\"Product quantity\"]:focus,\n      #UpcartPopup input[aria-label=\"Product quantity\"]:focus-visible {\n        outline: 3px solid #002c6b !important;\n        outline-offset: -3px !important;\n        box-shadow: none !important;\n      }\n      #UpcartPopup button[aria-label=\"Decrease quantity\"]:focus,\n      #UpcartPopup button[aria-label=\"Decrease quantity\"]:focus-visible,\n      #UpcartPopup button[aria-label=\"Increase quantity\"]:focus,\n      #UpcartPopup button[aria-label=\"Increase quantity\"]:focus-visible,\n      #UpcartPopup button[aria-label=\"Close cart\"]:focus,\n      #UpcartPopup button[aria-label=\"Close cart\"]:focus-visible,\n      #UpcartPopup .upcart-public-component-product-tile__subscription-upgrade-btn:focus,\n      #UpcartPopup .upcart-public-component-product-tile__subscription-upgrade-btn:focus-visible {\n        outline: 3px solid #002c6b !important;\n        outline-offset: -3px !important;\n        border-radius: 4px !important;\n        box-shadow: none !important;\n      }\n      #UpcartPopup .upcart-public-component-product-tile__subscription-upgrade-btn:focus-visible {\n        box-shadow: inset 0 0 0 5px #fff !important;\n      }\n    `;\n      root.appendChild(style);\n    }\n\n    if (observedRoots.has(root)) return;\n    observedRoots.add(root);\n\n    let activePopup = null;\n    let wasOpen = false;\n    let focusGuardUntil = 0;\n\n    const getOpenCloseButton = () => {\n      const popup = root.querySelector(\"#UpcartPopup\");\n      if (!popup?.classList.contains(\"upcartPopupShow\")) return null;\n      return popup.querySelector('[aria-label=\"Close cart\"]');\n    };\n\n    const holdFocusOnCloseButton = () => {\n      if (performance.now() > focusGuardUntil) return;\n      const closeButton = getOpenCloseButton();\n      if (closeButton && root.activeElement !== closeButton) {\n        closeButton.focus({ preventScroll: true });\n      }\n    };\n\n    const releaseFocusGuard = () => {\n      focusGuardUntil = 0;\n    };\n\n    // Document capture runs before the cart's own shadow-root handlers, some of which stop propagation.\n    document.addEventListener(\"keydown\", releaseFocusGuard, true);\n    document.addEventListener(\"pointerdown\", releaseFocusGuard, true);\n    root.addEventListener(\"focusin\", holdFocusOnCloseButton, true);\n\n    // UpCart renders product titles as <h4> directly under the <h2> cart title; expose them as level 3.\n    const repairHeadingLevels = () => {\n      root.querySelectorAll(\"#UpcartPopup h4\").forEach((heading) => {\n        if (heading.getAttribute(\"aria-level\") !== \"3\") {\n          heading.setAttribute(\"aria-level\", \"3\");\n        }\n      });\n    };\n\n    const handleCartState = () => {\n      repairHeadingLevels();\n      const popup = root.querySelector(\"#UpcartPopup\");\n      if (popup !== activePopup) {\n        activePopup = popup;\n        wasOpen = false;\n      }\n\n      const isOpen = popup?.classList.contains(\"upcartPopupShow\") || false;\n      if (isOpen && !wasOpen) {\n        closeThemeDialogsUnderCart();\n        focusGuardUntil = performance.now() + OPEN_FOCUS_GUARD_MS;\n      } else if (!isOpen) {\n        releaseFocusGuard();\n      }\n      wasOpen = isOpen;\n\n      // While closed, the cart panel is only slid past the right edge of the screen, so its close button, \"Shop Now\"\n      // and recommended products stay invisible tab stops (Tab after the last control on a page disappears into\n      // them). Make the closed panel inert; it is cleared before UpCart moves focus in on open.\n      const cartPanel = popup?.querySelector(\"#CartPopup\");\n      if (cartPanel && cartPanel.inert === isOpen) cartPanel.inert = !isOpen;\n      setPageBehindCartInert(isOpen);\n\n      // Also covers UpCart re-rendering the close button, which drops focus to <body>.\n      holdFocusOnCloseButton();\n    };\n\n    new MutationObserver(handleCartState).observe(root, {\n      childList: true,\n      subtree: true,\n      attributes: true,\n      attributeFilter: [\"class\"]\n    });\n    handleCartState();\n  };\n  // UpCart adds and changes items with its own requests, so the theme never hears about it and the header's cart\n  // count stayed at 0 (and hidden) while the cart had items. Watch for cart requests finishing and update the count\n  // (visible number and its screen reader text) from the server.\n  let cartCountTimer;\n  const syncCartCount = async () => {\n    const response = await fetch(`${window.Shopify?.routes?.root || \"/\"}cart.js`);\n    if (!response.ok) return;\n    const count = (await response.json()).item_count;\n    document.querySelectorAll(\"cart-count\").forEach((bubble) => {\n      const label = bubble.querySelector(\".sr-only\");\n      const number = bubble.querySelector(\"[aria-hidden='true']\");\n      if (label && number) {\n        label.textContent = `${count} ${count === 1 ? \"item\" : \"items\"}`;\n        number.textContent = String(count);\n      } else {\n        bubble.textContent = String(count);\n      }\n      bubble.classList.toggle(\"opacity-0\", count === 0);\n      bubble.style.opacity = count === 0 ? \"0\" : \"1\";\n    });\n  };\n  if (\"PerformanceObserver\" in window) {\n    new PerformanceObserver((list) => {\n      const cartChanged = list\n        .getEntries()\n        .some((entry) => /\\/cart\\/(add|change|update|clear)(\\.js)?$/.test(new URL(entry.name, location.href).pathname));\n      if (!cartChanged) return;\n      window.clearTimeout(cartCountTimer);\n      cartCountTimer = window.setTimeout(syncCartCount, 200);\n    }).observe({ type: \"resource\", buffered: false });\n  }\n\n  installUpcartKeyboardSupport();\n  new MutationObserver(installUpcartKeyboardSupport).observe(document.documentElement, {\n    childList: true,\n    subtree: true\n  });\n})();\n"],
  "mappings": "CAAC,IAAM,CACL,MAAM,cAAgB,IAAI,QAIpB,oBAAsB,IAKtB,2BAA6B,IAAM,CACvC,SAAS,iBAAiB,uBAAuB,EAAE,QAAS,QAAW,CACrE,GAAI,OAAO,OAAO,MAAS,YAAc,CAAC,OAAO,WAAY,OAE7D,MAAM,OAAS,OAAO,UAAU,KAAM,SAAY,QAAQ,eAAe,EAAE,OAAS,CAAC,EACjF,QACF,SAAS,cACP,IAAI,YAAY,6BAA8B,CAAE,OAAQ,CAAE,OAAQ,MAAO,CAAE,CAAC,CAC9E,EAIF,OAAO,WAAW,WAAW,CAAE,YAAa,EAAM,CAAC,EACnD,OAAO,KAAK,CACd,CAAC,CACH,EAIM,uBAA0B,QAAW,CACzC,MAAM,KAAO,SAAS,cAAc,SAAS,EAC7C,GAAI,QAAU,KAAM,CAClB,MAAM,SAAW,MAAM,KAAK,SAAS,KAAK,QAAQ,EAAE,KAAM,OAAU,MAA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