import { HTMLTag, HTMLText, ElementStructure } from "./htmlStructure"
import * as pathModule from "path"
import * as Helper from "./helper"
import * as Leaf from "../../build/leaf.export"
export function getElementTypeStringByTagName(name: string): string {
    let map = {
        "a": "HTMLAnchorElement",
        "audio": "HTMLAudioElement",
        "body": "HTMLBodyElement",
        "button": "HTMLButtonElement",
        "canvas": "HTMLCanvasElement",
        "content": "HTMLContentElement",
        "div": "HTMLDivElement",
        "embeded": "HTMLEmbedElement",
        "form": "HTMLFormElement",
        "head": "HTMLHeadElement",
        "h1": "HTMLHeadingElement",
        "html": "HTMLHtmlElement",
        "iframe": "HTMLIFrameElement",
        "img": "HTMLImageElement",
        "input": "HTMLInputElement",
        "li": "HTMLLIElement",
        "label": "HTMLLabelElement",
        "link": "HTMLLinkElement",
        "ol": "HTMLOListElement",
        "object": "HTMLObjectElement",
        "p": "HTMLParagraphElement",
        "picture": "HTMLPictureElement",
        "pre": "HTMLPreElement",
        "progress": "HTMLProgressElement",
        "quote": "HTMLQuoteElement",
        "script": "HTMLScriptElement",
        "select": "HTMLSelectElement",
        "span": "HTMLSpanElement",
        "style": "HTMLStyleElement",
        "template": "HTMLTemplateElement",
        "textarea": "HTMLTextAreaElement",
        "title": "HTMLTitleElement",
        "ul": "HTMLUListElement",
        "video": "HTMLVideoElement"
    }
    return map[name.toLowerCase()] || "HTMLDivElement"
}
export function pathToName(path: string) {
    let ext = pathModule.extname(path)
    let base = pathModule.basename(path, ext)
    return base
}
export function pathToResourceResolution(path) {
    let ext = pathModule.extname(path)
    let dir = pathModule.dirname(path)
    let base = pathModule.basename(path, ext)
    let full = pathModule.join(dir, base)
    full = pathModule.normalize(full)
    return full.split("/").filter(item => !!item).map(item => item[0].toUpperCase() + item.slice(1)).join(".")
}
export function pathToId(path: string) {
    let name = pathModule.basename(path)
    return Leaf.Util.camelToSlug(name) + "-" + Helper.hash(path).slice(0, 6)
}
