import { r as registerInstance, h, H as Host } from './index-b7735e0d.js';
import { d as dark } from './dark-debf9c41.js';
import { D as DataApiImpl } from './dataApi-82558134.js';
import { K as KimlikApiImpl } from './kimlikApi-0d7e6ce7.js';
import { i as isUserLoggedIn } from './index-c7307038.js';
import { C as CookieStorage } from './cookie-1686830b.js';
import { A as APIBase } from './apiBase-d573f009.js';
import { p as prod } from './services-2b193868.js';
import './colors-4dc9e03b.js';
import './data-transfer-field-918730a3.js';
import './BaseField-461b6d0c.js';
import './filter-cbaa3d7d.js';
import './_commonjsHelpers-27f122dd.js';

class DevingenApi {
  constructor(endpoint, defaultHeaders = {}) {
    // region products
    this.createProduct = (body) => this.api.post(`products`, body);
    this.getProducts = () => this.api.get('products');
    this.getProduct = (id) => this.api.get(`products/${id}`);
    this.updateProduct = (id, body) => this.api.put(`products/${id}`, body);
    this.deleteProduct = (id) => this.api.delete(`products/${id}`);
    // endregion
    // region workspace
    this.createWorkspace = (name) => this.api.post(`workspaces`, { name });
    this.updateWorkspace = (id, body) => this.api.put(`workspaces/${id}`, body);
    this.deleteWorkspace = (id) => this.api.delete(`workspaces/${id}`);
    // endregion
    this.getWorkspaceOwnerships = () => this.api.get('workspace-ownerships');
    this.api = new APIBase(endpoint, defaultHeaders);
  }
}

const wrapContent = (content) => (h(Host, null, h("dvn-theme-provider", { theme: dark, colorBackground: true, fitHeight: true }, h("dvn-global-table", null), h("dvn-global-grid", null), h("dvn-global-text", null), h("notifier-wrapper", null, content))));
let 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, 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 };
