{"version":3,"file":"7070-5cd4c8284d7218889e7d.js","mappings":"mMAGA,IAAIA,EAIEC,EAAa,IAAIC,QAEjBC,EACHC,UAAkBC,YAClBD,UAAkBE,eAClBF,UAAkBG,iBAAA,SAQLC,EACdA,GAKA,MAAM,yBAA0BC,QAO3BT,IACHA,EAAuB,IAAIU,sBACzB,SAAAV,GACEA,EAAQW,SAAQ,SAAAX,GAAA,IAAAG,EACVH,EAAMY,iBAAA,OAAAT,EAERF,EAAWY,IAAIb,EAAMc,UAAAX,IAErBF,EAAAc,OAAkBf,EAAMc,QAAA,MAI9B,CACEE,WAAA,cAvBiBb,OAAA,EAAAA,EAAYc,gBAAA,MAwBCd,GAAAA,EAAYe,SAAA,8BAQ9Cf,GAQA,OANIA,EAAQgB,UAEVlB,EAAWmB,IAAIjB,EAAQgB,QAASX,GAChCR,EAAqBqB,QAAQlB,EAAQgB,UAAA,WAIjCnB,GAAwBG,EAAQgB,UAClClB,EAAAc,OAAkBZ,EAAQgB,SAC1BnB,EAAqBsB,UAAUnB,EAAQgB,SAAA,eArCzC,OADAX,IAAA,c","sources":["webpack://gears-of-war-website/../src/components/intersection-observer.ts"],"sourcesContent":["/* eslint-disable no-unused-expressions */\nimport { RefObject } from \"react\"\n\nlet intersectionObserver: IntersectionObserver\n\nexport type Unobserver = () => void\n\nconst ioEntryMap = new WeakMap<HTMLElement, () => void>()\n/* eslint-disable @typescript-eslint/no-explicit-any  */\nconst connection =\n  (navigator as any).connection ||\n  (navigator as any).mozConnection ||\n  (navigator as any).webkitConnection\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n// These match the thresholds used in Chrome's native lazy loading\n// @see https://web.dev/browser-level-image-lazy-loading/#distance-from-viewport-thresholds\nconst FAST_CONNECTION_THRESHOLD = `1250px`\nconst SLOW_CONNECTION_THRESHOLD = `2500px`\n\nexport function createIntersectionObserver(\n  callback: () => void\n): (element: RefObject<HTMLElement | undefined>) => Unobserver {\n  const connectionType = connection?.effectiveType\n\n  // if we don't support intersectionObserver we don't lazy load (Sorry IE 11).\n  if (!(`IntersectionObserver` in window)) {\n    return function observe(): Unobserver {\n      callback()\n      return function unobserve(): void {}\n    }\n  }\n\n  if (!intersectionObserver) {\n    intersectionObserver = new IntersectionObserver(\n      entries => {\n        entries.forEach(entry => {\n          if (entry.isIntersecting) {\n            // Get the matching entry's callback and call it\n            ioEntryMap.get(entry.target as HTMLElement)?.()\n            // We only need to call it once\n            ioEntryMap.delete(entry.target as HTMLElement)\n          }\n        })\n      },\n      {\n        rootMargin:\n          connectionType === `4g` && !connection?.saveData\n            ? FAST_CONNECTION_THRESHOLD\n            : SLOW_CONNECTION_THRESHOLD,\n      }\n    )\n  }\n\n  return function observe(\n    element: RefObject<HTMLElement | undefined>\n  ): Unobserver {\n    if (element.current) {\n      // Store a reference to the callback mapped to the element being watched\n      ioEntryMap.set(element.current, callback)\n      intersectionObserver.observe(element.current)\n    }\n\n    return function unobserve(): void {\n      if (intersectionObserver && element.current) {\n        ioEntryMap.delete(element.current)\n        intersectionObserver.unobserve(element.current)\n      }\n    }\n  }\n}\n"],"names":["n","e","WeakMap","t","navigator","connection","mozConnection","webkitConnection","r","window","IntersectionObserver","forEach","isIntersecting","get","target","delete","rootMargin","effectiveType","saveData","current","set","observe","unobserve"],"sourceRoot":""}