var t = require; var e = module; var i = exports; var s = (this && this.__awaiter) || function (t, n, r, l) { return new (r = r || Promise)(function (i, e) { function s(t) { try { a(l.next(t)); } catch (t) { e(t); } } function o(t) { try { a(l.throw(t)); } catch (t) { e(t); } } function a(t) { var e; t.done ? i(t.value) : ((e = t.value) instanceof r ? e : new r(function (t) { t(e); }) ).then(s, o); } a((l = l.apply(t, n || [])).next()); }); }; Object.defineProperty(i, "__esModule", {value: !0}), (i.WxMiniGameUtil = void 0); const o = t("ControllerConst"), a = t("App"), n = t("GamePlatform"); class r { static getSettings() { return "undefined" == typeof wx ? Promise.resolve(null) : null != r.s_authSetting ? Promise.resolve(r.s_authSetting) : new Promise(function (t) { wx.getSetting({ success: function (t) { r.s_authSetting = t.authSetting; }, fail: function () { r.s_authSetting = null; }, complete: function () { t(r.s_authSetting); } }); }); } static checkUserInfoAuth() { return s(this, void 0, void 0, function* () { var t = yield r.getSettings(); return !!t && !0 === t["scope.userInfo"]; }); } static checkWxFriendInteractionAuth() { return s(this, void 0, void 0, function* () { var t = yield r.getSettings(); return !!t && !0 === t["scope.WxFriendInteraction"]; }); } static updateUserInfo(t, e) { (a.default.GameDataMsr.playerInfo.nickName = t), (a.default.GameDataMsr.playerInfo.head = e); } static tryGetInfo() { return s(this, void 0, void 0, function* () { (yield r.checkUserInfoAuth()) && r.getUserInfo(); }); } static getUserInfo() { wx.getUserInfo({ success: function (t) { t && r.updateUserInfo(t.userInfo.nickName, t.userInfo.avatarUrl); }, fail: function () {} }); } static copyFunc(t) { wx.setClipboardData({ data: t, success: function () { wx.getClipboardData({success: function () {}}); } }); } static enablePassiveShare() { if ("undefined" == typeof wx) return null; wx.showShareMenu({withShareTicket: !0, menus: ["shareAppMessage", "shareTimeline"]}), wx.onShareAppMessage(function () { var t = a.default.ControllerManager.getControllerModel(o.ControllerConst.AD).getShareData(); return { title: t.message, imageUrl: t.image_src, imageUrlId: t.id, query: "fromUser=" + n.GamePlatform.getServerUID() }; }), wx.onShareTimeline(function () { var t = n.GamePlatform.randomShareData(); return { title: t[2], imageUrl: t[0], imageUrlId: t[1], imagePreviewUrl: n.WechatPreviewImageURL, imagePreviewUrlId: n.WechatPreviewImageURLId, query: "fromUser=" + n.GamePlatform.getServerUID() }; }); } } (i.WxMiniGameUtil = r), (r.s_authSetting = null);