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

  var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, find, _cc, _dec, _class, _crd, cc, ccclass, property, NewComponent;

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

      _cclegacy._RF.push({}, "2f85a7khA9MfKrRo7JB5b2Y", "scene1", undefined);

      __checkObsolete__(['_decorator', 'Component', 'find', 'Node']);

      cc = __checkObsoleteInNamespace__(_cc);
      ({
        ccclass,
        property
      } = _decorator);

      _export("NewComponent", NewComponent = (_dec = ccclass('NewComponent'), _dec(_class = class NewComponent extends Component {
        onLoad() {
          window.global = this;
          let sp = this.node.getChildByName("sp");
          let a = this.node.getChildByName("a");
          let b = this.node.getChildByName("b");
          let tt = sp.getComponent(cc.Sprite).spriteFrame;
          let x = 168,
              y = 250,
              width = 84,
              height = 50; // tt.rect = new cc.Rect(x, y - Math.round(Math.random()*100), width, height);

          tt.rect = new cc.Rect(x, y, width, height); // let vv = cc.Texture2D.WrapMode.CLAMP_TO_EDGE;
          // let vv = cc.Texture2D.WrapMode.REPEAT;
          // tt.texture.setWrapMode(vv, vv, vv);

          console.log(tt.texture);
          let content = find('Canvas/ScrollView/view/content/Node');

          for (var i = 0; i < 40; i++) {
            for (var j = 0; j < 200; j++) {
              var node = new cc.Node("A" + i + "_" + j);
              var Sprite = node.addComponent(cc.Sprite);
              var wh = node.getComponent(cc.UITransform);
              wh.anchorX = 0;
              wh.anchorY = 1;
              wh.width = width;
              wh.height = height;
              Sprite.spriteFrame = tt;

              if (j % 2 == 0) {
                node.setPosition(i * width, -j * height / 2);
              } else {
                node.setPosition(i * width + width / 2, -Math.floor(j / 2) * height - height / 2);
              }

              content.addChild(node);
            }
          }

          a.on(cc.Node.EventType.TOUCH_END, () => {
            for (var i = 0; i < content.children.length; i++) {
              var node = content.children[i];
              var Sprite = node.getComponent(cc.Sprite);
              Sprite.spriteFrame = null;
              Sprite.destroyRenderData();
            }
          }, this);
          b.on(cc.Node.EventType.TOUCH_END, () => {
            let arr = [];

            for (var i = 0; i < content.children.length; i++) {
              var node = content.children[i];
              arr.push(node);
            }

            content.removeAllChildren();
            this.shuffle(arr);

            for (var i = 0; i < arr.length; i++) {
              var node = arr[i];
              var Sprite = node.getComponent(cc.Sprite);

              Sprite._flushAssembler();

              Sprite.spriteFrame = tt;
              content.addChild(node);
            }
          }, this);
          console.time("aa");
          var ddd = [];

          for (var i = 0; i < 10000; i++) {
            var dd = new cc.Node();
            dd.addComponent(cc.Sprite);
            ddd.push(dd);
          }

          console.timeEnd("aa");
          ddd = [];

          for (var i = 0; i < 10000; i++) {
            var dd = new cc.Node();
            ddd.push(dd);
          }

          console.time("bb");

          for (var i = 0; i < 10000; i++) {
            ddd[i].addComponent(cc.Sprite);
          }

          console.timeEnd("bb");
        }

        shuffle(arr, deep = 5) {
          function sortFun(a, b) {
            return Math.random() < .5 ? 1 : -1;
          }

          while (deep > 0) {
            arr.sort(sortFun);
            deep--;
          }

          return arr;
        }

        start() {}

        update(deltaTime) {}

      }) || _class));

      _cclegacy._RF.pop();

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