import type { IAction } from '@src/model/Projects'
import type { IFriends, IGroupShort, IMyGroup, IPaymentType } from '@src/model/UserStore'
import type {
  IDepartment, IQueryAI, IProducer, IShareWithUs, IStorehouse, IProvider, IScontistica, ICategory, IGasordine, ICatProd, ISubCatProd, ICatAI,
  IProduct
} from '@src/model/Products';
import {
  IProductInfo
} from '@src/model/Products'

import type { IUserFields, IUserProfile } from '@src/model/UserStore'

export interface IPost {
  title: string
}

export interface ICheckUser {
  verified_email?: boolean
  teleg_id?: number
  profile?: IUserProfile
}

export interface INotData {
  num_reg?: number
  num_reg_today?: number
  online_today?: number
  activeusers?: number
  num_passeggeri?: number
  num_imbarcati?: number
  email_non_verif?: number
  num_teleg_attivo?: number
  num_autorizzare?: number
  num_autorizzati?: number
  num_teleg_pending?: number
  num_part_zoom?: number
  num_part_accepted?: number
  num_modalita_pagamento?: number
  arr_nations?: string
  lastsreg?: IUserFields[]
  lastsonline?: IUserFields[]
  lastssharedlink?: IUserFields[]
  diffusorilist?: IUserFields[]
  listlinksreg?: IUserFields[]
  receiveRislist?: IUserFields[]
  receiveRislistgroup?: IMyGroup[]
  strettelist?: IUserFields[]
  checkuser?: any // ICheckUser
  numreg_untilday?: number
  reg_daily?: string
  reg_weekly?: string
  num_transaz_tot?: number
  tot_RIS_transati?: number
  num_circuiti?: number
  num_circuiti_attivi?: number
  num_annunci?: number
  last_transactions?: IMovement[]
}


export interface IConnData {
  downloading_server: number
  downloading_indexeddb: number
  uploading_server: number
  uploading_indexeddb: number
}

export interface ICfgServer {
  chiave: string
  idapp: string
  userId: string
  valore: string
}

export interface ICfgData {
  _id?: string
  lang?: string
  token?: string
  userId?: string
}

export interface ITemplEmail {
  _id?: string
  subject?: string
  content?: string
  options?: ISettings[]
}

export interface IDestNewsletter {
  _id?: string
  descr?: string
  tipodest_id?: number
}

export interface ISettings {
  _id?: string
  idapp?: string
  key?: string
  type?: number
  value_str?: string
  value_date?: Date,
  value_num?: number
  value_bool?: boolean
  serv?: boolean
  crypted?: boolean
}

export interface ITeachUname {
  username?: string
}

export interface IInternalPage {
  path?: string
}

export interface IResp {
  _id?: string
  username?: string
  name?: string
  surname?: string
}

export interface IMyBot {
  _id?: string
  page?: number
  index?: number
  riga?: number
  active?: boolean
  main?: boolean
  label?: string
  type?: number
  value?: string
  visibility?: number
  date_updated?: Date
}

export interface IListaCron {
  active?: boolean
  descr?: string
  nomeFunzioneDbOp?: string
  startTime?: string
  everyXMinutes?: number
  lastJobEnd?: Date
  log?: string
}

export interface IMyElem {
  _id?: string
  type?: number
  path?: string
  idPage?: string
  img?: string
  container?: string
  container2?: string
  container3?: string
  container4?: string
  span?: boolean
  transition?: boolean
  align?: number
  vertalign?: number
  fit?: string
  parambool?: boolean
  parambool2?: boolean
  parambool3?: boolean
  parambool4?: boolean
  number?: number
  num2?: number
  imgback?: string
  ratio?: string
  containerHtml?: string
  size?: string
  order?: number
  width?: number
  height?: number
  heightimg?: string
  heightcarousel?: string
  widthimg?: string
  widthcard?: string
  heightcard?: string
  link?: string
  onlyif_logged?: boolean
  active?: boolean
  class?: string
  image?: string
  vers_img?: number
  class2?: string
  class3?: string
  class4?: string
  anim?: IAnim
  anim2?: IAnim
  styleadd?: string
  list?: IImgGallery[]
  listcards?: IMyCard[]
  catalogo?: IOptCatalogo
  elemsText?: IElemText[]
  titleBanner?: string
  classBanner?: string
}

