import { r as registerInstance, h, H as Host } from './index-ecdfb761.js';
import { p as prod } from './services-63217112.js';

const DevingenProductApiKeysPage = class {
  constructor(hostRef) {
    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 (h("div", { class: "container" }, h("div", { class: "row" }, h("div", { class: "col d-flex align-items-center pt-2 pb-3" }, 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 (h("div", { class: "d-flex justify-content-center pt-3" }, h("dvn-progress", { indefinite: true })));
    }
    const apiHeaders = {
      Authorization: this.apiKimlik.api.getDefaults().headers['Authorization'],
      'devingen-product-id': product._id,
    };
    return (h(Host, { class: "d-block" }, this.renderHeader(), h("kimlik-home", { apiEndpoint: `${prod.kimlik}/${prod.base}`, apiHeaders: apiHeaders, shownTabs: ['api-keys'], preSelectedTab: 'api-keys', predefinedScopesForAPIKeys: this.generatePredefinedScopes(), allowCustomScopesForAPIKeys: false })));
  }
};

export { DevingenProductApiKeysPage as devingen_product_api_keys_page };
