<script setup lang="ts">
import xpathDiffs from '@/assets/tooltips/xpath/xpathdiffs.json';
import xsltDiffs from '@/assets/tooltips/xslt/xsltdiffs.json';
import TooltipCategoryComponent from './TooltipCategoryComponent.vue';


const props = defineProps({
    toolName: {type: String, required: true},
    toolVersion: {type: String, required: true}
})

function getDiffEntry(toolVersion : String) : string[] {
    if ( props.toolName == "xpath" ){
        switch(toolVersion){
            case "2.0" : {
                return xpathDiffs.VersionDiffs[0].diffs
            }
            case "3.0" : {
                return xpathDiffs.VersionDiffs[1].diffs
            }
            case "3.1" : {
                return xpathDiffs.VersionDiffs[2].diffs
            }
            default: {
                return xpathDiffs.VersionDiffs[2].diffs
            }
        }
    } else if (props.toolName == "xslt") {
        return ["XSLT 2.0"].concat(xsltDiffs.VersionDiffs[0].diffs).concat(["XSLT 3.0"]).concat(xsltDiffs.VersionDiffs[1].diffs) ;
    } else{
        return ["foo"]
    }
    
}

function getInfo(num : number ){
    if(props.toolName == "xslt"){
        return xsltDiffs.universalInfo[num]
    } else{
        return xpathDiffs.universalInfo[num]
    }
}






</script>

<template>

<TooltipCategoryComponent :name="getInfo(0).category">
    <span class="text-center">
        {{ getInfo(0).description }}
    </span>
</TooltipCategoryComponent>    

<TooltipCategoryComponent v-if="toolVersion !== '1.0'"  :name="getInfo(1).category + ' ' + toolVersion + '?'">
        <span v-for=" diff in getDiffEntry(toolVersion)" v-bind:key="diff" class=" text-justify" >
            <div class="w-full h-4 text-center" v-if="diff.includes('XSLT')">
                ------------ {{ diff }} ------------
            </div>
            <span v-else>
                * {{ diff }}
            </span>
            
        </span>
</TooltipCategoryComponent>

</template>