export interface IElemText {
  _id: string
  text: string
  color?: string
  size?: string
  class?: string
  anim?: IAnim
}
export interface IMyPage {
  _id?: string
  author_username?: string
  lang?: string
  title?: string
  subtitle?: string
  icon?: string
  iconsize?: string
  order?: number
  path?: string
  keywords?: string
  description?: string
  img1?: string
  content?: string
  video1?: string
  ratio1?: string
  img2?: string
  content2?: string
  video2?: string
  ratio2?: string
  img3?: string
  content3?: string
  video3?: string
  ratio3?: string
  content4?: string
  active?: boolean
  inmenu?: boolean
  color?: string
  elemsText?: IElemText[]
  onlyif_logged?: boolean
  only_residenti?: boolean
  only_consiglio?: boolean
  submenu?: boolean
  l_par?: number,
  l_child?: number,
  infooter?: boolean
  internalpage?: boolean
  extraclass?: string
  loadFirst?: boolean
  showFooter?: boolean
  mainMenu?: boolean
  sottoMenu?: string[]

  //Memory
  loaded?: boolean
}

export interface IOption {
  options: number
}

export interface IConfPages {
  font?: string
  col_toolbar: string
  col_bgfooter: string
  show_darkopt: boolean
  showButtHome: boolean
  showProfile: boolean
  showUserMenu: boolean
  showiscrittiMenu: boolean
  showRegButton: boolean
  enableReg: boolean
  showNL: boolean
  sendNewsletter?: boolean
  showMsgs: boolean
  showNotif: boolean
  showCoins: boolean
  showRIS?: boolean
  showMenuCoins?: boolean
  showNameSurname: boolean
  showCompetenze: boolean
  showConnected: boolean
  bookingEvents: boolean
  enableEcommerce: boolean
  enableAI: boolean
  enableGroups: boolean
  enableCircuits: boolean
  enableProj?: boolean
  enableTodos?: boolean
  enableRegByBot: boolean
  enableRegMultiChoice?: boolean
  enableTokenExpired?: boolean
  enableDebugOn: boolean
  enabledRegNeedTelegram?: boolean
  enableGoods?: boolean
  enableServices?: boolean
  enableActivities?: boolean
  enableHosps: boolean
  enableEvents: boolean
  showViewGroups: boolean
  showViewEventi: boolean
  showViewCircuits: boolean
  showViewUsers: boolean
  showViewBooking: boolean
  showViewProfile: boolean
  showViewCart: boolean
  showViewOrders: boolean
  enablePwa: boolean
  lang: number
  videoPromo: string
  PDFPromo: string
}
export interface IContacts {
  facebook: string
  instagram: string
  whatsapp: string
  whatsapp_home: boolean
  telegram: string
  youtube: string
  email: string
  address: string
  map: string
  info2: string
  cell: string
}


export interface IPolicy {
  show: boolean
  owneremail: string
  siteName: string
  ownerDataName: string
  managerData: string
  includeData: string
  url: string
  lastdataupdate: string
  country: string
}

export interface IECommSettings {
  enablePreOrders: boolean
  NoteExtraOnCart: string
}

export interface ISites {
  _id?: string
  attiva?: boolean
  idapp?: string
  name?: string
  adminemail?: string
  manageremail?: string
  replyTo?: string
  host?: string
  host_ip?: string
  host_test?: string
  host_test_ip?: string
  host_api?: string
  host_api_ip?: string
  host_testapi?: string
  host_testapi_ip?: string
  cf_token?: string
  cf_zoneId?: string
  enable_servermail?: boolean
  servermail?: string
  servermailip?: string
  dkim?: string
  portapp?: string
  dir?: string
  email_from?: string
  email_pwd?: string
  telegram_key?: string
  telegram_bot_name?: string
  telegram_key_test?: string
  load_process_telegram_test?: string
  load_process_telegram?: string
  telegram_bot_name_test?: string
  telegram_support_chat?: string
  pathreg_add?: string
  confsite: IOption
  policy?: IPolicy
  description?: string
  keywords?: string
  contacts?: IContacts
  confpages: IConfPages
  ecomm?: IECommSettings
  idMyGroup?: string
}

