<script setup lang="ts">
import { onMounted, onUnmounted, reactive, toRefs } from "vue";
const props = defineProps({
	selectList: {
		type: Array,
		default: () => [],
	} as any,
	select: {
		type: Array,
		default: () => {},
	} as any,
})
const emit = defineEmits([
	'update:select'
])
let data = reactive({
})

const setLike = (item,str)=>{
	if(str === 'like'){
		item.isLike = true
	}else{
		item.isLike = false
	}
}

const setSelectList = (item)=>{
	emit('update:select', {...item})
}

const deleteStyle = (index)=>{
	props.selectList.splice(index,1)
}

const updateStyle = (item,index)=>{
	props.selectList[index] = {
		id:item.id,
		imgList:[
			'https://www.minio-api.aida.com.hk/aida-collection-element/83/Printboard/2cbd8c93-c759-4565-92ab-d066bc5f70a4.png?response-content-type=image%2Fpng&response-content-disposition=inline&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20251009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251009T025033Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=806fef8c43183a528cd2033226523abc4f7b4f69040cd8952294534a98f67c6a',
			'https://www.minio-api.aida.com.hk/aida-collection-element/83/Printboard/2cbd8c93-c759-4565-92ab-d066bc5f70a4.png?response-content-type=image%2Fpng&response-content-disposition=inline&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20251009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251009T025033Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=806fef8c43183a528cd2033226523abc4f7b4f69040cd8952294534a98f67c6a',
			'https://www.minio-api.aida.com.hk/aida-collection-element/83/Printboard/2cbd8c93-c759-4565-92ab-d066bc5f70a4.png?response-content-type=image%2Fpng&response-content-disposition=inline&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20251009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251009T025033Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=806fef8c43183a528cd2033226523abc4f7b4f69040cd8952294534a98f67c6a',
			'https://www.minio-api.aida.com.hk/aida-collection-element/83/Printboard/2cbd8c93-c759-4565-92ab-d066bc5f70a4.png?response-content-type=image%2Fpng&response-content-disposition=inline&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20251009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251009T025033Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=806fef8c43183a528cd2033226523abc4f7b4f69040cd8952294534a98f67c6a',
		],
		isLike: false,
		isAdd: false,
	}
}

onMounted(()=>{
})
onUnmounted(()=>{
})
defineExpose({})
const {} = toRefs(data);
</script>
<template>
	<div class="list">
		<div class="item" v-for="(item,index) in selectList" :key="item.id">
			<div class="title">look {{ index + 1 }}</div>
			<div class="imgBox" @click="setSelectList(item)">
				<img v-for="(img,index) in item?.imgList" :key="index" :src="img" alt="">
				<div class="icon" v-if="item.id == select?.id">
					<SvgIcon  name="modelSelected" size="60" />
				</div>
			</div>
			<div class="btn">
				<div>
					<SvgIcon v-if="!item.isLike" @click.stop="setLike(item,'like')" name="noLike" size="30" />
					<SvgIcon v-else name="like" @click.stop="setLike(item,'noLike')" color="#FF4949" size="30" />
				</div>
				<div>
					<SvgIcon @click.stop="updateStyle(item,index)" name="update" size="30" />
				</div>
				<!-- <div>
					<SvgIcon v-if="!item.isAdd" @click.stop="addLibrary(item,'add')" name="add" size="30" />
					<SvgIcon v-else @click.stop="addLibrary(item,'delete')" name="confirmation" size="30" />
				</div> -->
				<div>
					<SvgIcon @click.stop="deleteStyle(index)" name="delete" size="30" />
				</div>
			</div>
		</div>
		
	</div>
</template>
<style lang="less" scoped>
	.list{
		display: flex;
		width: 100%;
		flex-wrap: wrap;
		justify-content: space-between;
		> .item{
			width: calc(50% - 3.1rem / 2);
			position: relative;
			margin-bottom: 3.3rem;
			display: flex;
			flex-direction: column;
			> .title{
				font-size: 3.6rem;
				font-weight: 700;
				color: #000;
				font-family: 'satoshiMedium';
			}
			> .imgBox{
				display: flex;
				justify-content: space-between;
				align-items: center;
				flex-wrap: wrap;
				height: 47.2rem;
				margin: 2.4rem 0;
				background-color: #fff;
				justify-content: center;
				border: .6px solid #acacac;
				border-radius: 1.3px;
				position: relative;
				> .icon{
					position: absolute;
					width: 6rem;
					height: 6rem;
					bottom: -1.8rem;
					right: -2.1rem;
				}
				> img{
					height: 26rem;
					object-fit: cover;
					// object-fit: contain;
					max-width: 50%;
					max-height: 50%;
				}
			}
			> .btn{
				display: flex;
				align-items: center;
				justify-content: flex-end;
				> div{
					color: #000;
					margin-right: 1.2rem;
					border-radius: 50%;
					width: 6.6rem;
					height: 6.6rem;
					padding: 1rem;
					background-color: #fff;
					&:last-child{
						margin-right: 0rem;
					}
					&:hover{
						color: #000;
					}
				}
			}
		}
	}
</style>