// import { Resource } from "@/page/app/components/PublicTypes/resource";
import { StyleState } from "../style/styleState";
import { VALIDATION_TYPES } from "@/utils/validationFactory";

export interface Params {
  key: string
  value: string
  [key: string]: string
}

export type RestApiAuth =
  | NoneAuth
  | RestAPIBasicAuth
  | RestAPIBearerAuth
  | DigestAuth

export interface NoneAuth { }

export interface RestAPIBasicAuth {
  username: string
  password: string
}

export interface RestAPIBearerAuth {
  token: string
}

export interface DigestAuth {
  username: string
  password: string
}

export type RestApiAuthType = "none" | "basic" | "bearer" | "digest"

export type VerifyMode = "verify-full" | "verify-ca" | "skip"

export interface RestApiResource<T extends RestApiAuth> {
  baseUrl: string
  urlParams?: Params[]
  headers?: Params[]
  cookies?: Params[],
  authentication?: RestApiAuthType
  authContent?: T
  body: T

}


export type ResourceType =
  | "restapi" | "impaktapps"


export type ResourceContent =
  | RestApiResource<RestApiAuth>

export interface Resource<T extends ResourceContent = ResourceContent> {
  resourceID: string
  resourceName: string
  resourceType: ResourceType
  createdBy?: string
  updatedBy?: string
  createdAt?: string
  updatedAt?: string
  content?: T
}

/* eslint-disable @typescript-eslint/no-explicit-any */
export type ControllerType =
  | "impakt"

export interface ImpaktProps {
  model: any,
  mode: "edit" | "preview" | "production"
  getResource: () => Promise<RestApiResource<RestApiAuth>>,
  onModelUpdate: (model: any) => void,
  onModelSave: () => Promise<void>
  theme?: 'light' | 'dark' | 'hc' | 'hcLight';
  getPages: () => Promise<Page[]>
  getRules: () => Promise<Rule[]>
  getStyles: () => Promise<StyleState>
  setStyles: (style: any) => void
  onModelUpdatefunction: (model: any) => void
}

export interface Page {
  $refText: string;
  $ref:string
}


export interface Parameters {
  name: string;
  type: VALIDATION_TYPES;
}

export interface Rule {
  name: string;
  parameters: Parameters[]
}

// actions:[{

// actionRef:{
//   $refText: Page.$refText
// }
//   ...
// }]

export interface Description {
  name: string,
  uri: string,
}

export interface ParamDescription extends Description {
  type: string
}

export interface Rule extends Page {

}


export interface ControllerContent extends ImpaktProps {
  rules?: Rule[]
  pages?: Page[]
  // { pageName: string, actionref: Record<string, unknown> }[]
  // router:
}

export type Controller = any;

