'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-1141a245.js');

const DevingenProductRootTaban = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.fetchProductSettings();
  }
  fetchProductSettings() {
    this.apiDevingen.findProductSettingsTaban(this.product._id)
      .then(response => this.productSettings = response)
      .catch((e) => {
      var _a;
      if (((_a = e === null || e === void 0 ? void 0 : e.data) === null || _a === void 0 ? void 0 : _a.error) === 'product-setting-not-found-for-product') {
        this.apiDevingen.createProductSettingsTaban(this.product._id)
          .then((response) => {
          this.productSettings = response;
        })
          .catch(error => this.error = error);
      }
      else {
        this.error = e;
      }
    });
  }
  render() {
    const { error } = this;
    if (error) {
      return (index.h(index.Host, null, index.h("div", { class: "d-flex justify-content-center" }, index.h("devingen-error-card", { error: error, message: "Unexpected error occurred." }))));
    }
    return (index.h(index.Host, { class: "container d-flex flex-grow-1 flex-column" }));
  }
};

exports.devingen_product_root_taban = DevingenProductRootTaban;
