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

  var _reporterNs, _cclegacy, _decorator, instantiate, UICoordinateTrackerComponent, EventHandler, Label, OTWObjectComponent, _dec, _dec2, _class, _class2, _descriptor, _temp, _crd, ccclass, property, OTWFlagComponent;

  function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }

  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

  function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }

  function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); }

  function _reportPossibleCrUseOfICountry(extras) {
    _reporterNs.report("ICountry", "../../../shared/gameClient/games/OccupationTheWarModels", _context.meta, extras);
  }

  function _reportPossibleCrUseOfOTWGameData(extras) {
    _reporterNs.report("OTWGameData", "../Data/OTWGameData", _context.meta, extras);
  }

  function _reportPossibleCrUseOfOTWObjectComponent(extras) {
    _reporterNs.report("OTWObjectComponent", "./OTWObjectComponent", _context.meta, extras);
  }

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      _decorator = _cc._decorator;
      instantiate = _cc.instantiate;
      UICoordinateTrackerComponent = _cc.UICoordinateTrackerComponent;
      EventHandler = _cc.EventHandler;
      Label = _cc.Label;
    }, function (_unresolved_2) {
      OTWObjectComponent = _unresolved_2.OTWObjectComponent;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "676de4cgS1E+Jbb2Ogukne6", "OTWFlagComponent", undefined);

      ({
        ccclass,
        property
      } = _decorator);

      _export("OTWFlagComponent", OTWFlagComponent = (_dec = ccclass('OTWFlagComponent'), _dec2 = property({
        type: Label,
        tooltip: "文本显示"
      }), _dec(_class = (_class2 = (_temp = class OTWFlagComponent extends (_crd && OTWObjectComponent === void 0 ? (_reportPossibleCrUseOfOTWObjectComponent({
        error: Error()
      }), OTWObjectComponent) : OTWObjectComponent) {
        constructor() {
          super(...arguments);

          _initializerDefineProperty(this, "Text", _descriptor, this);

          _defineProperty(this, "country", null);
        }

        updateShow() {
          var _this$getGameData, _this$getGameData$map;

          var player = this.country && this.country.playerConnId ? (_this$getGameData = this.getGameData()) === null || _this$getGameData === void 0 ? void 0 : (_this$getGameData$map = _this$getGameData.map) === null || _this$getGameData$map === void 0 ? void 0 : _this$getGameData$map.allPlayer[this.country.playerConnId] : null;

          if (player) {
            //有玩家,则输出玩家名
            this.Text.string = player.userName;
          } else if (this.country) {
            //没玩家,则显示国家名
            this.Text.string = this.country.name;
          } else {
            //也没国家
            this.Text.string = "无主之地";
          }
        }
        /**
         * 创建并返回UIFlag节点,要自行添加到UI节点
         * @date 2022/3/18 - 下午3:47:29
         *
         * @public
         * @static
         * @template FlagComp extends OTWFlagComponent
         * @param {__private._types_globals__Constructor<FlagComp>} FlagComp
         * @param {() => OTWGameData} getGameData
         * @param {Prefab} flagPrefab
         * @param {Node} gameObjNode
         * @param {Camera} mainCamera
         * @param {Node} gameMgrNode
         * @param {string} handlerFnName
         * @param {string} customEventData
         * @param {(flagComp:FlagComp)=>void} init
         * @returns {Node}
         */


        static createFlagNode(FlagComp, getGameData, flagPrefab, gameObjNode, mainCamera, gameMgrNode, gameMgrClassName, handlerFnName, customEventData, country, init) {
          var flag = instantiate(flagPrefab);
          flag.name = gameObjNode.name;
          var flagComp = flag.getComponent(FlagComp);
          flagComp.getGameData = getGameData;
          flagComp.country = country;
          init(flagComp);
          /*
          var c = gameObjNode.addComponent(PositionMapToUIComponent);
          c.targetUI = flag;
          c.camera = mainCamera;
          */

          /*
          */

          var c = gameObjNode.addComponent(UICoordinateTrackerComponent);
          c.target = flag;
          c.camera = mainCamera;
          var ev = new EventHandler();
          ev.target = gameMgrNode;
          ev.component = gameMgrClassName;
          ev.handler = handlerFnName;
          ev.customEventData = customEventData;
          c.syncEvents.push(ev);
          return flag;
        }

      }, _temp), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "Text", [_dec2], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: null
      })), _class2)) || _class));

      _cclegacy._RF.pop();

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