{"version":3,"file":"index.cjs","sources":[""],"sourcesContent":["import { getDocument, getWindow } from \"ssr-window\";\r\nimport { wait } from \"../../fn/wait/index.ts\";\r\nimport { getId } from \"../../str/getId/index.ts\";\r\n\r\nexport type TIsAdblockArgs = Parameters<typeof isAdblock>;\r\n\r\nexport type TIsAdblockReturn = ReturnType<typeof isAdblock>;\r\n\r\n/**\r\n * Detects if an ad-blocker likely hides known ad-related elements.\r\n * Implementation detail:\r\n * Injects a hidden container with an \"ad-like\" child element\r\n * Measures computed style after a tick to infer blocking\r\n *\r\n * @returns {boolean} True if ad-blocking likely detected\r\n * @example\r\n * const blocked = isAdblock();\r\n * console.log(blocked); // => false\r\n */\r\nexport const isAdblock = (): boolean => {\r\n  const id = `adv_${getId()}`;\r\n  const css = \"position: fixed; bottom: -100vh; left: -100vh; overflow: hidden; pointer-events: none;\";\r\n\r\n  const doc = getDocument();\r\n  if (!doc.getElementById(id)) {\r\n    doc.body.insertAdjacentHTML(\"beforeend\", `\r\n      <div aria-hidden=\"true\" style=\"${css}\" id=\"${id}\">\r\n        <div style=\"width: 100px; height: 100px;\"\r\n             class=\"ad_box ad-richmedia-overlay ads ad adsbox doubleclick ad-placement carbon-ads\"></div>\r\n      </div>`);\r\n  }\r\n\r\n  const block = doc.getElementById(id)!;\r\n  const ad = block.children[0] as HTMLElement;\r\n\r\n  // Force layout and allow extensions to react\r\n  getWindow().getComputedStyle(block).getPropertyValue(\"visibility\");\r\n\r\n  void wait(2000)\r\n    .then(() => block?.remove());\r\n\r\n  return getWindow().getComputedStyle(ad).getPropertyValue(\"display\") === \"none\";\r\n};\r\n"],"names":["isAdblock","id","getId","css","doc","getDocument","getElementById","body","insertAdjacentHTML","block","ad","children","getWindow","getComputedStyle","getPropertyValue","wait","then","remove"],"mappings":";;;;;;;;;;;GAmBO,MAAMA,UAAYA,KACvB,MAAMC,GAAK,OAAOC,MAAAA,UAClB,MAAMC,IAAM,yFAEZ,MAAMC,IAAMC,UAAAA,cACZ,IAAKD,IAAIE,eAAeL,IACtBG,IAAIG,KAAKC,mBAAmB,YAAa,0CACNL,YAAYF,oLAMjD,MAAMQ,MAAQL,IAAIE,eAAeL,IACjC,MAAMS,GAAKD,MAAME,SAAS;6CAG1BC;UAAAA,YAAYC,iBAAiBJ,OAAOK,iBAAiB,mBAEhDC,QAAAA,KAAK,MACPC,KAAK,IAAMP,OAAOQ,UAErB,OAAOL,UAAAA,YAAYC,iBAAiBH,IAAII,iBAAiB,aAAe"}