<template>
  <label class="priv">
    <USwitch
      :model-value="isPrivate"
      aria-label="Private"
      size="xs"
      @update:model-value="onChange"
    />
    <span class="priv-label">Private</span>
  </label>
</template>

<script setup>
const props = defineProps({
  modelValue: { type: String, default: "members" },
});

const emit = defineEmits(["update:modelValue"]);

// Treat legacy "public" values as "members" (visible to signed-in members).
const isPrivate = computed(() => props.modelValue === "private");

const onChange = (val) => {
  emit("update:modelValue", val ? "private" : "members");
};
</script>

<style scoped>
.priv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-family: "Commit Mono", monospace;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  user-select: none;
  cursor: pointer;
}

.priv-label {
  line-height: 1;
}
</style>
