var t = require; var e = module; var i = exports; var e = (this && this.__decorate) || function (t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }, 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.ShopBoxItem = void 0); const o = t("App"), a = t("GameText"), n = t("ControllerConst"), r = (t("ViewConst"), t("ADController"), t("ADManageBase"), t("BagConst")), l = t("ShopConst"), h = t("ShopItem"), {property: c, ccclass: d, menu: u} = cc._decorator; t = class extends h.ShopItem { constructor() { super(...arguments), (this.title = null), (this.descLab = null), (this.costIcon = null), (this.adBtn = null), (this.adLab = null), (this.progressBar = null), (this.progessLab = null), (this.adCoolTimeLab = null), (this.adCoolTime = null), (this.item = null), (this.tempTime = 0); } initItem() { (this.item = o.default.ControllerManager.applyFunc( n.ControllerConst.Item, r.BagConst.GET_ITEM, this.data.cfg.itemId )), (this.title.string = a.GameText.getTextByStr(this.item.data.name)), this.data.cfg.diamond && (this.costLab.string = this.data.cfg.diamond.toString()), this.updateItem(), this.updateAdState(); } updateItem() { var t, e, i, s; this.data && this.data.cfg.ad ? ((i = o.default.ControllerManager.applyFunc(n.ControllerConst.AD, 4, 7)), (e = o.default.ControllerManager.applyFunc(n.ControllerConst.AD, 3, 7)), i.freeCnt >= e.freeCnt && ((this.adLab.string = `${e.adTimes - i.adCnt}/${e.adTimes}`), i.adCnt || (this.data.time = 0)), (t = this.item.getUseCnt()), (i = (e = this.item.getCurSuitcaseUpgradeCfg()).level), (this.title.string = `Lv.${i} ${a.GameText.getTextByStr(this.item.data.name)} `), 0 < e.upgrade_count ? ((s = e.upgrade_count), (this.progessLab.string = `${t} /${s}`), (this.progressBar.progress = t / s)) : ((this.progessLab.node.active = !1), (this.progressBar.progress = 1))) : this.item && (this.item.cnt ? ((this.costIcon.active = !1), (this.costLab.string = `${this.item.cnt}/1`)) : ((this.costIcon.active = !0), (this.costLab.string = this.data.cfg.diamond.toString())), this.descLab) && ((s = this.item.getRuleByKey(r.CostumeItemRuleKey.NORMAL)), (this.descLab.string = "" + (s.cnt - this.item.getSpecialRuleCnt(r.CostumeItemRuleKey.NORMAL)))); } updateTime() { var e = o.default.DateUtils.Now(); if (this.adCoolTime) { let t = this.adCoolTime - e; t < 0 && ((t = 0), (this.adCoolTime = 0), this.updateAdState()), (this.adCoolTimeLab.string = "下一次广告奖励:\n" + o.default.DateUtils.getFormatBySecond(t / 1e3, 10)); } } update(t) { this.adCoolTime && ((this.tempTime -= t), this.tempTime <= 0 && ((this.tempTime = 0.5), this.updateTime())); } updateAdState() { var t, e; this.data.cfg.ad && ((t = o.default.ControllerManager.applyFunc(n.ControllerConst.AD, 5, 7)), o.default.DateUtils.secondNow() < (e = this.data.cfg.ad + this.data.time) && t ? ((this.adCoolTime = 1e3 * e), (this.adBtn.node.active = !1), (this.adCoolTimeLab.node.active = !0)) : ((this.adBtn.node.active = t), (this.adCoolTimeLab.node.active = !1))); } onTouchUseBtn() { return s(this, void 0, void 0, function* () { o.default.ControllerManager.applyFunc(n.ControllerConst.Shop, l.ShopConst.USE, this.data), this.updateItem(), this.updateAdState(); }); } onTouchBuyBtn() { return s(this, void 0, void 0, function* () { this.item.cnt ? o.default.ControllerManager.applyFunc(n.ControllerConst.Shop, l.ShopConst.USE, this.data) : yield o.default.ControllerManager.applyFunc(n.ControllerConst.Shop, l.ShopConst.BUY, this.data, 7), this.updateItem(), this.updateAdState(); }); } onTouchTip() { o.default.ViewManager.open(30, this.item); } }; e([c(cc.Label)], t.prototype, "title", void 0), e([c(cc.Label)], t.prototype, "descLab", void 0), e([c(cc.Node)], t.prototype, "costIcon", void 0), e([c(cc.Button)], t.prototype, "adBtn", void 0), e([c(cc.Label)], t.prototype, "adLab", void 0), e([c(cc.ProgressBar)], t.prototype, "progressBar", void 0), e([c(cc.Label)], t.prototype, "progessLab", void 0), e([c(cc.Label)], t.prototype, "adCoolTimeLab", void 0), (t = e([d, u("view/Shop/item/ShopBoxItem")], t)), (i.ShopBoxItem = t);