import { State, Rule } from "../../state-machine";
import { SAMPA } from "../../sampa";

export const wState = new State(
  "w",
  [
    "wurt",
    "wisig",
    "wag",
    "wa",
    "wi"
  ],
  new Map([
    ["*", new Rule(null, SAMPA.FR.semiVowels["w"], 1)], // fallback [w]

    ["wa", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /a/ }
    ]}, SAMPA.FR.semiVowels["w"], 2)], // wa → w

    ["wag", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /ag/ }
    ]}, SAMPA.FR.consonants["v"], 1)], // wag → v

    ["wi", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /i/ }
    ]}, SAMPA.FR.vowels["u"], 1)], // wi → [u]

    ["wisig", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /isig/ }
    ]}, SAMPA.FR.consonants["v"], 1)], // wisig → v

    ["wurt", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /urt/ }
    ]}, SAMPA.FR.consonants["v"], 1)] // wurt → v
  ])
);