export interface INewsToSent {
  _id: string
  idapp?: string
  label?: string
  activate?: boolean
  templemail_str?: string
  destnewsletter_str?: string
  numemail_tot?: number
  numemail_sent?: number
  datetoSent?: Date
  datestartJob?: Date
  datefinishJob?: Date
  lastemailsent_Job?: Date
  starting_job?: boolean
  finish_job?: boolean
  error_job?: string
}

export interface ICalZoom {
  lang?: string
  title?: string
  typeconf?: string
  date_start?: string
  date_end?: Date
  id_conf_zoom?: number
  note?: string
}

export interface IGroup {
  _id?: any
  descr?: string
}

export interface IMailinglist {
  name?: string
  surname?: string
  email: string
  lastid_newstosent?: string
}

export interface IDiscipline {
  typol_code?: string
  order?: number
  label?: string
  description?: string
  linkpage?: string
  color?: string
  icon?: string
  img_small?: string
  showinhome?: boolean
  showinnewsletter?: boolean
  img?: string
  teachers?: ITeachUname[]
}

export interface ITestp1 {
  contatore: number
  mioarray: ICfgServer[]
}

export type StateConnection = 'online' | 'offline'

export interface IFilterCatalogo {
  author: string
  sort_field: string
  sort_dir: number
  publisher: string
  type: string
  ageGroup: string
}

export interface IConfig {
  _id: string,
  key?: string,
  value: string
}

export interface IMetaTags {
  title?: string
  keywords?: string
  description?: string
}

export interface ICircuitState {
  listcircuits: ICircuit[]
  listaccounts: IAccount[]
}

export interface ISelector {
  data: object
  table: string
}
export interface IGlobalState {
  finishLoading: boolean
  conta: number
  wasAlreadySubOnDb: boolean
  wasAlreadySubscribed: boolean
  isLoginPage: boolean
  layoutNeeded: boolean
  mobileMode: boolean
  menuCollapse: boolean
  leftDrawerOpen: boolean
  rightDrawerOpen: boolean
  rightNotifOpen: boolean
  rightCoinsOpen: boolean
  rightCartOpen: boolean
  category: string
  stateConnection: string
  serverError: boolean
  serverMsgError: any
  networkDataReceived: boolean
  clickcmd?: string
  cfgServer: ICfgServer[]
  testp1: ITestp1
  connData: IConnData
  posts: IPost[]
  menulinks: object,
  listatodo: IMenuList[]
  arrConfig: IConfig[]
  lastaction: IAction
  serv_settings: ISettings[],
  settings: ISettings[],
  disciplines: IDiscipline[],
  paymenttypes: IPaymentType[],
  newstosent: INewsToSent[],
  gallery: IGallery[],
  mypage: IMyPage[],
  myelems: IMyElem[],
  lista_cron: IListaCron[],
  myschedas: ISchedaSingola[],
  templemail: ITemplEmail[],
  destnewsletter?: IDestNewsletter[],
  opzemail: ISettings[],
  mailinglist: IMailinglist[],
  calzoom: ICalZoom[],
  producers: IProducer[],
  providers: IProvider[],
  catprods: ICatProd[],
  subcatprods: ISubCatProd[],
  gasordines: IGasordine[],
  scontisticas: IScontistica[],
  storehouses: IStorehouse[],
  departments: IDepartment[],
  categories: ICategory[],
  sharewithus: IShareWithUs[],
  groups: IGroup[],
  resps: IResp[],
  workers: IResp[],
  autoplaydisc: number
  TIMER: any
  TIMEOUT: any
  CUT: any
  TIMER_STATE: number
  URL_RITORNA: string
  URL_RESTORE: string
  serverHost?: string
  levels: ILevel[],
  adtypes: IAdType[],
  adtypegoods: IAdType[],
  skills: ISkill[],
  goods: IGood[],
  // subSkills: ISubSkill[],
  statusSkills: IStatusSkill[],
  sectors: ISector[],
  sectorgoods: ISectorGood[],
  catgrps: ICatGrp[],
  catAI: ICatAI[],
  queryAIList: IQueryAI[],
  provinces: IProvince[],
  datastat?: INotData
  site: ISites,
  mygroups: IMyGroup[],
  selElem?: IMyElem,
  editOn?: boolean,
  myselector: ISelector,
  addNewRecord: string,
  isAppRunning: boolean,
  deferredPrompt: any,
  homescreen: any,
}

