// Generated by purs version 0.12.5
"use strict";
var Control_Category = require("../Control.Category/index.js");
var Data_Array = require("../Data.Array/index.js");
var Data_Foldable = require("../Data.Foldable/index.js");
var Data_Monoid = require("../Data.Monoid/index.js");
var Normal = (function () {
    function Normal() {

    };
    Normal.value = new Normal();
    return Normal;
})();
var Optional = (function () {
    function Optional() {

    };
    Optional.value = new Optional();
    return Optional;
})();
var FTText = (function () {
    function FTText() {

    };
    FTText.value = new FTText();
    return FTText;
})();
var FTEmphasized = (function () {
    function FTEmphasized() {

    };
    FTEmphasized.value = new FTEmphasized();
    return FTEmphasized;
})();
var FTError = (function () {
    function FTError() {

    };
    FTError.value = new FTError();
    return FTError;
})();
var FTValue = (function () {
    function FTValue() {

    };
    FTValue.value = new FTValue();
    return FTValue;
})();
var FTIdentifier = (function () {
    function FTIdentifier() {

    };
    FTIdentifier.value = new FTIdentifier();
    return FTIdentifier;
})();
var FTFunction = (function () {
    function FTFunction() {

    };
    FTFunction.value = new FTFunction();
    return FTFunction;
})();
var FTUnit = (function () {
    function FTUnit() {

    };
    FTUnit.value = new FTUnit();
    return FTUnit;
})();
var Formatted = (function () {
    function Formatted(value0, value1, value2) {
        this.value0 = value0;
        this.value1 = value1;
        this.value2 = value2;
    };
    Formatted.create = function (value0) {
        return function (value1) {
            return function (value2) {
                return new Formatted(value0, value1, value2);
            };
        };
    };
    return Formatted;
})();
var val = Formatted.create(Normal.value)(FTValue.value);
var unit = Formatted.create(Normal.value)(FTUnit.value);
var uncurry = function (fmt) {
    return function (v) {
        return fmt(v.value0)(v.value1)(v.value2);
    };
};
var text = Formatted.create(Normal.value)(FTText.value);
var optional = function (v) {
    return new Formatted(Optional.value, v.value1, v.value2);
};
var nl = text("\x0a");
var jtClass = function (v) {
    return function (v1) {
        if (v1 === "") {
            return "";
        };
        return "[[;;;hl-" + (v + ("]" + (v1 + "]")));
    };
};
var ident = Formatted.create(Normal.value)(FTIdentifier.value);
var $$function = Formatted.create(Normal.value)(FTFunction.value);
var format = function (formatter) {
    return function (m) {
        return Data_Foldable.foldMap(Data_Foldable.foldableArray)(Data_Monoid.monoidString)(uncurry(formatter))(Data_Array.cons(optional(nl))(m));
    };
};
var fmtPlain = function (v) {
    return function (v1) {
        return function (v2) {
            if (v instanceof Normal) {
                return v2;
            };
            if (v instanceof Optional) {
                return "";
            };
            throw new Error("Failed pattern match at Insect.Format (line 95, column 1 - line 95, column 21): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
        };
    };
};
var fmtJqueryTerminal = function (v) {
    return function (v1) {
        if (v1 instanceof FTText) {
            return Control_Category.identity(Control_Category.categoryFn);
        };
        if (v1 instanceof FTEmphasized) {
            return jtClass("emphasized");
        };
        if (v1 instanceof FTError) {
            return jtClass("error");
        };
        if (v1 instanceof FTValue) {
            return jtClass("value");
        };
        if (v1 instanceof FTIdentifier) {
            return jtClass("identifier");
        };
        if (v1 instanceof FTFunction) {
            return jtClass("function");
        };
        if (v1 instanceof FTUnit) {
            return jtClass("unit");
        };
        throw new Error("Failed pattern match at Insect.Format (line 104, column 1 - line 104, column 30): " + [ v.constructor.name, v1.constructor.name ]);
    };
};
var error = Formatted.create(Normal.value)(FTError.value);
var emph = Formatted.create(Normal.value)(FTEmphasized.value);
var consoleCode = function (code) {
    return function (str) {
        return "\x1b[" + (code + ("m" + (str + "\x1b[0m")));
    };
};
var fmtConsole = function (v) {
    return function (v1) {
        return function (s) {
            if (v1 instanceof FTText) {
                return s;
            };
            if (v1 instanceof FTEmphasized) {
                return consoleCode("01")(s);
            };
            if (v1 instanceof FTError) {
                return consoleCode("31")(s);
            };
            if (v1 instanceof FTValue) {
                return consoleCode("36")(s);
            };
            if (v1 instanceof FTIdentifier) {
                return consoleCode("33")(s);
            };
            if (v1 instanceof FTFunction) {
                return consoleCode("03")(s);
            };
            if (v1 instanceof FTUnit) {
                return consoleCode("32")(s);
            };
            throw new Error("Failed pattern match at Insect.Format (line 117, column 1 - line 117, column 23): " + [ v.constructor.name, v1.constructor.name, s.constructor.name ]);
        };
    };
};
module.exports = {
    text: text,
    emph: emph,
    error: error,
    val: val,
    ident: ident,
    "function": $$function,
    unit: unit,
    optional: optional,
    nl: nl,
    format: format,
    fmtPlain: fmtPlain,
    fmtJqueryTerminal: fmtJqueryTerminal,
    fmtConsole: fmtConsole
};
