'use strict';

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

const index = require('./index-a1121663.js');
require('./BaseField-f50bb8f0.js');
require('./_commonjsHelpers-206db00d.js');
const kimlikApi = require('./kimlikApi-6a581864.js');
require('./data-transfer-field-025bce2f.js');
require('./filter-52876f3c.js');
const dataApi = require('./dataApi-5225d8e2.js');
const cookie = require('./cookie-8a49bf23.js');
const index$1 = require('./index-6e5eb542.js');
const services = require('./services-895a8d1d.js');

class DevingenApi {
  constructor(endpoint, defaultHeaders = {}) {
    this.createWorkspace = (name) => this.api.post(`workspaces`, { name });
    this.getWorkspaceOwnerships = () => this.api.get('workspace-ownerships');
    this.createProduct = (name, workspaceId, type) => this.api.post(`products`, { name, workspaceId, type });
    this.getProducts = () => this.api.get('products');
    this.getProduct = (id) => this.api.get(`products/${id}`);
    this.api = new kimlikApi.APIBase(endpoint, defaultHeaders);
  }
}

const wrapContent = (content) => (index.h(index.Host, null, index.h("dvn-theme-provider", { colorBackground: true, fitHeight: true }, index.h("dvn-global-table", null), index.h("dvn-global-grid", null), index.h("dvn-global-text", null), index.h("notifier-wrapper", null, content))));
const DevingenRoot = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
  }
  render() {
    const jwt = new cookie.CookieStorage().getAll().jwt;
    const headers = {
      Authorization: jwt ? `Bearer ${new cookie.CookieStorage().getAll().jwt}` : undefined,
    };
    const apiKimlik = new kimlikApi.KimlikApiImpl(`${services.prod.kimlik}/${services.prod.base}`, headers);
    const apiData = new dataApi.DataApiImpl(`${services.prod.data}/${services.prod.base}`, headers);
    const apiDevingen = new DevingenApi(`${services.prod.devingen}/${services.prod.base}`, headers);
    if (!index$1.isUserLoggedIn()) {
      return wrapContent(index.h("devingen-login-page", { apiKimlik: apiKimlik }));
    }
    return wrapContent(index.h("devingen-router", { apiKimlik: apiKimlik, apiDevingen: apiDevingen, apiData: apiData }));
  }
};

exports.devingen_root = DevingenRoot;
