System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, sys, csvMgr, Data, GameConst, Utils, Singleton, _dec, _class, _crd, ccclass, property, LevelsData, levelsData;

  function _reportPossibleCrUseOfcsvMgr(extras) {
    _reporterNs.report("csvMgr", "../core/csv/CsvManager", _context.meta, extras);
  }

  function _reportPossibleCrUseOfData(extras) {
    _reporterNs.report("Data", "../core/manager/Data", _context.meta, extras);
  }

  function _reportPossibleCrUseOfGameConst(extras) {
    _reporterNs.report("GameConst", "../core/common/GameConst", _context.meta, extras);
  }

  function _reportPossibleCrUseOfUtils(extras) {
    _reporterNs.report("Utils", "../core/utils/Utils", _context.meta, extras);
  }

  function _reportPossibleCrUseOfSingleton(extras) {
    _reporterNs.report("Singleton", "../core/manager/Singleton", _context.meta, extras);
  }

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      sys = _cc.sys;
    }, function (_unresolved_2) {
      csvMgr = _unresolved_2.csvMgr;
    }, function (_unresolved_3) {
      Data = _unresolved_3.default;
    }, function (_unresolved_4) {
      GameConst = _unresolved_4.GameConst;
    }, function (_unresolved_5) {
      Utils = _unresolved_5.default;
    }, function (_unresolved_6) {
      Singleton = _unresolved_6.Singleton;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "fb446aWSyFGJZyrjtaEtWz4", "LevelsData", undefined);

      __checkObsolete__(['_decorator', 'sys']);

      ({
        ccclass,
        property
      } = _decorator);

      _export("LevelsData", LevelsData = (_dec = ccclass("LevelsData"), _dec(_class = class LevelsData extends (_crd && Singleton === void 0 ? (_reportPossibleCrUseOfSingleton({
        error: Error()
      }), Singleton) : Singleton) {
        constructor() {
          super(...arguments);
          this._data = null;
        }

        get data() {
          if (!this._data) {
            this.loadFromCache();
          }

          return this._data;
        }
        /**
         * 读取数据缓存
         */


        loadFromCache() {
          var l = sys.localStorage.getItem((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).localCache.levelsData);

          if (l) {
            this._data = JSON.parse((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
              error: Error()
            }), Utils) : Utils).decrypt(l));
          } else {
            //没有数据保存一份默认的初始数据
            this._data = {};
            this.saveToCache();
          }

          return this.data;
        }
        /**
         * 得到模型名字数组
         */


        getModesNames() {
          var modelNames = (_crd && csvMgr === void 0 ? (_reportPossibleCrUseOfcsvMgr({
            error: Error()
          }), csvMgr) : csvMgr).getTableArr("model_names");
          return modelNames.map(item => item.name);
        }
        /**
         * 得到当前关卡下的数据
         */


        getCurLevelInfo() {
          var levels = (_crd && csvMgr === void 0 ? (_reportPossibleCrUseOfcsvMgr({
            error: Error()
          }), csvMgr) : csvMgr).getTableArr("levels");
          var lv = (_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
            error: Error()
          }), Data) : Data).user.lv - 1;

          if (lv > levels.length) {
            return levels[levels.length - 1];
          } else {
            return levels[lv];
          }
        }
        /**
         * 保存到缓存中
         */


        saveToCache() {
          var data = JSON.stringify(this.data); //序列化JSON字符串过后加密存储

          sys.localStorage.setItem((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).localCache.levelsData, (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).encrypt(data));
        }
        /**
         * 删除缓存
         */


        remove() {
          sys.localStorage.removeItem((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).localCache.levelsData);
          this.loadFromCache();
        }

      }) || _class)); //全局单例


      _export("levelsData", levelsData = LevelsData.ins());

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=11baaee28eaf94eb18202b7cdc9a58e8d549dbc2.js.map