import { r as registerInstance, h, H as Host } from './index-acdc1ac0.js';
import './BaseField-d94c5b14.js';
import './_commonjsHelpers-63c253cd.js';
import { A as APIBase, K as KimlikApiImpl } from './kimlikApi-81acfec6.js';
import './data-transfer-field-1ad95e08.js';
import './filter-cbaa3d7d.js';
import { D as DataApiImpl } from './dataApi-95bebee9.js';
import { C as CookieStorage } from './cookie-d9098150.js';
import { i as isUserLoggedIn } from './index-3a5c6fef.js';
import { p as prod } from './services-fc4ce8f3.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 APIBase(endpoint, defaultHeaders);
  }
}

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

export { DevingenRoot as devingen_root };
