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

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, assetManager, Prefab, resources, sp, SpriteAtlas, SpriteFrame, Texture2D, Singleton, GameConst, LogMgr, EventManager, ResManger, _crd;

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

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

  function _reportPossibleCrUseOfLogMgr(extras) {
    _reporterNs.report("LogMgr", "./LogMgr", _context.meta, extras);
  }

  function _reportPossibleCrUseOfEventManager(extras) {
    _reporterNs.report("EventManager", "./EventManager", _context.meta, extras);
  }

  _export("default", void 0);

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      assetManager = _cc.assetManager;
      Prefab = _cc.Prefab;
      resources = _cc.resources;
      sp = _cc.sp;
      SpriteAtlas = _cc.SpriteAtlas;
      SpriteFrame = _cc.SpriteFrame;
      Texture2D = _cc.Texture2D;
    }, function (_unresolved_2) {
      Singleton = _unresolved_2.default;
    }, function (_unresolved_3) {
      GameConst = _unresolved_3.GameConst;
    }, function (_unresolved_4) {
      LogMgr = _unresolved_4.default;
    }, function (_unresolved_5) {
      EventManager = _unresolved_5.default;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "1f47f4RJv9Mba5RBEd6yyIl", "ResManger", undefined);

      __checkObsolete__(['assetManager', 'Prefab', 'ImageAsset', 'resources', 'sp', 'SpriteAtlas', 'SpriteFrame', 'Texture2D']);

      _export("default", ResManger = class ResManger extends (_crd && Singleton === void 0 ? (_reportPossibleCrUseOfSingleton({
        error: Error()
      }), Singleton) : Singleton) {
        //spine动画挂载
        static init() {
          this._res = {};
          resources.load('plist/tile', SpriteAtlas, (err, res) => {
            if (err) {
              (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                error: Error()
              }), LogMgr) : LogMgr).error("load commonAtlas error:" + err);
              return;
            }

            this.tileAtlas = res;
          });
          (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
            error: Error()
          }), LogMgr) : LogMgr).log("\u8D44\u6E90\u7BA1\u7406\u5668\u521D\u59CB\u5316\u6210\u529F");
        }
        /**加载本地有的资源图片
         * @param imgPath 图片路径
         * @param cb 回调函数
         */


        static loadImg(imgPath, cb) {
          if (this._res[imgPath]) {
            cb(this._res[imgPath]);
            return;
          }

          resources.load(imgPath + "/spriteFrame", SpriteFrame, (err, res) => {
            if (err) {
              (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                error: Error()
              }), LogMgr) : LogMgr).error("load " + imgPath + " err:" + err);
              return;
            }

            this._res[imgPath] = res;
            cb(this._res[imgPath]);
          });
        }
        /**加载远程图片：卡牌内容素材
         * @param imgName 图片名一般是指卡牌的cardId
         * @param imgUrl 图片网址，没有主域名的url
         * @param cb 回调函数
         */


        static loadRemoteImg(imgName, imgUrl, cb) {
          //本地cocos网页调试环境不加载远程图片
          if ((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).ignoreRemoteImg) {
            cb(null); //LogMgr.warn(`cocos网页调试环境不加载远程图片:${imgName} => ${imgUrl}`);

            return;
          }

          if (this._cardFrames[imgName]) {
            cb(this._cardFrames[imgName]);
            return;
          }

          if (imgUrl.indexOf('http://') == -1) {
            //imgUrl = GameConst.serverIp + imgUrl;
            imgUrl = 'https://h5tg.yszdata.cn' + imgUrl;
          }

          assetManager.loadRemote(imgUrl, (error, imageAsset) => {
            if (error) {
              (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                error: Error()
              }), LogMgr) : LogMgr).error("ResManger loadRemoteImg " + imgUrl + " error:", error);
              return;
            } //LogMgr.log('loadRemoteImg,imgName:', imgName,imgUrl);


            var spriteFrame = new SpriteFrame();
            var texture = new Texture2D();
            texture.image = imageAsset;
            spriteFrame.texture = texture;
            this._cardFrames[imgName] = spriteFrame;
            cb(this._cardFrames[imgName]);
          });
        }

        static getTileSP(imgKey) {
          if (!this.tileAtlas) {
            (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
              error: Error()
            }), LogMgr) : LogMgr).error("tileAtlas is null,imgKey:" + imgKey);
            return null;
          } else {
            return this.tileAtlas.getSpriteFrame('' + imgKey);
          }
        }
        /**获取文物图集里面的图片
             * @param imgKey 图片名称
             */


        static getArtSP(imgKey) {
          if (!this.artAtlas) {
            (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
              error: Error()
            }), LogMgr) : LogMgr).error("artAtlas is null,imgKey:" + imgKey);
            return null;
          } else {
            return this.artAtlas.getSpriteFrame(imgKey);
          }
        } //加载spine骨骼动画


        static loadSpine(spKey, animKey, spCom) {
          if (!this._spine[spKey]) {
            resources.load('spine/' + spKey + '/skeleton', sp.SkeletonData, (err, data) => {
              if (err) {
                (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                  error: Error()
                }), LogMgr) : LogMgr).error('loadSpine', err);
                return;
              }

              spCom.skeletonData = data;

              if (animKey) {
                spCom.setAnimation(0, animKey, animKey == 'idle' ? true : false);
              }
            });
          } else {
            spCom.skeletonData = this._spine[spKey];

            if (animKey) {
              spCom.setAnimation(0, animKey, animKey == 'idle' ? true : false);
            }
          }
        } //加载远程spine文件json格式 spKey : https://h5tg.yszdata.cn/tgImages/pet/spine/hero_tengtengshe


        static loadRemoteSpine(url, cb) {
          var strArr = url.split('/'),
              spKey = strArr[strArr.length - 1];

          if (this._spine[spKey]) {
            cb(this._spine[spKey]);
            return;
          } //console.log('spKey:', spKey);


          var imageUrl = url + ".png";
          var skeUrl = url + ".json";
          var atlasUrl = url + ".atlas";
          assetManager.loadAny([{
            url: atlasUrl,
            ext: '.txt'
          }, {
            url: skeUrl,
            ext: '.txt'
          }], (error, assets) => {
            if (error) {
              console.log("加载远程骨骼动画失败，atlasUrl：" + atlasUrl + "  skeUrl:" + skeUrl);
              return;
            }

            assetManager.loadRemote(imageUrl, (error, imageAsset) => {
              if (error) {
                console.log("加载远程骨骼动画图片失败，imageUrl：" + imageUrl);
                (_crd && EventManager === void 0 ? (_reportPossibleCrUseOfEventManager({
                  error: Error()
                }), EventManager) : EventManager).emit('showHideLoading', false);
                return;
              }

              var asset = new sp.SkeletonData();
              asset.skeletonJson = assets[1];
              asset.atlasText = assets[0];
              var texture = new Texture2D();
              texture.image = imageAsset;
              asset.textures = [texture];
              asset.textureNames = [spKey + '.png'];
              this._spine[spKey] = asset;
              cb(asset);
            });
          });
        }

        static loadPetSpine(spKey, cb) {
          resources.load('spine/' + spKey, sp.SkeletonData, (err, data) => {
            if (err) {
              (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                error: Error()
              }), LogMgr) : LogMgr).error('loadPetSpine', err);
              return;
            }

            cb && cb(data);
          });
        }

        static loadRemotePetSpine(url, cb) {
          var strArr = url.split('/'),
              spKey = strArr[strArr.length - 1];

          if (this._spine[spKey]) {
            cb(this._spine[spKey]);
            return;
          }

          var imageUrl = url + ".png";
          var skeUrl = url + ".skel";
          var atlasUrl = url + ".atlas";
          assetManager.loadAny([{
            url: atlasUrl,
            ext: '.txt'
          }, {
            url: skeUrl,
            ext: '.bin'
          }], (skelErr, skeAssets) => {
            if (skelErr) {
              (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                error: Error()
              }), LogMgr) : LogMgr).error("loadRemotePetSpine \uFF1A" + url + "\uFF0Cerr:" + skelErr);
              return;
            } //LogMgr.warn(`loadRemotePetSpine spKey：${spKey}，skeAssets:${skeAssets}`);


            assetManager.loadRemote(imageUrl, (imgErr, img) => {
              if (imgErr) {
                (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                  error: Error()
                }), LogMgr) : LogMgr).error("loadRemotePetSpine imgUrl\uFF1A" + url + "\uFF0Cerr:" + imgErr);
                return;
              }

              var texture = new Texture2D();
              texture.image = img;
              var asset = new sp.SkeletonData();
              asset._nativeAsset = skeAssets[1]; //若出错改成 skeAssets[1]._buffer

              asset.atlasText = skeAssets[0]; //若出错改成 skeAssets[0].text

              asset.textures = [texture];
              asset.textureNames = [spKey + '.png'];
              asset._uuid = spKey; // 可以传入任意字符串，但不能为空

              asset._nativeUrl = skeUrl; // 传入一个二进制路径用作 initSkeleton 时的 filePath 参数使用

              this._spine[spKey] = asset;
              cb(asset);
            });
          });
        }

        static loadRemoteSkillSpine(url, cb) {
          var strArr = url.split('/'),
              spKey = strArr[strArr.length - 1];

          if (this._spine[spKey]) {
            cb(this._spine[spKey]);
            return;
          }

          var imageUrl = url + ".png";
          var skeUrl = url + ".skel";
          var atlasUrl = url + ".atlas";
          assetManager.loadAny([{
            url: atlasUrl,
            ext: '.txt'
          }, {
            url: skeUrl,
            ext: '.bin'
          }], (skelErr, skeAssets) => {
            if (skelErr) {
              (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                error: Error()
              }), LogMgr) : LogMgr).error("loadRemotePetSpine \uFF1A" + url + "\uFF0Cerr:" + skelErr);
              cb(null);
              return;
            } //LogMgr.warn(`loadRemotePetSpine spKey：${spKey}，skeAssets:${skeAssets}`);


            assetManager.loadRemote(imageUrl, (imgErr, img) => {
              if (imgErr) {
                (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                  error: Error()
                }), LogMgr) : LogMgr).error("loadRemotePetSpine imgUrl\uFF1A" + url + "\uFF0Cerr:" + imgErr);
                return;
              }

              var texture = new Texture2D();
              texture.image = img;
              var asset = new sp.SkeletonData();
              asset._nativeAsset = skeAssets[1]; //若出错改成 skeAssets[1]._buffer

              asset.atlasText = skeAssets[0]; //若出错改成 skeAssets[0].text

              asset.textures = [texture];
              asset.textureNames = [spKey + '.png'];
              asset._uuid = spKey; // 可以传入任意字符串，但不能为空

              asset._nativeUrl = skeUrl; // 传入一个二进制路径用作 initSkeleton 时的 filePath 参数使用

              this._spine[spKey] = asset;
              cb(asset);
            });
          });
        }

        static loadRemoteMonsterSpine(url, cb) {
          var strArr = url.split('/'),
              spKey = strArr[strArr.length - 1];

          if (this._spine[spKey]) {
            cb(this._spine[spKey]);
            return;
          }

          var imageUrl = url + ".png";
          var skeUrl = url + ".skel";
          var atlasUrl = url + ".atlas";
          assetManager.loadAny([{
            url: atlasUrl,
            ext: '.txt'
          }, {
            url: skeUrl,
            ext: '.bin'
          }], (skelErr, skeAssets) => {
            if (skelErr) {
              (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                error: Error()
              }), LogMgr) : LogMgr).error("loadRemotePetSpine \uFF1A" + url + "\uFF0Cerr:" + skelErr);
              return;
            } //LogMgr.warn(`loadRemotePetSpine spKey：${spKey}，skeAssets:${skeAssets}`);


            assetManager.loadRemote(imageUrl, (imgErr, img) => {
              if (imgErr) {
                (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                  error: Error()
                }), LogMgr) : LogMgr).error("loadRemotePetSpine imgUrl\uFF1A" + url + "\uFF0Cerr:" + imgErr);
                return;
              }

              var texture = new Texture2D();
              texture.image = img;
              var asset = new sp.SkeletonData();
              asset._nativeAsset = skeAssets[1]; //若出错改成 skeAssets[1]._buffer

              asset.atlasText = skeAssets[0]; //若出错改成 skeAssets[0].text

              asset.textures = [texture];
              asset.textureNames = [spKey + '.png'];
              asset._uuid = spKey; // 可以传入任意字符串，但不能为空

              asset._nativeUrl = skeUrl; // 传入一个二进制路径用作 initSkeleton 时的 filePath 参数使用

              this._spine[spKey] = asset;
              cb(asset);
            });
          });
        }

        static getSpine() {
          (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
            error: Error()
          }), LogMgr) : LogMgr).warn('资源管理器getSpine:', this._spine);
          return this._spine;
        }
        /**
        * 预加载资源
        * @param pageName 页面名称
        * @param params 
        */


        static preloadPage(pageName) {
          resources.load("page/" + pageName, Prefab, (error, Prefab) => {
            if (error) {
              (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
                error: Error()
              }), LogMgr) : LogMgr).error("showPage,load page:" + pageName + " err:" + error);
              return;
            }

            (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
              error: Error()
            }), LogMgr) : LogMgr).log("\u9884\u52A0\u8F7D\u9875\u9762:" + pageName + " success");
          });
        }

      });

      ResManger._res = {};
      ResManger.comAtlas = null;
      //通用图集
      ResManger.mineAtlas = null;
      //地砖矿石图集
      ResManger.artAtlas = null;
      //文物图集
      ResManger.tileAtlas = null;
      //文物图集
      ResManger._cardFrames = {};
      //远程图片挂载
      ResManger._spine = {};

      _cclegacy._RF.pop();

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