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

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, sys, constants, utils, _dec, _class, _class2, _crd, ccclass, property, settingData;

  function _reportPossibleCrUseOfconstants(extras) {
    _reporterNs.report("constants", "./constants", _context.meta, extras);
  }

  function _reportPossibleCrUseOfutils(extras) {
    _reporterNs.report("utils", "./utils", _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) {
      constants = _unresolved_2.constants;
    }, function (_unresolved_3) {
      utils = _unresolved_3.utils;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "d9065Lh72BI6psd86s2PxAJ", "settingData", undefined);

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

      ({
        ccclass,
        property
      } = _decorator);

      _export("settingData", settingData = (_dec = ccclass("settingData"), _dec(_class = (_class2 = class settingData {
        constructor() {
          this.data = null;
        }

        /**单例*/
        static ins() {
          if (!this.instance) {
            this.instance = new settingData();
          }

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


        loadFromCache() {
          var l = sys.localStorage.getItem((_crd && constants === void 0 ? (_reportPossibleCrUseOfconstants({
            error: Error()
          }), constants) : constants).localCache.settingData);

          if (l) {
            this.data = JSON.parse((_crd && utils === void 0 ? (_reportPossibleCrUseOfutils({
              error: Error()
            }), utils) : utils).decrypt(l));
          } else {
            //没有数据保存一份默认的初始数据
            this.data = {
              //背景音乐开关
              bg_music_status: true,
              //音效开关
              sound_status: true,
              //震动开关
              shock_status: false
            };
            this.saveToCache();
          }
        }
        /*修改音效状态
         */


        changeStatus(idx) {
          if (idx == 0) {
            this.data.bg_music_status = !this.data.bg_music_status;
          } else if (idx == 1) {
            this.data.sound_status = !this.data.sound_status;
          } else if (idx == 2) {
            this.data.shock_status = !this.data.shock_status;
          }

          this.saveToCache();
        }
        /**
         * 得到设置的数据数组
         */


        getSettingDatas() {
          var datas = [{
            name: "背景音乐",
            selected: this.data.bg_music_status
          }, {
            name: "音效",
            selected: this.data.sound_status
          }, {
            name: "震动",
            selected: this.data.sound_status
          }];
          return datas;
        }
        /**
         * 保存到缓存中
         */


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

          sys.localStorage.setItem((_crd && constants === void 0 ? (_reportPossibleCrUseOfconstants({
            error: Error()
          }), constants) : constants).localCache.settingData, (_crd && utils === void 0 ? (_reportPossibleCrUseOfutils({
            error: Error()
          }), utils) : utils).encrypt(data));
        }
        /**
         * 删除缓存
         */


        remove() {
          sys.localStorage.removeItem((_crd && constants === void 0 ? (_reportPossibleCrUseOfconstants({
            error: Error()
          }), constants) : constants).localCache.settingData);
          this.loadFromCache();
        }

      }, _class2.instance = null, _class2)) || _class));

      _export("default", settingData.ins());

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=87f213e42316eab5de8c169f9327ab6ca77fa7f7.js.map