export interface IMenuList {
  nametranslate: string
  description?: string
  idelem?: string
  icon?: string
  name?: string
  level_parent?: number
  level_child?: number
  urlroute?: string
  routes2?: IMenuList[]
}

export interface IPathFile {
  path: string
  file: string
}

export interface IListRoutes {
  active?: boolean
  order: number
  path: string
  name: string
  subtitle?: string
  lang?: string
  materialIcon?: string
  iconsize?: string
  component?: any
  children?: any
  reqauth?: boolean
  isseparator?: boolean
  inmenu?: boolean
  solotitle?: boolean
  infooter?: boolean
  submenu?: boolean
  noroute?: boolean
  onlyAdmin?: boolean
  onlyif_logged?: boolean
  onlyManager?: boolean
  onlySocioResidente?: boolean
  onlyConsiglio?: boolean
  onlyNotSoci?: boolean
  onlyDepartment?: boolean
  onlyFacilitatore?: boolean
  color?: string
  onlyEditor?: boolean
  onlyCommerciale?: boolean
  onlyGrafico?: boolean
  extraclass?: string
  meta?: any
  idelem?: string
  urlroute?: string
  img?: string
  mainMenu?: boolean
  sottoMenu?: string[]
  // ------------------------
  faIcon?: string
  text?: string
  routes2?: IListRoutes[]
  level_parent?: number
  level_child?: number
  separator?: boolean
}

export interface IOperators {
  username: string
  name: string
  surname: string
  email?: string
  qualification?: string
  disciplines?: string
  certifications?: string
  img?: string
  cell?: string
  usertelegram?: string
  paginaweb?: string
  paginafb?: string
  intro?: string
  info?: string
  vario?: string
  tab?: string
}

export interface IPreloadImages {
  imgname: string
  alt: string
  mobile: boolean
}

export interface ILang {
  label: string
  icon: string
  value: string
  image: string
  short: string
}

export interface IAllLang {
  es?: string
  enUs?: string
  fr?: string
  de?: string
  it?: string
}

export interface ITimeLineEntry {
  date: string
  title: string
  description: IAllLang
  description2?: IAllLang
  description3?: IAllLang
  icon: string
  image: string
  image2?: string
  image3?: string
  image4?: string
  video?: string
  side: string
  link_url?: string
  link_url_lang?: IAllLang
  link_text?: IAllLang
  ingallery?: boolean
}

export interface ITimeLineMain {
  titlemain: any
  body: ITimeLineEntry[]
}

export interface IImgGallery {
  _id?: string
  imagefile: string
  vers_img?: number
  // order?: number
  alt?: string
  description?: string
}

export interface IMyCard {
  _id?: string
  imagefile?: string
  vers_img?: number
  alt?: string
  description?: string
  style?: string
  size?: string
  color?: string
  content?: string
  colorsub?: string
  link?: string
}

export interface ISize {
  width?: string
  height?: string
  gap?: string
  fit?: string
}
export interface IFont {
  name?: string
  size?: string
  line_height?: number
  posiz_text?: number
  perc_text?: string
  height?: string
}

export interface IBorder {
  top?: string
  bottom?: string
  left?: string
  right?: string
}

export interface IImg {
  imagefile?: string
  fit?: string
}

export interface INovita {
  show?: boolean
  months?: number
}

export interface IBestseller {
  show?: boolean
  quantiFattRaggiunti?: number
}

export interface IEtichette {
  novita?: INovita
  bestseller?: IBestseller
}

export interface IBarCode {
  show?: boolean
  format?: string
  size?: ISize
  font?: IFont
  widthlines?: number
  show_at_right?: boolean
}

export interface IPagina {
  dimensioni?: IDimensioni
  testo_title?: IText
  testo_up?: IText
  testo_down?: IText
}

export interface IDimensioni {
  size?: ISize
  margini?: IBorder
  padding?: IBorder
  imgsfondo?: IImg
  text_html?: IText
}

export interface IAreaDiStampa {
  margini?: IBorder
  unit?: string
  format?: number[]
  orientation?: string
  compress?: boolean
  scale?: number
  scale_printable?: number
  scalecanvas?: number
}

export interface IElementiPagina {
  pagina: IDimensioni
}

