import { Component, h, Prop, State, Element } from '@stencil/core';
import mammoth from 'mammoth';
export class AkordDocsViewer {
  constructor() {
    this.isLoading = true;
  }
  componentWillLoad() {
    const jsonFile = new XMLHttpRequest();
    jsonFile.open('GET', this.src, true);
    jsonFile.send();
    jsonFile.responseType = 'arraybuffer';
    jsonFile.onreadystatechange = () => {
      if (jsonFile.readyState === 4 && jsonFile.status === 200) {
        mammoth.convertToHtml({ arrayBuffer: jsonFile.response }, { includeDefaultStyleMap: true })
          .then((result) => {
          this.el.innerHTML = result.value;
        })
          .catch((e) => {
          console.log(e);
        });
      }
    };
  }
  render() {
    return (h("div", null));
  }
  static get is() { return "akord-docs-viewer"; }
  static get originalStyleUrls() { return {
    "$": ["akord-docs-viewer.css"]
  }; }
  static get styleUrls() { return {
    "$": ["akord-docs-viewer.css"]
  }; }
  static get properties() { return {
    "src": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "src",
      "reflect": false
    }
  }; }
  static get states() { return {
    "content": {},
    "isLoading": {},
    "html": {}
  }; }
  static get elementRef() { return "el"; }
}
