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

  var _cclegacy, _decorator, Component, Node, NodePool, Prefab, instantiate, v3, _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _temp, _crd, ccclass, property, root;

  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.'); }

  return {
    setters: [function (_cc) {
      _cclegacy = _cc.cclegacy;
      _decorator = _cc._decorator;
      Component = _cc.Component;
      Node = _cc.Node;
      NodePool = _cc.NodePool;
      Prefab = _cc.Prefab;
      instantiate = _cc.instantiate;
      v3 = _cc.v3;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "490aemA5VJCvrjLnscY1POr", "root", undefined);

      ({
        ccclass,
        property
      } = _decorator);
      /**
       * Predefined variables
       * Name = root
       * DateTime = Tue Feb 08 2022 16:03:35 GMT+0800 (中国标准时间)
       * Author = 鄙人姓鄙
       * FileBasename = root.ts
       * FileBasenameNoExtension = root
       * URL = db://assets/root.ts
       * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
       *
       */

      _export("root", root = (_dec = ccclass('root'), _dec2 = property(Node), _dec3 = property(Prefab), _dec(_class = (_class2 = (_temp = class root extends Component {
        constructor(...args) {
          super(...args);

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

          _initializerDefineProperty(this, "item", _descriptor2, this);

          _defineProperty(this, "pool", void 0);
        }

        onLoad() {
          this.pool = new NodePool('pool');
          this.refreshView();
        }

        refreshView() {
          var cells = [];

          for (var i = 0, len = this.content.children.length; i < len; i++) {
            var obj = this.content.children[i];
            cells.push(obj);
          }

          if (cells.length > 0) {
            var t1 = cells[0];
            cells[0] = cells[2];
            cells[2] = t1;
          }

          for (var i = 0, len = cells.length; i < len; i++) {
            var cell = cells[i];
            this.pool.put(cell);
          }

          var list = [1, 2, 3];
          var data = {
            prefab: this.item,
            list: list,
            content: this.content
          }; //NOTE: 只要不是同一帧内执行removeFromParent  setParent就不会有问题
          // setTimeout(() => {
          //     this.refreshContentView(data);
          // }, 0);

          this.refreshContentView(data);
        }

        refreshContentView(data) {
          var prefab = data.prefab;
          var content = data.content;
          var list = data.list;
          var scriptName = data.scriptName || prefab.data.name;
          var ext = data.ext;
          var ext2 = data.ext2;
          var ext3 = data.ext3;
          var result = [];

          for (var i = 0, len = list.length; i < len; i++) {
            var info = list[i];
            var item = content.children[i];

            if (!item) {
              item = this.getPool(prefab);
              item.parent = content;
            }

            item.position = v3(-300 + i * 200, item.position.y);
            var script = item.getComponent(scriptName);

            if (script && script.init) {
              script.init(i, info, ext, ext2, ext3);
            }
          }

          return result;
        }

        getPool(prefab) {
          var node = this.pool.get();

          if (!node) {
            node = instantiate(prefab);
          }

          return node;
        } // update (deltaTime: number) {
        //     // [4]
        // }


      }, _temp), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "content", [_dec2], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function () {
          return null;
        }
      }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "item", [_dec3], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function () {
          return null;
        }
      })), _class2)) || _class));
      /**
       * [1] Class member could be defined like this.
       * [2] Use `property` decorator if your want the member to be serializable.
       * [3] Your initialization goes here.
       * [4] Your update function goes here.
       *
       * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
       * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
       * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
       */


      _cclegacy._RF.pop();

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