export interface IText {
  contenuto?: string
  maxlength?: number
  font?: IFont
  size?: ISize
}

export interface IElementiScheda {
  pagina: IPagina
  riga: IDimensioni
  scheda_prodotto: IDimensioni
  immagine_prodotto: IDimensioni
}

export interface IMyScheda {
  _id?: string,
  idapp?: string,
  isTemplate?: boolean,
  isPagIntro?: boolean,
  linkIdTemplate?: string,
  name?: string,
  numschede_perRiga?: number
  numschede_perCol?: number
  show_separatore: boolean
  testo_right_attaccato?: IText
  testo_right?: IText
  testo_bottom?: IText
  barcode?: IBarCode,
  etichette?: IEtichette,
  dimensioni: IElementiScheda

  productTypes?: number[]
  excludeproductTypes?: number[]
  idTipologie?: number[]
  idTipoFormato?: number[]
  editore?: string[]
  argomenti?: string[]
  idCollane?: string[]
  author?: string
  sort_field?: string
  sort_dir?: number
  arrProdottiSpeciali?: string[]

}

export interface IRecFields {
  editOn?: boolean
  label?: string
  title?: string
  table?: string
  id?: string
  rec?: any
  mykey?: string
  mysubkey?: string
  jointable?: string
  debounce?: string
  type?: number
  dense?: boolean
  maxlength?: number
  showall?: boolean
}

export interface ISchedaSingola {
  _id?: string
  scheda?: IMyScheda,
  order?: number,
  numPagineMax?: number,

  // In Memoria
  idPageOrig?: string
  arrProdToShow?: IProduct[][][]
}

export interface IOptRigenera {
  visibilitaDisp?: string
  rig_mod?: string
  stato?: string
}

export interface IOptCatalogo {
  //++AddCATALOGO_FIELDS
  productTypes?: number[]
  excludeproductTypes?: number[]
  formato?: string[]
  idTipologie?: number[]
  idTipoFormato?: number[]
  Categoria?: string[]
  editore?: string[]
  argomenti?: string[]
  idCollane?: string[]
  sort_field?: string
  sort_dir?: number
  pdf?: boolean
  pdf_filename?: string
  printable?: boolean
  indebug?: boolean
  maxnumlibri?: number
  showListaArgomenti?: boolean
  showListaCollane?: boolean
  generazionePDFInCorso?: boolean

  first_page?: IDimensioni
  last_page?: IDimensioni
  areadistampa?: IAreaDiStampa

  dimensioni_def?: IElementiPagina

  arrSchede?: ISchedaSingola[]
  aggiorna?: number
}


export interface IGallery {
  _id?: string
  author_username?: string
  title?: string
  directory?: string
  list?: IImgGallery[]
}

export interface IColl {
  title: any  // IAllLang
  date?: string
  subtitle?: any  //IAllLang
  img: string
  img2?: string
  linkagg?: string
  linkagg_type?: number
  width?: number
  height?: number
  ingallery?: boolean
  inexibitions?: boolean
}

export interface ICollaborations {
  withwhom_title: any
  list: IColl[]
}

export interface IParamDialog {
  param1?: any
  param2?: any
  param3?: any
}


export interface IParLookup {
  lk_tab?: string,
  af_objId_tab?: string,
  lk_LF?: string,
  lk_FF?: string,
  lk_as?: string,
  lk_proj?: string,
}

export interface IParamsPickup {
  table: string
  search: string
  filter: string
}
export interface IParamsQuery {
  newvers: boolean
  table: string
  startRow: number
  endRow: number
  filter: string
  filterand: string
  sortBy: string
  descending: number
  userId: string
  codeId?: string
  filtersearch: string
  filtersearch2: string
  filtercustom: string
  filterextra?: string
  filterextra2?: string
  filter_gte: string
  lookup1?: IParLookup
  lookup2?: IParLookup
  lookup3?: IParLookup
  lookup4?: IParLookup
  options?: number
  extrapar?: string
  noaut?: boolean
}

export interface ISocial {
  description: string
  network: string
  title: string
  url: string
  quote: string
}

export interface ISpecialField {
  findsubkey?: any
  paramtosetsubkey?: any
  paramdef?: any
  defaultnewrec?: object
}

