{
  "version": 3,
  "sources": ["/cdn/shop/t/8/assets/fly-to-cart.js?cb=jch2oepiyd"],
  "sourcesContent": ["import { yieldToMainThread } from '@theme/utilities';\nimport { Component } from '@theme/component';\n\n/**\n * FlyToCart custom element for animating product images to cart\n * This component creates a visual effect of a product \"flying\" to the cart when added\n */\nclass FlyToCart extends Component {\n  /** @type {Element} */\n  source;\n\n  /** @type {boolean} */\n  useSourceSize = false;\n\n  /** @type {Element} */\n  destination;\n\n  connectedCallback() {\n    super.connectedCallback();\n    const intersectionObserver = new IntersectionObserver((entries) => {\n      /** @type {DOMRectReadOnly | null} */\n      let sourceRect = null;\n      /** @type {DOMRectReadOnly | null} */\n      let destinationRect = null;\n\n      entries.forEach((entry) => {\n        if (entry.target === this.source) {\n          sourceRect = entry.boundingClientRect;\n        } else if (entry.target === this.destination) {\n          destinationRect = entry.boundingClientRect;\n        }\n      });\n\n      if (sourceRect && destinationRect) {\n        this.#animate(sourceRect, destinationRect);\n      }\n\n      intersectionObserver.disconnect();\n    });\n    intersectionObserver.observe(this.source);\n    intersectionObserver.observe(this.destination);\n  }\n\n  /**\n   * Animates the flying thingy along the bezier curve.\n   * @param {DOMRectReadOnly} sourceRect - The bounding client rect of the source.\n   * @param {DOMRectReadOnly} destinationRect - The bounding client rect of the destination.\n   */\n  #animate = async (sourceRect, destinationRect) => {\n    //Define bezier curve points\n    const startPoint = {\n      x: sourceRect.left + sourceRect.width / 2,\n      y: sourceRect.top + sourceRect.height / 2,\n    };\n\n    const endPoint = {\n      x: destinationRect.left + destinationRect.width / 2,\n      y: destinationRect.top + destinationRect.height / 2,\n    };\n\n    // Position the flying thingy back to the start point\n    if (this.useSourceSize) {\n      this.style.setProperty('--width', `${sourceRect.width}px`);\n      this.style.setProperty('--height', `${sourceRect.height}px`);\n    }\n    this.style.setProperty('--start-x', `${startPoint.x}px`);\n    this.style.setProperty('--start-y', `${startPoint.y}px`);\n    this.style.setProperty('--travel-x', `${endPoint.x - startPoint.x}px`);\n    this.style.setProperty('--travel-y', `${endPoint.y - startPoint.y}px`);\n\n    await yieldToMainThread();\n\n    await Promise.allSettled(this.getAnimations().map((a) => a.finished));\n    this.remove();\n  };\n}\n\nif (!customElements.get('fly-to-cart')) {\n  customElements.define('fly-to-cart', FlyToCart);\n}\n"],
  "mappings": "AAAA,OAAS,sBAAyB,mBAClC,OAAS,cAAiB,mBAM1B,MAAM,kBAAkB,SAAU,CAEhC,OAGA,cAAgB,GAGhB,YAEA,mBAAoB,CAClB,MAAM,kBAAkB,EACxB,MAAM,qBAAuB,IAAI,qBAAsB,SAAY,CAEjE,IAAI,WAAa,KAEb,gBAAkB,KAEtB,QAAQ,QAAS,OAAU,CACrB,MAAM,SAAW,KAAK,OACxB,WAAa,MAAM,mBACV,MAAM,SAAW,KAAK,cAC/B,gBAAkB,MAAM,mBAE5B,CAAC,EAEG,YAAc,iBAChB,KAAK,SAAS,WAAY,eAAe,EAG3C,qBAAqB,WAAW,CAClC,CAAC,EACD,qBAAqB,QAAQ,KAAK,MAAM,EACxC,qBAAqB,QAAQ,KAAK,WAAW,CAC/C,CAOA,SAAW,MAAO,WAAY,kBAAoB,CAEhD,MAAM,WAAa,CACjB,EAAG,WAAW,KAAO,WAAW,MAAQ,EACxC,EAAG,WAAW,IAAM,WAAW,OAAS,CAC1C,EAEM,SAAW,CACf,EAAG,gBAAgB,KAAO,gBAAgB,MAAQ,EAClD,EAAG,gBAAgB,IAAM,gBAAgB,OAAS,CACpD,EAGI,KAAK,gBACP,KAAK,MAAM,YAAY,UAAW,GAAG,WAAW,KAAK,IAAI,EACzD,KAAK,MAAM,YAAY,WAAY,GAAG,WAAW,MAAM,IAAI,GAE7D,KAAK,MAAM,YAAY,YAAa,GAAG,WAAW,CAAC,IAAI,EACvD,KAAK,MAAM,YAAY,YAAa,GAAG,WAAW,CAAC,IAAI,EACvD,KAAK,MAAM,YAAY,aAAc,GAAG,SAAS,EAAI,WAAW,CAAC,IAAI,EACrE,KAAK,MAAM,YAAY,aAAc,GAAG,SAAS,EAAI,WAAW,CAAC,IAAI,EAErE,MAAM,kBAAkB,EAExB,MAAM,QAAQ,WAAW,KAAK,cAAc,EAAE,IAAK,GAAM,EAAE,QAAQ,CAAC,EACpE,KAAK,OAAO,CACd,CACF,CAEK,eAAe,IAAI,aAAa,GACnC,eAAe,OAAO,cAAe,SAAS",
  "names": []
}
