import { utils, SystemManager, settings, ExtensionType, extensions } from 'pixijs/core';

const { deprecation } = utils;
const _CanvasRenderer = class extends SystemManager {
  constructor(options) {
    super();
    this.rendererLogId = "Canvas";
    options = Object.assign({}, settings.RENDER_OPTIONS, options);
    const systemConfig = {
      runners: [
        "init",
        "destroy",
        "contextChange",
        "resolutionChange",
        "reset",
        "update",
        "postrender",
        "prerender",
        "resize"
      ],
      systems: _CanvasRenderer.__systems,
      priority: [
        "textureGenerator",
        "background",
        "_view",
        "_plugin",
        "startup",
        "mask",
        "canvasContext",
        "objectRenderer"
      ]
    };
    this.setup(systemConfig);
    if ("useContextAlpha" in options) {
      deprecation("7.0.0", "options.useContextAlpha is deprecated, use options.backgroundAlpha instead");
      options.backgroundAlpha = options.useContextAlpha === false ? 1 : options.backgroundAlpha;
    }
    const startupOptions = {
      hello: options.hello,
      _plugin: _CanvasRenderer.__plugins,
      background: {
        alpha: options.backgroundAlpha,
        color: options.background ?? options.backgroundColor,
        clearBeforeRender: options.clearBeforeRender
      },
      _view: {
        height: options.height,
        width: options.width,
        autoDensity: options.autoDensity,
        resolution: options.resolution,
        view: options.view
      }
    };
    this.startup.run(startupOptions);
  }
  static test() {
    return true;
  }
  generateTexture(displayObject, options) {
    return this.textureGenerator.generateTexture(displayObject, options);
  }
  reset() {
  }
  render(displayObject, options) {
    this.objectRenderer.render(displayObject, options);
  }
  clear() {
    this.canvasContext.clear();
  }
  destroy(removeView) {
    this.runners.destroy.items.reverse();
    this.emitWithCustomOptions(this.runners.destroy, {
      _view: removeView
    });
    super.destroy();
  }
  get plugins() {
    return this._plugin.plugins;
  }
  resize(desiredScreenWidth, desiredScreenHeight) {
    this._view.resizeView(desiredScreenWidth, desiredScreenHeight);
  }
  get width() {
    return this._view.element.width;
  }
  get height() {
    return this._view.element.height;
  }
  get resolution() {
    return this._view.resolution;
  }
  set resolution(value) {
    this._view.resolution = value;
    this.runners.resolutionChange.emit(value);
  }
  get autoDensity() {
    return this._view.autoDensity;
  }
  get view() {
    return this._view.element;
  }
  get screen() {
    return this._view.screen;
  }
  get lastObjectRendered() {
    return this.objectRenderer.lastObjectRendered;
  }
  get renderingToScreen() {
    return this.objectRenderer.renderingToScreen;
  }
  get clearBeforeRender() {
    return this.background.clearBeforeRender;
  }
  get blendModes() {
    deprecation("7.0.0", "renderer.blendModes has been deprecated, please use renderer.canvasContext.blendModes instead");
    return this.canvasContext.blendModes;
  }
  get maskManager() {
    deprecation("7.0.0", "renderer.maskManager has been deprecated, please use renderer.mask instead");
    return this.mask;
  }
  get refresh() {
    deprecation("7.0.0", "renderer.refresh has been deprecated");
    return true;
  }
  get rootContext() {
    deprecation("7.0.0", "renderer.rootContext has been deprecated, please use renderer.canvasContext.rootContext instead");
    return this.canvasContext.rootContext;
  }
  get context() {
    deprecation("7.0.0", "renderer.context has been deprecated, please use renderer.canvasContext.activeContext instead");
    return this.canvasContext.activeContext;
  }
  get smoothProperty() {
    deprecation("7.0.0", "renderer.smoothProperty has been deprecated, please use renderer.canvasContext.smoothProperty instead");
    return this.canvasContext.smoothProperty;
  }
  setBlendMode(blendMode, readyForOuterBlend) {
    deprecation("7.0.0", "renderer.setBlendMode has been deprecated, use renderer.canvasContext.setBlendMode instead");
    this.canvasContext.setBlendMode(blendMode, readyForOuterBlend);
  }
  invalidateBlendMode() {
    deprecation("7.0.0", "renderer.invalidateBlendMode has been deprecated, use renderer.canvasContext.invalidateBlendMode instead");
    this.canvasContext.invalidateBlendMode();
  }
  setContextTransform(transform, roundPixels, localResolution) {
    deprecation("7.0.0", "renderer.setContextTransform has been deprecated, use renderer.canvasContext.setContextTransform instead");
    this.canvasContext.setContextTransform(transform, roundPixels, localResolution);
  }
  get backgroundColor() {
    deprecation("7.0.0", "renderer.backgroundColor has been deprecated, use renderer.background.color instead.");
    return this.background.color;
  }
  set backgroundColor(value) {
    deprecation("7.0.0", "renderer.backgroundColor has been deprecated, use renderer.background.color instead.");
    this.background.color = value;
  }
  get backgroundAlpha() {
    deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
    return this.background.color;
  }
  set backgroundAlpha(value) {
    deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
    this.background.alpha = value;
  }
  get preserveDrawingBuffer() {
    deprecation("7.0.0", "renderer.preserveDrawingBuffer has been deprecated");
    return false;
  }
  get useContextAlpha() {
    deprecation("7.0.0", "renderer.useContextAlpha has been deprecated");
    return false;
  }
};
let CanvasRenderer = _CanvasRenderer;
CanvasRenderer.extension = {
  type: ExtensionType.Renderer,
  priority: 0
};
CanvasRenderer.__plugins = {};
CanvasRenderer.__systems = {};
extensions.handleByMap(ExtensionType.CanvasRendererPlugin, CanvasRenderer.__plugins);
extensions.handleByMap(ExtensionType.CanvasRendererSystem, CanvasRenderer.__systems);
extensions.add(CanvasRenderer);

export { CanvasRenderer };
//# sourceMappingURL=CanvasRenderer.mjs.map
