{
  "version": 3,
  "sources": ["/cdn/shop/t/3/assets/notification.js?cv=674ee16"],
  "sourcesContent": ["import { t as throttle } from \"./lodash-utils.js\";\nimport { s as slideUp, a as slideDown } from \"./slide.js\";\nimport { p as pubsub } from \"./shared-utilities.js\";\nimport { l as layout } from \"./layout-store.js\";\nconst calculateMilliseconds = (hours, mins = 0, seconds = 0) => (hours * 60 * 60 + mins * 60 + seconds) * 1e3;\nclass CreateNotification {\n  constructor(elementId, type = \"bar\", timeIn = 0, trigger = false) {\n    this.type = \"bar\";\n    this.handleCloseBar = () => {\n      this.notificationEl.parentNode.classList.remove(\"bar-open\");\n      document.body.style.removeProperty(\"--height-screen\");\n      document.body.style.removeProperty(\"--notificationOffset\");\n      slideUp(this.notificationEl, { duration: this.animationTiming }, () => {\n        pubsub.emit(\"notificationBarState\");\n        pubsub.off(\"mainNavOpen\", this.handleCloseBar);\n        pubsub.off(\"megaMenuOpen\", this.handleCloseBar);\n      });\n    };\n    this.handleCloseNotification = () => {\n      this.open = false;\n      const timestamp = Date.now();\n      const storage = window.localStorage;\n      storage.setItem(`notification-${this.elementId}`, timestamp.toString());\n      if (this.type === \"bar\") {\n        this.handleCloseBar();\n      }\n      if (this.type == \"fade\" || this.type == \"age-gate\") {\n        this.notificationEl.classList.add(\"fade-out\");\n        this.notificationEl.classList.remove(\"fade-in\");\n      }\n      document.dispatchEvent(\n        new CustomEvent(\"notificationClose\", {\n          detail: {\n            elementId: this.elementId,\n            type: this.type\n          }\n        })\n      );\n      document.body.style.removeProperty(\"overflow\");\n      setTimeout(() => {\n        this.notificationEl.remove();\n      }, this.animationTiming);\n    };\n    this.elementId = elementId;\n    this.type = type;\n    this.notificationEl = document.getElementById(elementId);\n    this.animationTiming = 300;\n    this.closeButton;\n    this.open = false;\n    this.timeout = calculateMilliseconds(24);\n    if (this.notificationEl) {\n      this.timein = this.notificationEl.dataset.timein ? calculateMilliseconds(\n        0,\n        0,\n        Number(this.notificationEl.dataset.timein)\n      ) : timeIn ? timeIn : 0;\n      if (this.checkCookieStatus()) {\n        this.notificationEl.remove();\n      } else {\n        setTimeout(() => {\n          this.initializeEvents();\n        }, this.timein);\n      }\n    }\n    this.canOpen = this.timein && this.timein > 0 ? false : true;\n    this.trigger = trigger;\n  }\n  checkCookieStatus() {\n    const storage = window.localStorage;\n    const originalCookie = storage.getItem(`notification-${this.elementId}`);\n    const now = Date.now();\n    if (originalCookie !== null && originalCookie !== void 0 && Number(originalCookie) + this.timeout > now) {\n      return true;\n    }\n    return false;\n  }\n  handleOpenBar() {\n    this.notificationEl.parentNode.classList.add(\"bar-open\");\n    console.log(\"bar-open\");\n    slideDown(this.notificationEl, { duration: this.animationTiming }, () => {\n      document.body.style.setProperty(\n        \"--height-screen\",\n        `calc(100vh - ${this.notificationEl.offsetHeight}px)`\n      );\n      document.body.style.setProperty(\n        \"--notificationOffset\",\n        `${this.notificationEl.offsetHeight}px`\n      );\n      pubsub.emit(\"notificationBarState\");\n    });\n    pubsub.on(\"mainNavOpen\", this.handleCloseBar);\n    pubsub.on(\"megaMenuOpen\", this.handleCloseBar);\n  }\n  initializeEvents() {\n    if (this.canOpen) {\n      if (this.type === \"bar\") {\n        this.handleOpenBar();\n      } else if (this.type === \"modal\") {\n        layout.modal.value = this.elementId;\n        this.notificationEl.addEventListener(\n          \"close\",\n          this.handleCloseNotification\n        );\n      } else if (this.type === \"fade\") {\n        this.notificationEl.classList.remove(\"hidden\");\n        this.notificationEl.classList.add(\"fade-in\");\n        this.notificationEl.classList.add(\"active\");\n      }\n      this.closeButton = this.notificationEl.querySelector(\".js-close\");\n      if (this.closeButton) {\n        this.closeButton.addEventListener(\n          \"click\",\n          this.handleCloseNotification\n        );\n      }\n      document.dispatchEvent(\n        new CustomEvent(\"notificationOpen\", {\n          detail: {\n            elementId: this.elementId,\n            type: this.type\n          }\n        })\n      );\n    } else {\n      setTimeout(() => {\n        this.canOpen = true;\n        this.initializeEvents();\n      }, this.timein);\n    }\n    if (this.notificationEl.getAttribute(\"hide-scroll\")) {\n      document.addEventListener(\n        \"scroll\",\n        throttle((e) => {\n          if (window.scrollY > 400) {\n            this.handleCloseNotification();\n          }\n        }, 200)\n      );\n    }\n    if (this.trigger) {\n      const triggerEl = this.notificationEl.querySelector(\"button\");\n      if (triggerEl) {\n        triggerEl.addEventListener(\"click\", () => {\n          this.handleCloseNotification();\n        });\n      }\n    }\n  }\n}\nexport {\n  CreateNotification as C\n};\n"],
  "mappings": "AAAA,OAAS,KAAK,aAAgB,oBAC9B,OAAS,KAAK,QAAS,KAAK,cAAiB,aAC7C,OAAS,KAAK,WAAc,wBAC5B,OAAS,KAAK,WAAc,oBAC5B,MAAM,sBAAwB,CAAC,MAAO,KAAO,EAAG,QAAU,KAAO,MAAQ,GAAK,GAAK,KAAO,GAAK,SAAW,IAC1G,MAAM,kBAAmB,CACvB,YAAY,UAAW,KAAO,MAAO,OAAS,EAAG,QAAU,GAAO,CAChE,KAAK,KAAO,MACZ,KAAK,eAAiB,IAAM,CAC1B,KAAK,eAAe,WAAW,UAAU,OAAO,UAAU,EAC1D,SAAS,KAAK,MAAM,eAAe,iBAAiB,EACpD,SAAS,KAAK,MAAM,eAAe,sBAAsB,EACzD,QAAQ,KAAK,eAAgB,CAAE,SAAU,KAAK,eAAgB,EAAG,IAAM,CACrE,OAAO,KAAK,sBAAsB,EAClC,OAAO,IAAI,cAAe,KAAK,cAAc,EAC7C,OAAO,IAAI,eAAgB,KAAK,cAAc,CAChD,CAAC,CACH,EACA,KAAK,wBAA0B,IAAM,CACnC,KAAK,KAAO,GACZ,MAAM,UAAY,KAAK,IAAI,EACX,OAAO,aACf,QAAQ,gBAAgB,KAAK,SAAS,GAAI,UAAU,SAAS,CAAC,EAClE,KAAK,OAAS,OAChB,KAAK,eAAe,GAElB,KAAK,MAAQ,QAAU,KAAK,MAAQ,cACtC,KAAK,eAAe,UAAU,IAAI,UAAU,EAC5C,KAAK,eAAe,UAAU,OAAO,SAAS,GAEhD,SAAS,cACP,IAAI,YAAY,o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