shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$ExternalSource = function(global, require, module, exports) {
  var GlTexture = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$gl$texture$GlTexture"), GpuTextureSystem = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$texture$GpuTextureSystem"), types = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$types");
  global = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$TextureSource");
  "use strict";
  const placeholderGl = Object.create(null), placeholderGpu = Object.create(null);
  class ExternalSource extends global.TextureSource {
    constructor({resource, renderer, label, width, height}) {
      if (!resource) {
        var _a;
        renderer.type === types.RendererType.WEBGPU ? (placeholderGpu[_a = renderer.uid] || (placeholderGpu[_a] = renderer.gpu.device.createTexture({label:"ExternalSource placeholder", size:{width:1, height:1}, format:"rgba8unorm", usage:GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST})), resource = placeholderGpu[renderer.uid]) : (placeholderGl[renderer.uid] || (resource = renderer.gl, _a = resource.createTexture(), resource.bindTexture(resource.TEXTURE_2D, _a), resource.texImage2D(resource.TEXTURE_2D, 
        0, resource.RGBA, 1, 1, 0, resource.RGBA, resource.UNSIGNED_BYTE, null), placeholderGl[renderer.uid] = _a), resource = placeholderGl[renderer.uid]);
      }
      width || (width = width ?? resource?.width ?? 1);
      height || (height = height ?? resource?.height ?? 1);
      super({resource, width, height, label, autoGarbageCollect:!1});
      this._renderer = renderer;
      this._initGpuData(resource);
    }
    static test(resource) {
      return globalThis.GPUTexture && resource instanceof GPUTexture || globalThis.WebGLTexture && resource instanceof WebGLTexture;
    }
    _validateTexture(resource) {
      var renderer = this._renderer;
      const isWebGPU = !!renderer.gpu, isGPUTexture = globalThis.GPUTexture && resource instanceof GPUTexture, isWebGLTexture = globalThis.WebGLTexture && resource instanceof WebGLTexture;
      if (isWebGPU && isWebGLTexture) {
        throw Error("Cannot use WebGLTexture with a WebGPU renderer");
      }
      if (!isWebGPU && isGPUTexture) {
        throw Error("Cannot use GPUTexture with a WebGL renderer");
      }
      if (!isWebGPU && (renderer = renderer.gl) && !renderer.isTexture(resource)) {
        throw Error("WebGLTexture does not belong to this renderer's WebGL context");
      }
    }
    _initGpuData(resource) {
      const renderer = this._renderer;
      this._validateTexture(resource);
      this._gpuData[renderer.uid] = renderer.gpu ? new GpuTextureSystem.GPUTextureGpuData(resource) : new GlTexture.GlTexture(resource);
    }
    updateGPUTexture(gpuTexture, width, height) {
      var renderer = this._renderer;
      const gpuData = this._gpuData[renderer.uid];
      this.resource = gpuTexture;
      renderer.gpu ? (this._validateTexture(gpuTexture), gpuData.gpuTexture !== gpuTexture && (gpuData.gpuTexture = gpuTexture, gpuData.textureView = null, renderer = renderer.texture, renderer?._bindGroupHash && (renderer._bindGroupHash[this.uid] = null)), this.resize(width ?? gpuTexture.width, height ?? gpuTexture.height)) : (this._validateTexture(gpuTexture), gpuData.texture = gpuTexture, void 0 !== width && void 0 !== height && this.resize(width, height));
      this.emit("update", this);
    }
    destroy() {
      delete this._gpuData[this._renderer.uid];
      super.destroy();
    }
  }
  exports.ExternalSource = ExternalSource;
};

//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$ExternalSource.js.map
