import type { ComponentType } from 'react'

export interface ArgType {
  description?: string
  control?: string | false
  defaultValue?: unknown
}

export interface StoryMeta {
  title: string
  component: ComponentType<any>
  description?: string
  /** Left-menu group in the Design tab; falls back to the first tag. */
  group?: string
  tags?: string[]
  argTypes?: Record<string, ArgType>
}

export interface Story {
  args?: Record<string, unknown>
  render?: ComponentType<any>
  name?: string
}

/** A query or mutation an app widget consumes. Listed in the Design tab's
 *  right-column inspector under the App lens. */
export interface AppInput {
  name: string
  kind: 'query' | 'mutation'
  type?: string
  description?: string
}

/** Meta for an app-level widget (`*.app.stories.tsx`). Such a widget is composed
 *  from the library and driven by queries/mutations, so it's previewed across
 *  named data-state scenarios rather than simple variants. */
export interface AppStoryMeta extends StoryMeta {
  inputs?: AppInput[]
}

/** One named data-state scenario of an app widget (e.g. Loading / Error / Ready).
 *  `tag` annotates the data state, e.g. "query: pending". */
export interface AppStory extends Story {
  tag?: string
}
