'use strict';

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

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

const DevingenProductApiKeysPage = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fetchProduct = async () => {
      const { id } = this.match.params;
      this.product = await this.apiDevingen.getProduct(id).catch((e) => this.error = e);
    };
    this.renderHeader = () => {
      var _a;
      return (index.h("div", { class: "container" }, index.h("div", { class: "row" }, index.h("div", { class: "col d-flex align-items-center pt-2 pb-3" }, index.h("h2", { class: "m-0" }, (_a = this.product) === null || _a === void 0 ? void 0 :
        _a.name, " / API Key Settings")))));
    };
    this.generatePredefinedScopes = () => {
      const { product } = this;
      switch (product.type) {
        case 'damga':
          return [
            { label: 'Target Groups - Write', value: `dri:das:products:${product._id}:damga:target-groups:*.write` },
          ];
        case 'sepet':
          return [
            { label: 'Files - Write', value: `dri:das:products:${product._id}:sepet:files:*.write` },
            { label: 'Buckets - Write', value: `dri:das:products:${product._id}:sepet:buckets:*.write` },
          ];
      }
    };
  }
  componentWillLoad() {
    this.fetchProduct();
  }
  render() {
    const { product } = this;
    if (!product) {
      return (index.h("div", { class: "d-flex justify-content-center pt-3" }, index.h("dvn-progress", { indefinite: true })));
    }
    const apiHeaders = {
      Authorization: this.apiKimlik.api.getDefaults().headers['Authorization'],
      'devingen-product-id': product._id,
    };
    return (index.h(index.Host, { class: "d-block" }, this.renderHeader(), index.h("kimlik-home", { apiEndpoint: `${services.prod.kimlik}/${services.prod.base}`, apiHeaders: apiHeaders, shownTabs: ['api-keys'], preSelectedTab: 'api-keys', predefinedScopesForAPIKeys: this.generatePredefinedScopes(), allowCustomScopesForAPIKeys: false })));
  }
};

exports.devingen_product_api_keys_page = DevingenProductApiKeysPage;
