<template>
	<!-- 高级工具选择 -->
	<div class="cards-select">
		<div v-for="v in list" :key="v.type" @click="onClickItem(v)" v-show="v.tier === tier">
			<span class="icon">
				<svg-icon :name="v.type + '-2'" size="15" size-unit="px" />
			</span>
			<span class="title">{{ v.title }}</span>
		</div>
	</div>
</template>

<script setup lang="ts">
	import { ref, inject, computed } from 'vue'
	import { NODE_DATATYPE, NODE_DATATIER } from '../../../tools/index.d'
	const nodeManager = inject('nodeManager') as any
	const stateManager = inject('stateManager') as any
	const props = defineProps({
		node: { required: true, type: Object },
		tier: { default: 1, type: Number }
	})
	const list = ref([
		{
			tier: NODE_DATATIER.TO_REAL_STYLE,
			type: NODE_DATATYPE.TO_REAL_STYLE,
			title: 'To Real Style'
		},
		{
			tier: NODE_DATATIER.SURFACE_EDIT,
			type: NODE_DATATYPE.SURFACE_EDIT,
			title: 'Surface Edit'
		},
		{
			tier: NODE_DATATIER.SCENE_COMPOSITION,
			type: NODE_DATATYPE.SCENE_COMPOSITION,
			title: 'Scene Composition'
		},
		{
			tier: NODE_DATATIER.COLOR_PALETTE,
			type: NODE_DATATYPE.COLOR_PALETTE,
			title: 'Color Palette'
		},
		{
			tier: NODE_DATATIER.TO_3D_MODEL,
			type: NODE_DATATYPE.TO_3D_MODEL,
			title: 'To 3D Model'
		},
		{
			tier: NODE_DATATIER.TO_3VIEW,
			type: NODE_DATATYPE.TO_3VIEW,
			title: 'To 3-View'
		}
	])
	const onClickItem = (v) => {
		const id = props.node.id
		if (!id) return
		stateManager.deleteNode(id)
		const superiorID = props.node.data.superiorID
		nodeManager.createCardNode({
			data: {
				tier: v.tier,
				type: v.type,
				superiorID
			}
		})
	}

	defineExpose({})
</script>

<style lang="less" scoped>
	.cards-select {
		--cards-item-margin-bottom: 8px;
		user-select: none;
		> div {
			display: flex;
			align-items: center;
			padding: 0 5px;
			height: 30px;
			border-radius: 5px;
			cursor: pointer;
			&:hover {
				background-color: rgb(225, 225, 225);
			}
			> .icon {
				margin-right: 10px;
			}
			> .title {
				font-size: 14px;
				color: #000;
			}
		}
	}
</style>
