import { ref, h } from 'vue';
import { u as useAPI } from './api-aea70669.mjs';
import { i as isRealmResourceWritable } from './utils-252b142e.mjs';
import { d as defineNuxtComponent, a as useToast, e as useRoute, n as navigateTo, f as useAuthStore, s as storeToRefs, N as NuxtPage } from './server.mjs';
import { b as buildDomainEntityNav } from './enity-nav-a1b4cf76.mjs';
import { u as updateObjectProperties } from './object-80310ce0.mjs';
import 'ofetch';
import 'hookable';
import 'unctx';
import 'destr';
import '@unhead/ssr';
import 'unhead';
import '@unhead/shared';
import 'vue-router';
import 'h3';
import 'ufo';
import '@ebec/http';
import 'hapic';
import '@hapic/oauth2';
import 'rapiq';
import '@vue-layout/basic';
import 'change-case';
import '@ucast/mongo2js';
import 'ilingo';
import '@vue-layout/hyperscript';
import '@vuelidate/validators';
import '@vuelidate/core';
import 'nanoid';
import 'smob';
import 'browser-storage-adapter';
import 'cookie-es';
import 'ohash';
import 'vue/server-renderer';
import 'defu';
import './node-server.mjs';
import 'node-fetch-native/polyfill';
import 'node:http';
import 'node:https';
import 'unenv/runtime/fetch/index';
import 'scule';
import 'unstorage';
import 'radix3';
import 'node:fs';
import 'node:url';
import 'pathe';
import './nuxt-link-d23e8ff6.mjs';

const _id_ = /* @__PURE__ */ defineNuxtComponent({
  async setup() {
    const items = [
      {
        name: "General",
        icon: "fas fa-bars",
        urlSuffix: ""
      },
      {
        name: "Permissions",
        icon: "fas fa-user-secret",
        urlSuffix: "permissions"
      },
      {
        name: "Users",
        icon: "fas fa-users",
        urlSuffix: "users"
      }
    ];
    const toast = useToast();
    const route = useRoute();
    const entity = ref(null);
    try {
      entity.value = await useAPI().role.getOne(route.params.id);
    } catch (e) {
      return navigateTo({ path: "/admin/roles" });
    }
    const store = useAuthStore();
    const { realmManagement } = storeToRefs(store);
    if (!isRealmResourceWritable(realmManagement.value, entity.value.realm_id)) {
      return navigateTo({ path: "/admin/roles" });
    }
    const handleUpdated = (e) => {
      toast.success("The role was successfully updated.");
      updateObjectProperties(entity, e);
    };
    const handleFailed = (e) => {
      toast.warning(e.message);
    };
    return () => h("div", [
      h("h1", { class: "title no-border mb-3" }, [
        h("i", { class: "fa-solid fa-user-group me-1" }),
        entity.value.name,
        h("span", { class: "sub-title ms-1" }, [
          "Details"
        ])
      ]),
      h("div", { class: "mb-2" }, [
        buildDomainEntityNav(`/admin/roles/${entity.value.id}`, items, { prevLink: true })
      ]),
      h("div", [
        h(NuxtPage, {
          onUpdated: handleUpdated,
          onFailed: handleFailed,
          entity: entity.value
        })
      ])
    ]);
  }
});

export { _id_ as default };
//# sourceMappingURL=_id_-3fa523bd.mjs.map
