package com.lyrx.latex.documents

import com.lyrx.latex.{LaTeXArticle, LaTeXReplacements}
import com.lyrx.structures.Whitepaper
import com.lyrx.text._
import com.lyrx.text.bib.{BibItem, Online}

import scala.collection.immutable.HashMap

object WhitepaperLaTeX extends LaTeXReplacements with FileAssertions {

  def main(args: Array[String]): Unit = {
    implicit val ctx = Context()
      .withInputDir("src/main/resources/blockchain/whitepaper")
      .withOutputDir("target/generated/latex")
      .inEnglish
    implicit val coll = new SimpleStringCollector();
    assertFile(Whitepaper.collect[String](WhitepaperLaTeX()).writeOut())
  }

  def apply(): WhitepaperLaTeX =
    new WhitepaperLaTeX(new ParData[String](
      Nil,
      "whitepaper.tex",
      sections = Seq(
        "Abstract",
        "eBooks in the Blockchain",
        "eBooks in the files-sharing network",
        "Resales"
      ),
      replacements = HashMap[String, String]("llb" -> "lyrx Books"),
      decorations =  math("transferCopyFrom(...)")
        ++italic("PKI") ++
          bold("lyrx GmbH",
               "transfer PKI",
               "transfer private key",
               "transfer public key",
               "blockchain public key",
               "blockchain private key",
               "public key infrastructure",
               "RSA",
          "Step 2", "step 3")

      ,
      subSections = Seq(
        "The blockchain",
        "The smart contract",
        "The request",
        "The transfer"
      ),
      bibItems = Seq[BibItem](
        Online(
          id = "bibSmartContracts",
          author = "Alexander Weinmann",
          title =
            "Using smart contracts and file sharing to create an eBook market",
          url = "http://www.blockchain.lyrx.de"
        )
      )
    ))

}

class WhitepaperLaTeX(override val parData: ParData[String])
    extends LaTeXArticle
    with BookData {

  override val texTemplate: String = "../latex1.tex"
  override def withParData(aParData: ParData[String]): WhitepaperLaTeX =
    new WhitepaperLaTeX(aParData)

  override val title: String =
    "Using Smart Contracts And File-sharing To Create An eBook Market"
  override val publisher: String = "lyrx GmbH"
  override val author: String = "Alexander Weinmann"
  override val subtitle: String = ""
  override val motto: String = "Motto"
  override val widmung: String = "Widmung"
}
