import { defineAsyncComponent, type Component } from 'vue'
import type { UiAdapter, UiAdapterCapability } from '../contracts'
const lazy = (loader: () => Promise<{ default: Component }>) => defineAsyncComponent({ loader, suspensible: false })
const Button = lazy(() => import('./PrimeButtonAdapter.vue'))
const TextField = lazy(() => import('./PrimeTextFieldAdapter.vue'))
const TextArea = lazy(() => import('./PrimeTextAreaAdapter.vue'))
const Select = lazy(() => import('./PrimeSelectAdapter.vue'))
const MultiSelect = lazy(() => import('./PrimeMultiSelectAdapter.vue'))
const Checkbox = lazy(() => import('./PrimeCheckboxAdapter.vue'))
const DateField = lazy(() => import('./PrimeDateFieldAdapter.vue'))
const NumberField = lazy(() => import('./PrimeNumberFieldAdapter.vue'))
const Dialog = lazy(() => import('./PrimeDialogAdapter.vue'))
const StatusTag = lazy(() => import('./PrimeStatusTagAdapter.vue'))
const InlineMessage = lazy(() => import('./PrimeInlineMessageAdapter.vue'))
const Paginator = lazy(() => import('./PrimePaginatorAdapter.vue'))
const Tabs = lazy(() => import('./PrimeTabsAdapter.vue'))
const DataGrid = lazy(() => import('./AgGridAdapter.vue'))

const capabilities: ReadonlySet<UiAdapterCapability> = new Set([
  'button','text-field','text-area','select','multi-select','checkbox','date-field','number-field',
  'dialog','status-tag','inline-message','paginator','tabs','data-grid'
])

export const primeVueUiAdapter: UiAdapter = Object.freeze({
  descriptor: Object.freeze({ id: 'primevue-aggrid', version: '4.x+34.x', contractVersion: '4.0', vendor: 'PrimeVue + AG Grid Community', capabilities, productionEligible: true, accessibilityBaseline: 'WCAG_2_2_AA_TARGET' }),
  components: Object.freeze({ Button, TextField, TextArea, Select, MultiSelect, Checkbox, DateField, NumberField, Dialog, StatusTag, InlineMessage, Paginator, Tabs, DataGrid })
})
