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

  var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Label, math, _dec, _dec2, _class, _class2, _descriptor, _crd, ccclass, property, NumRaiseLable;

  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 _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 ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }

  return {
    setters: [function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      Label = _cc.Label;
      math = _cc.math;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "3f43dXREG5P1LIco7w9mkJo", "NumRaiseLable", undefined);

      __checkObsolete__(['_decorator', 'Component', 'Label', 'math', 'Node']);

      ({
        ccclass,
        property
      } = _decorator);
      /**
       * 调用事例
       * this.combatLable.startCounting(data.total);
       */
      //数字自增长

      _export("NumRaiseLable", NumRaiseLable = (_dec = ccclass('NumRaiseLable'), _dec2 = property({
        tooltip: '数字增长动画持续时间（秒）'
      }), _dec(_class = (_class2 = class NumRaiseLable extends Label {
        constructor(...args) {
          super(...args);

          // 动画持续时间（秒）
          _initializerDefineProperty(this, "_duration", _descriptor, this);

          // 当前显示的数字
          this._currentValue = 0;
          // 目标数字
          this._targetValue = 0;
          // 是否正在播放动画
          this._isAnimating = false;
          // 每帧增量
          this._incrementPerFrame = 0;
        }

        get duration() {
          return this._duration;
        }

        set duration(value) {
          this._duration = math.clamp(value, 0.1, 5);
        }

        /**
         * 开始数字增长动画
         * @param targetValue 目标数值
         * @param duration 可选，动画持续时间（秒），默认使用组件设置的duration
         */
        startCounting(targetValue, duration) {
          if (this._isAnimating) {
            this.stopCounting();
          } //使用传入的duration或默认值


          const animDuration = duration != null ? duration : this._duration;
          this._targetValue = targetValue;
          this._currentValue = 0;
          this._isAnimating = true; //计算每帧增量（假设60FPS）

          this._incrementPerFrame = this._targetValue / (animDuration * 60); //取消之前的调度

          this.unschedule(this.updateNumber); //开始新的调度

          this.schedule(this.updateNumber, 1 / 60);
        }
        /**
         * 停止数字增长动画
         */


        stopCounting() {
          this._isAnimating = false;
          this.unschedule(this.updateNumber);
          this._currentValue = this._targetValue;
          this.updateDisplay();
        }
        /**
         * 立即完成动画
         */


        completeCounting() {
          this.stopCounting();
          this._currentValue = this._targetValue;
          this.updateDisplay();
        }
        /**
         * 每帧更新数字
         */


        updateNumber() {
          if (!this._isAnimating) return;
          this._currentValue += this._incrementPerFrame; //确保不超过目标值

          if (this._currentValue >= this._targetValue) {
            this._currentValue = this._targetValue;
            this._isAnimating = false;
            this.unschedule(this.updateNumber);
          }

          this.updateDisplay();
        }
        /**
         * 更新显示文本
         */


        updateDisplay() {
          this.string = Math.floor(this._currentValue).toString();
        } //组件销毁时清理


        onDestroy() {
          this.unschedule(this.updateNumber);
        }

      }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "_duration", [_dec2], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function () {
          return 0.5;
        }
      }), _applyDecoratedDescriptor(_class2.prototype, "duration", [property], Object.getOwnPropertyDescriptor(_class2.prototype, "duration"), _class2.prototype)), _class2)) || _class));

      _cclegacy._RF.pop();

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