{
  "version": 3,
  "sources": ["/cdn/shop/t/3/assets/sticky-absolute-wrap.js?cv=402f958"],
  "sourcesContent": ["class StickyAbsoluteWrap extends HTMLElement {\n  constructor() {\n    super();\n    this.stickyEl = this.querySelector(\".saw-sticky\");\n    this.stickyAbsoluteChild = this.querySelector(\".saw-sticky-absolute\");\n    this.relativeContainer = this.querySelector(\".saw-relative-container\");\n    const verifyElementsArray = [\n      {\n        element: this.stickyEl,\n        name: \"Sticky element\"\n      },\n      {\n        element: this.stickyAbsoluteChild,\n        name: \"Sticky absolute child element\"\n      },\n      {\n        element: this.relativeContainer,\n        name: \"Relative container element\"\n      }\n    ];\n    if (this.verifyElements(verifyElementsArray)) {\n      return;\n    }\n    this.initResizeObserver();\n  }\n  verifyElements(array) {\n    let error = false;\n    array.forEach((item) => {\n      if (item.element === null) {\n        console.error(`${item.name} not found in StickyAbsoluteWrap`);\n        error = true;\n      }\n    });\n    console.log(\"StickyAbsoluteWrap\", array);\n    return error;\n  }\n  /**\n   * Initializes a resize observer for the relative container\n   * Updates the max height of the absolute child element when container size changes\n   */\n  initResizeObserver() {\n    this.resizeObserver = new ResizeObserver((entries) => {\n      for (const entry of entries) {\n        if (entry.target === this.relativeContainer) {\n          this.updateAbsoluteChildMaxHeight();\n        }\n      }\n    });\n    this.resizeObserver.observe(this.relativeContainer);\n    this.updateAbsoluteChildMaxHeight();\n  }\n  /**\n   * Updates the maximum height of the absolute child element\n   * to match the height of the relative container\n   */\n  updateAbsoluteChildMaxHeight() {\n    const containerHeight = this.relativeContainer.offsetHeight;\n    this.stickyAbsoluteChild.style.maxHeight = `calc(${containerHeight}px + (var(--notificationOffset, 0px) * 2))`;\n    this.stickyAbsoluteChild.style.bottom = \"calc(var(--notificationOffset, 0px) )\";\n    this.stickyAbsoluteChild.style.height = \"100vh\";\n  }\n  /**\n   * Clean up the resize observer when element is disconnected from DOM\n   */\n  disconnectedCallback() {\n    if (this.resizeObserver) {\n      this.resizeObserver.disconnect();\n    }\n  }\n}\nif (!customElements.get(\"sticky-absolute-wrap\")) {\n  customElements.define(\"sticky-absolute-wrap\", StickyAbsoluteWrap);\n}\nexport {\n  StickyAbsoluteWrap\n};\n"],
  "mappings": "AAAA,MAAM,2BAA2B,WAAY,CAC3C,aAAc,CACZ,MAAM,EACN,KAAK,SAAW,KAAK,cAAc,aAAa,EAChD,KAAK,oBAAsB,KAAK,cAAc,sBAAsB,EACpE,KAAK,kBAAoB,KAAK,cAAc,yBAAyB,EACrE,MAAM,oBAAsB,CAC1B,CACE,QAAS,KAAK,SACd,KAAM,gBACR,EACA,CACE,QAAS,KAAK,oBACd,KAAM,+BACR,EACA,CACE,QAAS,KAAK,kBACd,KAAM,4BACR,CACF,EACI,KAAK,eAAe,mBAAmB,GAG3C,KAAK,mBAAmB,CAC1B,CACA,eAAe,MAAO,CACpB,IAAI,MAAQ,GACZ,aAAM,QAAS,MAAS,CAClB,KAAK,UAAY,OACnB,QAAQ,MAAM,GAAG,KAAK,IAAI,kCAAkC,EAC5D,MAAQ,GAEZ,CAAC,EACD,QAAQ,IAAI,qBAAsB,KAAK,EAChC,KACT,CAKA,oBAAqB,CACnB,KAAK,eAAiB,IAAI,eAAgB,SAAY,CACpD,UAAW,SAAS,QACd,MAAM,SAAW,KAAK,mBACxB,KAAK,6BAA6B,CAGxC,CAAC,EACD,KAAK,eAAe,QAAQ,KAAK,iBAAiB,EAClD,KAAK,6BAA6B,CACpC,CAKA,8BAA+B,CAC7B,MAAM,gBAAkB,KAAK,kBAAkB,aAC/C,KAAK,oBAAoB,MAAM,UAAY,QAAQ,eAAe,6CAClE,KAAK,oBAAoB,MAAM,OAAS,wCACxC,KAAK,oBAAoB,MAAM,OAAS,OAC1C,CAIA,sBAAuB,CACjB,KAAK,gBACP,KAAK,eAAe,WAAW,CAEnC,CACF,CACK,eAAe,IAAI,sBAAsB,GAC5C,eAAe,OAAO,uBAAwB,kBAAkB,EAElE,OACE",
  "names": []
}
