'use client';
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var schema_1 = require("@qaing/schema");
var instance_1 = require("../../../hooks/instance");
var config_1 = require("../../../utils/config");
var util_1 = __importDefault(require("./util"));
var pluginKey = config_1.env.channeltalkKey;
exports.default = (function () {
    var data = (0, instance_1.useQAingSWR)(schema_1.schemas.user.getByMe).data;
    react_1.default.useEffect(function () {
        if (!pluginKey)
            return;
        util_1.default.loadScript();
        util_1.default.boot({ pluginKey: pluginKey });
    }, []);
    react_1.default.useEffect(function () {
        if (!pluginKey || !data || !('_id' in data))
            return;
        util_1.default.updateUser({
            profile: {
                id: data._id,
                email: data.userEmail,
                name: data.userName,
                phoneNumber: data.userPhoneNumber,
            },
        });
    }, [data]);
    return null;
});
//# sourceMappingURL=index.js.map