export interface IColGridTable {
  name: string
  subfield?: string
  required?: boolean
  label?: string
  label_trans?: string
  visibleif?: number
  visib_field?: string
  visib_value?: any
  align?: string
  field?: string
  sortable?: boolean
  visulabel?: boolean
  disable?: boolean
  titlepopupedit?: string
  visible?: boolean
  icon?: string
  action?: any
  askaction?: string
  foredit?: boolean
  isInModif?: boolean
  fieldtype?: number
  typeobj?: string
  inline?: boolean
  fieldtype_real?: number
  field_outtype?: number
  noshowlabel?: boolean
  numpag_carousel?: number
  tipovisu?: number
  link?: string
  jointable?: string
  addall?: boolean
  addnone?: boolean
  filter?: any
  resultjoin?: string[]
  tablesel?: string
  notsave?: boolean
  isadvanced_field?: boolean
  showWhen?: number
  maxlength?: number
  minlength?: number
  allowchar?: number
  filter_table?: string
  filter_field?: string
  remote_table?: string
  remote_key?: string
  remote_field?: string
  showonlyif_dipersona?: boolean
  field_extra1?: string
  field_toduplicate_nospace?: string
  showLinkResult?: string
  subfield_extra1?: string
  allowNewValue?: boolean
  showpicprofile_ifnotset?: boolean
  extrafield?: string
  tipoconto?: number
  path?: string
  onlyforAdmin?: boolean
}

export interface ITableRec {
  label: string
  value: string
  columns: IColGridTable[]
  colkey: string
  collabel: string
  colicon?: string
  onlyAdmin?: boolean
  noshow: boolean
  remote?: boolean
}

export interface ISearchList {
  label: string
  table: string
  key: string
  arrvalue: any[]
  value: any
  type: number
  filter: any
  param1?: any
  useinput: boolean
  notinsearch?: boolean
  addall?: boolean
  addnone?: boolean
  keycookie?: string
  showcount?: boolean
  tablesel?: string
  collabel?: string | object
  icon?: string
  filteradv?: boolean
  filter_extra?: object
  visible: boolean
  dense?: boolean
}

export interface IOptGrid {
  rowclass?: boolean
  widthcard?: string
  heightcard?: string
  widthimg?: string
  heightimg?: string
}

export interface IFilter {
  label: string
  value: string
  hide?: boolean
  default?: boolean
}

export interface IDataPass {
  id: string
  table: string
  fieldsvalue: any
}

export interface IMsgGlobParam {
  typemsg: number,
  title?: string,
  content?: string,
  openUrl?: string,
  openUrl2?: string,
  tag?: string,
  actions?: any[],
  cmd?: number
  usernameOrig?: string
  usernameDest?: string
  groupnameDest?: string
  text?: string
  typesend: number
  sendreally?: boolean
  textaddTelegram?: string
  textcontent_Telegram?: string
  linkaddTelegram?: string
  tablerec?: string
  idrec?: string
  idapp?: string
}

export interface IDataToSet {
  id?: string | null
  username?: string
  table?: string
  fieldsvalue?: any
  unset?: any,
  notifBot?: any
  tipomsg?: number
  invitante_username?: string
  ind_order?: any
  num_tess?: number
  data?: any
  myfunc?: any
  inviaemail?: any
  aggiornainmem?: boolean
}

export interface INewsState {
  lastnewstosent: INewsToSent | null
  nextnewstosent: INewsToSent | null
  totemail: number
  totsubscribed: number
  totunsubscribed: number
  totsentlastid: number
}

export const DefaultNewsState: INewsState = {
  lastnewstosent: null,
  nextnewstosent: null,
  totemail: 0,
  totsubscribed: 0,
  totunsubscribed: 0,
  totsentlastid: 0,
}

export interface IPagination {
  sortBy: string,
  descending: boolean
  rowsNumber: number
  page: number,
  rowsPerPage: number // specifying this determines pagination is server-side
}

export interface ISkill {
  _id: number
  descr: string
  idSector: number[]
  icon?: string
  img?: string
}
export interface IGood {
  _id: number
  descr: string
  idSectorGood: number[]
  icon?: string
  img?: string
}

/*
export interface ISubSkill {
  _id: number
  descr: string
  idSkill: number
  icon?: string
  img?: string
}

 */


