import { r as registerInstance, h, H as Host } from './index-ea07f6f8.js';
var disqusCommentsCss = ":host{display:block}";
var DisqusComments = /** @class */ (function () {
    function DisqusComments(hostRef) {
        var _this = this;
        registerInstance(this, hostRef);
        this.setScriptEl = function (el) {
            _this.targetEl = el;
        };
    }
    DisqusComments.prototype.componentDidLoad = function () {
        var _a;
        var script = "\n    var disqus_config = function () {\n      this.page.url = '" + this.url + "';  // Replace PAGE_URL with your page's canonical URL variable\n      this.page.identifier = '" + this.siteId + "'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable\n    };\n\n    (function() {\n    var d = document, s = d.createElement('script');\n    s.src = 'https://" + this.siteId + ".disqus.com/embed.js';\n    s.setAttribute('data-timestamp', +new Date());\n    (d.head || d.body).appendChild(s);\n    })();\n    ";
        this.scriptEl = document.createElement('script');
        this.scriptEl.type = 'text/javascript';
        this.scriptEl.innerHTML = script;
        (_a = this.targetEl) === null || _a === void 0 ? void 0 : _a.appendChild(this.scriptEl);
        var disqusScript = document.createElement('script');
        disqusScript.id = 'dsq-count-scr';
        disqusScript.async = true;
        disqusScript.src = "//" + this.siteId + ".disqus.com/count.js";
        this.disqusScriptEl = disqusScript;
        document.body.appendChild(disqusScript);
    };
    DisqusComments.prototype.componentDidUnload = function () {
        var _a, _b, _c, _d;
        (_b = (_a = this.scriptEl) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.scriptEl);
        (_d = (_c = this.disqusScriptEl) === null || _c === void 0 ? void 0 : _c.parentNode) === null || _d === void 0 ? void 0 : _d.removeChild(this.disqusScriptEl);
    };
    DisqusComments.prototype.render = function () {
        var _this = this;
        return (h(Host, null, h("div", { id: "disqus_thread" }), h("div", { ref: function (e) { return _this.setScriptEl(e); } }), h("noscript", null, "Please enable JavaScript to view the", ' ', h("a", { href: "https://disqus.com/?ref_noscript" }, "comments powered by Disqus."))));
    };
    return DisqusComments;
}());
DisqusComments.style = disqusCommentsCss;
export { DisqusComments as disqus_comments };
