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

export const mState = new State(
  "m",
  [
    "m", "damn", "tomn", "misole", "apostrophe"
  ],
  new Map<string, Rule>([
    ["*", new Rule(null, SAMPA.FR.consonants["m"], 1)], // fallback

    ["m", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /m/ }
    ]}, SAMPA.FR.consonants["m"], 2)],

    ["damn", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /n/ },
      { direction: "before", regExp: /da/ }
    ]}, SAMPA.specials["#"], 1)], // "damné"

    ["tomn", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /n/ },
      { direction: "before", regExp: /to/ }
    ]}, SAMPA.specials["#"], 1)], // "automne"

    ["misole", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: /$/ },
      { direction: "before", regExp: /^/ }
    ]}, SAMPA.FR.consonants["m"], 1)], // isolated "m"

    ["apostrophe", new Rule({ type: "regExp", regExps: [
      { direction: "after", regExp: apostropheRegExp }
    ]}, SAMPA.FR.consonants["m"], 1)]
  ])
);