export interface IStatusSkill {
  _id: number
  descr: string
  color: string
  icon: string
  theme: string
}


export interface ISector {
  _id: number
  descr: string
  idSector?: number
  icon?: string
  img?: string
  color: string
  theme: string
}

export interface ISectorGood {
  _id: number
  descr: string
  idSectorGood?: number
  icon?: string
  img?: string
  color: string
  theme: string
}

export interface ICatGrp {
  _id: number
  descr: string
  idCatGrp?: number
  icon?: string
  img?: string
  color: string
  theme: string
}

export interface ILevel {
  _id: number
  descr: string
  color: string
  theme: string
  years_of_exp: number
}

export interface IAdType {
  _id: number
  descr: string
}

export interface ICity {
  _id: number
  istat: string
  comune: string
  prov: string
}

export interface IProvince {
  _id: number
  prov: string
  reg: string
  descr: string
  card: string
  link_grp: string
  link_telegram: string
}

export interface IMySkill extends IMyMain {
  _id: string
  idSector: number
  idSkill: number
  // idSubSkill: number[]
  idStatusSkill: number[]
  idContribType: string[]
  idCity: number[]
  photos: IGallery[]
  NumLevel: number
  adType: number
  note: string
  groupname: string,
  // **ADDFIELD_MYSKILL
  website: string
  descr: string
  date_created?: Date,
  date_updated?: Date,

  username?: string
}

export interface IMyMain {
  pub_to_share?: number
}

export interface IMyGoods extends IMyMain {
  _id: string
  idSector: number
  idSkill: number
  idShipping: number[]
  idStatusSkill: number[]
  idContribType: string[]
  otherfilters: number[]
  idCity: number[]
  photos: IGallery[]
  NumLevel: number
  adType: number
  note: string
  groupname: string,
  // **ADDFIELD_MYSKILL
  website: string
  descr: string
  date_created?: Date,
  date_updated?: Date,
}

export interface IMyBacheca extends IMyMain {
  _id: string
  idSector: number
  idSkill: number
  // idSubSkill: number[]
  idStatusSkill: number[]
  idContribType: string[]
  dateTimeStart: Date
  dateTimeEnd: Date
  idCity: number[]
  photos: IGallery[]
  NumLevel: number
  adType: number
  note: string
  organisedBy: string,
  address: string,
  min_partecip: number,
  max_partecip: number,
  contribstr: string,
  groupname: string,
  mygrp?: IMyGroup

  // **ADDFIELD_MYBACHECAS
  website: string
  descr: string
  date_created?: Date,
  date_updated?: Date,
}

export interface IAccomodation {
  type: number  // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo)
  location: number  // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
  num: number
}

export interface IMyHosp extends IMyMain {
  _id: string
  visibile: boolean
  typeHosp: number
  numMaxPeopleHosp: number
  accomodation: IAccomodation[]
  photos: IGallery[]
  preferences: number[]
  idContribType: string[]
  idCity: number[]
  descr: string
  note: string
  website: string
  date_created?: Date,
  date_updated?: Date,
  groupname: string,
  //**ADDFIELD_MYHOSPS
}


export interface IMyCircuit {
  _id: string
  circuitname: string
  date: Date
}

export interface ISendCoin {
  circuitname: string
  qty: number
  dest: string
  groupdest: string
  grouporig: string
  contoComOrig?: string
  contoComDest?: string
  causal: string
  causalDest: string
  symbol: string
}

export interface ICircuit {
  _id: string
  groupnameId: string
  name: string
  path: string
  subname: string
  idCity: string[]
  strProv: string
  card: string
  link_group: string
  longdescr: string
  systemUserDescr: string
  systemUserId: string
  totCircolante: number
  totTransato: number
  // nome_valuta: string
  symbol: string
  color: string
  abbrev: string
  compara_valuta?: number
  compara_euro?: number
  valuta_per_euro?: number
  fido_scoperto_default?: number
  qta_max_default?: number
  fido_scoperto_default_grp?: number
  qta_max_default_grp?: number
  fido_scoperto_default_contocom?: number
  qta_max_default_contocom?: number
  data_costituz?: Date
  deperimento: boolean
  showAlways: boolean
  ignoreLimits: boolean
  askManagerToEnter?: boolean
  sendEmailAfterAskingToEnter?: boolean
  circuitoIndipendente?: boolean
  creditodiPartenza?: number
  transactionsEnabled: boolean
  status: number
  freq_deper?: string
  minuto_deper?: string
  ora_deper?: string
  giorno_deper?: string
  mese_deper?: string
  ultimo_deper?: Date
  durata_deper?: number
  photos?: IImgGallery[]
  date_created?: Date
  date_updated?: Date
  admins?: IFriends[]
  createdBy?: string
  regulation?: string
  note?: string
  numMembers?: number
  req_users?: IFriends[]
  refused_users?: IFriends[]
  req_groups?: IGroupShort[]
  refused_groups?: IGroupShort[]
  // --- Mem:
  movements: IMovement[]

