shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$blendModes$BlendModePipe = function(global, require, module, exports) {
  global = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions");
  var FilterEffect = require("module$node_modules$pixi_DOT_js$lib$filters$FilterEffect"), RenderGroup = require("module$node_modules$pixi_DOT_js$lib$scene$container$RenderGroup"), warn = require("module$node_modules$pixi_DOT_js$lib$utils$logging$warn");
  "use strict";
  const BLEND_MODE_FILTERS = {};
  global.extensions.handle(global.ExtensionType.BlendMode, value => {
    if (!value.name) {
      throw Error("BlendMode extension must have a name property");
    }
    BLEND_MODE_FILTERS[value.name] = value.ref;
  }, value => {
    delete BLEND_MODE_FILTERS[value.name];
  });
  class BlendModePipe {
    constructor(renderer) {
      this._blendModeStack = [];
      this._isAdvanced = !1;
      this._filterHash = Object.create(null);
      this._renderer = renderer;
      this._renderer.runners.prerender.add(this);
    }
    prerender() {
      this._activeBlendMode = "normal";
      this._isAdvanced = !1;
    }
    pushBlendMode(renderable, blendMode, instructionSet) {
      this._blendModeStack.push(blendMode);
      this.setBlendMode(renderable, blendMode, instructionSet);
    }
    popBlendMode(instructionSet) {
      this._blendModeStack.pop();
      this.setBlendMode(null, this._blendModeStack[this._activeBlendMode.length - 1] ?? "normal", instructionSet);
    }
    setBlendMode(renderable, blendMode, instructionSet) {
      const isRenderGroup = renderable instanceof RenderGroup.RenderGroup;
      this._activeBlendMode === blendMode ? this._isAdvanced && renderable && !isRenderGroup && this._renderableList?.push(renderable) : (this._isAdvanced && this._endAdvancedBlendMode(instructionSet), this._activeBlendMode = blendMode, renderable && (this._isAdvanced = !!BLEND_MODE_FILTERS[blendMode]) && this._beginAdvancedBlendMode(renderable, instructionSet));
    }
    _beginAdvancedBlendMode(renderable, instructionSet) {
      this._renderer.renderPipes.batch.break(instructionSet);
      var blendMode = this._activeBlendMode;
      if (BLEND_MODE_FILTERS[blendMode]) {
        blendMode = this._ensureFilterEffect(blendMode);
        var isRenderGroup = renderable instanceof RenderGroup.RenderGroup;
        renderable = {renderPipeId:"filter", action:"pushFilter", filterEffect:blendMode, renderables:isRenderGroup ? null : [renderable], container:isRenderGroup ? renderable.root : null, canBundle:!1};
        this._renderableList = renderable.renderables;
        instructionSet.add(renderable);
      } else {
        warn.warn(`Unable to assign BlendMode: '${blendMode}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);
      }
    }
    _ensureFilterEffect(blendMode) {
      let filterEffect = this._filterHash[blendMode];
      filterEffect || (filterEffect = this._filterHash[blendMode] = new FilterEffect.FilterEffect(), filterEffect.filters = [new BLEND_MODE_FILTERS[blendMode]()]);
      return filterEffect;
    }
    _endAdvancedBlendMode(instructionSet) {
      this._isAdvanced = !1;
      this._renderableList = null;
      this._renderer.renderPipes.batch.break(instructionSet);
      instructionSet.add({renderPipeId:"filter", action:"popFilter", canBundle:!1});
    }
    buildStart() {
      this._isAdvanced = !1;
    }
    buildEnd(instructionSet) {
      this._isAdvanced && this._endAdvancedBlendMode(instructionSet);
    }
    destroy() {
      this._renderableList = this._renderer = null;
      for (const i in this._filterHash) {
        this._filterHash[i].destroy();
      }
      this._filterHash = null;
    }
  }
  BlendModePipe.extension = {type:[global.ExtensionType.WebGLPipes, global.ExtensionType.WebGPUPipes, global.ExtensionType.CanvasPipes], name:"blendMode"};
  exports.BlendModePipe = BlendModePipe;
};

//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$blendModes$BlendModePipe.js.map
