/* -------------------------------------------------------------------------- */
/*                                  Libraries                                 */
/* -------------------------------------------------------------------------- */
import React from "react";
import { PathMatch, RouteObject } from "react-router-dom";
/* -------------------------------------------------------------------------- */
/*                             Custom routes types                            */
/* -------------------------------------------------------------------------- */

export type ActiveRoutePathTitleCallbackParams<ParamKey extends string = string> = {
  definition: RoutePathDefinition;
  match: PathMatch<ParamKey>;
  locationPathname: string;
  translation: (key: string) => string,
};

export type ActiveRoutePathTitleCallback = (params: ActiveRoutePathTitleCallbackParams) => string;

export interface WithRouteProps {
  name: string;
  pageName?: string;
  path: string;
  activePath: ActiveRoutePath[];
}


export interface RoutePathDefinition<
  K = Pick<WithRouteProps, "name" | "path" | "pageName">,
  T extends K = {} & K
> extends RouteObject {
  name: string;
  title?: string | ActiveRoutePathTitleCallback;
  nav?: boolean;
  children?: RoutePathDefinition[];
  path: string;
  icon?: React.FC<React.SVGProps<SVGSVGElement>>,
  Component?: React.FC<T> | React.ClassicComponentClass<T>;
}

export type ActiveRoutePath = {
  title?: string;
  match: PathMatch<string>
  definition: RoutePathDefinition;
  siblings: ActiveRoutePath[];
};