import { defineComponent, ref, resolveComponent, h } from 'vue';
import { I as IdentityProviderProtocol } from './server.mjs';
import { buildFormSelect } from '@vue-layout/hyperscript';
import { u as useAuthStore, b as storeToRefs } from './auth-2d06b6ac.mjs';
import { b as navigateTo } from './nuxt-link-5ac46069.mjs';
import 'ofetch';
import 'destr';
import '@unhead/vue';
import '@unhead/dom';
import '@unhead/ssr';
import './page-011b4897.mjs';
import 'vue-router';
import 'defu';
import 'unctx';
import 'h3';
import 'ufo';
import 'hapic';
import 'rapiq';
import '@vue-layout/basic';
import '@vuelidate/validators';
import 'ilingo';
import 'nanoid';
import 'smob';
import 'browser-storage-adapter';
import 'cookie-es';
import 'ohash';
import 'vue/server-renderer';
import './composables-31566dd1.mjs';
import './_plugin-vue_export-helper-cc2b3d55.mjs';
import './config.mjs';
import 'scule';
import '@ucast/mongo2js';
import 'change-case';
import '@ebec/http';
import '@hapic/oauth2';
import 'hookable';

const add = defineComponent({
  emits: ["failed", "created"],
  setup(props, { emit }) {
    const handleCreated = (e) => {
      navigateTo({ path: `/admin/identity-providers/${e.id}` });
    };
    const handleFailed = (e) => {
      emit("failed", e);
    };
    const protocol = ref(null);
    const select = buildFormSelect({
      labelContent: "Protocol",
      options: [
        { id: IdentityProviderProtocol.OAUTH2, value: "OAuth2" },
        { id: IdentityProviderProtocol.OIDC, value: "OIDC" },
        { id: IdentityProviderProtocol.LDAP, value: "LDAP" }
      ],
      value: protocol,
      onChange(value) {
        protocol.value = value;
      }
    });
    const store = useAuthStore();
    const { realmManagementId } = storeToRefs(store);
    const form = resolveComponent("OAuth2ProviderForm");
    const renderForm = () => {
      switch (protocol.value) {
        case IdentityProviderProtocol.OAUTH2:
          return [
            h("hr"),
            h(form, {
              onCreated: handleCreated,
              onFailed: handleFailed,
              realmId: realmManagementId
            })
          ];
      }
      return [];
    };
    return () => h("div", [
      select,
      renderForm()
    ]);
  }
});

export { add as default };
//# sourceMappingURL=add-b1a466a2.mjs.map
