import './module'

declare global {
  // SpreadSheet
  interface JsminExtension {
    spreadSheet: {
      readFromFile( file: fn.Input.Filer.CustomFile ): Promise<JsminExtension.SpreadSheet.Method>
      readFromJson( v: JsminExtension.SpreadSheet.Json ): Promise<JsminExtension.SpreadSheet.Method>
    }
  }
  namespace JsminExtension {
    namespace SpreadSheet {
      interface Instance {
        fn: Method
        prototype: Method

        ( v: any,a: string ): any
      }
      interface Method {
        isValid(): boolean
        getWorkbook(): any
        updateFileName( fileName: string ): void
        updateMerges( merges: Merge[][] ): void
        updateStyles( styles: Style[][] ): void
        toJson(): {
          fileName: string
          sheets: {
            sheetName: string
            rows: any[]
          }[]
        }
        export( type?: 'xlsx' | 'csv' ): void
      }

      type Json = {
        fileName: string
        sheets: SheetParams[]
      }
      type SheetParams = {
        sheetName: string
        rows: RowParams[]
        merges?: Merge[]
        styles?: Style[]
      }
      type RowParams = ( string | number )[]
      type Merge = [ string,string ] | [ null,null ]
      type Style = {
        type: 'cell' | 'row' | 'column'
        target: string | number | ( string | number )[]
        values: {
          [ key: string ]: any
        }
      }
    }
  }

  // Others
  interface JsminExtension {
    formCollect( form: string ): Promise<{
      valid: boolean
      data: plainObject
    }>
    NoticeHttpStatus( params: {
      status: number
      statusText: string
      label: ReactElement
    } & fn.SnackBar.AddParams ): void

    copyToClipboard( data: any,notice?: boolean ): Promise<{
      ok: boolean
      body: any
    }>
    getCurrentLocation: {
      (): Promise<JsminExtension.getCurrentLocationOutput>
    }
    CDNReader: {
      ( url: string ): void
    }
    ImageLoader: {
      ( dataUrl: string,img?: HTMLImageElement ): Promise<HTMLImageElement>
    }
    isJSXElement( v: any ): v is JSX.Element
  }
  namespace JsminExtension {
    type getCurrentLocationOutput = {
      ok: false
      status: number
      body: {
        reason: any
      }
    } | {
      ok: true
      status: 200
      body: {
        lat: number
        lng: number
      }
    }

  }
  type base64ToBlobTypeProps = 'image/png' | 'image/jpeg' | string

  interface String {
    zen2hanNumber(): string
  }
}

export type Device = 'windows' | 'android' | 'iPhone' | 'iPad' | 'macOSX' | 'undefined'
export type Browser = 'chrome' | 'firefox' | 'safari' | 'opera' | 'ie' | 'edge' | 'undefined'
export type ReactElement = React.ReactNode | React.ReactNode[]

import { TagProps } from './property'
export type { TagProps }
// export { TagProps }
import {
  config,
  global,
  atoms,
  mols,
  orgs,
  temps,
  fn
} from './amotify'
export type {
// export {
  config,
  global,
  atoms,
  mols,
  orgs,
  temps,
  fn
}

export interface amotify {
  config: config.Methods
  global: global.Methods
  atoms: atoms.Methods
  mols: mols.Methods
  orgs: orgs.Methods
  temps: temps.Methods
  fn: fn.Methods
}