text: // Generated by BUCKLESCRIPT VERSION 5.0.6, PLEASE EDIT WITH CARE
  'use strict';
  
  var Rebase = require("@glennsl/rebase/lib/js/src/Rebase.bs.js");
  var Util$AgdaMode = require("./Util.bs.js");
  var Parser$AgdaMode = require("./Parser.bs.js");
  var Caml_chrome_debugger = require("bs-platform/lib/js/caml_chrome_debugger.js");
  var Highlighting$AgdaMode = require("./Highlighting.bs.js");
  var Emacs__AllGoalsWarnings$AgdaMode = require("./View/Emacs/Emacs__AllGoalsWarnings.bs.js");
  
  function toString(param) {
    if (typeof param === "number") {
      return "CompilationOk";
    } else {
      switch (param.tag | 0) {
        case 0 : 
            var match = param[0];
            if (match !== undefined) {
              return "Constraints " + match;
            } else {
              return "Constraints";
            }
        case 1 : 
            return "AllGoalsWarnings " + Emacs__AllGoalsWarnings$AgdaMode.toString(param[0]);
        case 2 : 
            return "Time " + param[0];
        case 3 : 
            return "Error " + param[0];
        case 4 : 
            return "Intro " + param[0];
        case 5 : 
            return "Auto " + param[0];
        case 6 : 
            return "ModuleContents " + param[0];
        case 7 : 
            return "SearchAbout " + param[0];
        case 8 : 
            return "WhyInScope " + param[0];
        case 9 : 
            return "NormalForm " + param[0];
        case 10 : 
            return "GoalType " + param[0];
        case 11 : 
            return "CurrentGoal " + param[0];
        case 12 : 
            return "InferredType " + param[0];
        case 13 : 
            return "Context " + param[0];
        case 14 : 
            return "HelperFunction " + param[0];
        case 15 : 
            return "Version " + param[0];
        
      }
    }
  }
  
  function parse(xs) {
    var match = Rebase.$$Array[/* get */17](xs, 1);
    if (match !== undefined) {
      var match$1 = match;
      if (match$1.tag) {
        return undefined;
      } else {
        var payload = match$1[0].replace((/\\r\\n|\\n/g), "\n");
        var match$2 = Rebase.$$Array[/* get */17](xs, 0);
        if (match$2 !== undefined) {
          var match$3 = match$2;
          if (match$3.tag) {
            return undefined;
          } else {
            var title = match$3[0];
            switch (title) {
              case "*Agda Version*" : 
                  return /* Version */Caml_chrome_debugger.variant("Version", 15, [payload]);
              case "*Auto*" : 
                  return /* Auto */Caml_chrome_debugger.variant("Auto", 5, [payload]);
              case "*Compilation result*" : 
                  return /* CompilationOk */0;
              case "*Constraints*" : 
                  if (payload === "nil") {
                    return /* Constraints */Caml_chrome_debugger.variant("Constraints", 0, [undefined]);
                  } else {
                    return /* Constraints */Caml_chrome_debugger.variant("Constraints", 0, [payload]);
                  }
              case "*Context*" : 
                  return /* Context */Caml_chrome_debugger.variant("Context", 13, [payload]);
              case "*Current Goal*" : 
                  return /* CurrentGoal */Caml_chrome_debugger.variant("CurrentGoal", 11, [payload]);
              case "*Error*" : 
                  return /* Error */Caml_chrome_debugger.variant("Error", 3, [payload]);
              case "*Goal type etc.*" : 
                  return /* GoalType */Caml_chrome_debugger.variant("GoalType", 10, [payload]);
              case "*Helper function*" : 
                  return /* HelperFunction */Caml_chrome_debugger.variant("HelperFunction", 14, [payload]);
              case "*Inferred Type*" : 
                  return /* InferredType */Caml_chrome_debugger.variant("InferredType", 12, [payload]);
              case "*Intro*" : 
                  return /* Intro */Caml_chrome_debugger.variant("Intro", 4, [payload]);
              case "*Module contents*" : 
                  return /* ModuleContents */Caml_chrome_debugger.variant("ModuleContents", 6, [payload]);
              case "*Normal Form*" : 
                  return /* NormalForm */Caml_chrome_debugger.variant("NormalForm", 9, [payload]);
              case "*Scope Info*" : 
                  return /* WhyInScope */Caml_chrome_debugger.variant("WhyInScope", 8, [payload]);
              case "*Search About*" : 
                  return /* SearchAbout */Caml_chrome_debugger.variant("SearchAbout", 7, [payload]);
              case "*Time*" : 
                  return /* Time */Caml_chrome_debugger.variant("Time", 2, [payload]);
              default:
                return /* AllGoalsWarnings */Caml_chrome_debugger.variant("AllGoalsWarnings", 1, [Emacs__AllGoalsWarnings$AgdaMode.parse(title, payload)]);
            }
          }
        } else {
          return undefined;
        }
      }
    }
    
  }
  
  var Info = /* module */Caml_chrome_debugger.localModule([
      "toString",
      "parse"
    ], [
      toString,
      parse
    ]);
  
  function toString$1(param) {
    if (typeof param === "number") {
      switch (param) {
        case 0 : 
            return "NoStatus";
        case 1 : 
            return "ClearRunningInfo";
        case 2 : 
            return "ClearHighlighting";
        case 3 : 
            return "DoneAborting";
        
      }
    } else {
      switch (param.tag | 0) {
        case 0 : 
            if (param[0]) {
              return "HighlightingInfoDirect Keep " + Util$AgdaMode.Pretty[/* array */1](Rebase.$$Array[/* map */0](Highlighting$AgdaMode.Annotation[/* toString */0], param[1]));
            } else {
              return "HighlightingInfoDirect Remove " + Util$AgdaMode.Pretty[/* array */1](Rebase.$$Array[/* map */0](Highlighting$AgdaMode.Annotation[/* toString */0], param[1]));
            }
        case 1 : 
            return "HighlightingInfoIndirect " + param[0];
        case 2 : 
            return "Status: implicit arguments " + ((
                      param[0] ? "displayed, " : "not displayed, "
                    ) + ("module " + (
                        param[1] ? "type checked" : "not type checked"
                      )));
        case 3 : 
            return "JumpToError " + (param[0] + (" " + String(param[1])));
        case 4 : 
            return "InteractionPoints " + Util$AgdaMode.Pretty[/* array */1](Rebase.$$Array[/* map */0]((function (prim) {
                              return String(prim);
                            }), param[0]));
        case 5 : 
            var match = param[1];
            var index = param[0];
            if (typeof match === "number") {
              if (match !== 0) {
                return "GiveAction " + (String(index) + " NoParen");
              } else {
                return "GiveAction " + (String(index) + " Paren");
              }
            } else {
              return "GiveAction " + (String(index) + (" String " + match[0]));
            }
        case 6 : 
            if (param[0]) {
              return "MakeCase ExtendedLambda " + Util$AgdaMode.Pretty[/* array */1](param[1]);
            } else {
              return "MakeCase Function " + Util$AgdaMode.Pretty[/* array */1](param[1]);
            }
        case 7 : 
            return "SolveAll " + Util$AgdaMode.Pretty[/* array */1](Rebase.$$Array[/* map */0]((function (param) {
                              return String(param[0]) + (" " + param[1]);
                            }), param[0]));
        case 8 : 
            return "DisplayInfo " + toString(param[0]);
        case 9 : 
            return "RunningInfo " + (String(param[0]) + (" " + param[1]));
        
      }
    }
  }
  
  function parse$1(tokens) {
    if (tokens.tag) {
      var xs = tokens[0];
      var match = Rebase.$$Array[/* get */17](xs, 0);
      var exit = 0;
      if (match !== undefined) {
        var match$1 = match;
        if (match$1.tag) {
          return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                        14,
                        tokens
                      ])]);
        } else {
          switch (match$1[0]) {
            case "agda2-abort-done" : 
                return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* DoneAborting */3]);
            case "agda2-give-action" : 
                var match$2 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$2 !== undefined) {
                  var match$3 = match$2;
                  if (match$3.tag) {
                    return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                  7,
                                  tokens
                                ])]);
                  } else {
                    return Rebase.$$Option[/* mapOr */18]((function (x) {
                                  return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [x]);
                                }), /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                      6,
                                      tokens
                                    ])]), Rebase.$$Option[/* flatMap */5]((function (i) {
                                      var match = Rebase.$$Array[/* get */17](xs, 2);
                                      if (match !== undefined) {
                                        var match$1 = match;
                                        if (match$1.tag) {
                                          return undefined;
                                        } else {
                                          var result = match$1[0];
                                          switch (result) {
                                            case "no-paren" : 
                                                return /* GiveAction */Caml_chrome_debugger.variant("GiveAction", 5, [
                                                          i,
                                                          /* NoParen */1
                                                        ]);
                                            case "paren" : 
                                                return /* GiveAction */Caml_chrome_debugger.variant("GiveAction", 5, [
                                                          i,
                                                          /* Paren */0
                                                        ]);
                                            default:
                                              return /* GiveAction */Caml_chrome_debugger.variant("GiveAction", 5, [
                                                        i,
                                                        /* String */Caml_chrome_debugger.simpleVariant("String", [result])
                                                      ]);
                                          }
                                        }
                                      }
                                      
                                    }), Parser$AgdaMode.$$int(match$3[0])));
                  }
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                7,
                                tokens
                              ])]);
                }
            case "agda2-goals-action" : 
                var match$4 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$4 !== undefined) {
                  return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* InteractionPoints */Caml_chrome_debugger.variant("InteractionPoints", 4, [Rebase.$$Array[/* filterMap */23](Parser$AgdaMode.$$int, Parser$AgdaMode.SExpression[/* flatten */2](match$4))])]);
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                5,
                                tokens
                              ])]);
                }
            case "agda2-highlight-add-annotations" : 
                var annotations = Highlighting$AgdaMode.Annotation[/* parseDirectHighlightings */2](xs);
                var match$5 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$5 !== undefined) {
                  var match$6 = match$5;
                  if (match$6.tag) {
                    return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* HighlightingInfoDirect */Caml_chrome_debugger.variant("HighlightingInfoDirect", 0, [
                                  /* Keep */1,
                                  /* array */[]
                                ])]);
                  } else {
                    switch (match$6[0]) {
                      case "nil" : 
                          return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* HighlightingInfoDirect */Caml_chrome_debugger.variant("HighlightingInfoDirect", 0, [
                                        /* Keep */1,
                                        annotations
                                      ])]);
                      case "remove" : 
                          return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* HighlightingInfoDirect */Caml_chrome_debugger.variant("HighlightingInfoDirect", 0, [
                                        /* Remove */0,
                                        annotations
                                      ])]);
                      default:
                        return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* HighlightingInfoDirect */Caml_chrome_debugger.variant("HighlightingInfoDirect", 0, [
                                      /* Keep */1,
                                      /* array */[]
                                    ])]);
                    }
                  }
                } else {
                  return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* HighlightingInfoDirect */Caml_chrome_debugger.variant("HighlightingInfoDirect", 0, [
                                /* Keep */1,
                                /* array */[]
                              ])]);
                }
            case "agda2-highlight-clear" : 
                return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* ClearHighlighting */2]);
            case "agda2-highlight-load-and-delete-action" : 
                var match$7 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$7 !== undefined) {
                  var match$8 = match$7;
                  if (match$8.tag) {
                    return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                  2,
                                  tokens
                                ])]);
                  } else {
                    return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* HighlightingInfoIndirect */Caml_chrome_debugger.variant("HighlightingInfoIndirect", 1, [match$8[0]])]);
                  }
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                2,
                                tokens
                              ])]);
                }
            case "agda2-info-action" : 
            case "agda2-info-action-and-copy" : 
                exit = 1;
                break;
            case "agda2-make-case-action" : 
                var match$9 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$9 !== undefined) {
                  return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* MakeCase */Caml_chrome_debugger.variant("MakeCase", 6, [
                                /* Function */0,
                                Parser$AgdaMode.SExpression[/* flatten */2](match$9)
                              ])]);
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                8,
                                tokens
                              ])]);
                }
            case "agda2-make-case-action-extendlam" : 
                var match$10 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$10 !== undefined) {
                  return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* MakeCase */Caml_chrome_debugger.variant("MakeCase", 6, [
                                /* ExtendedLambda */1,
                                Parser$AgdaMode.SExpression[/* flatten */2](match$10)
                              ])]);
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                9,
                                tokens
                              ])]);
                }
            case "agda2-maybe-goto" : 
                var match$11 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$11 !== undefined) {
                  var match$12 = match$11;
                  if (match$12.tag) {
                    var match$13 = match$12[0];
                    if (match$13.length !== 3) {
                      return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                    4,
                                    tokens
                                  ])]);
                    } else {
                      var match$14 = match$13[0];
                      if (match$14.tag) {
                        return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                      4,
                                      tokens
                                    ])]);
                      } else {
                        var filepath = match$14[0];
                        var match$15 = match$13[2];
                        if (match$15.tag) {
                          return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                        4,
                                        tokens
                                      ])]);
                        } else {
                          return Rebase.$$Option[/* mapOr */18]((function (x) {
                                        return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [x]);
                                      }), /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                            3,
                                            tokens
                                          ])]), Rebase.$$Option[/* flatMap */5]((function (index) {
                                            return /* JumpToError */Caml_chrome_debugger.variant("JumpToError", 3, [
                                                      filepath,
                                                      index
                                                    ]);
                                          }), Parser$AgdaMode.$$int(match$15[0])));
                        }
                      }
                    }
                  } else {
                    return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                  4,
                                  tokens
                                ])]);
                  }
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                4,
                                tokens
                              ])]);
                }
            case "agda2-solveAll-action" : 
                var match$16 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$16 !== undefined) {
                  var tokens$1 = Parser$AgdaMode.SExpression[/* flatten */2](match$16);
                  var isEven = function (i) {
                    return i % 2 === 0;
                  };
                  var i = /* record */Caml_chrome_debugger.record(["contents"], [0]);
                  var solutions = Rebase.$$Array[/* filterMap */23]((function (token) {
                          var solution = isEven(i[0]) ? Rebase.$$Option[/* flatMap */5]((function (index) {
                                    return Rebase.$$Option[/* map */0]((function (s) {
                                                  return /* tuple */[
                                                          index,
                                                          s
                                                        ];
                                                }), Rebase.$$Array[/* get */17](tokens$1, i[0] + 1 | 0));
                                  }), Parser$AgdaMode.$$int(token)) : undefined;
                          i[0] = i[0] + 1 | 0;
                          return solution;
                        }), tokens$1);
                  return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* SolveAll */Caml_chrome_debugger.variant("SolveAll", 7, [solutions])]);
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                10,
                                tokens
                              ])]);
                }
            case "agda2-status-action" : 
                var match$17 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$17 !== undefined) {
                  var match$18 = match$17;
                  if (match$18.tag) {
                    return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* NoStatus */0]);
                  } else {
                    var pulp = match$18[0].split(",");
                    return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* Status */Caml_chrome_debugger.variant("Status", 2, [
                                  pulp.includes("ShowImplicit"),
                                  pulp.includes("Checked")
                                ])]);
                  }
                } else {
                  return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* NoStatus */0]);
                }
            case "agda2-verbose" : 
                var match$19 = Rebase.$$Array[/* get */17](xs, 1);
                if (match$19 !== undefined) {
                  var match$20 = match$19;
                  if (match$20.tag) {
                    return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                  13,
                                  tokens
                                ])]);
                  } else {
                    return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* RunningInfo */Caml_chrome_debugger.variant("RunningInfo", 9, [
                                  2,
                                  match$20[0]
                                ])]);
                  }
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                13,
                                tokens
                              ])]);
                }
            default:
              return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                            14,
                            tokens
                          ])]);
          }
        }
      } else {
        return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                      14,
                      tokens
                    ])]);
      }
      if (exit === 1) {
        var match$21 = Rebase.$$Array[/* get */17](xs, 1);
        var exit$1 = 0;
        if (match$21 !== undefined) {
          var match$22 = match$21;
          if (match$22.tag || match$22[0] !== "*Type-checking*") {
            exit$1 = 2;
          } else {
            var match$23 = Rebase.$$Array[/* get */17](xs, 3);
            if (match$23 !== undefined) {
              var match$24 = match$23;
              if (match$24.tag || match$24[0] !== "t") {
                return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* ClearRunningInfo */1]);
              } else {
                var match$25 = Rebase.$$Array[/* get */17](xs, 2);
                if (match$25 !== undefined) {
                  var match$26 = match$25;
                  if (match$26.tag) {
                    return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                  11,
                                  tokens
                                ])]);
                  } else {
                    return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* RunningInfo */Caml_chrome_debugger.variant("RunningInfo", 9, [
                                  1,
                                  match$26[0]
                                ])]);
                  }
                } else {
                  return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                                11,
                                tokens
                              ])]);
                }
              }
            } else {
              return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* ClearRunningInfo */1]);
            }
          }
        } else {
          exit$1 = 2;
        }
        if (exit$1 === 2) {
          var match$27 = parse(xs.slice(1));
          if (match$27 !== undefined) {
            return /* Ok */Caml_chrome_debugger.variant("Ok", 0, [/* DisplayInfo */Caml_chrome_debugger.variant("DisplayInfo", 8, [match$27])]);
          } else {
            return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                          12,
                          tokens
                        ])]);
          }
        }
        
      }
      
    } else {
      return /* Error */Caml_chrome_debugger.variant("Error", 1, [/* Response */Caml_chrome_debugger.variant("Response", 1, [
                    0,
                    tokens
                  ])]);
    }
  }
  
  var $$Event = 0;
  
  var Token = 0;
  
  exports.$$Event = $$Event;
  exports.Token = Token;
  exports.Info = Info;
  exports.toString = toString$1;
  exports.parse = parse$1;
  /* Util-AgdaMode Not a pure module */
  