shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$buffer$Buffer = function(global, require, module, exports) {
  global = require("module$node_modules$eventemitter3$index");
  var uid = require("module$node_modules$pixi_DOT_js$lib$utils$data$uid"), _const = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$buffer$const");
  "use strict";
  class Buffer extends global {
    constructor(options) {
      let {data, size} = options;
      const {usage, label, shrinkToFit} = options;
      super();
      this._gpuData = Object.create(null);
      this._gcLastUsed = -1;
      this.autoGarbageCollect = !0;
      this.uid = uid.uid("buffer");
      this._resourceType = "buffer";
      this._resourceId = uid.uid("resource");
      this._touched = 0;
      this._updateID = 1;
      this._dataInt32 = null;
      this.shrinkToFit = !0;
      this.destroyed = !1;
      data instanceof Array && (data = new Float32Array(data));
      this._data = data;
      size ?? (size = data?.byteLength);
      this.descriptor = {size, usage, mappedAtCreation:!!data, label};
      this.shrinkToFit = shrinkToFit ?? !0;
    }
    get data() {
      return this._data;
    }
    set data(value) {
      this.setDataWithSize(value, value.length, !0);
    }
    get dataInt32() {
      this._dataInt32 || (this._dataInt32 = new Int32Array(this.data.buffer));
      return this._dataInt32;
    }
    get static() {
      return !!(this.descriptor.usage & _const.BufferUsage.STATIC);
    }
    set static(value) {
      this.descriptor.usage = value ? this.descriptor.usage | _const.BufferUsage.STATIC : this.descriptor.usage & ~_const.BufferUsage.STATIC;
    }
    setDataWithSize(value, size, syncGPU) {
      this._updateID++;
      this._updateSize = size * value.BYTES_PER_ELEMENT;
      this._data === value ? syncGPU && this.emit("update", this) : (size = this._data, this._data = value, this._dataInt32 = null, size && size.length === value.length ? syncGPU && this.emit("update", this) : !this.shrinkToFit && size && value.byteLength < size.byteLength ? syncGPU && this.emit("update", this) : (this.descriptor.size = value.byteLength, this._resourceId = uid.uid("resource"), this.emit("change", this)));
    }
    update(sizeInBytes) {
      this._updateSize = sizeInBytes ?? this._updateSize;
      this._updateID++;
      this.emit("update", this);
    }
    unload() {
      this.emit("unload", this);
      for (const key in this._gpuData) {
        this._gpuData[key]?.destroy();
      }
      this._gpuData = Object.create(null);
    }
    destroy() {
      this.destroyed = !0;
      this.unload();
      this.emit("destroy", this);
      this.emit("change", this);
      this.descriptor = this._data = null;
      this.removeAllListeners();
    }
  }
  exports.Buffer = Buffer;
};

//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$buffer$Buffer.js.map
