'use client';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ChannelService = (function () {
    function ChannelService() {
    }
    ChannelService.prototype.loadScript = function () {
        (function () {
            var w = window;
            if (w.ChannelIO) {
                return w.console.error('ChannelIO script included twice.');
            }
            var ch = function () {
                var _a;
                (_a = ch.c) === null || _a === void 0 ? void 0 : _a.call(ch, arguments);
            };
            ch.q = [];
            ch.c = function (args) {
                var _a;
                (_a = ch.q) === null || _a === void 0 ? void 0 : _a.push(args);
            };
            w.ChannelIO = ch;
            function l() {
                if (w.ChannelIOInitialized) {
                    return;
                }
                w.ChannelIOInitialized = true;
                var s = document.createElement('script');
                s.type = 'text/javascript';
                s.async = true;
                s.src = 'https://cdn.channel.io/plugin/ch-plugin-web.js';
                var x = document.getElementsByTagName('script')[0];
                if (x.parentNode) {
                    x.parentNode.insertBefore(s, x);
                }
            }
            if (document.readyState === 'complete') {
                l();
            }
            else {
                w.addEventListener('DOMContentLoaded', l);
                w.addEventListener('load', l);
            }
        })();
    };
    ChannelService.prototype.boot = function (option, callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'boot', option, callback);
    };
    ChannelService.prototype.shutdown = function () {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'shutdown');
    };
    ChannelService.prototype.showMessenger = function () {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'showMessenger');
    };
    ChannelService.prototype.hideMessenger = function () {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'hideMessenger');
    };
    ChannelService.prototype.openChat = function (chatId, message) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'openChat', chatId, message);
    };
    ChannelService.prototype.track = function (eventName, eventProperty) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'track', eventName, eventProperty);
    };
    ChannelService.prototype.onShowMessenger = function (callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'onShowMessenger', callback);
    };
    ChannelService.prototype.onHideMessenger = function (callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'onHideMessenger', callback);
    };
    ChannelService.prototype.onBadgeChanged = function (callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'onBadgeChanged', callback);
    };
    ChannelService.prototype.onChatCreated = function (callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'onChatCreated', callback);
    };
    ChannelService.prototype.onFollowUpChanged = function (callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'onFollowUpChanged', callback);
    };
    ChannelService.prototype.onUrlClicked = function (callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'onUrlClicked', callback);
    };
    ChannelService.prototype.clearCallbacks = function () {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'clearCallbacks');
    };
    ChannelService.prototype.updateUser = function (userInfo, callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'updateUser', userInfo, callback);
    };
    ChannelService.prototype.addTags = function (tags, callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'addTags', tags, callback);
    };
    ChannelService.prototype.removeTags = function (tags, callback) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'removeTags', tags, callback);
    };
    ChannelService.prototype.setPage = function (page) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'setPage', page);
    };
    ChannelService.prototype.resetPage = function () {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'resetPage');
    };
    ChannelService.prototype.showChannelButton = function () {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'showChannelButton');
    };
    ChannelService.prototype.hideChannelButton = function () {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'hideChannelButton');
    };
    ChannelService.prototype.setAppearance = function (appearance) {
        var _a;
        (_a = window.ChannelIO) === null || _a === void 0 ? void 0 : _a.call(window, 'setAppearance', appearance);
    };
    return ChannelService;
}());
exports.default = new ChannelService();
//# sourceMappingURL=util.js.map