<script lang="ts">
	import type { ScriptCondition } from "$lib/models/script";
	import BFormOption from "../bforms/BFormOption.svelte";
	import BFormParameter from "../bforms/BFormParameter.svelte";

  export let value: Required<ScriptCondition>
</script>

<BFormOption state unclickable icon="question">
  <BFormParameter narrowest type="checkbox" bind:value={value.not} label="Not" />
  <BFormParameter narrow type="select" bind:value={value.scope} label="Scope" options={[
    { label: "Match", value: "match" },
    { label: "Devices", value: "device" },
    { label: "Global", value: "global" },
  ]} />
  <BFormParameter type="text" bind:value={value.key} label="Key" />
  <BFormParameter narrow type="select" bind:value={value.op} label="Op" options={[
    { label: "==", value: "eq" },
    { label: "!==", value: "neq" },
    { label: ">", value: "gt" },
    { label: ">=", value: "gte" },
    { label: "<", value: "lt" },
    { label: "<=", value: "lte" },
    { label: "contains", value: "contains" },
    { label: "exists", value: "exists" },
    { label: "numerical", value: "numerical" },
  ]} />
  {#if value.op !== "numerical" && value.op !== "exists"}
    <BFormParameter type="text" bind:value={value.value} label="Value" />
  {/if}
</BFormOption>