import { Component, Event, Prop, State } from '@stencil/core';
export class ScConsumer {
  constructor() {
    this.setContext = async (context) => {
      this.context = context;
      return this.promise;
    };
    this.promise = new Promise(resolve => {
      this.resolvePromise = resolve;
    });
  }
  componentWillLoad() {
    this.mountEmitter.emit(this.setContext);
  }
  disconnectedCallback() {
    this.resolvePromise();
  }
  render() {
    if (!this.context) {
      return null;
    }
    return this.renderer(this.context);
  }
  static get is() { return "sc-consumer"; }
  static get properties() { return {
    "renderer": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "renderer",
      "reflect": false
    }
  }; }
  static get states() { return {
    "context": {},
    "promise": {},
    "resolvePromise": {}
  }; }
  static get events() { return [{
      "method": "mountEmitter",
      "name": "mountConsumer",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
}
