"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResponsiveAdUnit = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importStar(require("react"));
const router_1 = require("next/router");
const initAd = () => {
    (window.adsbygoogle = window.adsbygoogle || []).push({});
};
function ResponsiveAdUnit({ publisherId, slotId, type = "default-ad-unit-type", style = {} }) {
    var _a;
    (0, react_1.useEffect)(() => {
        initAd();
    });
    const _publisherId = (_a = process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID) !== null && _a !== void 0 ? _a : publisherId;
    if (!_publisherId || !slotId) {
        console.error("nextjs-google-adsense: publisherId or slotId can't be empty for the unit");
        return null;
    }
    style.display = "block";
    const router = (0, router_1.useRouter)();
    return (react_1.default.createElement("div", { key: router.asPath.replace(/\//g, "-") + "-" + slotId + "-" + type, style: style },
        react_1.default.createElement("ins", { className: "adsbygoogle", style: { display: 'block' }, "data-ad-client": `ca-${_publisherId}`, "data-ad-slot": String(slotId), "data-ad-format": "auto", "data-full-width-responsive": "true" })));
}
exports.ResponsiveAdUnit = ResponsiveAdUnit;
//# sourceMappingURL=ResponsiveAdUnit.js.map