1import { r as reactExports, j as jsxRuntimeExports } from "./vendor-react-Bay9Y7Lb.js"; 2import { u as useSettings } from "./index-D0Bmh-UX.js"; 3function useShouldShowAd(type) { 4 var _a; 5 const { adSettings } = useSettings(); 6 const [isExcluded, setIsExcluded] = reactExports.useState(false); 7 reactExports.useEffect(() => { 8 var _a2; 9 const savedSession = localStorage.getItem("hamie_session"); 10 let userRole = "GUEST"; 11 let isSupporter = false; 12 if (savedSession) { 13 try { 14 const user = JSON.parse(savedSession); 15 if (user) { 16 if (user.role) { 17 userRole = user.role; 18 } 19 const tier = (_a2 = user.subscriptionTier) == null ? void 0 : _a2.toLowerCase(); 20 if (tier === "gold" || tier === "premium" || tier === "pro") { 21 isSupporter = true; 22 } 23 } 24 } catch (e) { 25 console.error("Failed to parse hamie_session for ad blocking", e); 26 } 27 } 28 if (isSupporter) { 29 setIsExcluded(true); 30 return; 31 } 32 if (adSettings && adSettings.excludeRoles) { 33 setIsExcluded(adSettings.excludeRoles.includes(userRole)); 34 } 35 }, [adSettings]); 36 if (!adSettings || !adSettings.isEnabled) return false; 37 const unit = (_a = adSettings.adUnits) == null ? void 0 : _a[type]; 38 if (!unit || !unit.enabled || !unit.slotId) return false; 39 if (isExcluded) return false; 40 return true; 41} 42const AdSlot = ({ type, className = "", style }) => { 43 var _a; 44 const { adSettings } = useSettings(); 45 const shouldShow = useShouldShowAd(type); 46 const initialized = reactExports.useRef(false); 47 reactExports.useEffect(() => { 48 if (!shouldShow) return; 49 try { 50 if (typeof window !== "undefined" && !initialized.current) { 51 window.adsbygoogle = window.adsbygoogle || []; 52 window.adsbygoogle.push({}); 53 initialized.current = true; 54 } 55 } catch (err) { 56 console.warn(`AdSense ad unit push failed for slot ${type}:`, err); 57 } 58 }, [shouldShow, type]); 59 if (!shouldShow) return null; 60 const unit = (_a = adSettings.adUnits) == null ? void 0 : _a[type]; 61 const client = adSettings.publisherId.startsWith("ca-") ? adSettings.publisherId : `ca-${adSettings.publisherId}`; 62 const isNonIntrusive = !!adSettings.enableNonIntrusiveOnly; 63 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `ad-slot-wrapper my-6 flex flex-col justify-center items-center overflow-hidden w-full bg-zinc-100/40 dark:bg-zinc-900/30 border border-zinc-200 dark:border-zinc-800 rounded-xl p-3 transition-all duration-300 ${isNonIntrusive ? "min-h-[90px] max-h-[140px] py-2 my-4" : "min-h-[100px]"} ${className}`, children: [ 64 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] text-zinc-500 dark:text-zinc-400 block mb-2 uppercase tracking-widest font-mono font-bold select-none", children: "Advertisement" }), 65 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full flex justify-center items-center overflow-hidden", style: isNonIntrusive ? { maxHeight: "90px" } : void 0, children: /* @__PURE__ */ jsxRuntimeExports.jsx( 66 "ins", 67 { 68 className: "adsbygoogle", 69 style: isNonIntrusive ? { display: "block", width: "100%", height: "90px", maxHeight: "90px" } : style || { display: "block", textAlign: "center" }, 70 "data-ad-client": client, 71 "data-ad-slot": unit.slotId, 72 "data-ad-format": isNonIntrusive ? "horizontal" : "auto", 73 "data-full-width-responsive": isNonIntrusive ? "false" : "true" 74 } 75 ) }) 76 ] }); 77}; 78export { 79 AdSlot as A, 80 useShouldShowAd as u 81};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.