  account?: IAccount | null
}

export interface IMovUserProfile {
  img: string
}

export interface IMovUserQuery {
  verified_by_aportador: boolean
  username: string
  profile: IMovUserProfile
}


export interface IMovGroupQuery {
  verified_by_aportador: boolean
  groupname: string
  title: string
  photos: string
}


export interface IMovContoComQuery {
  path: string
  name: string
}

export interface IMovCircuitQuery {
  name: string
  symbol: string
}

export interface IMovQuery {
  tipocontofrom: number
  tipocontoto: number
  userfrom: IMovUserQuery
  userto: IMovUserQuery

  groupfrom: IMovGroupQuery
  groupto: IMovGroupQuery

  contocomfrom: IMovContoComQuery
  contocomto: IMovContoComQuery

  circuitfrom: IMovCircuitQuery

  transactionDate: Date
  amount: number
  causal: string
  notifId: string
}


export interface IMovement {
  _id: string
  transactionDate: Date
  accountFromId: string
  accountToId: string
  amount: number
  causal: string
  residual: number
  expiringDate: Date
}

export interface IMovVisu {
  transactionDate: Date
  groupfrom: IMyGroup
  groupto: IMyGroup
  userfrom: IUserFields
  userto: IUserFields
  circuitfrom: ICircuit
  circuitto: ICircuit
  amount: number
  causal: string
  residual: number
  expiringDate: Date
}

export interface ITransaction {
  _id: string
  transacDate: Date
  mitt_username: string
  mitt_group: string
  dest_username: string
  dest_group: string
  circuito: string
  amount: number
  causale: string
}

export interface IAccount {
  _id: string
  username: string
  contocom: string
  groupname: string
  circuitId: string
  circuit: ICircuit[]
  name: string
  deperibile: boolean
  fidoConcesso: number
  qta_maxConcessa: number
  importo_iniziale?: number
  saldo: number
  saldo_pend: number
  totTransato: number
  totTransato_pend: number
  regulation_ok: boolean
  date_created?: Date
  date_updated?: Date
  numtransactions: number
  // Memory
  notifspending: any[]
}
export interface IAnim {
  name: string,
  clduration: string,
  cldelay: string,
  timingtype: string,
}

export interface ICoordLatLng {
  lat: any
  lng: any
}



export interface ICoordinates {
  lat: any
  long: any
}

export interface ICoordinatesGPS {
  coordinates: [number, number]; // [lng, lat]
}

export interface ITipoDiAttivita {
  _id: string
  label: string
  note: string
}

export interface ICoordGPS {
  address: string
  type: string
  coordinates: [number, number]
}

export interface IAttivita {
  _id: string

  // INFORMAZIONI:
  tipodiAttivita: ITipoDiAttivita
  descr: string
  note: string
  idSector: number[]

  idCity: number[]
  coordinate_gps: ICoordGPS

  // FOTO
  logo: IGallery
  photos: IGallery[]

  // Contatto (Opzionale)
  email: string
  telegram_username: string
  cell_phone: string
  whatsapp: string
  website: string

  //++Todo: Aggiungere ORARI

  // Altri CAMPI:

  date_updated?: Date

  createdBy?: string  // Username del creatore (proponente)
}

export interface IOptQueryGM {
  idapp?: string
  nameTable: string
  campispeciali?: boolean
  query?: string
  numrec?: number
  where?: string
  fieldGM?: string
  outhtml?: boolean
  showQtaDisponibile?: boolean
  cmd?: number
  insertMode?: boolean
  data?: any
  updatelocaldb?: boolean
}

