import { defineStore } from 'pinia'
import { reactive, ref } from 'vue'

export const useScreenStore = defineStore('screen',() => {
    const controllerData = reactive({})
    let placeList = []
    const tunnelList = reactive([])
    const currentTunnel = ref({})

    const setController = (val) => {
        Object.assign(controllerData, val)
    }

    const setTunnelList = (val) => {
        placeList.length = 0;
        val.list.forEach(item => {
            placeList.push({
                styleId: item.ID,
                position: { lat: item.latitude, lng: item.longitude } ,
            })
        })
        tunnelList.length = 0
        tunnelList.push(...val.list)
    }

    const setCurrentTunnel = (val) => {
        currentTunnel.value = val
    }
    return {
        controllerData,
        setController,
        tunnelList,
        setTunnelList,
        placeList,
        currentTunnel,
        setCurrentTunnel
    }
})
