<template>
    <div v-if="brotherInstances" class="ui-gate-content" :class="{ active }">
        <slot :active="active" />
    </div>
</template>

<script lang="ts" setup>
// getCurrentInstance
import { inject, onBeforeMount, onUnmounted, ref } from 'vue'
import { Relation } from './constant'

defineOptions({
    name: 'UIGateContent',
})

const active = ref(false)
const brotherInstances = inject(Relation)

if (brotherInstances) {
    onBeforeMount(() => brotherInstances.value.push(active))
    onUnmounted(() => {
        const index = brotherInstances.value.indexOf(active)
        if (~index) {
            brotherInstances.value.splice(index, 1)
        }
    })
}
</script>

<!-- <script>
export default { name: 'UiGateContent' }
</script> -->
